Skip to content

Align behavior of the "nativeTest" Maven profile with "native" to make it suitable for multi-module projects #44696

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

Closed
NoxFr opened this issue Mar 12, 2025 · 5 comments
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@NoxFr
Copy link

NoxFr commented Mar 12, 2025

Context

nativeTest profile does not suit well in a multi module project.

Whereas the native profile does not enforce plugin addition, nativeTest profiles does.
This cause failures in modules without spring boot application (like shared class modules) when running mvn test command.

See definitions in spring-boot-parent pom

  • native profile use
  • nativeTest profile use direct definitions
 <profiles>
    <profile>
      <id>native</id>
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-jar-plugin</artifactId>
              <configuration>
                <archive>
                  <manifestEntries>
                    <Spring-Boot-Native-Processed>true</Spring-Boot-Native-Processed>
                  </manifestEntries>
                </archive>
              </configuration>
            </plugin>
            <plugin>
              <groupId>org.springframework.boot</groupId>
              <artifactId>spring-boot-maven-plugin</artifactId>
              <executions>
                <execution>
                  <id>process-aot</id>
                  <goals>
                    <goal>process-aot</goal>
                  </goals>
                </execution>
              </executions>
            </plugin>
            <plugin>
              <groupId>org.graalvm.buildtools</groupId>
              <artifactId>native-maven-plugin</artifactId>
              <configuration>
                <classesDirectory>${project.build.outputDirectory}</classesDirectory>
                <requiredVersion>22.3</requiredVersion>
              </configuration>
              <executions>
                <execution>
                  <id>add-reachability-metadata</id>
                  <goals>
                    <goal>add-reachability-metadata</goal>
                  </goals>
                </execution>
              </executions>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
    </profile>
    <profile>
      <id>nativeTest</id>
      <dependencies>
        <dependency>
          <groupId>org.junit.platform</groupId>
          <artifactId>junit-platform-launcher</artifactId>
          <scope>test</scope>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>process-test-aot</id>
                <goals>
                  <goal>process-test-aot</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.graalvm.buildtools</groupId>
            <artifactId>native-maven-plugin</artifactId>
            <configuration>
              <classesDirectory>${project.build.outputDirectory}</classesDirectory>
              <requiredVersion>22.3</requiredVersion>
            </configuration>
            <executions>
              <execution>
                <id>native-test</id>
                <goals>
                  <goal>test</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

Sample Projet

https://github.com/NoxFr/nativetest-issue

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 12, 2025
@RivennZhang

This comment has been minimized.

@wilkinsona

This comment has been minimized.

@wilkinsona
Copy link
Member

@snicoll could we do something similar to 75b7463, but for the nativeTest side of things?

@snicoll
Copy link
Member

snicoll commented Mar 17, 2025

Yes, I think so. I'll have a look

@snicoll snicoll self-assigned this Mar 17, 2025
@snicoll snicoll changed the title nativeTest Maven profile is not suitable in multi module project Align behavior of the "nativeTest" Maven profile with "native" to make it suitable for multi-module projects Mar 17, 2025
@snicoll snicoll added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 17, 2025
@snicoll snicoll added this to the 3.5.0-M3 milestone Mar 17, 2025
@NoxFr
Copy link
Author

NoxFr commented Mar 17, 2025

Thanks @snicoll

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

No branches or pull requests

5 participants