mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Drop RepackageTask.getDependencies()
Drop `RepackageTask.getDependencies` from the gradle plugin in favor of exposing `getLibraries()` and using the callback. Drop getDependencies
This commit is contained in:
parent
c713c8091d
commit
5de2661b43
@ -17,6 +17,7 @@
|
||||
package org.springframework.boot.gradle.repackage;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.gradle.api.Action;
|
||||
import org.gradle.api.Project;
|
||||
@ -27,6 +28,8 @@ import org.gradle.api.plugins.BasePlugin;
|
||||
import org.gradle.api.tasks.bundling.Jar;
|
||||
import org.springframework.boot.gradle.PluginFeatures;
|
||||
import org.springframework.boot.gradle.SpringBootPluginExtension;
|
||||
import org.springframework.boot.loader.tools.LibraryCallback;
|
||||
import org.springframework.boot.loader.tools.LibraryScope;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@ -124,11 +127,25 @@ public class RepackagePluginFeatures implements PluginFeatures {
|
||||
+ classifier + "." + StringUtils.getFilenameExtension(outputName);
|
||||
File outputFile = new File(inputFile.getParentFile(), outputName);
|
||||
this.task.getInputs().file(jarTask);
|
||||
this.task.getInputs().file(this.task.getDependencies());
|
||||
addLibraryDependencies(this.task);
|
||||
this.task.getOutputs().file(outputFile);
|
||||
this.task.setOutputFile(outputFile);
|
||||
}
|
||||
|
||||
private void addLibraryDependencies(final RepackageTask task) {
|
||||
try {
|
||||
task.getLibraries().doWithLibraries(new LibraryCallback() {
|
||||
@Override
|
||||
public void library(File file, LibraryScope scope) throws IOException {
|
||||
task.getInputs().file(file);
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw new IllegalStateException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,8 +18,6 @@ package org.springframework.boot.gradle.repackage;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.gradle.api.Action;
|
||||
@ -29,8 +27,6 @@ import org.gradle.api.tasks.TaskAction;
|
||||
import org.gradle.api.tasks.TaskContainer;
|
||||
import org.gradle.api.tasks.bundling.Jar;
|
||||
import org.springframework.boot.gradle.SpringBootPluginExtension;
|
||||
import org.springframework.boot.loader.tools.LibraryCallback;
|
||||
import org.springframework.boot.loader.tools.LibraryScope;
|
||||
import org.springframework.boot.loader.tools.Repackager;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
|
||||
@ -101,23 +97,7 @@ public class RepackageTask extends DefaultTask {
|
||||
project.getTasks().withType(Jar.class, new RepackageAction(extension, libraries));
|
||||
}
|
||||
|
||||
public File[] getDependencies() {
|
||||
ProjectLibraries libraries = getLibraries();
|
||||
final List<File> files = new ArrayList<File>();
|
||||
try {
|
||||
libraries.doWithLibraries(new LibraryCallback() {
|
||||
@Override
|
||||
public void library(File file, LibraryScope scope) throws IOException {
|
||||
files.add(file);
|
||||
}
|
||||
});
|
||||
} catch (IOException ex) {
|
||||
throw new IllegalStateException("Cannot retrieve dependencies", ex);
|
||||
}
|
||||
return files.toArray(new File[files.size()]);
|
||||
}
|
||||
|
||||
private ProjectLibraries getLibraries() {
|
||||
public ProjectLibraries getLibraries() {
|
||||
Project project = getProject();
|
||||
SpringBootPluginExtension extension = project.getExtensions().getByType(
|
||||
SpringBootPluginExtension.class);
|
||||
|
Loading…
Reference in New Issue
Block a user