"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/ResolveMainClassName.java" between
spring-boot-2.7.3.tar.gz and spring-boot-2.7.4.tar.gz

About: Spring Boot helps to create Spring-powered, production-grade applications and services.

ResolveMainClassName.java  (spring-boot-2.7.3):ResolveMainClassName.java  (spring-boot-2.7.4)
skipping to change at line 37 skipping to change at line 37
import org.gradle.api.DefaultTask; import org.gradle.api.DefaultTask;
import org.gradle.api.InvalidUserDataException; import org.gradle.api.InvalidUserDataException;
import org.gradle.api.Project; import org.gradle.api.Project;
import org.gradle.api.Task; import org.gradle.api.Task;
import org.gradle.api.Transformer; import org.gradle.api.Transformer;
import org.gradle.api.file.FileCollection; import org.gradle.api.file.FileCollection;
import org.gradle.api.file.RegularFile; import org.gradle.api.file.RegularFile;
import org.gradle.api.file.RegularFileProperty; import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.plugins.BasePlugin; import org.gradle.api.plugins.BasePlugin;
import org.gradle.api.plugins.Convention;
import org.gradle.api.plugins.JavaApplication; import org.gradle.api.plugins.JavaApplication;
import org.gradle.api.provider.Property; import org.gradle.api.provider.Property;
import org.gradle.api.provider.Provider; import org.gradle.api.provider.Provider;
import org.gradle.api.tasks.Classpath; import org.gradle.api.tasks.Classpath;
import org.gradle.api.tasks.Input; import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.Optional; import org.gradle.api.tasks.Optional;
import org.gradle.api.tasks.OutputFile; import org.gradle.api.tasks.OutputFile;
import org.gradle.api.tasks.TaskAction; import org.gradle.api.tasks.TaskAction;
import org.gradle.api.tasks.TaskProvider; import org.gradle.api.tasks.TaskProvider;
import org.gradle.work.DisableCachingByDefault;
import org.springframework.boot.gradle.dsl.SpringBootExtension; import org.springframework.boot.gradle.dsl.SpringBootExtension;
import org.springframework.boot.loader.tools.MainClassFinder; import org.springframework.boot.loader.tools.MainClassFinder;
/** /**
* {@link Task} for resolving the name of the application's main class. * {@link Task} for resolving the name of the application's main class.
* *
* @author Andy Wilkinson * @author Andy Wilkinson
* @since 2.4 * @since 2.4
*/ */
@DisableCachingByDefault(because = "Not worth caching")
public class ResolveMainClassName extends DefaultTask { public class ResolveMainClassName extends DefaultTask {
private static final String SPRING_BOOT_APPLICATION_CLASS_NAME = "org.spr ingframework.boot.autoconfigure.SpringBootApplication"; private static final String SPRING_BOOT_APPLICATION_CLASS_NAME = "org.spr ingframework.boot.autoconfigure.SpringBootApplication";
private final RegularFileProperty outputFile; private final RegularFileProperty outputFile;
private final Property<String> configuredMainClass; private final Property<String> configuredMainClass;
private FileCollection classpath; private FileCollection classpath;
skipping to change at line 159 skipping to change at line 160
} }
Provider<String> readMainClassName() { Provider<String> readMainClassName() {
return this.outputFile.map(new ClassNameReader()); return this.outputFile.map(new ClassNameReader());
} }
static TaskProvider<ResolveMainClassName> registerForTask(String taskName , Project project, static TaskProvider<ResolveMainClassName> registerForTask(String taskName , Project project,
Callable<FileCollection> classpath) { Callable<FileCollection> classpath) {
TaskProvider<ResolveMainClassName> resolveMainClassNameProvider = project.getTasks() TaskProvider<ResolveMainClassName> resolveMainClassNameProvider = project.getTasks()
.register(taskName + "MainClassName", ResolveMain ClassName.class, (resolveMainClassName) -> { .register(taskName + "MainClassName", ResolveMain ClassName.class, (resolveMainClassName) -> {
Convention convention = project.getConven tion();
resolveMainClassName.setDescription( resolveMainClassName.setDescription(
"Resolves the name of the application's main class for the " + taskName + " task."); "Resolves the name of the application's main class for the " + taskName + " task.");
resolveMainClassName.setGroup(BasePlugin. BUILD_GROUP); resolveMainClassName.setGroup(BasePlugin. BUILD_GROUP);
resolveMainClassName.setClasspath(classpa th); resolveMainClassName.setClasspath(classpa th);
resolveMainClassName.getConfiguredMainCla ssName().convention(project.provider(() -> { resolveMainClassName.getConfiguredMainCla ssName().convention(project.provider(() -> {
String javaApplicationMainClass = getJavaApplicationMainClass(convention); String javaApplicationMainClass = getJavaApplicationMainClass(project);
if (javaApplicationMainClass != n ull) { if (javaApplicationMainClass != n ull) {
return javaApplicationMai nClass; return javaApplicationMai nClass;
} }
SpringBootExtension springBootExt ension = project.getExtensions() SpringBootExtension springBootExt ension = project.getExtensions()
.findByType(Sprin gBootExtension.class); .findByType(Sprin gBootExtension.class);
return springBootExtension.getMai nClass().getOrNull(); return springBootExtension.getMai nClass().getOrNull();
})); }));
resolveMainClassName.getOutputFile() resolveMainClassName.getOutputFile()
.set(project.getLayout(). getBuildDirectory().file(taskName + "MainClassName")); .set(project.getLayout(). getBuildDirectory().file(taskName + "MainClassName"));
}); });
return resolveMainClassNameProvider; return resolveMainClassNameProvider;
} }
private static String getJavaApplicationMainClass(Convention convention) private static String getJavaApplicationMainClass(Project project) {
{ JavaApplication javaApplication = project.getExtensions().findByT
JavaApplication javaApplication = convention.findByType(JavaAppli ype(JavaApplication.class);
cation.class);
if (javaApplication == null) { if (javaApplication == null) {
return null; return null;
} }
return javaApplication.getMainClass().getOrNull(); return javaApplication.getMainClass().getOrNull();
} }
private static final class ClassNameReader implements Transformer<String, RegularFile> { private static final class ClassNameReader implements Transformer<String, RegularFile> {
@Override @Override
public String transform(RegularFile file) { public String transform(RegularFile file) {
 End of changes. 6 change blocks. 
7 lines changed or deleted 6 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)