use of org.gradle.api.plugins.ApplicationPluginConvention 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.plugins.ApplicationPluginConvention in project gradle-eta by typelead.
the class EtaPlugin method configureApplicationPluginIfPresent.
private void configureApplicationPluginIfPresent() {
project.getPlugins().all(plugin -> {
if (ApplicationPlugin.class.isInstance(plugin)) {
ApplicationPluginConvention pluginConvention = project.getConvention().getPlugin(ApplicationPluginConvention.class);
pluginConvention.setMainClassName("eta.main");
}
});
}
use of org.gradle.api.plugins.ApplicationPluginConvention in project wildfly-swarm by wildfly-swarm.
the class PackageTask method getMainClassName.
@Input
@Optional
private String getMainClassName() {
Project project = getProject();
SwarmExtension swarmExtension = getSwarmExtension();
String mainClassName = swarmExtension.getMainClassName();
if (mainClassName == null && project.getConvention().getPlugins().containsKey("application")) {
ApplicationPluginConvention app = (ApplicationPluginConvention) project.getConvention().getPlugins().get("application");
mainClassName = app.getMainClassName();
}
if (mainClassName != null && !mainClassName.equals("")) {
getLogger().warn("\n------\n" + "Custom main() usage is intended to be deprecated in a future release and is no longer supported, \n" + "please refer to http://docs.wildfly-swarm.io for YAML configuration that replaces it." + "\n------");
}
return mainClassName;
}
Aggregations