Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native profile should configure execution in pluginManagement #33184

Closed
alexandreroman opened this issue Nov 15, 2022 · 13 comments
Closed

Native profile should configure execution in pluginManagement #33184

alexandreroman opened this issue Nov 15, 2022 · 13 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@alexandreroman
Copy link

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.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 15, 2022
@snicoll
Copy link
Member

snicoll commented Nov 15, 2022

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?

@snicoll snicoll added the status: waiting-for-feedback We need additional information before we can continue label Nov 15, 2022
@alexandreroman
Copy link
Author

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>

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Nov 15, 2022
@wilkinsona
Copy link
Member

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>

@wilkinsona wilkinsona added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Nov 15, 2022
@alexandreroman
Copy link
Author

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.

@snicoll
Copy link
Member

snicoll commented Nov 15, 2022

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.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Nov 15, 2022
@snicoll snicoll added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged status: feedback-provided Feedback has been provided labels Nov 15, 2022
@snicoll snicoll added this to the 3.0.0 milestone Nov 15, 2022
@snicoll snicoll changed the title Skip process-aot for Maven project when packaging is set to pom Native profile should configure execution in pluginManagement Nov 15, 2022
@snicoll
Copy link
Member

snicoll commented Nov 15, 2022

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

@snicoll
Copy link
Member

snicoll commented Nov 15, 2022

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?

@snicoll snicoll removed this from the 3.0.0 milestone Nov 15, 2022
@snicoll snicoll added status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged and removed type: bug A general bug labels Nov 15, 2022
@alexandreroman
Copy link
Author

@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.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Nov 16, 2022
@snicoll
Copy link
Member

snicoll commented Nov 17, 2022

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.

@snicoll snicoll added the for: team-attention An issue we'd like other members of the team to review label Nov 17, 2022
@alexandreroman
Copy link
Author

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".

@snicoll
Copy link
Member

snicoll commented Nov 17, 2022

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.

snicoll added a commit to snicoll/spring-boot that referenced this issue Nov 21, 2022
@snicoll snicoll self-assigned this Nov 21, 2022
@snicoll
Copy link
Member

snicoll commented Nov 21, 2022

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.

snicoll added a commit to snicoll/spring-boot that referenced this issue Nov 21, 2022
snicoll added a commit to snicoll/spring-boot that referenced this issue Nov 21, 2022
@snicoll snicoll added type: bug A general bug and removed for: team-attention An issue we'd like other members of the team to review status: waiting-for-triage An issue we've not yet triaged status: feedback-provided Feedback has been provided labels Nov 22, 2022
@snicoll snicoll added this to the 3.0.0 milestone Nov 22, 2022
@snicoll
Copy link
Member

snicoll commented Nov 22, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

4 participants