diff --git a/maven-plugin/plugin-core/src/main/java/org/jvnet/jaxb/maven/AbstractXJC2Mojo.java b/maven-plugin/plugin-core/src/main/java/org/jvnet/jaxb/maven/AbstractXJC2Mojo.java
index c30f9181d..f347ab5e1 100644
--- a/maven-plugin/plugin-core/src/main/java/org/jvnet/jaxb/maven/AbstractXJC2Mojo.java
+++ b/maven-plugin/plugin-core/src/main/java/org/jvnet/jaxb/maven/AbstractXJC2Mojo.java
@@ -1000,7 +1000,27 @@ public void setPlugins(Dependency[] plugins) {
this.plugins = plugins;
}
- @Component
+ /**
+ *
+ * A list of artifacts to exclude from XJC Plugins resolveTransitively function.
+ *
+ *
+ * If you are using xerces:xercesImpl
and / or xml-apis
,
+ * adding them will exclude from the classpath resolution, fixing issue #560.
+ *
+ */
+ @Parameter
+ private String[] artifactExcludes = new String[] {};
+
+ public String[] getArtifactExcludes() {
+ return artifactExcludes;
+ }
+
+ public void setArtifactExcludes(String[] artifactExcludes) {
+ this.artifactExcludes = artifactExcludes;
+ }
+
+ @Component
private RepositorySystem repositorySystem;
@Component
@@ -1140,6 +1160,7 @@ protected void logConfiguration() throws MojoExecutionException {
+ getScanDependenciesForBindings());
getLog().info("xjcPlugins:" + Arrays.toString(getPlugins()));
getLog().info("episodes:" + Arrays.toString(getEpisodes()));
+ getLog().info("artifactExcludes:" + Arrays.toString(getArtifactExcludes()));
}
private static final String XML_SCHEMA_CLASS_NAME = "XmlSchema";
diff --git a/maven-plugin/plugin-core/src/main/java/org/jvnet/jaxb/maven/RawXJC2Mojo.java b/maven-plugin/plugin-core/src/main/java/org/jvnet/jaxb/maven/RawXJC2Mojo.java
index 4dd716373..341b8c283 100644
--- a/maven-plugin/plugin-core/src/main/java/org/jvnet/jaxb/maven/RawXJC2Mojo.java
+++ b/maven-plugin/plugin-core/src/main/java/org/jvnet/jaxb/maven/RawXJC2Mojo.java
@@ -394,8 +394,10 @@ protected void resolveArtifacts() throws MojoExecutionException {
protected void resolveXJCPluginArtifacts()
throws ArtifactResolutionException, ArtifactNotFoundException, InvalidDependencyVersionException {
- this.xjcPluginArtifacts = ArtifactUtils.resolveTransitively(getArtifactFactory(), getRepositorySystem(),
- getMavenSession().getLocalRepository(), getArtifactMetadataSource(), getPlugins(), getProject());
+ this.xjcPluginArtifacts = ArtifactUtils.resolveTransitively(
+ getArtifactFactory(), getRepositorySystem(),
+ getMavenSession().getLocalRepository(), getArtifactMetadataSource(),
+ getPlugins(), getProject(), getArtifactExcludes());
this.xjcPluginFiles = ArtifactUtils.getFiles(this.xjcPluginArtifacts);
this.xjcPluginURLs = CollectionUtils.apply(this.xjcPluginFiles, IOUtils.GET_URL);
}
diff --git a/maven-plugin/plugin-core/src/main/java/org/jvnet/jaxb/maven/util/ArtifactUtils.java b/maven-plugin/plugin-core/src/main/java/org/jvnet/jaxb/maven/util/ArtifactUtils.java
index fee22cd92..b1c4fb72f 100644
--- a/maven-plugin/plugin-core/src/main/java/org/jvnet/jaxb/maven/util/ArtifactUtils.java
+++ b/maven-plugin/plugin-core/src/main/java/org/jvnet/jaxb/maven/util/ArtifactUtils.java
@@ -15,6 +15,7 @@
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
+import org.apache.maven.artifact.resolver.filter.ExclusionSetFilter;
import org.apache.maven.model.Dependency;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
@@ -27,13 +28,28 @@ public class ArtifactUtils {
private ArtifactUtils() {
}
+ public static Collection resolveTransitively(
+ final ArtifactFactory artifactFactory,
+ final RepositorySystem artifactResolver,
+ final ArtifactRepository localRepository,
+ final ArtifactMetadataSource artifactMetadataSource,
+ final Dependency[] dependencies, final MavenProject project)
+ throws InvalidDependencyVersionException,
+ ArtifactResolutionException, ArtifactNotFoundException {
+ return resolveTransitively(
+ artifactFactory, artifactResolver,
+ localRepository, artifactMetadataSource,
+ dependencies, project,
+ null);
+ }
public static Collection resolveTransitively(
final ArtifactFactory artifactFactory,
final RepositorySystem artifactResolver,
final ArtifactRepository localRepository,
final ArtifactMetadataSource artifactMetadataSource,
- final Dependency[] dependencies, final MavenProject project)
+ final Dependency[] dependencies, final MavenProject project,
+ final String[] artifactExcludes)
throws InvalidDependencyVersionException,
ArtifactResolutionException, ArtifactNotFoundException {
if (dependencies == null) {
@@ -49,6 +65,10 @@ public static Collection resolveTransitively(
request.setResolveRoot(false);
request.setArtifact(project.getArtifact());
request.setArtifactDependencies(artifacts);
+ if (artifactExcludes != null && artifactExcludes.length > 0) {
+ // remove dependencies from resolution
+ request.setCollectionFilter(new ExclusionSetFilter(artifactExcludes));
+ }
request.setRemoteRepositories(project.getRemoteArtifactRepositories());
request.setLocalRepository(localRepository);