use of org.gradle.api.tasks.JavaExec in project spring-security by spring-projects.
the class S101Plugin method configure.
private void configure(JavaExec exec) {
exec.setDescription("Runs Structure101 headless analysis, installing and configuring if necessary");
exec.dependsOn("check");
Project project = exec.getProject();
S101PluginExtension extension = project.getExtensions().getByType(S101PluginExtension.class);
exec.workingDir(extension.getInstallationDirectory()).classpath(new File(extension.getInstallationDirectory().get(), "structure101-java-build.jar")).args(new File(new File(project.getBuildDir(), "s101"), "config.xml")).systemProperty("s101.label", computeLabel(extension).get()).doFirst((task) -> {
installAndConfigureIfNeeded(project);
copyConfigurationToBuildDirectory(extension, project);
}).doLast((task) -> {
copyResultsBackToConfigurationDirectory(extension, project);
});
}
use of org.gradle.api.tasks.JavaExec in project spring-boot by spring-projects.
the class FindMainClassTask method findMainClass.
private String findMainClass() {
Project project = getProject();
String mainClass = null;
// Try the SpringBoot extension setting
SpringBootPluginExtension bootExtension = project.getExtensions().getByType(SpringBootPluginExtension.class);
if (bootExtension.getMainClass() != null) {
mainClass = bootExtension.getMainClass();
}
ApplicationPluginConvention application = (ApplicationPluginConvention) project.getConvention().getPlugins().get("application");
if (mainClass == null && application != null) {
// Try the Application extension setting
mainClass = application.getMainClassName();
}
JavaExec runTask = findRunTask(project);
if (mainClass == null && runTask != null) {
mainClass = runTask.getMain();
}
if (mainClass == null) {
Task bootRunTask = project.getTasks().findByName("bootRun");
if (bootRunTask != null) {
mainClass = (String) bootRunTask.property("main");
}
}
if (mainClass == null) {
// Search
if (this.mainClassSourceSetOutput != null) {
project.getLogger().debug("Looking for main in: " + this.mainClassSourceSetOutput.getClassesDir());
try {
mainClass = MainClassFinder.findSingleMainClass(this.mainClassSourceSetOutput.getClassesDir(), SPRING_BOOT_APPLICATION_CLASS_NAME);
project.getLogger().info("Computed main class: " + mainClass);
} catch (IOException ex) {
throw new IllegalStateException("Cannot find main class", ex);
}
}
}
project.getLogger().info("Found main: " + mainClass);
if (bootExtension.getMainClass() == null) {
bootExtension.setMainClass(mainClass);
}
if (application != null && application.getMainClassName() == null) {
application.setMainClassName(mainClass);
}
if (runTask != null && !runTask.hasProperty("main")) {
runTask.setMain(mainClass);
}
return mainClass;
}
use of org.gradle.api.tasks.JavaExec in project gradle by gradle.
the class ApplicationPlugin method addRunTask.
private void addRunTask() {
JavaExec run = project.getTasks().create(TASK_RUN_NAME, JavaExec.class);
run.setDescription("Runs this project as a JVM application");
run.setGroup(APPLICATION_GROUP);
JavaPluginConvention javaPluginConvention = project.getConvention().getPlugin(JavaPluginConvention.class);
run.setClasspath(javaPluginConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME).getRuntimeClasspath());
run.getConventionMapping().map("main", new Callable<Object>() {
@Override
public Object call() throws Exception {
return pluginConvention.getMainClassName();
}
});
run.getConventionMapping().map("jvmArgs", new Callable<Object>() {
@Override
public Object call() throws Exception {
return pluginConvention.getApplicationDefaultJvmArgs();
}
});
}
Aggregations