public ProjectLibraries getLibraries() { Project project = getProject(); SpringBootPluginExtension extension = project.getExtensions() .getByType(SpringBootPluginExtension.class); ProjectLibraries libraries = new ProjectLibraries(project, extension, (this.excludeDevtools != null && this.excludeDevtools) || extension.isExcludeDevtools()); if (extension.getProvidedConfiguration() != null) { libraries.setProvidedConfigurationName(extension.getProvidedConfiguration()); } if (this.customConfiguration != null) { libraries.setCustomConfigurationName(this.customConfiguration); } else if (extension.getCustomConfiguration() != null) { libraries.setCustomConfigurationName(extension.getCustomConfiguration()); } return libraries; }
public ProjectLibraries getLibraries() { Project project = getProject(); SpringBootPluginExtension extension = project.getExtensions() .getByType(SpringBootPluginExtension.class); ProjectLibraries libraries = new ProjectLibraries(project, extension); if (extension.getProvidedConfiguration() != null) { libraries.setProvidedConfigurationName(extension.getProvidedConfiguration()); } if (this.customConfiguration != null) { libraries.setCustomConfigurationName(this.customConfiguration); } else if (extension.getCustomConfiguration() != null) { libraries.setCustomConfigurationName(extension.getCustomConfiguration()); } return libraries; }
@Override public void apply(Project project) { project.getExtensions().create("springBoot", SpringBootPluginExtension.class, project); project.getPlugins().apply(JavaPlugin.class); new AgentPluginFeatures().apply(project); new RepackagePluginFeatures().apply(project); new RunPluginFeatures().apply(project); new DependencyManagementPluginFeatures().apply(project); project.getTasks().withType(JavaCompile.class).all(new SetUtf8EncodingAction()); }
private void setup(Project project) { project.getLogger().info("Configuring agent"); SpringBootPluginExtension extension = project.getExtensions() .getByType(SpringBootPluginExtension.class); this.noverify = extension.getNoverify(); this.agent = getAgent(project, extension); if (this.agent == null) { this.agent = getSpringLoadedAgent(); if (this.noverify == null) { this.noverify = true; } } project.getLogger().debug("Agent: " + this.agent); }
@TaskAction public void repackage() { Project project = getProject(); SpringBootPluginExtension extension = project.getExtensions() .getByType(SpringBootPluginExtension.class); ProjectLibraries libraries = getLibraries(); project.getTasks().withType(Jar.class, new RepackageAction(extension, libraries)); }
/** * Create a new {@link ProjectLibraries} instance of the specified {@link Project}. * @param project the gradle project * @param extension the extension * @param excludeDevTools whether Spring Boot Devtools should be excluded */ ProjectLibraries(Project project, SpringBootPluginExtension extension, boolean excludeDevTools) { this.project = project; this.extension = extension; this.excludeDevtools = excludeDevTools; }
@Override public void execute(Jar jarTask) { if ("".equals(jarTask.getClassifier())) { String classifier = this.task.getClassifier(); if (classifier == null) { SpringBootPluginExtension extension = this.project.getExtensions() .getByType(SpringBootPluginExtension.class); classifier = extension.getClassifier(); this.task.setClassifier(classifier); } if (classifier != null) { setupInputOutputs(jarTask, classifier); } } }
private File getAgent(Project project, SpringBootPluginExtension extension) { if (project.hasProperty("run.agent")) { return project.file(project.property("run.agent")); } return extension.getAgent(); }
RepackageAction(SpringBootPluginExtension extension, ProjectLibraries libraries) { this.extension = extension; this.libraries = libraries; }
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()); 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; }
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(); } Task runTask = project.getTasks().findByName("run"); if (mainClass == null && runTask != null) { mainClass = (String) runTask.property("main"); } 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()); 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.setProperty("main", mainClass); } return mainClass; }
/** * Create a new {@link ProjectLibraries} instance of the specified {@link Project}. * @param project the gradle project * @param extension the extension */ ProjectLibraries(Project project, SpringBootPluginExtension extension) { this.project = project; this.extension = extension; }