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

Handling Versioning in Multi-Module Gradle Projects with Axion-Release Plugin #695

Open
berkanterdogan opened this issue Jan 12, 2024 · 9 comments

Comments

@berkanterdogan
Copy link

berkanterdogan commented Jan 12, 2024

I have a demo application which has libraries. It has 2 sub modules:

demo/
->sub-demo1/
->sub-demo2/

Their gradle configurations:

build.gradle.kts for demo

plugins {
	java
	id("pl.allegro.tech.build.axion-release") version "1.16.1"
}

subprojects {
	apply(plugin = "java")
	apply(plugin = "java-library")
	apply(plugin = "pl.allegro.tech.build.axion-release")
	
	group = "com.example"
	java.sourceCompatibility = JavaVersion.VERSION_17
	java.targetCompatibility = JavaVersion.VERSION_17


	repositories {
		mavenCentral()
	}
}

tasks.jar {
	isEnabled = false
}

build.gradle.kts for sub-demo2:

scmVersion {
    tag {
        prefix.set("sub-demo2")
        versionSeparator.set("/")

        snapshotCreator { versionFromTag, scmPosition -> "-NO_TAG" }
    }
}

version = scmVersion.version

build.gradle.kts for sub-demo1:

scmVersion {
    tag {
        prefix.set("sub-demo1")
        versionSeparator.set("/")

        snapshotCreator { versionFromTag, scmPosition -> "-NO_TAG" }
    }
}

version = scmVersion.version

Scenario:

  • Add a new commit
  • Add sub-demo1/1.0.0-SNAPSHOT and sub-demo2/2.0.0-SNAPSHOT tags to the commit above.
  • Check version with running gradle cV command: 1.0.0-SNAPSHOT for sub-demo1 and 2.0.0-SNAPSHOT for sub-demo2 -> These versions are as expected.
  • Add a new commit again and do not add new tags now.
  • Check version with running gradle cV command: 1.0.0-SNAPSHOT for sub-demo1 and 2.0.0-SNAPSHOT for sub-demo2 -> These versions are not as expected.

I am expecting the versions with -NO_TAG prefix here. My expectation is working if the project is not a multi-module project.
What is the wrong for multi-module applications?

@muhammedsager11
Copy link

Hi,
I am facing the same problem. If you can help it would be greatly appreciated.. I would also be very grateful if you could fill your document with more examples.

@ozgurbahar
Copy link

Having the same problem, could not solve it. Could you please help on this ? Thanks

@scprek
Copy link

scprek commented Jan 13, 2024

I had a lot in my last issue, solved all but the snapshot problem here so closed mine and referencin. #694

However in mine the tag pushed is correct without snapshot, but then gradle publish puts -SNAPSHOT in the artifacts.

I'm not trying to change the snapshot suffix, I just don't know why it things my publish should be a snapshot when the tags exist so my issue may be related to #677

@Zordid
Copy link

Zordid commented Sep 19, 2024

I need to reorganize our project into a multi project Gradle build as well - but I am completely unsure which of the sub projects should get the Axion plugin installed and the configuration done in its build.gradle.kts file.. can you help? Could this please be documented?

@bgalek
Copy link
Member

bgalek commented Sep 19, 2024

@Zordid it really depends on what you want - do you want the same version over every publication? or do you want to have multiple tags and multiple different versions?

@Zordid
Copy link

Zordid commented Sep 19, 2024

Hm, how would that be possible? Since a multi-project-build lives in one repo (it's just a folder tree) there's only ever one version. (and that's what I still need)
I just want to restructure how the project is built.
But my main question is: since a multi-project build does not have any top level build.gradle.kts file (but only a settings.gradle.kts in the root), where would the Axion plugin plus its configuration belong?

my-gradle-project (root)
|- settings.gradle.kts (includes :app and :lib)
|- app/
|     |- build.gradle.kts
|- lib/
      |- build.gradle.kts

It will still be exactly the same artifacts that get built and should be versioned.

But, do I mention the Axion plugin along with scmVersion block ONLY in the app subproject's build.gradle.kts file?

@bgalek
Copy link
Member

bgalek commented Sep 19, 2024

You can have multiple tags in one repo, like:

  • module1-1.0.0
  • module2-2.0.1
  • module3-3.1.2

so it's possible (done such config few times)
but it's pain for library users, I'd rather have one unified version of all ;)

I think it should work if you apply the plugin in every submodule - but it will be a duplication.
I would recommend creating root build.gradle ;)

@Zordid
Copy link

Zordid commented Sep 19, 2024

Ok, will give it a try... Did not hear about a root build.gradle.kts before...

@bgalek
Copy link
Member

bgalek commented Sep 19, 2024

sure, it just works ;)

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

No branches or pull requests

6 participants