My pom looks like
<plugins>
<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>
<generateDirectory>src/main/java</generateDirectory>
<schemaDirectory>src/main/resources/wsdl/</schemaDirectory>
<schemaIncludes>
<include>*.xsd</include>
<include>draw/*.xsd</include>
</schemaIncludes>
</configuration>
</plugin>
</plugins>
When I do a mvn clean package
it is built according to the configuration. However after I have built it once I don't want to build it every time I do a mvn clean package
unless the XSD
has been modified somehow.
How do I achieve this?
The default phase declared in this plugin for the goal <goal>generate</goal>
is generate-resources
. referring to Maven Default Lifecycle you can't skip phases. The mvn phase-x command always means "run all phases until phase-x, inclusive".
The option you may use is profile
. so you can profile your project to be build with or without generating resources.
Example:
<profiles>
<profile>
<id>GEN-RESOURCES</id>
<build>
<plugins>
<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>
<generateDirectory>src/main/java</generateDirectory>
<schemaDirectory>src/main/resources/wsdl/</schemaDirectory>
<schemaIncludes>
<include>*.xsd</include>
<include>draw/*.xsd</include>
</schemaIncludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
to activate the profile use -P
mvn clean package -PGEN-RESOURCES
otherwise no thing will be generated Maven profile explained here
I hope this helps.