Hello to the Maven users.
I am trying to generate two artefacts, each containing two different flavours
of generated classes.
I am able to generate the classes under two different folders:
target\generated-sources-jacorb
target\generated-sources-sunorb
Now I would like to compile these two folders separately in the same build, and
include them in two different artefacts.
I am using the following configuration, with two executions
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>compile-with-jacorb</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/classes-jacorb</outputDirectory>
<excludes>
<exclude>**/generated-sources-sunorb/*</exclude>
</excludes>
</configuration>
</execution>
<execution>
<id>compile-with-sunorb</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/classes-sunorb</outputDirectory>
<excludes>
<exclude>**/generated-sources-jacorb/*</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
however the compilation fails with the error
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile)
on project test-attach-artifact: Compilation failure: Compilation failure:
[ERROR]
\dev\Projects\test-attach-artifact\target\generated-sources-jacorb\idl\uk\co\igindex\corba\service\V3_0\NoDataHelper.java:[11,13]
duplicate class: uk.co.igindex.corba.service.V3_0.NoDataHelper
..........
I.e. both generated source folders are included during compilation. I can see
this in the maven output:
[DEBUG] Configuring mojo
'org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile' with basic
configurator -->
[DEBUG] (f) basedir = C:\dev\Projects\test-attach-artifact
[DEBUG] (f) buildDirectory = C:\dev\Projects\test-attach-artifact\target
[DEBUG] (f) classpathElements =
[C:\dev\Projects\test-attach-artifact\target\classes]
[DEBUG] (f) compileSourceRoots =
[C:\dev\Projects\test-attach-artifact\src\main\java,
C:\dev\Projects\test-attach-artifact\target\generated-sources-jacorb\idl,
C:\dev\Projects\test-attach-artifact\target\generated-sources-sunorb\idl]
......
However, looking at the first part of the output (before the above excerpt), it
looks the configuration is picked up
[DEBUG] Goal:
org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile
(compile-with-jacorb)
[DEBUG] Style: Regular
[DEBUG] Configuration: <?xml version="1.0" encoding="UTF-8"?>
<configuration>
<basedir default-value="${basedir}"/>
<buildDirectory default-value="${project.build.directory}"/>
<classpathElements default-value="${project.compileClasspathElements}"/>
<compileSourceRoots default-value="${project.compileSourceRoots}"/>
<compilerId default-value="javac">${maven.compiler.compilerId}</compilerId>
<compilerVersion>${maven.compiler.compilerVersion}</compilerVersion>
<debug default-value="true">${maven.compiler.debug}</debug>
<debuglevel>${maven.compiler.debuglevel}</debuglevel>
<encoding
default-value="${project.build.sourceEncoding}">${encoding}</encoding>
<excludes>
<exclude>**/generated-sources-sunorb/*</exclude>
</excludes>
.........
and
[DEBUG] Goal:
org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile
(compile-with-sunorb)
[DEBUG] Style: Regular
[DEBUG] Configuration: <?xml version="1.0" encoding="UTF-8"?>
<configuration>
<basedir default-value="${basedir}"/>
<buildDirectory default-value="${project.build.directory}"/>
<classpathElements default-value="${project.compileClasspathElements}"/>
<compileSourceRoots default-value="${project.compileSourceRoots}"/>
<compilerId default-value="javac">${maven.compiler.compilerId}</compilerId>
<compilerVersion>${maven.compiler.compilerVersion}</compilerVersion>
<debug default-value="true">${maven.compiler.debug}</debug>
<debuglevel>${maven.compiler.debuglevel}</debuglevel>
<encoding
default-value="${project.build.sourceEncoding}">${encoding}</encoding>
<excludes>
<exclude>**/generated-sources-jacorb/*</exclude>
</excludes>
.......
Therefore, I do not understand why the configuration is loaded and then
discarded. If someone could help me, I would really appreciate.
Thanks
Claves
________________________________
The information contained in this email is strictly confidential and for the
use of the addressee only, unless otherwise indicated. If you are not the
intended recipient, please do not read, copy, use or disclose to others this
message or any attachment. Please also notify the sender by replying to this
email or by telephone (+44 (0)20 7896 0011) and then delete the email and any
copies of it. Opinions, conclusions (etc) that do not relate to the official
business of this company shall be understood as neither given nor endorsed by
it. IG Group Holdings plc is a company registered in England and Wales under
number 01190902. VAT registration number 761 2978 07. Registered Office: Cannon
Bridge House, 25 Dowgate Hill, London EC4R 2YA. Authorised and regulated by the
Financial Services Authority. FSA Register number 114059.