Maven JAXB plugin - xjc

I am using maven jaxb2 plugin to generate the classes from xsd.
However, the XJC generates the classes each time, I run mvn clean install, though I have not modified the XSD /binding files.
PS:I have to do clean install as it's required for other tasks.
forceRegenerate =false is not working
Pls guide.
pom.xml
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.12.3</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaLanguage>WSDL</schemaLanguage>
<!-- TODO need to confirm if directly updating source files are ok.
or should we move to target directory -->
<bindingDirectory>${basedir}/src/main/resources/wsdl</bindingDirectory>
<generateDirectory>${basedir}/src/main/java</generateDirectory>
<generatePackage>com.abc.def.chg.beans</generatePackage>
<specVersion>2.1</specVersion>
<forceRegenerate>false</forceRegenerate>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId>
<version>0.9.3</version>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics-annotate</artifactId>
<version>1.0.1</version>
</plugin>
</plugins>
<args>
<arg>-Xannotate</arg>
<arg>-XtoString</arg>
</args>
<schemas>
<schema>
<fileset>
<!-- Defaults to schemaDirectory. -->
<directory>${basedir}/src/main/resources/wsdl</directory>
<!-- Defaults to schemaIncludes. -->
<includes>
<include>*.xsd</include>
</includes>
<!-- Defaults to schemaIncludes -->
</fileset>
</schema>
</schemas>
</configuration>
</plugin>

Please run mvn clean install -X and check the log. It should explain, why the code is regenerated (look for depends and produces lines).

Related

Generate Classes from multiple webservices using maven

I have a POM where I am using JAXB2 plugin to generate code from mulitple webservices (wsdl).
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- maven-jaxb2-plugin -->
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<executions>
<execution>
<id>Bus</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<schemaLanguage>WSDL</schemaLanguage>
<schemas>
<schema>
<url>http://server/Service1?wsdl</url>
</schema>
</schemas>
<generatePackage>com.core.business</generatePackage>
</configuration>
</execution>
<execution>
<id>Ser</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<schemaLanguage>WSDL</schemaLanguage>
<schemas>
<schema>
<url>http://server/Service2?wsdl</url>
</schema>
</schemas>
<generatePackage>com.core.search</generatePackage>
</configuration>
</execution>
<execution>
<id>Tab</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<schemaLanguage>WSDL</schemaLanguage>
<schemas>
<schema>
<url>http://server/Service3?wsdl</url>
</schema>
</schemas>
<generatePackage>com.core.table</generatePackage>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
The generated class files are all included in all the Packages. Therefore
com.core.business
com.core.search
com.core.table
It appears that namespaces are not handled correctly as the classes for wsdl1,2,3 are combined in all the 3 packages.
How to ensure that these packages include the specific classes specified in the wsdl?
Those asterisk on each side of your <url> and <generatePackage> attributes are wild card characters.
See this example from http://www.mojohaus.org/jaxb2-maven-plugin/Documentation/v2.2/example_xjc_basic.html
<project>
...
<dependencies>
<!--
You need the JAXB API to be able to annotate your classes.
However, starting with Java 6 that API is included in the
Java SE platform so there is no need to declare a dependency.
-->
...
</dependencies>
...
<build>
<pluginManagement>
<plugins>
<!--
If we e.g. execute on JDK 1.7, we should compile for Java 7 to get
the same (or higher) JAXB API version as used during the xjc execution.
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>${project.version}</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- The package of your generated sources -->
<packageName>com.example.myschema</packageName>
</configuration>
</plugin>
...
</plugins>
<build>
...
</project>
I would definitely take the * and ** of the beginning of those lines. I found the answer to your question pretty quickly by going to https://github.com/highsource/maven-jaxb2-plugin/wiki/Configuration-Cheat-Sheet

JaCoCo not generating jacoco.exec until after skipping JaCoCo execution

I'm having trouble generating AHP reports via JaCoCo in one of my modules. When the build starts, I see JaCoCo correctly setting argLine with:
[INFO] jacoco.agent.argLine set to -javaagent:<...>/.m2/repository/org/jacoco/org.jacoco.agent/0.7.2.201409121644/org.jacoco.agent-0.7.2.201409121644-runtime.jar=destfile=<...>/target/jacoco.exec
However, the .exec hasn't been created yet by the time maven tries to run JaCoCo:
[INFO] Skipping JaCoCo execution due to missing execution data file:<...>/target/jacoco.exec
The jacoco.exec does eventually get created, after maven has skipped JaCoCo execution. Therefore, I can still generate AHP reports, if I re-run the build without cleaning.
I've seen in various other questions that I need to be careful using Maven Surefire with JaCoCo. However, I don't explicitly use argLine in my Surefire plugins, or in any plugin for that matter. I'm starting to wonder if one of the other plugins is hijacking the argLine parameter automatically like JaCoCo does.
Here is a list of all plugins used:
jacoco-maven-plugin
vertx-maven-plugin
maven-resources-plugin
maven-dependency-plugin
maven-surefire-plugin
maven-failsafe-plugin
maven-surefire-report-plugin
maven-assembly-plugin
I do see one suspicious message in the build output:
[INFO] --- maven-compiler-plugin:3.0:compile (default-compile) # <module> ---
[INFO] Changes detected - recompiling the module!
I'm not sure if that's relevant, but it appears twice before the Skipping message, and doesn't appear in a module where JaCoCo works properly.
Any ideas?
*edit - Here's the jacoco config
<plugins>
<...>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.jacoco</groupId>
<artifactId>
jacoco-maven-plugin
</artifactId>
<versionRange>
[0.7.2.201409121644,)
</versionRange>
<goals>
<goal>prepare-agent</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
I'm not sure exactly what that plugin management part is doing, but commenting it out doesn't fix anything. I've also tried putting the JaCoCo plugin config above the surefire/failsafe config in case order mattered for plugins sharing the same goals, but that didn't help either.
*edit 2 - Looks like the problem was surefire's includes. Commenting them out somehow fixes JaCoCo's .exec generation, and JaCoCo works properly.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.plugin.version}</version>
<configuration>
<!-- <includes>
<include>**/unit/**/*Test*.java</include>
</includes> -->
</configuration>
</plugin>
Anyone know why?
Just an addition to the answers already given.
It could happen that in your maven-surefire-plugin configuration you already use the argLine configuration to override something like the memory used. If you do so the argline set by jacoco-maven-plugin will not be used failing to generate the jacoco report.
In this case assign a property name to the jacoco-maven-plugin config and then reference it in your maven-surefire-plugin argLine parameter.
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.9</version>
<executions>
<!-- prepare agent for measuring unit tests -->
<execution>
<id>prepare-unit-tests</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<append>true</append>
<destFile>${sonar.jacoco.reportPath}</destFile>
<!-- Sets the VM argument line used when unit tests are run. -->
<propertyName>surefireArgLine</propertyName>
</configuration>
</execution>
</executions>
</plugin>
[...]
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<printSummary>false</printSummary>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<forkCount>3</forkCount>
<reuseForks>true</reuseForks>
<argLine>${surefireArgLine} -Xmx1024m -noverify</argLine>
</configuration>
</plugin>
To solve this issue I would use the following three steps:
Determine which plugin execution is producing the jacoco.exec file. To do that, you could run Maven with debug logging enabled (mvn -X) and look for the jacoco.agent.argLine property name or its value in the output. You could also have a look at the effective POM (mvn help:effective-pom) in case the relevant configuration comes from the parent POM. Note that my guess is that it's an execution of the maven-failsafe-plugin.
Determine the phase that plugin is executed in. E.g. for maven-failsafe-plugin this would likely be integration-test.
Change the configuration of the JaCoCo plugin so that the report goal is executed later in the build lifecycle. E.g. if the jacoco.exec file is produced in the integration-test phase, you could execute the report goal in the post-integration-test phase.
In my case the solution was what #massimo mentioned, i was overriding memory values inside <surefireArgLine> tag, after i removed the tag it started generating the report and showed code coverage.
for me one of the reason for exec file not getting generated is when i placed the prepare-agent , prepare-package goals inside plugin section of pluginManagement
when i tried the same outside pluginManagement , i was sucessfully able to run the same and jacoco-exec file was generated using mvn clean install command
my pomfile is as below :
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>mmt</groupId>
<artifactId>jacoco</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>jacoco</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<argLine>-Xms256m -Xmx1524m -XX:MaxPermSize=256m -Duser.language=en</argLine>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.7.201606060606</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I did not find any solution, but I did the following:
mvn clean jacoco:prepare-agent install
create file jacoco.exec, but execute mvn sonar:sonar not create File.
Solution:
Step 1:
mvn clean jacoco:prepare-agent install
Step 2:
copy file jacoco.exec from /src/main/resources
Step 3:
Add next plugin on pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>
${basedir}/target/</outputDirectory>
<resources>
<resource>
<directory>
${basedir}/src/main/resources/ </directory>
<includes>
<include>jacoco.exec</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
<configuration>
<encoding>cp1252</encoding>
</configuration>
</plugin>
Step 4:
mvn clean install
Step 5:
mvn sonar:sonar
READY
Add my section Plugins
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>cp1252</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>
${basedir}/target/</outputDirectory>
<resources>
<resource>
<directory>
${basedir}/src/main/resources/ </directory>
<includes>
<include>jacoco.exec</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>copy-folder</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}</outputDirectory>
<resources>
<resource>
<filtering>false</filtering>
<directory>${project.basedir}/src/main/resources</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
<configuration>
<encoding>cp1252</encoding>
</configuration>
</plugin>
<!-- Plugin Sonar -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.1</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.6.201602180812</version>
<configuration>
<destFile>${project.build.directory}/jacoco.exec</destFile>
</configuration>
<executions>
<execution>
<id>jacoco-initialize</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${basedir}/target/jacoco.exec</destFile>
<dataFile>${basedir}/target/jacoco.exec</dataFile>
</configuration>
</execution>
<execution>
<id>jacoco-site</id>
<phase>package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
I also faced the same problem where jacoco plugin was added to parent pom, and jacoco.exec file was generating for one of the sub modules. I had to remove the argLine arguments of maven surefire plugin, then it got generated.

Generated sources being compiled twice

Using Eclipse Luna with m2eclipse, I have a parent Maven project (facturas_root) and two Maven modules inheriting from it (sharepoint_ws and api_sharepoint).
sharepoint_ws was to be used only to generate JAXWS classes to connect to the Sharepoint WebServices, so I downloaded the related WSDL and included those as resources of the project. At generate-sources phase, it works correctly and generates the sources in target\generated-sources\ws-consume\mypackage\.
Now, the issue is that I made api_sharepoint import the sharepoint_ws dependency, but it does not detect any class. I assumed that it was because the generated classes were not at src/main/java, so I added a plugin to copy them there. Now, the problem is that at the compile phase of sharepoint_ws, it finds twice the source file of each class and throws an error.
My pom.xml -> build
<plugins>
<!-- clean /src/main/java and /target/generated-sources -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.6.1</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>clean</goal>
</goals>
<configuration>
<filesets>
<fileset>
<directory>${basedir}/src/main/java/es</directory>
</fileset>
<fileset>
<directory>${basedir}/target/generated-sources</directory>
</fileset>
</configuration>
</execution>
</executions>
</plugin>
<!-- generate jaxws -->
<plugin>
<groupId>org.jboss.ws.plugins</groupId>
<artifactId>maven-jaxws-tools-plugin</artifactId>
<version>1.1.2.Final</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>wsconsume</goal>
</goals>
<configuration>
<wsdls>
<wsdl>${basedir}/resources/lists.wsdl</wsdl>
</wsdls>
<targetPackage>es.ssib.otic.facturas.sharepoint_ws</targetPackage>
<outputDirectory>${basedir}/target/generated-sources</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<!-- copy sources -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-filtering</artifactId>
<version>1.3</version>
</dependency>
</dependencies>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/src/main/java</outputDirectory>
<resources>
<resource>
<directory>${basedir}/target/generated-sources/wsconsume</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
In order to try to exclude target/generated-sources I have addded this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>default-compile</id>
<phase>compile</phase>
<configuration>
<excludes>
<exclude>**/target/generated-sources/*.java</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
As stated above, I do comment the "copy" plugin, the module depending on sharepoint_ws does not have any ot its classes available; I do use it I get errors in the tune of
[ERROR] /C:/Users/s004256/workspace/facturas_root/sharepoint_ws/src/main/java/es/ssib/otic/facturas/sharepoint_ws/DeleteList.java:[34,8] duplicate class: es.ssib.otic.facturas.sharepoint_ws.DeleteList
for each generated list.
In the first place, I recommend you'd better declare target/generated-sources as a source folder, instead of copying files here and there:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>add-source</id>
<phase>initialize</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
This should be enough to make Maven compile the target/generated-sources/*.java and package them all in the library, and also for Eclipse to recognize target/generated-sources as a source directory (after you execute Maven/Update Project).
By the way: You should take care of binding the plugins to a phase in the correct order: If you bound all tasks to "generate-sources", you have no gurantee about in which order will they be executed. And the same goes for the "compile" phase: You have to set properly the source folders, with its inclusions and exclusions, before the compile phase.
Take a look a the Default Maven Lifecycle and try to chose different, sequential phases for your tasks.

Concordion with Maven, using different folder for integration tests

I am trying to run integration tests (written in Concordion) using Maven 3.2.5. I have done the following.
Created a maven project using quickstart archetype.
Put my source code in src/main/java, unit test in src/test/java and integration
tests in src/spec/java.
Used maven-antrun-plugin to put integration test *.class in target/integrationtest-classes
Use maven-surefire-plugin to run the unit test cases.
Use maven-failsafe-plugin to run the integration test cases.
Finally run everything using "mvn clean install"
The problem is, while the unit test cases are running, the integration test cases are not. When I run the integration test cases from Eclipse, by running them as JUnit they run alright. However, when I run them from Maven, somehow only the unit test cases run. Can someone please help.
I am attaching my pom.xml here.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.acme.bundler</groupId>
<artifactId>concordion</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>concordion</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- Integration test. -->
<integrationSourceDirectory>src/spec/java</integrationSourceDirectory>
<integrationOutputDirectory>target/integrationtest-classes</integrationOutputDirectory>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>org.concordion</groupId>
<artifactId>concordion</artifactId>
<version>1.4.6</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<!-- Compile and run using jdk 1.7 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
<executions>
<execution>
<phase>pre-integration-test</phase>
<goals>
<goal>testCompile</goal>
</goals>
<configuration>
<compilerArguments>
<d>${integrationOutputDirectory}</d>
</compilerArguments>
</configuration>
</execution>
</executions>
</plugin>
<!-- Run the main class of Java. -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.acme.bundler.concordion.App</mainClass>
<arguments>
<argument>foo</argument>
<argument>bar</argument>
</arguments>
</configuration>
</plugin>
<!-- The artefacts of integration tests need to move to a different folder
than the output of unit tests. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>create-directory</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo message="Creating Directory ${integrationOutputDirectory}" />
<mkdir dir="${integrationOutputDirectory}" />
</tasks>
</configuration>
</execution>
</executions>
</plugin>
<!-- Move the .class of the .java files in integration tests. <mkdir
dir="${itest.testOutputDirectory}" /> <move todir="${itest.testOutputDirectory}">
<fileset dir="${project.build.testOutputDirectory}"> <include name="**/*.class"
/> <present targetdir="${spec.testSourceDirectory}"> <mapper type="glob"
from="*.class" to="*.java" /> </present> </fileset> </move> -->
<!-- Surefire is designed to run the unit tests. If any of the tests
break the whole build breaks. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<test>**/*.java</test>
</configuration>
</plugin>
<!-- Failsafe is designed to run integration tests. -->
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.8</version>
<configuration>
<testClassesDirectory>${integrationOutputDirectory}</testClassesDirectory>
<reportsDirectory>${integrationOutputDirectory}/failsafe-reports</reportsDirectory>
<test>**/*.java</test>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<!-- Copy integration tests. -->
<execution>
<id>add-test-sources</id>
<phase>pre-integration-test</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>${integrationSourceDirectory}</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-test-resources</id>
<phase>pre-integration-test</phase>
<goals>
<goal>add-test-resource</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>${integrationSourceDirectory}</directory>
<targetPath>${integrationOutputDirectory}</targetPath>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>add-empty-directory</id>
<phase>pre-integration-test</phase>
<goals>
<goal>add-test-resource</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>${integrationSourceDirectory}</directory>
<targetPath>${integrationOutputDirectory}</targetPath>
<excludes>
<exclude>**/*</exclude>
</excludes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>

How to make Maven Clean Install build JavaFX8?

Every time I try to run my JavaFX 8 project, I need to do a clean install with Maven then build project with eclipse. Doing only the clean install will result in an Exception.
How can I make the maven clean install and eclipse build execute in one command.
If I need to add it in my pom.xml, should I put it in my parent pom.xml or all in its children?
Thanks!
Finally got mine working, I just added this lines of code on my parent pom.xml.
<build>
<plugins>
<!-- This will copy all your dependencies to target/libs, which will be
picked up by the ant task below -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/libs</outputDirectory>
<includeScope>compile</includeScope>
<includeScope>runtime</includeScope>
<excludeArtifactIds>javafx</excludeArtifactIds>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>create-javafx-packages</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target xmlns:fx="javafx:com.sun.javafx.tools.ant">
<taskdef uri="javafx:com.sun.javafx.tools.ant" resource="com/sun/javafx/tools/ant/antlib.xml" classpath="${javafx.tools.ant.jar}"/>
<fx:application id="fxApp" name="${project.name}" mainClass="${project.main.class}"/>
<!-- Note: this will overwrite the JAR produced by maven-jar-plugin,
change destfile if you don't want this -->
<fx:jar destfile="${project.build.directory}/../../${project.build.finalName}">
<fx:application refid="fxApp"/>
<fx:fileset dir="${project.build.directory}/../.." includes="target/classes"/>
<fx:resources>
<fx:fileset dir="${project.build.directory}/../.." includes="libs/*.jar"/>
</fx:resources>
</fx:jar>
<fx:deploy outdir="${project.build.directory}/../../javafx-output" outfile="${project.build.finalName}" nativeBundles="all">
<fx:application refid="fxApp"/>
<fx:resources>
<!-- If you changed <fx:jar> above, don't forget to modify the
line below -->
<fx:fileset dir="${project.build.directory}/../.." includes="${project.build.finalName}.jar"/>
<fx:fileset dir="${project.build.directory}/../.." includes="libs/*.jar"/>
</fx:resources>
</fx:deploy>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>javafx</artifactId>
<version>${javafx.version}</version>
<scope>system</scope>
<systemPath>${java.home}/lib/ext/jfxrt.jar</systemPath>
</dependency>
</dependencies>
Try doing the following
mvn clean install eclipse:clean eclipse:eclipse and then do a refresh on the project in eclipse.
HTH,
Keshava.

Resources