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

Spotless can unintentionally break maven plugin configuration #38

Open
Tiihott opened this issue Nov 27, 2024 · 2 comments
Open

Spotless can unintentionally break maven plugin configuration #38

Tiihott opened this issue Nov 27, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@Tiihott
Copy link
Contributor

Tiihott commented Nov 27, 2024

Describe the bug
When spotless is applied to pom.xml in certain cases it can break the plugin configuration.

Expected behavior
Spotless is expected to make changes that don't affect the functionality of the code.

How to reproduce
Problematic plugin before applying spotless (builds correctly):
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>3.1.0</version> <executions> <execution> <id>copy-sources</id> <phase>process-sources</phase> <goals> <goal>exec</goal> </goals> <configuration> <executable>cp</executable> <arguments> <argument>-a</argument> <argument>${project.build.directory}/../src/main/c/.</argument> <argument>.</argument> </arguments> <workingDirectory>${project.build.directory}/${project.artifactId}/src/main/c</workingDirectory> </configuration> </execution> <execution> <id>autoreconf</id> <phase>process-sources</phase> <goals> <goal>exec</goal> </goals> <configuration> <executable>autoreconf</executable> <arguments> <argument>-fvi</argument> </arguments> <workingDirectory>${project.build.directory}/${project.artifactId}/src/main/c</workingDirectory> </configuration> </execution> <execution> <id>configure</id> <phase>process-sources</phase> <goals> <goal>exec</goal> </goals> <configuration> <executable>./configure</executable> <arguments> <argument>--prefix=/</argument> <argument>--libdir=/</argument> </arguments> <workingDirectory>${project.build.directory}/${project.artifactId}/src/main/c</workingDirectory> </configuration> </execution> <execution> <id>make</id> <phase>process-sources</phase> <goals> <goal>exec</goal> </goals> <configuration> <executable>make</executable> <arguments> <argument>-j1</argument> </arguments> <workingDirectory>${project.build.directory}/${project.artifactId}/src/main/c</workingDirectory> </configuration> </execution> <execution> <id>make-install</id> <phase>process-sources</phase> <goals> <goal>exec</goal> </goals> <configuration> <executable>make</executable> <arguments> <argument>-j1</argument> <argument>install</argument> <argument>DESTDIR=${project.build.directory}/classes</argument> </arguments> <workingDirectory>${project.build.directory}/${project.artifactId}/src/main/c</workingDirectory> </configuration> </execution> </executions> </plugin>

Result after applying Spotless, unable to build (autoreconf: error: 'configure.ac' is required):
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>3.1.0</version> <executions> <execution> <id>autoreconf</id> <goals> <goal>exec</goal> </goals> <phase>process-sources</phase> <configuration> <executable>autoreconf</executable> <arguments> <argument>-fvi</argument> </arguments> <workingDirectory>${project.build.directory}/${project.artifactId}/src/main/c</workingDirectory> </configuration> </execution> <execution> <id>configure</id> <goals> <goal>exec</goal> </goals> <phase>process-sources</phase> <configuration> <executable>./configure</executable> <arguments> <argument>--prefix=/</argument> <argument>--libdir=/</argument> </arguments> <workingDirectory>${project.build.directory}/${project.artifactId}/src/main/c</workingDirectory> </configuration> </execution> <execution> <id>copy-sources</id> <goals> <goal>exec</goal> </goals> <phase>process-sources</phase> <configuration> <executable>cp</executable> <arguments> <argument>-a</argument> <argument>${project.build.directory}/../src/main/c/.</argument> <argument>.</argument> </arguments> <workingDirectory>${project.build.directory}/${project.artifactId}/src/main/c</workingDirectory> </configuration> </execution> <execution> <id>make</id> <goals> <goal>exec</goal> </goals> <phase>process-sources</phase> <configuration> <executable>make</executable> <arguments> <argument>-j1</argument> </arguments> <workingDirectory>${project.build.directory}/${project.artifactId}/src/main/c</workingDirectory> </configuration> </execution> <execution> <id>make-install</id> <goals> <goal>exec</goal> </goals> <phase>process-sources</phase> <configuration> <executable>make</executable> <arguments> <argument>-j1</argument> <argument>install</argument> <argument>DESTDIR=${project.build.directory}/classes</argument> </arguments> <workingDirectory>${project.build.directory}/${project.artifactId}/src/main/c</workingDirectory> </configuration> </execution> </executions> </plugin>

Software version
Spotless 2.30.0

@Tiihott Tiihott added the bug Something isn't working label Nov 27, 2024
@Tiihott
Copy link
Contributor Author

Tiihott commented Nov 29, 2024

After further debugging, it seems like the root issue is spotless swapping the ordering of executions.
When copy-sources execution is moved to be after autoreconf execution, it will cause build failure as the sources used by autoreconf are not yet available at the expected location.

@Tiihott
Copy link
Contributor Author

Tiihott commented Nov 29, 2024

It seems like Spotless reorders the executions alphabetically based on execution id. By changing the id of copy-sources to acopy-sources, spotless no longer tries to swap the execution ordering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant