So, I’ve been trying to create a Gradle counterpart of the SciJava POM for a while now
The idea is the following: publishing the Gradle Catalog (toml file) and Grade Platform (module/json file) alongside pom.xml
In this way everything is perfectly synchronized and in one place (maven central), so that Gradle users can simply re-use the very same GAV coordinates for platform and catalog
However this nice idea is currently obstructed by some issues
At the moment, we are generating both platform and catalog in one go, from the effective pom here and then creating a single task generateCatalogAndPlatform
that will generate both of them
Then we modified the pom adding the hard-coded comment for Gradle on top, while at the bottom, we add this for calling the Gradle task and append the two newly generated files alongside in the publication:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>generate-gradle-catalog-and-platform</id>
<phase>generate-sources</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>./gradlew</executable>
<workingDirectory>${basedir}/gradle-scijava</workingDirectory>
<arguments>
<argument>--project-cache-dir</argument>
<argument>../target/gradle/build</argument>
<argument>generateCatalogAndPlatform</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
<!-- https://www.mojohaus.org/exec-maven-plugin/exec-mojo.html -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>attach-gradle-catalog-and-platform</id>
<!-- Check if correct-->
<!-- <phase>package</phase>-->
<goals>
<!-- https://www.mojohaus.org/build-helper-maven-plugin/attach-artifact-mojo.html -->
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>target/gradle/version-catalog/libs.versions.toml</file>
<type>toml</type>
</artifact>
<artifact>
<file>target/gradle/publications/pomScijava/module.json</file>
<!-- it should be published with the `.module` extension -->
<type>module</type>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
Unfortunately, for some reason we ignore, Maven is calling Gradle not once, but 4 times, the first 3 successfully while the last unsuccessfully
Unfortunately we don’t have enough experience in Maven to fix that
What shall be changed to achieve on single, successful, call?