gradle-release
gradle-release copied to clipboard
Releasing doesn't remove "snapshot" from the jar names
I have
version=0.0.1-SNAPSHOT
In the gradle.properties, but when I do release with release.useAutomaticVersion=true, the jars I find in build/libs have the "snapshot" suffix.
My build.gradle contains:
plugins {
id 'java'
id 'application'
id 'maven-publish'
id 'net.researchgate.release' version '3.0.1'
id 'io.spring.dependency-management' version '1.0.12.RELEASE'
id 'org.springframework.boot' version '2.7.2'
}
// some more stuff
publishing {
publications {
library(MavenPublication) {
from components.java
}
}
repositories {
mavenLocal()
// here i also had a private repo, but it's commented out for the moment
}
}
Same for me, I have the following build.gradle
import java.time.LocalDate
import java.time.format.DateTimeFormatter
plugins {
id 'org.springframework.boot' version '2.7.0'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
id 'net.researchgate.release' version '3.0.2'
}
group = 'eu.lbase'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
test {
useJUnitPlatform()
}
release {
failOnCommitNeeded = false
failOnUnversionedFiles = false
def version = '${version}'
def isoDate = LocalDate.now().format(DateTimeFormatter.BASIC_ISO_DATE)
tagTemplate = "v_${version}-${isoDate}"
git {
requireBranch.set('')
}
}
Now, when I start with the gradle build (v7.5.1) -->
gradlew clean build bootJar release -Prelease.useAutomaticVersion=true
I only find Snapshot jars in directory build/libs/
I was experiencing the same problem. However, in my case, the issue was that the version property from the .kts script was taking preference over the gradle.properties
file.
I am experiencing the same problem, but might have a hint on where to look: It seems this behavior is connected to the tagTemplate. With only the following block in the build.gradle.kts
file, everything works fine:
configure<ReleaseExtension> {
failOnUnversionedFiles.set(false)
with(git) {
requireBranch.set("master")
}
}
i.e. running gradlew release -Prelease.useAutomaticVersion=true -Prelease.releaseVersion=0.16.0 -Prelease.newVersion=0.17.0-SNAPSHOT
creates a tag called 0.16.0
and changes version in gradle.properties
to 0.17.0-SNAPSHOT
.
However, if I add tagTemplate.set("v${version}")
to build.gradle.kts
and run gradlew release -Prelease.useAutomaticVersion=true -Prelease.releaseVersion=0.17.0 -Prelease.newVersion=0.18.0-SNAPSHOT
, I get a tag called v0.17.0-SNAPSHOT
(i.e. content of gradle.properties pre-release) and a new snapshot version 0.18.0-SNAPSHOT
.
Based on some quick skimming of the code, the issue seems to be in PluginHelper#tagName():
String tagName() {
def engine = new SimpleTemplateEngine()
def binding = [
"version": project.version,
"name" : project.name
]
return engine.createTemplate(extension.tagTemplate.get()).make(binding).toString()
}
The property used for the tag template seems to be project.version
, however, when using useAutomaticVersion
in conjucntion with an explicitly set version, that version is set through property release.releaseVersion
, so I guess this would have to be available to the tag template as well.
I was able to work around this.
I was having this issue only in Kotlin builds, and not in Groovy builds.
This build.gradle
works (tag is made without -SNAPSHOT
):
plugins {
id 'net.researchgate.release' version '3.0.2'
}
release {
tagTemplate = 'v${version}' // note: single quotes
}
But this gradle.kts
does not (tag is X.X.X-SNAPSHOT):
plugins {
id("net.researchgate.release") version "3.0.2"
}
release {
tagTemplate.set("v${version}") // note: double quotes
}
This seems to be a runtime interpolation issue. Once I escaped the dollar sign, things worked:
plugins {
id("net.researchgate.release") version "3.0.2"
}
release {
tagTemplate.set("v\${version}")
}