Make includes configurable via a property
See gh-39837
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2024 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.
|
||||
@@ -71,9 +71,10 @@ public abstract class AbstractDependencyFilterMojo extends AbstractMojo {
|
||||
|
||||
/**
|
||||
* Collection of artifact definitions to include. The {@link Include} element defines
|
||||
* mandatory {@code groupId} and {@code artifactId} properties and an optional
|
||||
* mandatory {@code groupId} and {@code artifactId} properties and an optional
|
||||
* {@code classifier} property.
|
||||
* mandatory {@code groupId} and {@code artifactId} components and an optional
|
||||
* {@code classifier} component. When configured as a property, values should be
|
||||
* comma-separated with colon-separated components:
|
||||
* {@code groupId:artifactId,groupId:artifactId:classifier}
|
||||
* @since 1.2.0
|
||||
*/
|
||||
@Parameter(property = "spring-boot.includes")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2024 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.
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package org.springframework.boot.maven;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* A model for a dependency to exclude.
|
||||
*
|
||||
@@ -26,17 +24,4 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class Exclude extends FilterableDependency {
|
||||
|
||||
// Maven looks for this public method if giving excludes as property
|
||||
// e.g. -Dspring-boot.excludes=myGroupId:myArtifactId:my-optional-classifier,foo:baz
|
||||
public void set(String propertyInput) {
|
||||
String[] parts = propertyInput.split(":");
|
||||
Assert.isTrue(parts.length == 2 || parts.length == 3,
|
||||
"Exclude must be in the form groupId:artifactId:optional-classifier");
|
||||
setGroupId(parts[0]);
|
||||
setArtifactId(parts[1]);
|
||||
if (parts.length == 3) {
|
||||
setClassifier(parts[2]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2024 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.
|
||||
@@ -18,13 +18,16 @@ package org.springframework.boot.maven;
|
||||
|
||||
import org.apache.maven.plugins.annotations.Parameter;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* A model for a dependency to include or exclude.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @author David Turanski
|
||||
* @since 3.1.11
|
||||
*/
|
||||
abstract class FilterableDependency {
|
||||
public abstract class FilterableDependency {
|
||||
|
||||
/**
|
||||
* The groupId of the artifact to exclude.
|
||||
@@ -68,4 +71,20 @@ abstract class FilterableDependency {
|
||||
this.classifier = classifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the include or exclude using a user-provided property in the form
|
||||
* {@code groupId:artifactId} or {@code groupId:artifactId:classifier}.
|
||||
* @param property the user-provided property
|
||||
*/
|
||||
public void set(String property) {
|
||||
String[] parts = property.split(":");
|
||||
Assert.isTrue(parts.length == 2 || parts.length == 3, getClass().getSimpleName()
|
||||
+ " must be in the form groupId:artifactId or groupId:artifactId:classifier");
|
||||
setGroupId(parts[0]);
|
||||
setArtifactId(parts[1]);
|
||||
if (parts.length == 3) {
|
||||
setClassifier(parts[2]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user