Search in sources :

Example 1 with SpringBootPluginExtension

use of org.springframework.boot.gradle.SpringBootPluginExtension in project spring-boot by spring-projects.

the class AgentTasksEnhancer method setup.

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);
}
Also used : SpringBootPluginExtension(org.springframework.boot.gradle.SpringBootPluginExtension)

Example 2 with SpringBootPluginExtension

use of org.springframework.boot.gradle.SpringBootPluginExtension in project spring-boot by spring-projects.

the class RepackageTask method repackage.

@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));
}
Also used : Project(org.gradle.api.Project) SpringBootPluginExtension(org.springframework.boot.gradle.SpringBootPluginExtension) TaskAction(org.gradle.api.tasks.TaskAction)

Example 3 with SpringBootPluginExtension

use of org.springframework.boot.gradle.SpringBootPluginExtension in project spring-boot by spring-projects.

the class RepackageTask method getLibraries.

public ProjectLibraries getLibraries() {
    Project project = getProject();
    SpringBootPluginExtension extension = project.getExtensions().getByType(SpringBootPluginExtension.class);
    ProjectLibraries libraries = new ProjectLibraries(project, extension, this.excludeDevtools == null ? extension.isExcludeDevtools() : this.excludeDevtools);
    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;
}
Also used : Project(org.gradle.api.Project) SpringBootPluginExtension(org.springframework.boot.gradle.SpringBootPluginExtension)

Example 4 with SpringBootPluginExtension

use of org.springframework.boot.gradle.SpringBootPluginExtension 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;
}
Also used : Project(org.gradle.api.Project) Task(org.gradle.api.Task) DefaultTask(org.gradle.api.DefaultTask) JavaExec(org.gradle.api.tasks.JavaExec) SpringBootPluginExtension(org.springframework.boot.gradle.SpringBootPluginExtension) ApplicationPluginConvention(org.gradle.api.plugins.ApplicationPluginConvention) IOException(java.io.IOException)

Aggregations

SpringBootPluginExtension (org.springframework.boot.gradle.SpringBootPluginExtension)4 Project (org.gradle.api.Project)3 IOException (java.io.IOException)1 DefaultTask (org.gradle.api.DefaultTask)1 Task (org.gradle.api.Task)1 ApplicationPluginConvention (org.gradle.api.plugins.ApplicationPluginConvention)1 JavaExec (org.gradle.api.tasks.JavaExec)1 TaskAction (org.gradle.api.tasks.TaskAction)1