Merge branch '2.0.x'
This commit is contained in:
commit
5dd4a7e91e
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -26,7 +26,6 @@ import org.apache.maven.plugin.AbstractMojo;
|
|||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugins.annotations.Parameter;
|
||||
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.FilterArtifacts;
|
||||
|
||||
|
@ -64,13 +63,6 @@ public abstract class AbstractDependencyFilterMojo extends AbstractMojo {
|
|||
@Parameter(property = "spring-boot.excludeGroupIds", defaultValue = "")
|
||||
private String excludeGroupIds;
|
||||
|
||||
/**
|
||||
* Comma separated list of artifact names to exclude (exact match).
|
||||
* @since 1.1
|
||||
*/
|
||||
@Parameter(property = "spring-boot.excludeArtifactIds", defaultValue = "")
|
||||
private String excludeArtifactIds;
|
||||
|
||||
protected void setExcludes(List<Exclude> excludes) {
|
||||
this.excludes = excludes;
|
||||
}
|
||||
|
@ -83,10 +75,6 @@ public abstract class AbstractDependencyFilterMojo extends AbstractMojo {
|
|||
this.excludeGroupIds = excludeGroupIds;
|
||||
}
|
||||
|
||||
protected void setExcludeArtifactIds(String excludeArtifactIds) {
|
||||
this.excludeArtifactIds = excludeArtifactIds;
|
||||
}
|
||||
|
||||
protected Set<Artifact> filterDependencies(Set<Artifact> dependencies,
|
||||
FilterArtifacts filters) throws MojoExecutionException {
|
||||
try {
|
||||
|
@ -109,8 +97,6 @@ public abstract class AbstractDependencyFilterMojo extends AbstractMojo {
|
|||
for (ArtifactsFilter additionalFilter : additionalFilters) {
|
||||
filters.addFilter(additionalFilter);
|
||||
}
|
||||
filters.addFilter(
|
||||
new ArtifactIdFilter("", cleanFilterConfig(this.excludeArtifactIds)));
|
||||
filters.addFilter(
|
||||
new MatchingGroupIdFilter(cleanFilterConfig(this.excludeGroupIds)));
|
||||
if (this.includes != null && !this.includes.isEmpty()) {
|
||||
|
|
|
@ -15,13 +15,11 @@
|
|||
executable jar. For consistency, they should not be present either when running the
|
||||
application.
|
||||
|
||||
There are three ways one can exclude a dependency from being packaged/used at runtime
|
||||
There are two ways one can exclude a dependency from being packaged/used at runtime
|
||||
|
||||
* Exclude a specific artifact identified by <<<groupId>>> and <<<artifactId>>>
|
||||
(optionally with a <<<classifier>>> if needed)
|
||||
|
||||
* Exclude any artifact matching a given <<<artifactId>>>
|
||||
|
||||
* Exclude any artifact belonging to a given <<<groupId>>>
|
||||
|
||||
[]
|
||||
|
@ -57,34 +55,7 @@
|
|||
</project>
|
||||
---
|
||||
|
||||
This example excludes any artifacts having the <<<my-lib>>> or <<<another-lib>>>
|
||||
artifact identifiers
|
||||
|
||||
---
|
||||
<project>
|
||||
...
|
||||
<build>
|
||||
...
|
||||
<plugins>
|
||||
...
|
||||
<plugin>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>${project.artifactId}</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<configuration>
|
||||
<excludeArtifactIds>my-lib,another-lib</excludeArtifactIds>
|
||||
</configuration>
|
||||
...
|
||||
</plugin>
|
||||
...
|
||||
</plugins>
|
||||
...
|
||||
</build>
|
||||
...
|
||||
</project>
|
||||
---
|
||||
|
||||
Finally this example excludes any artifact belonging to the <<<com.foo>>> group
|
||||
This example excludes any artifact belonging to the <<<com.foo>>> group
|
||||
|
||||
|
||||
---
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -42,12 +42,12 @@ public class DependencyFilterMojoTests {
|
|||
@Test
|
||||
public void filterDependencies() throws MojoExecutionException {
|
||||
TestableDependencyFilterMojo mojo = new TestableDependencyFilterMojo(
|
||||
Collections.emptyList(), "com.foo", "exclude-id");
|
||||
Collections.emptyList(), "com.foo");
|
||||
|
||||
Artifact artifact = createArtifact("com.bar", "one");
|
||||
Set<Artifact> artifacts = mojo.filterDependencies(
|
||||
createArtifact("com.foo", "one"), createArtifact("com.foo", "two"),
|
||||
createArtifact("com.bar", "exclude-id"), artifact);
|
||||
artifact);
|
||||
assertThat(artifacts).hasSize(1);
|
||||
assertThat(artifacts.iterator().next()).isSameAs(artifact);
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public class DependencyFilterMojoTests {
|
|||
@Test
|
||||
public void filterGroupIdExactMatch() throws MojoExecutionException {
|
||||
TestableDependencyFilterMojo mojo = new TestableDependencyFilterMojo(
|
||||
Collections.emptyList(), "com.foo", "");
|
||||
Collections.emptyList(), "com.foo");
|
||||
|
||||
Artifact artifact = createArtifact("com.foo.bar", "one");
|
||||
Set<Artifact> artifacts = mojo.filterDependencies(
|
||||
|
@ -68,7 +68,7 @@ public class DependencyFilterMojoTests {
|
|||
@Test
|
||||
public void filterScopeKeepOrder() throws MojoExecutionException {
|
||||
TestableDependencyFilterMojo mojo = new TestableDependencyFilterMojo(
|
||||
Collections.emptyList(), "", "",
|
||||
Collections.emptyList(), "",
|
||||
new ScopeFilter(null, Artifact.SCOPE_SYSTEM));
|
||||
Artifact one = createArtifact("com.foo", "one");
|
||||
Artifact two = createArtifact("com.foo", "two", Artifact.SCOPE_SYSTEM);
|
||||
|
@ -77,22 +77,10 @@ public class DependencyFilterMojoTests {
|
|||
assertThat(artifacts).containsExactly(one, three);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void filterArtifactIdKeepOrder() throws MojoExecutionException {
|
||||
TestableDependencyFilterMojo mojo = new TestableDependencyFilterMojo(
|
||||
Collections.emptyList(), "", "one,three");
|
||||
Artifact one = createArtifact("com.foo", "one");
|
||||
Artifact two = createArtifact("com.foo", "two");
|
||||
Artifact three = createArtifact("com.foo", "three");
|
||||
Artifact four = createArtifact("com.foo", "four");
|
||||
Set<Artifact> artifacts = mojo.filterDependencies(one, two, three, four);
|
||||
assertThat(artifacts).containsExactly(two, four);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void filterGroupIdKeepOrder() throws MojoExecutionException {
|
||||
TestableDependencyFilterMojo mojo = new TestableDependencyFilterMojo(
|
||||
Collections.emptyList(), "com.foo", "");
|
||||
Collections.emptyList(), "com.foo");
|
||||
Artifact one = createArtifact("com.foo", "one");
|
||||
Artifact two = createArtifact("com.bar", "two");
|
||||
Artifact three = createArtifact("com.bar", "three");
|
||||
|
@ -107,7 +95,7 @@ public class DependencyFilterMojoTests {
|
|||
exclude.setGroupId("com.bar");
|
||||
exclude.setArtifactId("two");
|
||||
TestableDependencyFilterMojo mojo = new TestableDependencyFilterMojo(
|
||||
Collections.singletonList(exclude), "", "");
|
||||
Collections.singletonList(exclude), "");
|
||||
Artifact one = createArtifact("com.foo", "one");
|
||||
Artifact two = createArtifact("com.bar", "two");
|
||||
Artifact three = createArtifact("com.bar", "three");
|
||||
|
@ -137,11 +125,9 @@ public class DependencyFilterMojoTests {
|
|||
private final ArtifactsFilter[] additionalFilters;
|
||||
|
||||
private TestableDependencyFilterMojo(List<Exclude> excludes,
|
||||
String excludeGroupIds, String excludeArtifactIds,
|
||||
ArtifactsFilter... additionalFilters) {
|
||||
String excludeGroupIds, ArtifactsFilter... additionalFilters) {
|
||||
setExcludes(excludes);
|
||||
setExcludeGroupIds(excludeGroupIds);
|
||||
setExcludeArtifactIds(excludeArtifactIds);
|
||||
this.additionalFilters = additionalFilters;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue