Add option to exclude devtools from fat jar
Add an `excludeDevtools` property to both the Maven and Gradle plugin that removes `org.springframework.boot:spring-boot-devtools` (if necessary) when repackaging the application. Closes gh-3171
This commit is contained in:
committed by
Phillip Webb
parent
e2fc30ef24
commit
e79ef9b73b
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2014 the original author or authors.
|
||||
* Copyright 2012-2015 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,6 +16,7 @@
|
||||
|
||||
package org.springframework.boot.maven;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
@@ -29,6 +30,10 @@ import org.apache.maven.artifact.Artifact;
|
||||
*/
|
||||
public class ExcludeFilter extends DependencyFilter {
|
||||
|
||||
public ExcludeFilter(Exclude... excludes) {
|
||||
this(Arrays.asList(excludes));
|
||||
}
|
||||
|
||||
public ExcludeFilter(List<Exclude> excludes) {
|
||||
super(excludes);
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ import org.apache.maven.plugins.annotations.Parameter;
|
||||
import org.apache.maven.plugins.annotations.ResolutionScope;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.MavenProjectHelper;
|
||||
import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter;
|
||||
import org.springframework.boot.loader.tools.DefaultLaunchScript;
|
||||
import org.springframework.boot.loader.tools.LaunchScript;
|
||||
import org.springframework.boot.loader.tools.Layout;
|
||||
@@ -153,6 +154,13 @@ public class RepackageMojo extends AbstractDependencyFilterMojo {
|
||||
@Parameter
|
||||
private Properties embeddedLaunchScriptProperties;
|
||||
|
||||
/**
|
||||
* Exclude Spring Boot devtools.
|
||||
* @since 1.3
|
||||
*/
|
||||
@Parameter(defaultValue = "false")
|
||||
private boolean excludeDevtools;
|
||||
|
||||
@Override
|
||||
public void execute() throws MojoExecutionException, MojoFailureException {
|
||||
if (this.project.getPackaging().equals("pom")) {
|
||||
@@ -190,7 +198,7 @@ public class RepackageMojo extends AbstractDependencyFilterMojo {
|
||||
}
|
||||
|
||||
Set<Artifact> artifacts = filterDependencies(this.project.getArtifacts(),
|
||||
getFilters());
|
||||
getFilters(getAdditionalFilters()));
|
||||
|
||||
Libraries libraries = new ArtifactsLibraries(artifacts, this.requiresUnpack,
|
||||
getLog());
|
||||
@@ -213,6 +221,17 @@ public class RepackageMojo extends AbstractDependencyFilterMojo {
|
||||
}
|
||||
}
|
||||
|
||||
private ArtifactsFilter[] getAdditionalFilters() {
|
||||
if (this.excludeDevtools) {
|
||||
Exclude exclude = new Exclude();
|
||||
exclude.setGroupId("org.springframework.boot");
|
||||
exclude.setArtifactId("spring-boot-devtools");
|
||||
ExcludeFilter filter = new ExcludeFilter(exclude);
|
||||
return new ArtifactsFilter[] { filter };
|
||||
}
|
||||
return new ArtifactsFilter[] {};
|
||||
}
|
||||
|
||||
private File getTargetFile() {
|
||||
String classifier = (this.classifier == null ? "" : this.classifier.trim());
|
||||
if (classifier.length() > 0 && !classifier.startsWith("-")) {
|
||||
|
||||
Reference in New Issue
Block a user