Search in sources :

Example 1 with SpringBootExtension

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

the class ResolveMainClassName method registerForTask.

static TaskProvider<ResolveMainClassName> registerForTask(String taskName, Project project, Callable<FileCollection> classpath) {
    TaskProvider<ResolveMainClassName> resolveMainClassNameProvider = project.getTasks().register(taskName + "MainClassName", ResolveMainClassName.class, (resolveMainClassName) -> {
        ExtensionContainer extensions = project.getExtensions();
        resolveMainClassName.setDescription("Resolves the name of the application's main class for the " + taskName + " task.");
        resolveMainClassName.setGroup(BasePlugin.BUILD_GROUP);
        resolveMainClassName.setClasspath(classpath);
        resolveMainClassName.getConfiguredMainClassName().convention(project.provider(() -> {
            String javaApplicationMainClass = getJavaApplicationMainClass(extensions);
            if (javaApplicationMainClass != null) {
                return javaApplicationMainClass;
            }
            SpringBootExtension springBootExtension = project.getExtensions().findByType(SpringBootExtension.class);
            return springBootExtension.getMainClass().getOrNull();
        }));
        resolveMainClassName.getOutputFile().set(project.getLayout().getBuildDirectory().file(taskName + "MainClassName"));
    });
    return resolveMainClassNameProvider;
}
Also used : SpringBootExtension(org.springframework.boot.gradle.dsl.SpringBootExtension) ExtensionContainer(org.gradle.api.plugins.ExtensionContainer)

Aggregations

ExtensionContainer (org.gradle.api.plugins.ExtensionContainer)1 SpringBootExtension (org.springframework.boot.gradle.dsl.SpringBootExtension)1