You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sj...@apache.org on 2024/11/16 17:08:17 UTC
(maven-dependency-plugin) branch master updated: [MDEP-689] Fixes ignored dependency filtering in go-offline goal (#417)
This is an automated email from the ASF dual-hosted git repository.
sjaranowski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git
The following commit(s) were added to refs/heads/master by this push:
new c8a22b6b [MDEP-689] Fixes ignored dependency filtering in go-offline goal (#417)
c8a22b6b is described below
commit c8a22b6b5623e0f9964176563ff00b1a36670063
Author: Lisa Hardy <11...@users.noreply.github.com>
AuthorDate: Sat Nov 16 12:08:13 2024 -0500
[MDEP-689] Fixes ignored dependency filtering in go-offline goal (#417)
---
pom.xml | 3 +
.../invoker.properties | 18 +
.../pom.xml | 109 ++++++
.../verify.groovy | 50 +++
.../AbstractDependencyFilterMojo.java | 4 +-
.../dependency/resolvers/AbstractResolveMojo.java | 41 +++
.../dependency/resolvers/GoOfflineMojo.java | 61 +++-
.../dependency/resolvers/ResolvePluginsMojo.java | 39 --
.../dependency/resolvers/GoOfflineMojoTest.java | 405 +++++++++++++++++++++
.../unit/go-offline-test/exclude-plugin-config.xml | 35 ++
.../go-offline-test/include-aid-plugin-config.xml | 25 ++
.../go-offline-test/include-gid-plugin-config.xml | 24 ++
.../include-scope-plugin-config.xml | 24 ++
.../include-types-plugin-config.xml | 24 ++
14 files changed, 819 insertions(+), 43 deletions(-)
diff --git a/pom.xml b/pom.xml
index d02c0181..5cdf2565 100644
--- a/pom.xml
+++ b/pom.xml
@@ -59,6 +59,9 @@ under the License.
<contributor>
<name>Maarten Mulders</name>
</contributor>
+ <contributor>
+ <name>Lisa Hardy</name>
+ </contributor>
</contributors>
<prerequisites>
diff --git a/src/it/projects/mdep-689-apply-filtering-go-offline-goal/invoker.properties b/src/it/projects/mdep-689-apply-filtering-go-offline-goal/invoker.properties
new file mode 100644
index 00000000..4623ccd6
--- /dev/null
+++ b/src/it/projects/mdep-689-apply-filtering-go-offline-goal/invoker.properties
@@ -0,0 +1,18 @@
+# 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.
+
+invoker.goals = clean ${project.groupId}:${project.artifactId}:${project.version}:go-offline
diff --git a/src/it/projects/mdep-689-apply-filtering-go-offline-goal/pom.xml b/src/it/projects/mdep-689-apply-filtering-go-offline-goal/pom.xml
new file mode 100644
index 00000000..a41847d9
--- /dev/null
+++ b/src/it/projects/mdep-689-apply-filtering-go-offline-goal/pom.xml
@@ -0,0 +1,109 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.maven.plugins.dependency</groupId>
+ <artifactId>mdep-739-go-offline-respect-classifiers</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <description>Test that dependency:go-offline applies exclude filters</description>
+ <dependencies>
+ <dependency> <!-- excluded by excludeGroupId -->
+ <groupId>skip.this.groupid</groupId>
+ <artifactId>dummy-artifact</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency> <!-- excluded by excludeGroupId -->
+ <groupId>skip.this.groupid.too</groupId>
+ <artifactId>dummy-artifact</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency> <!-- excluded by excludeArtifactId -->
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>skip-this-artifact</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency> <!-- excluded by excludeArtifactId -->
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>skip-this-artifact-too</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency> <!-- excluded by excludeClassifier -->
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-access</artifactId>
+ <version>1.4.7</version>
+ <classifier>skipThisClassifier</classifier>
+ </dependency>
+ <dependency> <!-- excluded by excludeClassifier -->
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-core</artifactId>
+ <version>1.5.6</version>
+ <classifier>skipThisClassifierToo</classifier>
+ </dependency>
+ <dependency><!-- should not be excluded -->
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>2.0.13</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency> <!-- excluded by excludeScope -->
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <version>1.5.4</version>
+ <scope>system</scope>
+ <!-- it doesn't matter what jar this points to, needs a systemPath to compile -->
+ <systemPath>${project.build.directory}/local-repo/junit/junit/4.13.2/junit-4.13.2.jar</systemPath>
+ </dependency>
+ <dependency><!-- should not be excluded -->
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <version>2.0.13</version>
+ </dependency>
+ <dependency> <!-- excluded by excludeType -->
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-examples</artifactId>
+ <version>1.4.7</version>
+ <type>ear</type>
+ </dependency>
+ </dependencies>
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>@project.version@</version>
+ <configuration>
+ <excludeGroupIds>skip.this.groupid,skip.this.groupid.too</excludeGroupIds>
+ <excludeArtifactIds>skip-this-artifact,skip-this-artifact-too</excludeArtifactIds>
+ <!-- the maven-common-artifact-filters library does not support comma delimited
+ scope exclusions. only one at a time. the other filters support comma delimited lists-->
+ <!-- <excludeScope>compile,system</excludeScope> -->
+ <excludeScope>system</excludeScope>
+ <excludeTypes>ear</excludeTypes>
+ <excludeClassifiers>skipThisClassifier,skipThisClassifierToo</excludeClassifiers>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+</project>
diff --git a/src/it/projects/mdep-689-apply-filtering-go-offline-goal/verify.groovy b/src/it/projects/mdep-689-apply-filtering-go-offline-goal/verify.groovy
new file mode 100644
index 00000000..1bc9464f
--- /dev/null
+++ b/src/it/projects/mdep-689-apply-filtering-go-offline-goal/verify.groovy
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+
+File file = new File( basedir, "build.log" )
+assert file.exists()
+
+String buildLog = file.getText( "UTF-8" )
+
+// Make sure non-exluded explicit dependencies are resolved
+assert buildLog.contains( 'Resolved dependency: slf4j-simple-2.0.13.jar' )
+assert buildLog.contains( 'Resolved dependency: slf4j-api-2.0.13.jar' )
+
+// Did group excludes work?
+assert !buildLog.contains( 'Resolving artifact skip.this.groupid' )
+
+// Did artifact excludes work?
+assert !buildLog.contains( 'Resolving artifact org.junit.jupiter:skip-this-artifact' )
+
+// Did scope exludes work?
+assert !buildLog.contains( 'Resolving artifact ch.qos.logback:logback-classic' )
+
+// Did type excludes work?
+assert !buildLog.contains( 'Resolving artifact ch.qos.logback:logback-examples' )
+
+// Did classifier excludes work?
+assert !buildLog.contains( 'Resolving artifact ch.qos.logback:logback-core:jar:skipThisClassifierToo' )
+assert !buildLog.contains( 'Resolving artifact ch.qos.logback:logback-core' )
+
+assert !buildLog.contains( 'Resolving artifact ch.qos.logback:logback-access:jar:skipThisClassifier' )
+assert !buildLog.contains( 'Resolving artifact ch.qos.logback:logback-access' )
+
+
+
+return true
diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java
index 655458b5..63a1cfa1 100644
--- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java
+++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java
@@ -136,7 +136,9 @@ public abstract class AbstractDependencyFilterMojo extends AbstractDependencyMoj
/**
* Scope threshold to exclude, if no value is defined for include.
- * An empty string indicates no dependencies (default).<br>
+ * An empty string indicates no dependencies (default). Unlike the other
+ * exclusion parameters, this property does not support a comma-delimited
+ * list of scope exclusions. Just one scope may be excluded at a time.<br>
* The scope threshold value being interpreted is the scope as
* Maven filters for creating a classpath, not as specified in the pom. In summary:
* <ul>
diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/AbstractResolveMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/AbstractResolveMojo.java
index a452968e..bf03a003 100644
--- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/AbstractResolveMojo.java
+++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/AbstractResolveMojo.java
@@ -22,6 +22,13 @@ import java.io.File;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.dependency.fromDependencies.AbstractDependencyFilterMojo;
+import org.apache.maven.plugins.dependency.utils.DependencyUtil;
+import org.apache.maven.shared.artifact.filter.collection.ArtifactIdFilter;
+import org.apache.maven.shared.artifact.filter.collection.ClassifierFilter;
+import org.apache.maven.shared.artifact.filter.collection.FilterArtifacts;
+import org.apache.maven.shared.artifact.filter.collection.GroupIdFilter;
+import org.apache.maven.shared.artifact.filter.collection.ScopeFilter;
+import org.apache.maven.shared.artifact.filter.collection.TypeFilter;
/**
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
@@ -52,4 +59,38 @@ public abstract class AbstractResolveMojo extends AbstractDependencyFilterMojo {
*/
@Parameter(property = "excludeReactor", defaultValue = "true")
protected boolean excludeReactor;
+
+ /**
+ * @return {@link FilterArtifacts}
+ */
+ protected FilterArtifacts getArtifactsFilter() {
+ final FilterArtifacts filter = new FilterArtifacts();
+
+ if (excludeReactor) {
+
+ filter.addFilter(new ExcludeReactorProjectsArtifactFilter(reactorProjects, getLog()));
+ }
+
+ filter.addFilter(new ScopeFilter(
+ DependencyUtil.cleanToBeTokenizedString(this.includeScope),
+ DependencyUtil.cleanToBeTokenizedString(this.excludeScope)));
+
+ filter.addFilter(new TypeFilter(
+ DependencyUtil.cleanToBeTokenizedString(this.includeTypes),
+ DependencyUtil.cleanToBeTokenizedString(this.excludeTypes)));
+
+ filter.addFilter(new ClassifierFilter(
+ DependencyUtil.cleanToBeTokenizedString(this.includeClassifiers),
+ DependencyUtil.cleanToBeTokenizedString(this.excludeClassifiers)));
+
+ filter.addFilter(new GroupIdFilter(
+ DependencyUtil.cleanToBeTokenizedString(this.includeGroupIds),
+ DependencyUtil.cleanToBeTokenizedString(this.excludeGroupIds)));
+
+ filter.addFilter(new ArtifactIdFilter(
+ DependencyUtil.cleanToBeTokenizedString(this.includeArtifactIds),
+ DependencyUtil.cleanToBeTokenizedString(this.excludeArtifactIds)));
+
+ return filter;
+ }
}
diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java
index 1bc3e4d7..6ca1c396 100644
--- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java
+++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java
@@ -25,13 +25,17 @@ import java.util.Set;
import java.util.stream.Collectors;
import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.DefaultArtifact;
+import org.apache.maven.artifact.handler.DefaultArtifactHandler;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.model.Dependency;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.dependency.utils.DependencyUtil;
import org.apache.maven.project.ProjectBuildingRequest;
+import org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException;
import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter;
+import org.apache.maven.shared.artifact.filter.collection.FilterArtifacts;
import org.apache.maven.shared.artifact.filter.resolve.TransformableFilter;
import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult;
import org.apache.maven.shared.transfer.dependencies.DefaultDependableCoordinate;
@@ -43,6 +47,7 @@ import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolverE
*
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
* @author Maarten Mulders
+ * @author Lisa Hardy
* @since 2.0
*/
@Mojo(name = "go-offline", threadSafe = true)
@@ -71,7 +76,7 @@ public class GoOfflineMojo extends AbstractResolveMojo {
}
}
- } catch (DependencyResolverException e) {
+ } catch (DependencyResolverException | ArtifactFilterException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
}
@@ -81,10 +86,13 @@ public class GoOfflineMojo extends AbstractResolveMojo {
*
* @return set of resolved dependency artifacts.
* @throws DependencyResolverException in case of an error while resolving the artifacts.
+ * @throws ArtifactFilterException
*/
- protected Set<Artifact> resolveDependencyArtifacts() throws DependencyResolverException {
+ protected Set<Artifact> resolveDependencyArtifacts() throws DependencyResolverException, ArtifactFilterException {
Collection<Dependency> dependencies = getProject().getDependencies();
+ dependencies = filterDependencies(dependencies);
+
Set<DependableCoordinate> dependableCoordinates = dependencies.stream()
.map(this::createDependendableCoordinateFromDependency)
.collect(Collectors.toSet());
@@ -133,8 +141,9 @@ public class GoOfflineMojo extends AbstractResolveMojo {
*
* @return set of resolved plugin artifacts.
* @throws DependencyResolverException in case of an error while resolving the artifacts.
+ * @throws ArtifactFilterException
*/
- protected Set<Artifact> resolvePluginArtifacts() throws DependencyResolverException {
+ protected Set<Artifact> resolvePluginArtifacts() throws DependencyResolverException, ArtifactFilterException {
Set<Artifact> plugins = getProject().getPluginArtifacts();
Set<Artifact> reports = getProject().getReportArtifacts();
@@ -143,6 +152,9 @@ public class GoOfflineMojo extends AbstractResolveMojo {
artifacts.addAll(reports);
artifacts.addAll(plugins);
+ final FilterArtifacts filter = getArtifactsFilter();
+ artifacts = filter.filter(artifacts);
+
Set<DependableCoordinate> dependableCoordinates = artifacts.stream()
.map(this::createDependendableCoordinateFromArtifact)
.collect(Collectors.toSet());
@@ -152,6 +164,16 @@ public class GoOfflineMojo extends AbstractResolveMojo {
return resolveDependableCoordinate(buildingRequest, dependableCoordinates, "plugins");
}
+ private Collection<Dependency> filterDependencies(Collection<Dependency> deps) throws ArtifactFilterException {
+
+ Set<Artifact> artifacts = createArtifactSetFromDependencies(deps);
+
+ final FilterArtifacts filter = getArtifactsFilter();
+ artifacts = filter.filter(artifacts);
+
+ return createDependencySetFromArtifacts(artifacts);
+ }
+
private DependableCoordinate createDependendableCoordinateFromArtifact(final Artifact artifact) {
final DefaultDependableCoordinate result = new DefaultDependableCoordinate();
result.setGroupId(artifact.getGroupId());
@@ -174,6 +196,39 @@ public class GoOfflineMojo extends AbstractResolveMojo {
return result;
}
+ private Set<Artifact> createArtifactSetFromDependencies(Collection<Dependency> deps) {
+ Set<Artifact> artifacts = new HashSet<>();
+ for (Dependency dep : deps) {
+ DefaultArtifactHandler handler = new DefaultArtifactHandler(dep.getType());
+ artifacts.add(new DefaultArtifact(
+ dep.getGroupId(),
+ dep.getArtifactId(),
+ dep.getVersion(),
+ dep.getScope(),
+ dep.getType(),
+ dep.getClassifier(),
+ handler));
+ }
+ return artifacts;
+ }
+
+ private Collection<Dependency> createDependencySetFromArtifacts(Set<Artifact> artifacts) {
+ Set<Dependency> dependencies = new HashSet<>();
+
+ for (Artifact artifact : artifacts) {
+ Dependency d = new Dependency();
+ d.setGroupId(artifact.getGroupId());
+ d.setArtifactId(artifact.getArtifactId());
+ d.setVersion(artifact.getVersion());
+ d.setType(artifact.getType());
+ d.setClassifier(artifact.getClassifier());
+ d.setScope(artifact.getScope());
+ dependencies.add(d);
+ }
+
+ return dependencies;
+ }
+
@Override
protected ArtifactsFilter getMarkedArtifactFilter() {
return null;
diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java
index 4c6e91ac..4a6a2378 100644
--- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java
+++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java
@@ -33,13 +33,8 @@ import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.dependency.utils.DependencyUtil;
import org.apache.maven.project.ProjectBuildingRequest;
import org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException;
-import org.apache.maven.shared.artifact.filter.collection.ArtifactIdFilter;
import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter;
-import org.apache.maven.shared.artifact.filter.collection.ClassifierFilter;
import org.apache.maven.shared.artifact.filter.collection.FilterArtifacts;
-import org.apache.maven.shared.artifact.filter.collection.GroupIdFilter;
-import org.apache.maven.shared.artifact.filter.collection.ScopeFilter;
-import org.apache.maven.shared.artifact.filter.collection.TypeFilter;
import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolverException;
import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult;
import org.apache.maven.shared.transfer.dependencies.DefaultDependableCoordinate;
@@ -174,40 +169,6 @@ public class ResolvePluginsMojo extends AbstractResolveMojo {
return artifacts;
}
- /**
- * @return {@link FilterArtifacts}
- */
- private FilterArtifacts getArtifactsFilter() {
- final FilterArtifacts filter = new FilterArtifacts();
-
- if (excludeReactor) {
-
- filter.addFilter(new ExcludeReactorProjectsArtifactFilter(reactorProjects, getLog()));
- }
-
- filter.addFilter(new ScopeFilter(
- DependencyUtil.cleanToBeTokenizedString(this.includeScope),
- DependencyUtil.cleanToBeTokenizedString(this.excludeScope)));
-
- filter.addFilter(new TypeFilter(
- DependencyUtil.cleanToBeTokenizedString(this.includeTypes),
- DependencyUtil.cleanToBeTokenizedString(this.excludeTypes)));
-
- filter.addFilter(new ClassifierFilter(
- DependencyUtil.cleanToBeTokenizedString(this.includeClassifiers),
- DependencyUtil.cleanToBeTokenizedString(this.excludeClassifiers)));
-
- filter.addFilter(new GroupIdFilter(
- DependencyUtil.cleanToBeTokenizedString(this.includeGroupIds),
- DependencyUtil.cleanToBeTokenizedString(this.excludeGroupIds)));
-
- filter.addFilter(new ArtifactIdFilter(
- DependencyUtil.cleanToBeTokenizedString(this.includeArtifactIds),
- DependencyUtil.cleanToBeTokenizedString(this.excludeArtifactIds)));
-
- return filter;
- }
-
/**
* This method resolves the plugin artifacts from the project.
*
diff --git a/src/test/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojoTest.java b/src/test/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojoTest.java
new file mode 100644
index 00000000..caa00f16
--- /dev/null
+++ b/src/test/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojoTest.java
@@ -0,0 +1,405 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugins.dependency.resolvers;
+
+import java.io.File;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.testing.stubs.ArtifactStub;
+import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase;
+import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.shared.artifact.filter.collection.FilterArtifacts;
+import org.junit.jupiter.api.Disabled;
+
+public class GoOfflineMojoTest extends AbstractDependencyMojoTestCase {
+ private GoOfflineMojo subject;
+
+ protected void setUp() throws Exception {
+ // required for mojo lookups to work
+ super.setUp("go-offline", true);
+ MavenProject project = new DependencyProjectStub();
+ getContainer().addComponent(project, MavenProject.class.getName());
+
+ MavenSession session = newMavenSession(project);
+ getContainer().addComponent(session, MavenSession.class.getName());
+ }
+
+ String GROUP_EXCLUDE_PREFIX = "skip.this.groupid";
+
+ String ARTIFACT_EXCLUDE_PREFIX = "skip-this-artifact";
+
+ String CLASSIFIER_EXCLUDE_PREFIX = "skipThisClassifier";
+
+ String DUMMY_ARTIFACT_NAME = "dummy-artifact";
+
+ String STUB_ARTIFACT_VERSION = "3.14";
+
+ String VALID_GROUP = "org.junit.jupiter";
+
+ public void test_excludeGroupIds() throws Exception {
+ File testPom = new File(getBasedir(), "target/test-classes/unit/go-offline-test/exclude-plugin-config.xml");
+
+ subject = (GoOfflineMojo) lookupMojo("go-offline", testPom);
+ assertNotNull(subject);
+
+ Artifact artifact1 = new ArtifactStub();
+ artifact1.setGroupId(GROUP_EXCLUDE_PREFIX);
+ artifact1.setArtifactId(DUMMY_ARTIFACT_NAME);
+ artifact1.setVersion(STUB_ARTIFACT_VERSION);
+
+ Artifact artifact2 = new ArtifactStub();
+ artifact2.setGroupId(GROUP_EXCLUDE_PREFIX + ".too");
+ artifact2.setArtifactId(DUMMY_ARTIFACT_NAME);
+ artifact2.setVersion(STUB_ARTIFACT_VERSION + "-SNAPSHOT");
+
+ Artifact artifact3 = new ArtifactStub();
+ artifact3.setGroupId("dont.skip.me");
+ artifact3.setArtifactId(DUMMY_ARTIFACT_NAME);
+ artifact3.setVersion("1.0");
+
+ Set<Artifact> artifacts = new HashSet<>();
+ artifacts.add(artifact1);
+ artifacts.add(artifact2);
+ artifacts.add(artifact3);
+
+ assertEquals(3, artifacts.size());
+ FilterArtifacts filter = subject.getArtifactsFilter();
+ artifacts = filter.filter(artifacts);
+ assertEquals(1, artifacts.size());
+ assertTrue(artifacts.contains(artifact3));
+ assertFalse(artifacts.contains(artifact1));
+ assertFalse(artifacts.contains(artifact2));
+ }
+
+ public void test_excludeArtifactIds() throws Exception {
+ File testPom = new File(getBasedir(), "target/test-classes/unit/go-offline-test/exclude-plugin-config.xml");
+
+ subject = (GoOfflineMojo) lookupMojo("go-offline", testPom);
+ assertNotNull(subject);
+
+ Artifact artifact1 = new ArtifactStub();
+ artifact1.setGroupId(VALID_GROUP);
+ artifact1.setArtifactId(ARTIFACT_EXCLUDE_PREFIX);
+ artifact1.setVersion(STUB_ARTIFACT_VERSION + "-SNAPSHOT");
+
+ Artifact artifact2 = new ArtifactStub();
+ artifact2.setGroupId(VALID_GROUP);
+ artifact2.setArtifactId(ARTIFACT_EXCLUDE_PREFIX + "-too");
+ artifact2.setVersion(STUB_ARTIFACT_VERSION);
+
+ Artifact artifact3 = new ArtifactStub();
+ artifact3.setGroupId("dont.skip.me");
+ artifact3.setArtifactId("dummy-artifact");
+ artifact3.setVersion("1.0");
+
+ Set<Artifact> artifacts = new HashSet<>();
+ artifacts.add(artifact1);
+ artifacts.add(artifact2);
+ artifacts.add(artifact3);
+
+ assertEquals(3, artifacts.size());
+ FilterArtifacts filter = subject.getArtifactsFilter();
+ artifacts = filter.filter(artifacts);
+ assertEquals(1, artifacts.size());
+ assertTrue(artifacts.contains(artifact3));
+ assertFalse(artifacts.contains(artifact1));
+ assertFalse(artifacts.contains(artifact2));
+ }
+
+ public void test_excludeScope() throws Exception {
+ File testPom = new File(getBasedir(), "target/test-classes/unit/go-offline-test/exclude-plugin-config.xml");
+
+ subject = (GoOfflineMojo) lookupMojo("go-offline", testPom);
+ assertNotNull(subject);
+
+ Artifact artifact1 = new ArtifactStub();
+ artifact1.setGroupId(VALID_GROUP);
+ artifact1.setArtifactId(DUMMY_ARTIFACT_NAME);
+ artifact1.setVersion(STUB_ARTIFACT_VERSION + "-SNAPSHOT");
+
+ Artifact artifact2 = new ArtifactStub();
+ artifact2.setGroupId(VALID_GROUP);
+ artifact2.setArtifactId(DUMMY_ARTIFACT_NAME + "-too");
+ artifact2.setVersion(STUB_ARTIFACT_VERSION);
+ artifact2.setScope("system");
+
+ Artifact artifact3 = new ArtifactStub();
+ artifact3.setGroupId(VALID_GROUP);
+ artifact3.setArtifactId(DUMMY_ARTIFACT_NAME);
+ artifact3.setVersion(STUB_ARTIFACT_VERSION);
+
+ Set<Artifact> artifacts = new HashSet<>();
+ artifacts.add(artifact1);
+ artifacts.add(artifact2);
+ artifacts.add(artifact3);
+
+ assertEquals(3, artifacts.size());
+ FilterArtifacts filter = subject.getArtifactsFilter();
+ artifacts = filter.filter(artifacts);
+ assertEquals(2, artifacts.size());
+ assertTrue(artifacts.contains(artifact3));
+ assertTrue(artifacts.contains(artifact1));
+ assertFalse(artifacts.contains(artifact2));
+ }
+
+ public void test_excludeTypes() throws Exception {
+ File testPom = new File(getBasedir(), "target/test-classes/unit/go-offline-test/exclude-plugin-config.xml");
+
+ subject = (GoOfflineMojo) lookupMojo("go-offline", testPom);
+ assertNotNull(subject);
+
+ ArtifactStub artifact1 = new ArtifactStub();
+ artifact1.setGroupId(VALID_GROUP);
+ artifact1.setArtifactId(DUMMY_ARTIFACT_NAME);
+ artifact1.setVersion(STUB_ARTIFACT_VERSION + "-SNAPSHOT");
+ artifact1.setType("ear");
+
+ ArtifactStub artifact2 = new ArtifactStub();
+ artifact2.setGroupId(VALID_GROUP);
+ artifact2.setArtifactId(DUMMY_ARTIFACT_NAME + "-too");
+ artifact2.setVersion(STUB_ARTIFACT_VERSION);
+ artifact2.setType("war");
+
+ ArtifactStub artifact3 = new ArtifactStub();
+ artifact3.setGroupId(VALID_GROUP);
+ artifact3.setArtifactId(DUMMY_ARTIFACT_NAME);
+ artifact3.setVersion(STUB_ARTIFACT_VERSION);
+ artifact3.setType("pom");
+
+ Set<Artifact> artifacts = new HashSet<>();
+ artifacts.add(artifact1);
+ artifacts.add(artifact2);
+ artifacts.add(artifact3);
+
+ assertEquals(3, artifacts.size());
+ FilterArtifacts filter = subject.getArtifactsFilter();
+ artifacts = filter.filter(artifacts);
+ assertEquals(1, artifacts.size());
+ assertFalse(artifacts.contains(artifact3));
+ assertTrue(artifacts.contains(artifact2));
+ assertFalse(artifacts.contains(artifact1));
+ }
+
+ /**
+ * Can't set a classifier on the ArtifactStub as of maven-plugin-testing-harness-3.3.0, there is a getter but no
+ * setter. If that ever gets implemented, comment in these two lines to support unit testing for this case, rename
+ * xtest to test and remove the Junit 5 Disabled annotation
+ *
+ * @throws Exception
+ */
+ @Disabled("Requires update to maven-plugin-test-harness to support this test")
+ public void xtest_excludeClassifiers() throws Exception {
+ File testPom = new File(getBasedir(), "target/test-classes/unit/go-offline-test/exclude-plugin-config.xml");
+
+ subject = (GoOfflineMojo) lookupMojo("go-offline", testPom);
+ assertNotNull(subject);
+
+ ArtifactStub artifact1 = new ArtifactStub();
+ artifact1.setGroupId(VALID_GROUP);
+ artifact1.setArtifactId(DUMMY_ARTIFACT_NAME);
+ artifact1.setVersion(STUB_ARTIFACT_VERSION + "-SNAPSHOT");
+ // artifact1.setClassifier(CLASSIFIER_EXCLUDE_PREFIX);
+
+ ArtifactStub artifact2 = new ArtifactStub();
+ artifact2.setGroupId(VALID_GROUP);
+ artifact2.setArtifactId(DUMMY_ARTIFACT_NAME + "-too");
+ artifact2.setVersion(STUB_ARTIFACT_VERSION);
+ // artifact2.setClassifier(CLASSIFIER_EXCLUDE_PREFIX + "Too");
+
+ ArtifactStub artifact3 = new ArtifactStub();
+ artifact3.setGroupId(VALID_GROUP);
+ artifact3.setArtifactId(DUMMY_ARTIFACT_NAME);
+ artifact3.setVersion(STUB_ARTIFACT_VERSION);
+
+ Set<Artifact> artifacts = new HashSet<>();
+ artifacts.add(artifact1);
+ artifacts.add(artifact2);
+ artifacts.add(artifact3);
+
+ assertEquals(3, artifacts.size());
+ FilterArtifacts filter = subject.getArtifactsFilter();
+ artifacts = filter.filter(artifacts);
+ assertEquals(1, artifacts.size());
+ assertFalse(artifacts.contains(artifact1));
+ assertFalse(artifacts.contains(artifact2));
+ assertTrue(artifacts.contains(artifact3));
+ }
+
+ String GROUP_INCLUDE_PREFIX = "include.this.groupid";
+
+ String ARTIFACT_INCLUDE_PREFIX = "include-this-artifact";
+
+ String CLASSIFIER_INCLUDE_PREFIX = "includeThisClassifier";
+
+ public void test_includeGroupIds() throws Exception {
+ File testPom = new File(getBasedir(), "target/test-classes/unit/go-offline-test/include-gid-plugin-config.xml");
+
+ subject = (GoOfflineMojo) lookupMojo("go-offline", testPom);
+ assertNotNull(subject);
+
+ Artifact artifact1 = new ArtifactStub();
+ artifact1.setGroupId(GROUP_INCLUDE_PREFIX);
+ artifact1.setArtifactId(DUMMY_ARTIFACT_NAME);
+ artifact1.setVersion(STUB_ARTIFACT_VERSION);
+
+ Artifact artifact2 = new ArtifactStub();
+ artifact2.setGroupId(GROUP_INCLUDE_PREFIX + ".too");
+ artifact2.setArtifactId(DUMMY_ARTIFACT_NAME);
+ artifact2.setVersion(STUB_ARTIFACT_VERSION + "-SNAPSHOT");
+
+ Artifact artifact3 = new ArtifactStub();
+ artifact3.setGroupId("skip.me");
+ artifact3.setArtifactId(DUMMY_ARTIFACT_NAME);
+ artifact3.setVersion("1.0");
+
+ Set<Artifact> artifacts = new HashSet<>();
+ artifacts.add(artifact1);
+ artifacts.add(artifact2);
+ artifacts.add(artifact3);
+
+ assertEquals(3, artifacts.size());
+ FilterArtifacts filter = subject.getArtifactsFilter();
+ artifacts = filter.filter(artifacts);
+
+ assertEquals(2, artifacts.size());
+ assertFalse(artifacts.contains(artifact3));
+ assertTrue(artifacts.contains(artifact1));
+ assertTrue(artifacts.contains(artifact2));
+ }
+
+ public void test_includeArtifactIds() throws Exception {
+ File testPom = new File(getBasedir(), "target/test-classes/unit/go-offline-test/include-aid-plugin-config.xml");
+
+ subject = (GoOfflineMojo) lookupMojo("go-offline", testPom);
+ assertNotNull(subject);
+
+ Artifact artifact1 = new ArtifactStub();
+ artifact1.setGroupId(VALID_GROUP);
+ artifact1.setArtifactId(ARTIFACT_INCLUDE_PREFIX);
+ artifact1.setVersion(STUB_ARTIFACT_VERSION);
+
+ Artifact artifact2 = new ArtifactStub();
+ artifact2.setGroupId(VALID_GROUP);
+ artifact2.setArtifactId(ARTIFACT_INCLUDE_PREFIX + "-too");
+ artifact2.setVersion(STUB_ARTIFACT_VERSION + "-SNAPSHOT");
+
+ Artifact artifact3 = new ArtifactStub();
+ artifact3.setGroupId(VALID_GROUP);
+ artifact3.setArtifactId(DUMMY_ARTIFACT_NAME);
+ artifact3.setVersion("1.0");
+
+ Set<Artifact> artifacts = new HashSet<>();
+ artifacts.add(artifact1);
+ artifacts.add(artifact2);
+ artifacts.add(artifact3);
+
+ assertEquals(3, artifacts.size());
+ FilterArtifacts filter = subject.getArtifactsFilter();
+ artifacts = filter.filter(artifacts);
+
+ assertEquals(2, artifacts.size());
+ assertFalse(artifacts.contains(artifact3));
+ assertTrue(artifacts.contains(artifact1));
+ assertTrue(artifacts.contains(artifact2));
+ }
+
+ public void test_includeScope() throws Exception {
+ File testPom =
+ new File(getBasedir(), "target/test-classes/unit/go-offline-test/include-scope-plugin-config.xml");
+
+ subject = (GoOfflineMojo) lookupMojo("go-offline", testPom);
+ assertNotNull(subject);
+
+ Artifact artifact1 = new ArtifactStub();
+ artifact1.setGroupId(VALID_GROUP);
+ artifact1.setArtifactId(DUMMY_ARTIFACT_NAME);
+ artifact1.setVersion(STUB_ARTIFACT_VERSION + "-SNAPSHOT");
+ artifact1.setScope("provided");
+
+ Artifact artifact2 = new ArtifactStub();
+ artifact2.setGroupId(VALID_GROUP);
+ artifact2.setArtifactId(DUMMY_ARTIFACT_NAME + "-too");
+ artifact2.setVersion(STUB_ARTIFACT_VERSION);
+ artifact2.setScope("system");
+
+ Artifact artifact3 = new ArtifactStub();
+ artifact3.setGroupId(VALID_GROUP);
+ artifact3.setArtifactId(DUMMY_ARTIFACT_NAME);
+ artifact3.setVersion(STUB_ARTIFACT_VERSION);
+ artifact3.setScope("test");
+
+ Set<Artifact> artifacts = new HashSet<>();
+ artifacts.add(artifact1);
+ artifacts.add(artifact2);
+ artifacts.add(artifact3);
+
+ assertEquals(3, artifacts.size());
+ FilterArtifacts filter = subject.getArtifactsFilter();
+ artifacts = filter.filter(artifacts);
+ assertEquals(1, artifacts.size());
+
+ assertTrue(artifacts.contains(artifact1));
+ assertFalse(artifacts.contains(artifact2));
+ assertFalse(artifacts.contains(artifact3));
+ }
+
+ public void test_includeTypes() throws Exception {
+ File testPom =
+ new File(getBasedir(), "target/test-classes/unit/go-offline-test/include-types-plugin-config.xml");
+
+ subject = (GoOfflineMojo) lookupMojo("go-offline", testPom);
+ assertNotNull(subject);
+
+ ArtifactStub artifact1 = new ArtifactStub();
+ artifact1.setGroupId(VALID_GROUP);
+ artifact1.setArtifactId(DUMMY_ARTIFACT_NAME);
+ artifact1.setVersion(STUB_ARTIFACT_VERSION + "-SNAPSHOT");
+ artifact1.setType("ear");
+
+ ArtifactStub artifact2 = new ArtifactStub();
+ artifact2.setGroupId(VALID_GROUP);
+ artifact2.setArtifactId(DUMMY_ARTIFACT_NAME + "-too");
+ artifact2.setVersion(STUB_ARTIFACT_VERSION);
+ artifact2.setType("pom");
+
+ ArtifactStub artifact3 = new ArtifactStub();
+ artifact3.setGroupId(VALID_GROUP);
+ artifact3.setArtifactId(DUMMY_ARTIFACT_NAME);
+ artifact3.setVersion(STUB_ARTIFACT_VERSION + "-SNAPSHOT");
+ artifact3.setType("war");
+
+ Set<Artifact> artifacts = new HashSet<>();
+ artifacts.add(artifact1);
+ artifacts.add(artifact2);
+ artifacts.add(artifact3);
+
+ assertEquals(3, artifacts.size());
+ FilterArtifacts filter = subject.getArtifactsFilter();
+ artifacts = filter.filter(artifacts);
+ assertEquals(2, artifacts.size());
+
+ assertTrue(artifacts.contains(artifact1));
+ assertTrue(artifacts.contains(artifact2));
+ assertFalse(artifacts.contains(artifact3));
+ }
+}
diff --git a/src/test/resources/unit/go-offline-test/exclude-plugin-config.xml b/src/test/resources/unit/go-offline-test/exclude-plugin-config.xml
new file mode 100644
index 00000000..c80cf343
--- /dev/null
+++ b/src/test/resources/unit/go-offline-test/exclude-plugin-config.xml
@@ -0,0 +1,35 @@
+<!-- * 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. * -->
+<project>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>@project.version@</version>
+ <configuration>
+ <excludeGroupIds>skip.this.groupid,skip.this.groupid.too
+ </excludeGroupIds>
+ <excludeArtifactIds>skip-this-artifact,skip-this-artifact-too
+ </excludeArtifactIds>
+ <!-- the maven-common-artifact-filters library does not support
+ comma delimited scope exclusions. only one at a time. the other filters support
+ comma delimited lists -->
+ <!-- <excludeScope>compile,system</excludeScope> -->
+ <excludeScope>system</excludeScope>
+ <excludeTypes>ear,pom</excludeTypes>
+ <excludeClassifiers>skipThisClassifier,skipThisClassifierToo
+ </excludeClassifiers>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/src/test/resources/unit/go-offline-test/include-aid-plugin-config.xml b/src/test/resources/unit/go-offline-test/include-aid-plugin-config.xml
new file mode 100644
index 00000000..cd792ec8
--- /dev/null
+++ b/src/test/resources/unit/go-offline-test/include-aid-plugin-config.xml
@@ -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. * -->
+<project>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>@project.version@</version>
+ <configuration>
+ <includeArtifactIds>include-this-artifact,include-this-artifact-too
+ </includeArtifactIds>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
diff --git a/src/test/resources/unit/go-offline-test/include-gid-plugin-config.xml b/src/test/resources/unit/go-offline-test/include-gid-plugin-config.xml
new file mode 100644
index 00000000..8d2c425a
--- /dev/null
+++ b/src/test/resources/unit/go-offline-test/include-gid-plugin-config.xml
@@ -0,0 +1,24 @@
+<!-- * 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. * -->
+<project>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>@project.version@</version>
+ <configuration>
+ <includeGroupIds>include.this.groupid,include.this.groupid.too</includeGroupIds>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
diff --git a/src/test/resources/unit/go-offline-test/include-scope-plugin-config.xml b/src/test/resources/unit/go-offline-test/include-scope-plugin-config.xml
new file mode 100644
index 00000000..2230d2a8
--- /dev/null
+++ b/src/test/resources/unit/go-offline-test/include-scope-plugin-config.xml
@@ -0,0 +1,24 @@
+<!-- * 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. * -->
+<project>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>@project.version@</version>
+ <configuration>
+ <includeScope>provided</includeScope>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
diff --git a/src/test/resources/unit/go-offline-test/include-types-plugin-config.xml b/src/test/resources/unit/go-offline-test/include-types-plugin-config.xml
new file mode 100644
index 00000000..e7e2365f
--- /dev/null
+++ b/src/test/resources/unit/go-offline-test/include-types-plugin-config.xml
@@ -0,0 +1,24 @@
+<!-- * 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. * -->
+<project>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>@project.version@</version>
+ <configuration>
+ <includeTypes>pom,ear</includeTypes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file