Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make testXjc attach test sources #184

Merged
merged 1 commit into from
Apr 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/main/java/org/codehaus/mojo/jaxb2/AbstractJaxbMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -361,10 +361,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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,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) {
Expand Down Expand Up @@ -579,13 +580,6 @@ protected boolean performExecution() throws MojoExecutionException, MojoFailureE
*/
protected abstract List<File> 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
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ protected List<String> getClasspath() throws MojoExecutionException {
* {@inheritDoc}
*/
@Override
protected void addGeneratedSourcesToProjectSourceRoot() {
protected void addGeneratedSourcesToProjectSourceRoot(String canonicalPathToOutputDirectory) {
getProject().addTestCompileSourceRoot(getOutputDirectory().getAbsolutePath());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,8 @@ protected List<String> getClasspath() throws MojoExecutionException {
* {@inheritDoc}
*/
@Override
protected void addGeneratedSourcesToProjectSourceRoot() {
getProject().addCompileSourceRoot(FileSystemUtilities.getCanonicalPath(getOutputDirectory()));
protected void addGeneratedSourcesToProjectSourceRoot(String canonicalPathToOutputDirectory) {
getProject().addCompileSourceRoot(canonicalPathToOutputDirectory);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,14 @@ protected List<String> getClasspath() throws MojoExecutionException {
return toReturn;
}

/**
* {@inheritDoc}
*/
@Override
protected void addGeneratedSourcesToProjectSourceRoot(String canonicalPathToOutputDirectory) {
getProject().addCompileSourceRoot(canonicalPathToOutputDirectory);
}

/**
* {@inheritDoc}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,14 @@ protected List<String> getClasspath() throws MojoExecutionException {
return toReturn;
}

/**
* {@inheritDoc}
*/
@Override
protected void addGeneratedSourcesToProjectSourceRoot(String canonicalPathToOutputDirectory) {
getProject().addTestCompileSourceRoot(canonicalPathToOutputDirectory);
}

/**
* {@inheritDoc}
*/
Expand Down