Tolerate module-info with AOT processing
This commit updates the Maven Plugin to tolerate projects that are using the module path on the JVM and targeting native images with AOT. Previously, the plugin compiled AOT sources directly to target/classes and the presence of a module-info there is enough to trigger a compilation on the module path. With this change we now compile in a separate directory that contains the generated AOT classes (typically CGLIB proxies). These are copied to target/classes once compilation completes already. The integration test also uses our parent, rather than relying on what Maven provides. That's because older Maven versions provide a default compiler plugin version that did not handle the module path correctly. Closes gh-33383
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -96,7 +96,7 @@ public class ProcessAotMojo extends AbstractAotMojo {
|
||||
: SpringBootApplicationClassFinder.findSingleClass(this.classesDirectory);
|
||||
URL[] classPath = getClassPath();
|
||||
generateAotAssets(classPath, AOT_PROCESSOR_CLASS_NAME, getAotArguments(applicationClass));
|
||||
compileSourceFiles(classPath, this.generatedSources, this.classesDirectory);
|
||||
compileSourceFiles(classPath, this.generatedSources, this.generatedClasses);
|
||||
copyAll(this.generatedResources.toPath(), this.classesDirectory.toPath());
|
||||
copyAll(this.generatedClasses.toPath(), this.classesDirectory.toPath());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -125,7 +125,7 @@ public class ProcessTestAotMojo extends AbstractAotMojo {
|
||||
return;
|
||||
}
|
||||
generateAotAssets(getClassPath(true), AOT_PROCESSOR_CLASS_NAME, getAotArguments());
|
||||
compileSourceFiles(getClassPath(false), this.generatedSources, this.testClassesDirectory);
|
||||
compileSourceFiles(getClassPath(false), this.generatedSources, this.generatedTestClasses);
|
||||
copyAll(this.generatedResources.toPath().resolve("META-INF/native-image"),
|
||||
this.testClassesDirectory.toPath().resolve("META-INF/native-image"));
|
||||
copyAll(this.generatedTestClasses.toPath(), this.testClassesDirectory.toPath());
|
||||
|
||||
Reference in New Issue
Block a user