Orange-OpenSource / fiware-cepheus

FIWARE Cepheus - CEP for NGSI IoT gateways
GNU General Public License v2.0
17 stars 21 forks source link

NGSI - Java 7 support #41

Closed masonlouchart closed 8 years ago

masonlouchart commented 8 years ago

I would like to use the cepheus-ngsi library in a Google App Engine application but GAE does not support Java 8.

My question is, what is the dependency who requires Java 8 ?

I hope to be able to make a fork with Java 7.

marcc-orange commented 8 years ago

The cepheus-ngsi library should work fine on Java 7 as only the test code is using Java 8 (for lambdas).

I just pushed a commit 5a8962b596e620b8820e8b47e8da99296338a8ba on master branch to allow building a Java 7 compatible library by activating the "java7" profile.

Hope this helps.

PascaleBorscia commented 8 years ago

We add also a maven classifier in the "java7" profile.

When you build the project, maven create the jar "cepheus-ngsi-{version}-java7.jar". In the next release 0.1.5, we will deploy on Sonatype the two jars: compatible java7 with the suffixe"-java7" and compatible java8 without suffixe.

Hope this helps.

marcc-orange commented 8 years ago

Currently the library is under GPLv2 which is too restrictive for reuse by other projects.

We will move the library out of the Cepheus project and use Apache Licence v2. Related issue: #43

masonlouchart commented 8 years ago

Thank you for your help and your reactivity. :+1: for the #43

masonlouchart commented 8 years ago

I cloned the project and built the cepheus-ngsi-0.1.5-SNAPSHOT-java7-jar using the profile java7. Then I put it into my project and defined it as library. When I run the command (mvn appengine:update) to deploy my project, it is build again (like mvn clean install). If I don't add the dependency of cepheus-ngsi in my pom.xml file the build fails. And if I add the dependency, the version with Java 8 is added and the deployment fails.

I think my issue will be fixed if I can tell that my external library (cepheus-ngsi-0.1.5-SNAPSHOT-java7.jar) is priority on Maven. Or if I can tell to Maven to remove the generated jar.

I'm not sure to be clear and like you can see, I'm not a master of Maven. :worried:

PascaleBorscia commented 8 years ago

Can you send the maven error and the pom.xml of your project ?

masonlouchart commented 8 years ago

First try

When I manually compile the library and insert it in the project as external dependency I have to add spring-context in my pom.xml file. Else I can't use the dependency injection Autowired on the NgsiClient.

After that I rebuild the app with mvn clean install and I get the 3 following errors:

However, my IDE is able to import classes and lets me use them.

Second try

So, I tried to add the cepheus-ngsi dependency into my pom.xml file

<dependency>
    <groupId>com.orange.cepheus</groupId>
    <artifactId>cepheus-ngsi</artifactId>
    <version>0.1.5-SNAPSHOT</version>
</dependency>

As you can imagine, I don't get any error anymore during the build. But Google App Engine does not support Java 8. I remove the generated library and expect that the app will use the manually generated one.

To deploy the app on App Engine I run the command mvn appengine:update and unfortunately, it rebuilds the app and re-generates the library with Java 8. So the deployment fails. (The related error message is "Unable to update app: Class file is Java 8 but max supported is Java 7")

Possible solutions (I guess)

Tell to Maven not to consider the libraries in the pom.xml if they are already provided as external libraries. Or do not rebuild the app when I run the command for deploying.

I think all those troubles will be gone when the version 0.1.5 will be released (if we're able to set the profile java7 in the pom.xml file).

PascaleBorscia commented 8 years ago

To use the library with java7 support, you have to add in your pom.xml the dependency with "classifier":

<dependency>
  <groupId>com.orange.cepheus</groupId>
  <artifactId>cepheus-ngsi</artifactId>
  <classifier>java7</classifier>
  <version>0.1.5-SNAPSHOT</version>
</dependency>

Please take in account that this library is currently under the GPL license.

masonlouchart commented 8 years ago

It works like a charm. I didn't knew what is Maven classifier. Thank you to warn me again about the licence. I'll just make a try for now and watch very close the issue #43.