JavierSegoviaCordoba / semver-gradle-plugin

Set projects versions based on git tags and following semantic versioning
https://semver-gradle-plugin.javiersc.com
Other
25 stars 3 forks source link

One submodule doesn't get the right version #95

Closed bric3 closed 1 year ago

bric3 commented 1 year ago

Noticed something strange in a multi-module project. One of the submodule, doesn't read the version correctly. And it's always fireplace-app

$ ./gradlew printSemver -Psemver.stage=snapshot
Type-safe project accessors is an incubating feature.

> Task :fireplace-swt-experiment-app:printSemver
semver for fireplace-swt-experiment-app: v0.0.1-SNAPSHOT

> Task :fireplace-swing:printSemver
semver for fireplace-swing: v0.0.1-SNAPSHOT

> Task :fireplace-swt-awt-bridge:printSemver
semver for fireplace-swt-awt-bridge: v0.0.1-SNAPSHOT

> Task :fireplace-app:printSemver
semver for fireplace-app: v0.1.0.0+62be628

> Task :printSemver
semver for fireplace: v0.0.1-SNAPSHOT

> Task :fireplace-swing-animation:printSemver
semver for fireplace-swing-animation: v0.0.1-SNAPSHOT

So basically the code is like that

The commit is here: https://github.com/bric3/fireplace/pull/137/commits/a6e24fc18f7d186c46251c0909fce09ceec244c9
JavierSegoviaCordoba commented 1 year ago

I haven't any test with allprojects as it is not recommended and it doesn't work with project isolation nowadays.

Additionally, apply function to apply plugins is not recommended too.

Gradle recommends convention plugins for this kind of things.

Can you try to put the plugin directly in the plugins block in the fireplace-app project?

I will try to reproduce it to investigate it later.

JavierSegoviaCordoba commented 1 year ago

You can try to add again that property to fix ordering issues with other plugins and so on:

semver.project.tagPrefix=v
JavierSegoviaCordoba commented 1 year ago

The problem is with the id("org.graalvm.plugin.compiler") plugin, looks like they are fetching the version in the configuration phase. Not sure if they have an issue recommending to avoid that as I haven't used graalvm.

The fix is using semver.project.tagPrefix=v in the fireplace-app/gradle.properties or in the root one as you are going to use v in all projects, so if in the future another module has this problem you will be safe.

bric3 commented 1 year ago

OK, note in my project the app is not published so at this time I don't quite care about versioning, but just wanted to report the discrepancy. I'm not sure why only this module was affected.

Regardless I changed the logic to avoid applying the plugin via allprojects.

On a side note I understand I should upgrade to convention plugins, but I'm not there yet. Currently I'm using the approach that was taken by spring-framework guys.


Can you try to put the plugin directly in the plugins block in the fireplace-app project?

Adding the plugin and semver block in fireplace-app didn't change anything (the parent pom still uses allprojects)

You can try to add again that property to fix ordering issues with other plugins and so on:

semver.project.tagPrefix=v

That seem to fix the issue.

bric3 commented 1 year ago

The problem is with the id("org.graalvm.plugin.compiler") plugin, looks like they are fetching the version in the configuration phase.

Ah interesting ! I remember indeed the version failures when I was trying a dev stage while the last version is an RC. And the failure happened during configuration phase of the graalvm plugin 🤔. Thanks for the insight.

Eventually I can remove this plugin, as the goal was to replace provide the JVM C2 compiler by graal. And while before I was configuring manually the dependencies and the command line, this plugin did everything automatically, that said if the plugin is an issue...

JavierSegoviaCordoba commented 1 year ago

I have tried to find the Graal repo to report that issue with org.graalvm.plugin.compiler but looks like they are not updating that plugin since 2020. Maybe they are using a different plugin?

bric3 commented 1 year ago

Not sure they are still working on this.

build.gradle.kts gradle.properties
```kotlin allprojects { group = "io.github.bric3.fireplace" apply(plugin = "com.javiersc.semver.gradle.plugin") semver { tagPrefix.set("v") } } ``` ```properties semver.tagPrefix=v semver.checkClean=false ```