situation
I have XML files which I need to deal with in my GUI (JavaXF) and in my JavaStoredProcedures in my oracle12c database.
In the GUI I want to use properties bindings.
So I configured the maven-jaxb2-plugin
to generate the sources with properties.
The database on the other hand does not support Java8 therefore is configured a second execution
for the maven-jaxb2-plugin to generate the sources without properties in a different folder ending up with two folders containing the same Java-classes in the same packages in different folders.
So what I have now looks like this:
project
\-target
\-generated-sources
+-java7
| \-package.with.java.files
| \-Java7-compilabe-sources*
\-java8
\-package.with.java.files
\-Java8-compilabe-sources*
What I want to do next is to compile the two folders target/generated-sources/java7
and target/generated-sources/java8
to different output folders target/java7/classes
and target/java8/classes
respectively within different executions of the maven-compiler-plugin.
But I'm not able to change the output directory of the maven-compiler-plugin for a single execution.
This is my current configuration of the maven-compiler-plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<verbose>true</verbose>
<fork>true</fork>
<encoding>ISO-8859-1</encoding>
</configuration>
<executions>
<execution>
<id>java8</id>
<configuration>
<source>1.8</source>
<target>1.8</target>
<executable>${jdk-1.8}/bin/javac</executable>
<compilerVersion>1.8</compilerVersion>
<sourceDirectory>${project.build.directory}/generated-sources/java8</sourceDirectory>
<outputDirectory>${basedir}/target/java8/classes</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
But from the maven output it looks like it does not respect either one of <sourceDirectory>
nor <outputDirectory>
:
[INFO] ------------------------------------------------------------------------
[INFO] Building MyProject 6.0.5
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ MyProject ---
[INFO] Deleting /ProjectRoot/target
[INFO]
[INFO] --- maven-jaxb2-plugin:0.13.1:generate (Java8) @ MyProject ---
[INFO] Up-to-date check for source resources [[file:/ProjectRoot/src/main/xsd/parad.xsd, file:/ProjectRoot/src/main/xjb/bindings.xml, file:/ProjectRoot/pom.xml]] and target resources [[]].
[INFO] Sources are not up-to-date, XJC will be executed.
[INFO] Episode file [/ProjectRoot/target\generated-sources\java8\META-INF\sun-jaxb.episode] was augmented with if-exists="true" attributes.
[INFO]
[INFO] --- maven-jaxb2-plugin:0.13.1:generate (Java7) @ MyProject ---
[INFO] Up-to-date check for source resources [[file:/ProjectRoot/src/main/xsd/parad.xsd, file:/ProjectRoot/src/main/xjb/bindings.xml, file:/ProjectRoot/pom.xml]] and target resources [[]].
[INFO] Sources are not up-to-date, XJC will be executed.
[INFO] Episode file [/ProjectRoot/target\generated-sources\java7\META-INF\sun-jaxb.episode] was augmented with if-exists="true" attributes.
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MyProject ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO] Copying 1 resource
[INFO] Copying 1 resource
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ MyProject ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 114 source files to /ProjectRoot/target\classes
findings
- the compiler pluging does not show the execution ID (as the maven-jaxb2-plugin does)
- the compiler pluging compiles both
target/generated-sources/java7
andtarget/generated-sources/java8
(each contains 57 *.java files) although<sourceDirectory>
is given inexecution/config
- the compiler pluging compiles to
target/classes
although<outputDirectory>
is given inexecution/config
question
how do I force maven to compile each of target/generated-sources/java7
and target/generated-sources/java8
to its own target folder separately?
additional info
$ mvn --version
Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T13:57:37+02:00)
I solved the problem by usting the maven-antrun-plugin.
first I turend off compilation by excluding all files:
I also turned of the maven-jar-plugin
then I configured separate executions in the maven-antrun-plugin to compile eache source folder and create the separate jars.
what's left is to configure the maven-deploy-plugin so that the two jars (and their source jars) are correctly placed in the maven repository so that they can be fetched as dependencies.