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