Add missing properties to RepackageTask and improve test coverage
Closes gh-4978
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2016 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.
|
||||
@@ -48,6 +48,8 @@ class ProjectLibraries implements Libraries {
|
||||
|
||||
private final SpringBootPluginExtension extension;
|
||||
|
||||
private final boolean excludeDevtools;
|
||||
|
||||
private String providedConfigurationName = "providedRuntime";
|
||||
|
||||
private String customConfigurationName = null;
|
||||
@@ -56,10 +58,13 @@ class ProjectLibraries implements Libraries {
|
||||
* Create a new {@link ProjectLibraries} instance of the specified {@link Project}.
|
||||
* @param project the gradle project
|
||||
* @param extension the extension
|
||||
* @param excludeDevTools whether Spring Boot Devtools should be excluded
|
||||
*/
|
||||
ProjectLibraries(Project project, SpringBootPluginExtension extension) {
|
||||
ProjectLibraries(Project project, SpringBootPluginExtension extension,
|
||||
boolean excludeDevTools) {
|
||||
this.project = project;
|
||||
this.extension = extension;
|
||||
this.excludeDevtools = excludeDevTools;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -165,7 +170,7 @@ class ProjectLibraries implements Libraries {
|
||||
}
|
||||
|
||||
private boolean isExcluded(GradleLibrary library) {
|
||||
if (this.extension.isExcludeDevtools() && isDevToolsJar(library)) {
|
||||
if (this.excludeDevtools && isDevToolsJar(library)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2016 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.
|
||||
@@ -19,6 +19,7 @@ package org.springframework.boot.gradle.repackage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -57,6 +58,14 @@ public class RepackageTask extends DefaultTask {
|
||||
|
||||
private File outputFile;
|
||||
|
||||
private Boolean excludeDevtools;
|
||||
|
||||
private Boolean executable;
|
||||
|
||||
private File embeddedLaunchScript;
|
||||
|
||||
private Map<String, String> embeddedLaunchScriptProperties;
|
||||
|
||||
public void setCustomConfiguration(String customConfiguration) {
|
||||
this.customConfiguration = customConfiguration;
|
||||
}
|
||||
@@ -89,6 +98,39 @@ public class RepackageTask extends DefaultTask {
|
||||
this.outputFile = file;
|
||||
}
|
||||
|
||||
public Boolean getExcludeDevtools() {
|
||||
return this.excludeDevtools;
|
||||
}
|
||||
|
||||
public void setExcludeDevtools(Boolean excludeDevtools) {
|
||||
this.excludeDevtools = excludeDevtools;
|
||||
}
|
||||
|
||||
public Boolean getExecutable() {
|
||||
return this.executable;
|
||||
}
|
||||
|
||||
public void setExecutable(Boolean executable) {
|
||||
this.executable = executable;
|
||||
}
|
||||
|
||||
public File getEmbeddedLaunchScript() {
|
||||
return this.embeddedLaunchScript;
|
||||
}
|
||||
|
||||
public void setEmbeddedLaunchScript(File embeddedLaunchScript) {
|
||||
this.embeddedLaunchScript = embeddedLaunchScript;
|
||||
}
|
||||
|
||||
public Map<String, String> getEmbeddedLaunchScriptProperties() {
|
||||
return this.embeddedLaunchScriptProperties;
|
||||
}
|
||||
|
||||
public void setEmbeddedLaunchScriptProperties(
|
||||
Map<String, String> embeddedLaunchScriptProperties) {
|
||||
this.embeddedLaunchScriptProperties = embeddedLaunchScriptProperties;
|
||||
}
|
||||
|
||||
@TaskAction
|
||||
public void repackage() {
|
||||
Project project = getProject();
|
||||
@@ -102,7 +144,9 @@ public class RepackageTask extends DefaultTask {
|
||||
Project project = getProject();
|
||||
SpringBootPluginExtension extension = project.getExtensions()
|
||||
.getByType(SpringBootPluginExtension.class);
|
||||
ProjectLibraries libraries = new ProjectLibraries(project, extension);
|
||||
ProjectLibraries libraries = new ProjectLibraries(project, extension,
|
||||
(this.excludeDevtools != null && this.excludeDevtools)
|
||||
|| extension.isExcludeDevtools());
|
||||
if (extension.getProvidedConfiguration() != null) {
|
||||
libraries.setProvidedConfigurationName(extension.getProvidedConfiguration());
|
||||
}
|
||||
@@ -223,14 +267,30 @@ public class RepackageTask extends DefaultTask {
|
||||
}
|
||||
|
||||
private LaunchScript getLaunchScript() throws IOException {
|
||||
if (this.extension.isExecutable()
|
||||
|| this.extension.getEmbeddedLaunchScript() != null) {
|
||||
return new DefaultLaunchScript(this.extension.getEmbeddedLaunchScript(),
|
||||
this.extension.getEmbeddedLaunchScriptProperties());
|
||||
if (isExecutable() || getEmbeddedLaunchScript() != null) {
|
||||
return new DefaultLaunchScript(getEmbeddedLaunchScript(),
|
||||
getEmbeddedLaunchScriptProperties());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isExecutable() {
|
||||
return RepackageTask.this.executable != null ? RepackageTask.this.executable
|
||||
: this.extension.isExecutable();
|
||||
}
|
||||
|
||||
private File getEmbeddedLaunchScript() {
|
||||
return RepackageTask.this.embeddedLaunchScript != null
|
||||
? RepackageTask.this.embeddedLaunchScript
|
||||
: this.extension.getEmbeddedLaunchScript();
|
||||
}
|
||||
|
||||
private Map<String, String> getEmbeddedLaunchScriptProperties() {
|
||||
return RepackageTask.this.embeddedLaunchScriptProperties != null
|
||||
? RepackageTask.this.embeddedLaunchScriptProperties
|
||||
: this.extension.getEmbeddedLaunchScriptProperties();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user