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

Don't replace the version with the snapshot version in documents #379

Merged
merged 1 commit into from Apr 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
49 changes: 29 additions & 20 deletions build.gradle.kts
Expand Up @@ -7,17 +7,19 @@ plugins {
}

val encoding: String by project
val isSnapshot = project.version.toString().endsWith("SNAPSHOT")
val isSnapshot = version.toString().endsWith("SNAPSHOT")
val releaseVersion = properties["release.releaseVersion"].toString()
val newVersion = properties["release.newVersion"].toString()
val secretKeyRingFile: String? =
findProperty("signing.secretKeyRingFile")?.toString()?.let {
if (it.isEmpty()) null
else file(it).absolutePath
}

fun replaceVersionArtifactClass() {
fun replaceVersionInArtifact(ver: String) {
ant.withGroovyBuilder {
"replaceregexp"("match" to """(private static final String VERSION = ")[^"]*(")""",
"replace" to "\\1${version}\\2",
"replace" to "\\1${ver}\\2",
"encoding" to encoding,
"flags" to "g") {
"fileset"("dir" to ".") {
Expand All @@ -43,14 +45,14 @@ subprojects {

extra["signing.secretKeyRingFile"] = secretKeyRingFile

val replaceVersionJava by tasks.registering {
val replaceVersionInJava by tasks.registering {
doLast {
replaceVersionArtifactClass()
replaceVersionInArtifact(version.toString())
}
}

val compileJava by tasks.existing(JavaCompile::class) {
dependsOn(tasks.named("replaceVersionJava"))
dependsOn(replaceVersionInJava)
options.encoding = encoding
}

Expand Down Expand Up @@ -176,26 +178,33 @@ subprojects {
rootProject.apply {
apply(from = "release.gradle")

val replaceVersion by tasks.registering {
mustRunAfter(tasks.named("updateVersion"))
doLast {
replaceVersionArtifactClass()
ant.withGroovyBuilder {
"replaceregexp"("match" to """("org.seasar.doma:doma(-core|-processor)?:)[^"]*(")""",
"replace" to "\\1${version}\\3",
"encoding" to encoding,
"flags" to "g") {
"fileset"("dir" to ".") {
"include"("name" to "README.md")
"include"("name" to "docs/**/*.rst")
}
fun replaceVersionInDocs(ver: String) {
ant.withGroovyBuilder {
"replaceregexp"("match" to """("org.seasar.doma:doma(-core|-processor)?:)[^"]*(")""",
"replace" to "\\1${ver}\\3",
"encoding" to encoding,
"flags" to "g") {
"fileset"("dir" to ".") {
"include"("name" to "README.md")
"include"("name" to "docs/**/*.rst")
}
}
}
}

val commitNewVersion by tasks.existing {
val replaceVersion by tasks.registering {
replaceVersionInArtifact(releaseVersion)
replaceVersionInDocs(releaseVersion)
}

val release by tasks.existing {
dependsOn(replaceVersion)
}

val updateVersion by tasks.existing {
doLast {
replaceVersionInArtifact(newVersion)
}
}

configure<com.diffplug.gradle.spotless.SpotlessExtension> {
Expand Down
3 changes: 3 additions & 0 deletions gradle.properties
Expand Up @@ -6,3 +6,6 @@ projectUrl=https://github.com/domaframework/doma
githubUrl=git@github.com:domaframework/doma.git
sonatypeUsername=
sonatypePassword=
release.useAutomaticVersion=true
release.releaseVersion=2.30.1
release.newVersion=2.30.2-SNAPSHOT