I have an xtext language project (using xtext 2.13/java8) that includes a code generator. The generator produces java code that needs to compile and run against another support library that I've included in my project as another plugin. The project includes generator junit tests that compile and execute using the generator test frameworks. Everything builds and runs fine in eclipse. I set up a maven build that succeeds in building everything, and running parser and validation tests, but it is failing in the generator tests because it is unable to resolve the dependency on my support library. The fact that these tests run successfully under eclipse tells me that I've constructed the plugin manifests correctly, but somehow the maven build is missing those compile/runt dependencies on the support library. What do I need to do to configure the generator test to include those dependencies when run under maven? I get the same error running maven inside eclipse, or on the commandline: the generator successfully generates the code, but it fails to compile because the compiler is unable to resolve dependencies on the support classes.
0
votes
Use the Xtext Maven Plugin look here: eclipse.org/Xtext/documentation/350_continuous_integration.html for more details...
- Rafael Guillen
By the way, adding the project or jar for the support library to the classpath for the generator tests (in the run config for the junit test) doesn't seem to have any effect.
- user2000974
How do you build the support Libary. Dow do you add it as dependency . How do you test the generator
- Christian Dietrich
I set up the project for maven build using the xtext project wizard, and like I said, it all builds and runs under maven except the generator tests. The documentation explains how to add dependencies to other xtext language resources, but it's not clear that this should work for other plugins/libraries.
- user2000974
The support library is built as an eclipse plugin as another sub-project of the parent project -- i.e., as a module in the parent pom. I added dependencies to the support library in the MANIFEST of the tests subproject, and that got it to work when running junit tests in eclipse. Not expressing any explicit dependencies in pom files, assuming that tycho is supposed to refer to MANIFEST dependencies.
- user2000974
1 Answers
0
votes
Problem turned out to be a subtle mistake in the build.properties file for the support library. The bin.includes settings was
bin.includes = META-INF
but it needed to also include '.' as follows:
bin.includes = META-INF,\
.
I don't know about you, but it was really hard for me to see that period. Not sure how it got removed, but the clue was that the generated jar files didn't contain any classes. Maven build resolves through the SNAPSHOT jar files, while apparently the eclipse build can find the classes directly.