When using Spring Boot Maven plugin 3.0.0-RC2 with a multi-module Maven project, the plugin fails to run at the parent level when packaging is set to pom. It turns out that the process-aot target is trying to run, but since there is no source code the plugins fails:

[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.321 s
[INFO] Finished at: 2022-11-15T11:39:28+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.0.0-RC2:process-aot (process-aot) on project wnisb3-otel-parent: Unable to find a suitable main class, please add a 'mainClass' property -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

As a workaround, I set <skip>true</skip> when the Maven project packaging is set to pom.

Comment From: snicoll

It's a bit strange to configure process-aot on the root. This should be only applied for the actual application. Can you share why you need to set it at the root?

Comment From: alexandreroman

I want to set a default buildpack builder for my multi-module project. This builder is set at the root level in the spring-boot-maven-plugin section:

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <image>
                    <builder>dashaun/java-native-builder-multiarch:7.37.0</builder>
                </image>
            </configuration>
        </plugin>
    </plugins>
</build>

Comment From: wilkinsona

I think you should configure that in plugin management so that it only affects modules that need to use Boot's Maven plugin:

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <image>
                        <builder>dashaun/java-native-builder-multiarch:7.37.0</builder>
                    </image>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

Comment From: alexandreroman

I think you should configure that in plugin management so that it only affects modules that need to use Boot's Maven plugin:

This is exactly what I did in the first place, but same error.

Comment From: snicoll

This is exactly what I did in the first place, but same error.

Please share a sample project. As Andy explained, the root should not enable the Spring Boot plugin so requesting process-aot to skip isn't the right way to fix whatever you're experiencing.

Comment From: snicoll

Nevermind, I can see that our native profile should also use pluginManagement. I'll get that sorted.

Comment From: snicoll

Actually, I am having second thoughts about this. @alexandreroman can you please share a sample project? I am assuming you're using Spring Boot's starter parent. Are all modules Spring Boot applications or do you have library or non-apps there?

Comment From: alexandreroman

@snicoll I'm using the Spring Boot starter as a parent, all modules are Spring Boot apps.

Here's my public repo. If you look at the otel project (Maven multi-module), I have to set skip=true at the root level otherwise process-aot would fail.

Comment From: snicoll

I'm using the Spring Boot starter as a parent, all modules are Spring Boot apps.

I am afraid that's really working so far for that reason alone. Our parent is meant to provide an out-of-the-box experience for an app, not a project. If you want to use our parent with a multi-module build, additional care is required.

For instance, if you add a module that isn't an application, this will fail as well:

[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.0.0-RC2:process-aot (process-aot) on project wnisb3-otel-lib: Unable to find a suitable main class, please add a 'mainClass' property -> [Help 1]

If you run mvn -Pnative native:compile this will fail as well:

[ERROR] Failed to execute goal org.graalvm.buildtools:native-maven-plugin:0.9.17:compile (default-cli) on project wnisb3-otel-parent: Image classpath is empty. Check if your classpath configuration is correct. -> [Help 1]

Also, the reachability metadata is enabled with the native profile, which means we attempt to build the metadata for each module. It's more than the Spring Boot plugin.

Long story short, I don't think our parent is the best option for a multi-module project with the native profile. I don't see how we could make this more flexible. Flagging for team attention.

Comment From: alexandreroman

As a Maven user, I don't expect any plugins dealing with source code to fail if the packaging is set to pom. The expected behaviour in this case is: "do nothing".

Comment From: snicoll

I am aware of that. I am just saying that even if we do this (we could), your setup will work by accident more than anything else. Please review the comment.

Comment From: snicoll

I've been looking at various use cases and it's increasingly apparent the current arrangement is not suited to a multi-modules build. See https://gist.github.com/snicoll/4ac487e2b671100647d8cb42ca05ae0e for a summary.

Comment From: snicoll

As I suspected, changing process-aot to skip a pom project isn't achieving anything (besides hiding the actual issue). I've pushed some change to the native profile so that it is multi-modules friendly. I've also updated the reference guide to describe what it does and how it should be used within a multi-modules setup.

There are a number of sample projects in this PR to the smoke tests repo that summarizes it all.