ProcessAotMojo Class — spring-boot Architecture
Architecture documentation for the ProcessAotMojo class in ProcessAotMojo.java from the spring-boot codebase.
Entity Profile
Source Code
build-plugin/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/ProcessAotMojo.java lines 42–144
@Mojo(name = "process-aot", defaultPhase = LifecyclePhase.PREPARE_PACKAGE, threadSafe = true,
requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME,
requiresDependencyCollection = ResolutionScope.COMPILE_PLUS_RUNTIME)
public class ProcessAotMojo extends AbstractAotMojo {
private static final String AOT_PROCESSOR_CLASS_NAME = "org.springframework.boot.SpringApplicationAotProcessor";
/**
* Directory containing the classes and resource files that should be packaged into
* the archive.
*/
@Parameter(defaultValue = "${project.build.outputDirectory}", required = true)
@SuppressWarnings("NullAway.Init")
private File classesDirectory;
/**
* Directory containing the generated sources.
*/
@Parameter(defaultValue = "${project.build.directory}/spring-aot/main/sources", required = true)
@SuppressWarnings("NullAway.Init")
private File generatedSources;
/**
* Directory containing the generated resources.
*/
@Parameter(defaultValue = "${project.build.directory}/spring-aot/main/resources", required = true)
@SuppressWarnings("NullAway.Init")
private File generatedResources;
/**
* Directory containing the generated classes.
*/
@Parameter(defaultValue = "${project.build.directory}/spring-aot/main/classes", required = true)
@SuppressWarnings("NullAway.Init")
private File generatedClasses;
/**
* Name of the main class to use as the source for the AOT process. If not specified
* the first compiled class found that contains a 'main' method will be used.
*/
@Parameter(property = "spring-boot.aot.main-class")
private @Nullable String mainClass;
/**
* Application arguments that should be taken into account for AOT processing.
*/
@Parameter
@SuppressWarnings("NullAway") // maven-maven-plugin can't handle annotated arrays
private String[] arguments;
/**
* Spring profiles to take into account for AOT processing.
*/
@Parameter
@SuppressWarnings("NullAway") // maven-maven-plugin can't handle annotated arrays
private String[] profiles;
@Inject
public ProcessAotMojo(ToolchainManager toolchainManager) {
super(toolchainManager);
}
@Override
protected void executeAot() throws Exception {
if (this.project.getPackaging().equals("pom")) {
getLog().debug("process-aot goal could not be applied to pom project.");
return;
}
String applicationClass = (this.mainClass != null) ? this.mainClass
: SpringBootApplicationClassFinder.findSingleClass(this.classesDirectory);
URL[] classPath = getClassPath();
generateAotAssets(classPath, AOT_PROCESSOR_CLASS_NAME, getAotArguments(applicationClass));
compileSourceFiles(classPath, this.generatedSources, this.generatedClasses);
copyAll(this.generatedResources.toPath(), this.classesDirectory.toPath());
copyAll(this.generatedClasses.toPath(), this.classesDirectory.toPath());
}
private String[] getAotArguments(String applicationClass) {
List<String> aotArguments = new ArrayList<>();
aotArguments.add(applicationClass);
aotArguments.add(this.generatedSources.toString());
aotArguments.add(this.generatedResources.toString());
aotArguments.add(this.generatedClasses.toString());
aotArguments.add(this.project.getGroupId());
aotArguments.add(this.project.getArtifactId());
aotArguments.addAll(resolveArguments().getArgs());
return aotArguments.toArray(String[]::new);
}
private URL[] getClassPath() throws Exception {
File[] directories = new File[] { this.classesDirectory, this.generatedClasses };
return getClassPath(directories, new ExcludeTestScopeArtifactFilter(), DEVTOOLS_EXCLUDE_FILTER);
}
private RunArguments resolveArguments() {
RunArguments runArguments = new RunArguments(this.arguments);
if (!ObjectUtils.isEmpty(this.profiles)) {
runArguments.getArgs().addFirst("--spring.profiles.active=" + String.join(",", this.profiles));
}
return runArguments;
}
}
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free