Skip to content

Commit

Permalink
Fail build when assembling a release version that depends on snapshots (
Browse files Browse the repository at this point in the history
  • Loading branch information
marcphilipp authored Dec 31, 2024
1 parent 529da15 commit bd7db61
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
12 changes: 6 additions & 6 deletions documentation/documentation.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ asciidoctorj {
}

val buildRevision: String by rootProject.extra
val snapshot = rootProject.version.toString().contains("SNAPSHOT")
val docsVersion = if (snapshot) "snapshot" else rootProject.version
val releaseBranch = if (snapshot) "HEAD" else "r${rootProject.version}"
val snapshot = version.isSnapshot()
val docsVersion = if (snapshot) "snapshot" else version
val releaseBranch = if (snapshot) "HEAD" else "r${version}"
val docsDir = layout.buildDirectory.dir("ghpages-docs")
val replaceCurrentDocs = buildParameters.documentation.replaceCurrentDocs
val uploadPdfs = !snapshot
val userGuidePdfFileName = "junit-user-guide-${rootProject.version}.pdf"
val ota4jDocVersion = if (libs.versions.opentest4j.get().contains("SNAPSHOT")) "snapshot" else libs.versions.opentest4j.get()
val apiGuardianDocVersion = if (libs.versions.apiguardian.get().contains("SNAPSHOT")) "snapshot" else libs.versions.apiguardian.get()
val userGuidePdfFileName = "junit-user-guide-${version}.pdf"
val ota4jDocVersion = libs.versions.opentest4j.map { if (it.isSnapshot()) "snapshot" else it }.get()
val apiGuardianDocVersion = libs.versions.apiguardian.map { if (it.isSnapshot()) "snapshot" else it }.get()

gitPublish {
repoUri = "https://github.com/junit-team/junit5.git"
Expand Down
1 change: 1 addition & 0 deletions gradle/plugins/common/src/main/kotlin/VersionExtensions.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fun Any.isSnapshot(): Boolean = toString().contains("SNAPSHOT")
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,17 @@ if (project in mavenizedProjects) {
}
}

if (!project.version.isSnapshot()) {
configurations {
compileClasspath {
resolutionStrategy.failOnChangingVersions()
}
runtimeClasspath {
resolutionStrategy.failOnChangingVersions()
}
}
}

} else {
tasks {
jar {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ plugins {
id("junitbuild.build-parameters")
}

val isSnapshot = project.version.toString().contains("SNAPSHOT")

val jupiterProjects: List<Project> by rootProject
val platformProjects: List<Project> by rootProject
val vintageProjects: List<Project> by rootProject
Expand Down Expand Up @@ -40,7 +38,7 @@ tasks.withType<PublishToMavenLocal>().configureEach {
dependsOn(tasks.build)
}

val signArtifacts = buildParameters.publishing.signArtifacts.getOrElse(!(isSnapshot || buildParameters.ci))
val signArtifacts = buildParameters.publishing.signArtifacts.getOrElse(!(project.version.isSnapshot() || buildParameters.ci))

signing {
useGpgCmd()
Expand Down

0 comments on commit bd7db61

Please sign in to comment.