|
|
|
@ -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.
|
|
|
|
@ -22,9 +22,12 @@ import java.io.IOException;
|
|
|
|
|
import org.gradle.api.Action;
|
|
|
|
|
import org.gradle.api.Project;
|
|
|
|
|
import org.gradle.api.Task;
|
|
|
|
|
import org.gradle.api.artifacts.Configuration;
|
|
|
|
|
import org.gradle.api.artifacts.Dependency;
|
|
|
|
|
import org.gradle.api.logging.Logger;
|
|
|
|
|
import org.gradle.api.plugins.BasePlugin;
|
|
|
|
|
import org.gradle.api.plugins.JavaPlugin;
|
|
|
|
|
import org.gradle.api.tasks.TaskDependency;
|
|
|
|
|
import org.gradle.api.tasks.bundling.Jar;
|
|
|
|
|
import org.springframework.boot.gradle.PluginFeatures;
|
|
|
|
|
import org.springframework.boot.gradle.SpringBootPluginExtension;
|
|
|
|
@ -37,6 +40,7 @@ import org.springframework.util.StringUtils;
|
|
|
|
|
*
|
|
|
|
|
* @author Phillip Webb
|
|
|
|
|
* @author Dave Syer
|
|
|
|
|
* @author Andy Wilkinson
|
|
|
|
|
*/
|
|
|
|
|
public class RepackagePluginFeatures implements PluginFeatures {
|
|
|
|
|
|
|
|
|
@ -55,9 +59,14 @@ public class RepackagePluginFeatures implements PluginFeatures {
|
|
|
|
|
+ "archives so that they can be executed from the command "
|
|
|
|
|
+ "line using 'java -jar'");
|
|
|
|
|
task.setGroup(BasePlugin.BUILD_GROUP);
|
|
|
|
|
task.dependsOn(project.getConfigurations()
|
|
|
|
|
.getByName(Dependency.ARCHIVES_CONFIGURATION).getAllArtifacts()
|
|
|
|
|
.getBuildDependencies());
|
|
|
|
|
Configuration runtimeConfiguration = project.getConfigurations().getByName(
|
|
|
|
|
JavaPlugin.RUNTIME_CONFIGURATION_NAME);
|
|
|
|
|
TaskDependency runtimeProjectDependencyJarTasks = runtimeConfiguration
|
|
|
|
|
.getTaskDependencyFromProjectDependency(true, JavaPlugin.JAR_TASK_NAME);
|
|
|
|
|
task.dependsOn(
|
|
|
|
|
project.getConfigurations().getByName(Dependency.ARCHIVES_CONFIGURATION)
|
|
|
|
|
.getAllArtifacts().getBuildDependencies(),
|
|
|
|
|
runtimeProjectDependencyJarTasks);
|
|
|
|
|
registerOutput(project, task);
|
|
|
|
|
ensureTaskRunsOnAssembly(project, task);
|
|
|
|
|
}
|
|
|
|
@ -121,7 +130,7 @@ public class RepackagePluginFeatures implements PluginFeatures {
|
|
|
|
|
private void setupInputOutputs(Jar jarTask, String classifier) {
|
|
|
|
|
Logger logger = this.project.getLogger();
|
|
|
|
|
logger.debug("Using classifier: " + classifier + " for task "
|
|
|
|
|
+ task.getName());
|
|
|
|
|
+ this.task.getName());
|
|
|
|
|
File inputFile = jarTask.getArchivePath();
|
|
|
|
|
String outputName = inputFile.getName();
|
|
|
|
|
outputName = StringUtils.stripFilenameExtension(outputName) + "-"
|
|
|
|
|