HEADS-project / training

Training material to get started with the HEADS technologies
10 stars 16 forks source link

How to combine Generated Java(ThingML) and Java(manual) in Kevoree #51

Closed sdalgard closed 9 years ago

sdalgard commented 9 years ago

In training 3. I want to have several components in my javanode.

I dont want to not have the manually written Java into the directories with generated Java. This may lead to overwritten files...

How do I set up this so Kevoree find all the components referred in the Kev-script?

brice-morin commented 9 years ago

I guess you have to:

If you mvn clean install into all these projects, every project should then be aware of the others.

Then you should use the API project to link the two other projects.

sdalgard commented 9 years ago

@maxleiko I dont see how that directory structure will look like. Will there then be two pom files? Previous turorial I tried with two projects and a root pom file in addition to the two project pom files. This approach failed because the jar didnt contain all kev-stuff. Maxime showed me how to combine it into one package. Now it will be several packages(?)

brice-morin commented 9 years ago

Maybe three independent POM.xml files:

In the end you will deploy two distincts (sets of) Kevoree components, the one(s) you wrote manually and the one(s) generated from ThingML. I do not think it should be a problem.... but @maxleiko knows best ;-)

maxleiko commented 9 years ago

Currently, while you are in dev-mode in Kevoree Java, you cannot run a KevScript that uses two separate Kevoree project because it won't "load" the generated Kevoree model of the "other" module.
So you will have to manually add the source code in one and only one project.

We could do a fix for that, just like I made for Kevoree JS though.

maxleiko commented 9 years ago

This is due to the fact that the KevScript interpreter tries to check on the registry while it cannot find DeployUnit. And the DeployUnits created by your other projects are not published on the registry. To bypass that, the Kevoree plugin loads your current model before interpretation so the check to the registry is not necessary.

brice-morin commented 9 years ago

Yes, it was a useful fix in Kevoree JS. That would be nice to have the same feature in Kevoree Java. Otherwise it will rapidly become cumbersome to develop HD-services with Kevoree where we have to develop everthing in a centralized way in one single project.......

maxleiko commented 9 years ago

Agreed. I will dig into that.

maxleiko commented 9 years ago

Alright, so I'm deploying Kevoree 5.2.6-SNAPSHOT that contains the fix for local multi-projects development workflow.
This fix allows you to specify, in the Maven Kevoree Plugin, a list of local libraries to merge.

<!-- Kevoree plugin -->
<plugin>
  <groupId>org.kevoree.tools</groupId>
  <artifactId>org.kevoree.tools.mavenplugin</artifactId>
  <version>5.2.6-SNAPSHOT</version>
    <configuration>
        <mergeLocalLibraries>
            <mergeLocalLibrary>/tmp/MyOtherComp/target/classes</mergeLocalLibrary>
        </mergeLocalLibraries>
    </configuration>
</plugin>

But you can also specify those paths as a command-line argument:

mvn kev:run -Ddev.target.dirs=/tmp/MyOtherComp/target/classes:/tmp/AnotherOne/target/classes

If you manage to use it sucessfully, I'll release a 5.2.6 version of Kevoree. But I'll wait for your feedback first :)

brice-morin commented 9 years ago

@sdalgard do you have time these days to try that new feature?

maxleiko commented 9 years ago

You will have to add those lines to the pom.xml in order to get access to SNAPSHOT builds

<pluginRepositories>
    <pluginRepository>
        <id>oss-snapshots</id>
        <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </pluginRepository>
</pluginRepositories>
brice-morin commented 9 years ago

Re-assigned to Steffen just to test the new feature.

sdalgard commented 9 years ago

It is woking and used in my checked in contribution:

https://github.com/sdalgard/training/blob/master/3.Wrapping_ThingML_into_Kevoree/3.3_Contrib/SINTEF-INST/3.3-contrib/trunkmux/pom.xml

brice-morin commented 9 years ago

@maxleiko can you release 5.2.6? (Maybe test it in depth to make sure something else is broken)