Tuesday, 27 August 2013

Referencing Groovy project from another using Eclipse, Maven, maven-eclipse-plugin and build-helper-maven-plugin

Referencing Groovy project from another using Eclipse, Maven,
maven-eclipse-plugin and build-helper-maven-plugin

I have an Eclipse Groovy project, say A, that needs to reference/use the
source code of another Eclipse Groovy project, called GenUtils. In the
Eclipse environment one would select project A and then Properties -->
Projects --> Add and check GenUtils. This produces the following in the
.classpath file of A: ... ...
where "/GenUtils" referenes a project in the workspace. And this works fine.
Now I am trying to do the same with Maven using the maven-eclipse-plugin
to generate the Eclipse project files for A from the maven pom.xml. (Using
mvn eclipse:eclipse)
By researching (I am a Maven newbie) I found that Maven does not support
multiple source locations by default and the recommended solution is the
build-helper-maven-plugin. Using this in my POM: org.codehaus.mojo
build-helper-maven-plugin 1.8 add-source generate-sources add-source
../../GenUtils I can give the relative path of the GenUtils project. This
produces the following in the .classpath file: that is, the project
sources are indeed referenced with an absolute path! Not ideal but would
do for the moment.
The problem is that Eclipse does not accept this and gives the errors: ":
is an invalid character in path 'C:/_SDE/Tools/ArtopBasedTools/GenUtils'."
(Error Log), "Project A us missing required source folder:
'C:/_SDE/Tools/ArtopBasedTools/GenUtils'" (Problems wndow). This is
probably due to the fact that Eclipse expects to reference other workspace
projects not arbitrary directories. It expects in the .classpath file a
path="/GenUtils" entry instead of the full absolute path.
So the question is: Is there a way to specify this in
build-helper-maven-plugin?
More generaly: Is this the correct approach to make accesible a Groovy
Eclipse project from another using Maven? Or is there another recommended
solution?

No comments:

Post a Comment