private void mainClassNameFinder(Project project) { FindMainClassTask findMainClassTask = project.getTasks() .create(FIND_MAIN_CLASS_TASK_NAME, FindMainClassTask.class); SourceSet mainSourceSet = SourceSets.findMainSourceSet(project); if (mainSourceSet != null) { findMainClassTask.setMainClassSourceSetOutput(mainSourceSet.getOutput()); } project.getTasks().all(new Action<Task>() { @Override public void execute(Task task) { if (task instanceof BootRunTask || task instanceof CreateStartScripts) { task.dependsOn(FIND_MAIN_CLASS_TASK_NAME); } } }); }
private void mainClassNameFinder(Project project) { FindMainClassTask findMainClassTask = project.getTasks() .create(FIND_MAIN_CLASS_TASK_NAME, FindMainClassTask.class); SourceSet mainSourceSet = SourceSets.findMainSourceSet(project); if (mainSourceSet != null) { findMainClassTask.setMainClassSourceSetOutput(mainSourceSet.getOutput()); } project.getTasks().all(new Action<Task>() { @Override public void execute(Task task) { if (task instanceof JavaExec || task instanceof CreateStartScripts) { task.dependsOn(FIND_MAIN_CLASS_TASK_NAME); } } }); }
private void addCreateScriptsTask() { CreateStartScripts startScripts = project.getTasks().create(TASK_START_SCRIPTS_NAME, CreateStartScripts.class); startScripts.setDescription("Creates OS specific scripts to run the project as a JVM application."); startScripts.setClasspath(project.getTasks().getAt(JavaPlugin.JAR_TASK_NAME).getOutputs().getFiles().plus(project.getConfigurations().getByName("runtime"))); startScripts.getConventionMapping().map("mainClassName", new Callable<Object>() { @Override public Object call() throws Exception { return pluginConvention.getMainClassName(); } }); startScripts.getConventionMapping().map("applicationName", new Callable<Object>() { @Override public Object call() throws Exception { return pluginConvention.getApplicationName(); } }); startScripts.getConventionMapping().map("outputDir", new Callable<Object>() { @Override public Object call() throws Exception { return new File(project.getBuildDir(), "scripts"); } }); startScripts.getConventionMapping().map("defaultJvmOpts", new Callable<Object>() { @Override public Object call() throws Exception { return pluginConvention.getApplicationDefaultJvmArgs(); } }); }