diff --git a/src/main/java/org/codehaus/mojo/jaxb2/AbstractJaxbMojo.java b/src/main/java/org/codehaus/mojo/jaxb2/AbstractJaxbMojo.java index 54b01bdd..38a0764c 100644 --- a/src/main/java/org/codehaus/mojo/jaxb2/AbstractJaxbMojo.java +++ b/src/main/java/org/codehaus/mojo/jaxb2/AbstractJaxbMojo.java @@ -358,10 +358,17 @@ public final void execute() throws MojoExecutionException, MojoFailureException } // Add the output Directory. - getProject().addCompileSourceRoot(canonicalPathToOutputDirectory); + addGeneratedSourcesToProjectSourceRoot(canonicalPathToOutputDirectory); } } + /** + * 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(String canonicalPathToOutputDirectory); + /** * Implement this method to check if this AbstractJaxbMojo should skip executing altogether. * 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 d32a353f..22ca2244 100644 --- a/src/main/java/org/codehaus/mojo/jaxb2/javageneration/AbstractJavaGeneratorMojo.java +++ b/src/main/java/org/codehaus/mojo/jaxb2/javageneration/AbstractJavaGeneratorMojo.java @@ -528,7 +528,8 @@ protected boolean performExecution() throws MojoExecutionException, MojoFailureE } // Add the generated source root to the project, enabling tooling and other plugins to see them. - addGeneratedSourcesToProjectSourceRoot(); + String canonicalPathToOutputDirectory = FileSystemUtilities.getCanonicalPath(getOutputDirectory()); + addGeneratedSourcesToProjectSourceRoot(canonicalPathToOutputDirectory); // Copy all source XSDs to the resulting artifact? if (xsdPathWithinArtifact != null) { @@ -604,13 +605,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(); - // // Private helpers // 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 f37885f7..f6b0046a 100644 --- a/src/main/java/org/codehaus/mojo/jaxb2/javageneration/TestXjcMojo.java +++ b/src/main/java/org/codehaus/mojo/jaxb2/javageneration/TestXjcMojo.java @@ -326,7 +326,7 @@ protected List getClasspath() throws MojoExecutionException { * {@inheritDoc} */ @Override - protected void addGeneratedSourcesToProjectSourceRoot() { + protected void addGeneratedSourcesToProjectSourceRoot(String canonicalPathToOutputDirectory) { 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 a085e348..8a94ee8c 100644 --- a/src/main/java/org/codehaus/mojo/jaxb2/javageneration/XjcMojo.java +++ b/src/main/java/org/codehaus/mojo/jaxb2/javageneration/XjcMojo.java @@ -332,8 +332,8 @@ protected List getClasspath() throws MojoExecutionException { * {@inheritDoc} */ @Override - protected void addGeneratedSourcesToProjectSourceRoot() { - getProject().addCompileSourceRoot(FileSystemUtilities.getCanonicalPath(getOutputDirectory())); + protected void addGeneratedSourcesToProjectSourceRoot(String canonicalPathToOutputDirectory) { + getProject().addCompileSourceRoot(canonicalPathToOutputDirectory); } /** diff --git a/src/main/java/org/codehaus/mojo/jaxb2/schemageneration/SchemaGenerationMojo.java b/src/main/java/org/codehaus/mojo/jaxb2/schemageneration/SchemaGenerationMojo.java index bb4f9874..1679b03b 100644 --- a/src/main/java/org/codehaus/mojo/jaxb2/schemageneration/SchemaGenerationMojo.java +++ b/src/main/java/org/codehaus/mojo/jaxb2/schemageneration/SchemaGenerationMojo.java @@ -244,6 +244,14 @@ protected List getClasspath() throws MojoExecutionException { return toReturn; } + /** + * {@inheritDoc} + */ + @Override + protected void addGeneratedSourcesToProjectSourceRoot(String canonicalPathToOutputDirectory) { + getProject().addCompileSourceRoot(canonicalPathToOutputDirectory); + } + /** * {@inheritDoc} */ diff --git a/src/main/java/org/codehaus/mojo/jaxb2/schemageneration/TestSchemaGenerationMojo.java b/src/main/java/org/codehaus/mojo/jaxb2/schemageneration/TestSchemaGenerationMojo.java index aa2931ed..584096a5 100644 --- a/src/main/java/org/codehaus/mojo/jaxb2/schemageneration/TestSchemaGenerationMojo.java +++ b/src/main/java/org/codehaus/mojo/jaxb2/schemageneration/TestSchemaGenerationMojo.java @@ -215,6 +215,14 @@ protected List getClasspath() throws MojoExecutionException { return toReturn; } + /** + * {@inheritDoc} + */ + @Override + protected void addGeneratedSourcesToProjectSourceRoot(String canonicalPathToOutputDirectory) { + getProject().addTestCompileSourceRoot(canonicalPathToOutputDirectory); + } + /** * {@inheritDoc} */