mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Check for a mainClass in "run" task if there is one
If there is a run task with an explicit main it can be used by the repackage task (assuming its own native setting is not used). Fixes gh-389
This commit is contained in:
parent
b7802f98bb
commit
511fff05bb
@ -23,6 +23,7 @@ import java.util.concurrent.TimeUnit;
|
||||
import org.gradle.api.Action;
|
||||
import org.gradle.api.DefaultTask;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.tasks.JavaExec;
|
||||
import org.gradle.api.tasks.TaskAction;
|
||||
import org.gradle.api.tasks.bundling.Jar;
|
||||
import org.springframework.boot.gradle.SpringBootPluginExtension;
|
||||
@ -71,6 +72,11 @@ public class Repackage extends DefaultTask {
|
||||
else if (extension.getCustomConfiguration() != null) {
|
||||
libraries.setCustomConfigurationName(extension.getCustomConfiguration());
|
||||
}
|
||||
JavaExec runner = (JavaExec) project.getTasks().findByName("run");
|
||||
if (runner!=null && mainClass==null) {
|
||||
getLogger().info("Found main in run task: " + runner.getMain());
|
||||
setMainClass(runner.getMain());
|
||||
}
|
||||
project.getTasks().withType(Jar.class, new RepackageAction(extension, libraries));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user