mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 12:09:16 +00:00
Allow jars to be marked as a development-tool to exclude from uber-jar
Closes gh-47320
This commit is contained in:
+1
-2
@@ -17,7 +17,6 @@
|
||||
package org.springframework.boot.gradle.plugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
@@ -33,7 +32,7 @@ import org.gradle.api.specs.Spec;
|
||||
*/
|
||||
class JarTypeFileSpec implements Spec<File> {
|
||||
|
||||
private static final Set<String> EXCLUDED_JAR_TYPES = Collections.singleton("dependencies-starter");
|
||||
private static final Set<String> EXCLUDED_JAR_TYPES = Set.of("dependencies-starter", "development-tool");
|
||||
|
||||
@Override
|
||||
public boolean isSatisfiedBy(File file) {
|
||||
|
||||
+5
@@ -283,6 +283,7 @@ abstract class AbstractBootArchiveIntegrationTests {
|
||||
void jarTypeFilteringIsApplied() throws IOException {
|
||||
File flatDirRepository = new File(this.gradleBuild.getProjectDir(), "repository");
|
||||
createDependenciesStarterJar(new File(flatDirRepository, "starter.jar"));
|
||||
createDependenciesDeveloperToolsJar(new File(flatDirRepository, "devonly.jar"));
|
||||
createStandardJar(new File(flatDirRepository, "standard.jar"));
|
||||
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
@@ -659,6 +660,10 @@ abstract class AbstractBootArchiveIntegrationTests {
|
||||
createJar(location, (attributes) -> attributes.putValue("Spring-Boot-Jar-Type", "dependencies-starter"));
|
||||
}
|
||||
|
||||
private void createDependenciesDeveloperToolsJar(File location) throws IOException {
|
||||
createJar(location, (attributes) -> attributes.putValue("Spring-Boot-Jar-Type", "development-tool"));
|
||||
}
|
||||
|
||||
private void createJar(File location, Consumer<Attributes> attributesConfigurer) throws IOException {
|
||||
location.getParentFile().mkdirs();
|
||||
Manifest manifest = new Manifest();
|
||||
|
||||
+2
-2
@@ -34,8 +34,8 @@ import org.apache.maven.artifact.Artifact;
|
||||
*/
|
||||
class JarTypeFilter extends DependencyFilter {
|
||||
|
||||
private static final Set<String> EXCLUDED_JAR_TYPES = Collections
|
||||
.unmodifiableSet(new HashSet<>(Arrays.asList("annotation-processor", "dependencies-starter")));
|
||||
private static final Set<String> EXCLUDED_JAR_TYPES = Collections.unmodifiableSet(
|
||||
new HashSet<>(Arrays.asList("annotation-processor", "dependencies-starter", "development-tool")));
|
||||
|
||||
JarTypeFilter() {
|
||||
super(Collections.emptyList());
|
||||
|
||||
+5
@@ -60,6 +60,11 @@ class JarTypeFilterTests {
|
||||
assertThat(new JarTypeFilter().filter(createArtifact("annotation-processor"))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenArtifactHasDevelopmentToolJarTypeThenItIsExcluded() {
|
||||
assertThat(new JarTypeFilter().filter(createArtifact("development-tool"))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenArtifactHasNoManifestFileThenItIsIncluded() {
|
||||
assertThat(new JarTypeFilter().filter(createArtifactWithNoManifest())).isFalse();
|
||||
|
||||
Reference in New Issue
Block a user