diff --git a/pom.xml b/pom.xml
index 26f715ee..b5647176 100644
--- a/pom.xml
+++ b/pom.xml
@@ -367,23 +367,47 @@
maven-invoker-plugintrue
- ${project.build.directory}/itverify${project.build.directory}/local-reposrc/it/settings.xml
-
- clean
- test-compile
-
- integration-test
+ installinstall
+
+
+
+ run-clean-test-compile
+
+ run
+
+
+ ${project.build.directory}/it
+
+ clean
+ test-compile
+
+
+
+
+
+ run-test-compile
+ run
+
+
+ ${project.build.directory}/it
+
+ xjc-test/pom.xml
+
+
+ test-compile
+
+
diff --git a/src/it/xjc-test/pom.xml b/src/it/xjc-test/pom.xml
index eb4aa1d9..141664d4 100644
--- a/src/it/xjc-test/pom.xml
+++ b/src/it/xjc-test/pom.xml
@@ -38,7 +38,7 @@
org.apache.maven.pluginsmaven-compiler-plugin
- 2.5.1
+ 3.5.11.6
diff --git a/src/it/xjc-test/src/test/java/Test.java b/src/it/xjc-test/src/test/java/Test.java
new file mode 100644
index 00000000..3990a585
--- /dev/null
+++ b/src/it/xjc-test/src/test/java/Test.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import com.example.myschema.AddressType;
+
+public class Test {
+ public AddressType createAddress() {
+ return new AddressType();
+ }
+}
diff --git a/src/main/java/org/codehaus/mojo/jaxb2/AbstractJaxbMojo.java b/src/main/java/org/codehaus/mojo/jaxb2/AbstractJaxbMojo.java
index 7628d82f..2e1be54b 100644
--- a/src/main/java/org/codehaus/mojo/jaxb2/AbstractJaxbMojo.java
+++ b/src/main/java/org/codehaus/mojo/jaxb2/AbstractJaxbMojo.java
@@ -270,19 +270,8 @@ public final void execute() throws MojoExecutionException, MojoFailureException
log.info("No changes detected in schema or binding files - skipping JAXB generation.");
}
- // 4) If the output directories exist, add them to the MavenProject's source directories
- if(getOutputDirectory().exists() && getOutputDirectory().isDirectory()) {
-
- final String canonicalPathToOutputDirectory = FileSystemUtilities.getCanonicalPath(getOutputDirectory());
-
- if(log.isDebugEnabled()) {
- log.debug("Adding existing JAXB outputDirectory [" + canonicalPathToOutputDirectory
- + "] to Maven's sources.");
- }
-
- // Add the output Directory.
- getProject().addCompileSourceRoot(canonicalPathToOutputDirectory);
- }
+ // 4) Update the project always.
+ updateProject();
}
/**
@@ -310,6 +299,13 @@ public final void execute() throws MojoExecutionException, MojoFailureException
*/
protected abstract boolean performExecution() throws MojoExecutionException, MojoFailureException;
+ /**
+ * Update the Maven project if necessary. This method will be called if {@code !shouldExecutionBeSkipped()}
+ * (even if {@link #performExecution()} is skipped).
+ */
+ protected void updateProject() {
+ }
+
/**
* Override this method to acquire a List holding all URLs to the sources which this
* AbstractJaxbMojo should use to produce its output (XSDs files for AbstractXsdGeneratorMojos and
diff --git a/src/main/java/org/codehaus/mojo/jaxb2/javageneration/AbstractJavaGeneratorMojo.java b/src/main/java/org/codehaus/mojo/jaxb2/javageneration/AbstractJavaGeneratorMojo.java
index b64d5d25..9ed5831b 100644
--- a/src/main/java/org/codehaus/mojo/jaxb2/javageneration/AbstractJavaGeneratorMojo.java
+++ b/src/main/java/org/codehaus/mojo/jaxb2/javageneration/AbstractJavaGeneratorMojo.java
@@ -430,9 +430,6 @@ protected boolean performExecution() throws MojoExecutionException, MojoFailureE
}
}
- // Add the generated source root to the project, enabling tooling and other plugins to see them.
- addGeneratedSourcesToProjectSourceRoot();
-
// Copy all source XSDs to the resulting artifact?
if (xsdPathWithinArtifact != null) {
@@ -507,13 +504,6 @@ protected boolean performExecution() throws MojoExecutionException, MojoFailureE
*/
protected abstract List getSourceXJBs();
- /**
- * Adds any directories containing the generated XJC classes to the appropriate Project compilation sources;
- * either {@code TestCompileSourceRoot} or {@code CompileSourceRoot} depending on the exact Mojo implementation
- * of this AbstractJavaGeneratorMojo.
- */
- protected abstract void addGeneratedSourcesToProjectSourceRoot();
-
/**
* Adds the supplied Resource to the project using the appropriate scope (i.e. resource or testResource)
* depending on the exact implementation of this AbstractJavaGeneratorMojo.
diff --git a/src/main/java/org/codehaus/mojo/jaxb2/javageneration/TestXjcMojo.java b/src/main/java/org/codehaus/mojo/jaxb2/javageneration/TestXjcMojo.java
index b324bfbd..704807f6 100644
--- a/src/main/java/org/codehaus/mojo/jaxb2/javageneration/TestXjcMojo.java
+++ b/src/main/java/org/codehaus/mojo/jaxb2/javageneration/TestXjcMojo.java
@@ -305,7 +305,7 @@ protected List getClasspath() throws MojoExecutionException {
* {@inheritDoc}
*/
@Override
- protected void addGeneratedSourcesToProjectSourceRoot() {
+ protected void updateProject() {
getProject().addTestCompileSourceRoot(getOutputDirectory().getAbsolutePath());
}
diff --git a/src/main/java/org/codehaus/mojo/jaxb2/javageneration/XjcMojo.java b/src/main/java/org/codehaus/mojo/jaxb2/javageneration/XjcMojo.java
index be0529e3..d6cc4ac8 100644
--- a/src/main/java/org/codehaus/mojo/jaxb2/javageneration/XjcMojo.java
+++ b/src/main/java/org/codehaus/mojo/jaxb2/javageneration/XjcMojo.java
@@ -319,7 +319,7 @@ protected List getClasspath() throws MojoExecutionException {
* {@inheritDoc}
*/
@Override
- protected void addGeneratedSourcesToProjectSourceRoot() {
+ protected void updateProject() {
getProject().addCompileSourceRoot(getOutputDirectory().getAbsolutePath());
}