Skip to content

Commit

Permalink
Dirty/snapshot versions were determined too early
Browse files Browse the repository at this point in the history
  • Loading branch information
Virtlink committed Jul 15, 2024
1 parent 07386b1 commit 6d2a500
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
8 changes: 2 additions & 6 deletions convention-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ plugins {
group = "org.metaborg"
description = "The Metaborg Gradle convention plugin."

extra["isReleaseVersion"] = !version.toString().endsWith("-SNAPSHOT")
extra["isDirtyVersion"] = version.toString().endsWith("+dirty")
extra["isCI"] = !System.getenv("CI").isNullOrEmpty()

repositories {
mavenCentral()
gradlePluginPortal()
Expand Down Expand Up @@ -100,7 +96,7 @@ publishing {
val releasesRepoUrl = uri("https://artifacts.metaborg.org/content/repositories/releases/")
val snapshotsRepoUrl = uri("https://artifacts.metaborg.org/content/repositories/snapshots/")
name = "MetaborgArtifacts"
url = if (project.extra["isReleaseVersion"] as Boolean) releasesRepoUrl else snapshotsRepoUrl
url = if (!version.toString().contains("-SNAPSHOT")) releasesRepoUrl else snapshotsRepoUrl
credentials {
username = project.findProperty("publish.repository.metaborg.artifacts.username") as String? ?: System.getenv("METABORG_ARTIFACTS_USERNAME")
password = project.findProperty("publish.repository.metaborg.artifacts.password") as String? ?: System.getenv("METABORG_ARTIFACTS_PASSWORD")
Expand Down Expand Up @@ -130,7 +126,7 @@ publishing {

val checkNotDirty by tasks.registering {
doLast {
if (project.extra["isDirtyVersion"] as Boolean) {
if (project.version.toString().endsWith("+dirty")) {
throw GradleException("Cannot publish a dirty version: ${project.version}")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ class MavenPublishConventionPlugin: Plugin<Project> {
// Apply the Maven Publish plugin
plugins.apply("maven-publish")

extra["isReleaseVersion"] = !version.toString().endsWith("-SNAPSHOT")
extra["isDirtyVersion"] = version.toString().endsWith("+dirty")
extra["isCI"] = !System.getenv("CI").isNullOrEmpty()

// Set the metadata for (existing) publications
afterEvaluate {
configure<PublishingExtension> {
Expand Down Expand Up @@ -84,7 +80,7 @@ class MavenPublishConventionPlugin: Plugin<Project> {
val releasesRepoUrl = uri("https://artifacts.metaborg.org/content/repositories/releases/")
val snapshotsRepoUrl = uri("https://artifacts.metaborg.org/content/repositories/snapshots/")
name = METABORG_ARTIFACTS_PUBLICATION_NAME
url = if (project.extra["isReleaseVersion"] as Boolean) releasesRepoUrl else snapshotsRepoUrl
url = if (!version.toString().contains("-SNAPSHOT")) releasesRepoUrl else snapshotsRepoUrl
credentials {
username = project.findProperty("publish.repository.metaborg.artifacts.username") as String? ?: System.getenv("METABORG_ARTIFACTS_USERNAME")
password = project.findProperty("publish.repository.metaborg.artifacts.password") as String? ?: System.getenv("METABORG_ARTIFACTS_PASSWORD")
Expand Down

0 comments on commit 6d2a500

Please sign in to comment.