Skip to content

Commit

Permalink
Use property for publishing version string
Browse files Browse the repository at this point in the history
The previous solution using `rootProject.ext.versionForPublishing` failed when building
Aerie locally from a separate Gradle project, likely due to `rootProject` taking on a different
value/meaning in that context.

Using a global property here we're able to specify the publishing version in the top-level build
and guarentee that any uses of it are localized to subprojects of our top-level build.
  • Loading branch information
pcrosemurgy committed Nov 2, 2022
1 parent c14bcaf commit a9e87b1
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 11 deletions.
5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,15 @@ configure(subprojects.findAll { it.projectDir.toPath().resolve('sql').toFile().e
archiveDeployment.dependsOn distributeSql
}

project.ext.versionForPublishing = {
// Set publishing version property globally for this project
setProperty('publishing.version', {
if (findProperty("version.isRelease").toBoolean()) {
return "${findProperty("version.number")}"
} else {
def hash = 'git rev-parse --short HEAD'.execute().text.trim()
return "${findProperty("version.number")}-SNAPSHOT-$hash"
}
}()
}())

subprojects {
apply plugin: 'com.github.ben-manes.versions'
Expand Down
2 changes: 1 addition & 1 deletion contrib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ dependencies {
publishing {
publications {
library(MavenPublication) {
version = rootProject.ext.versionForPublishing
version = findProperty('publishing.version')
from components.java
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/banananation/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ javadoc.options.tags = [ "contact", "subsystem" ]
publishing {
publications {
library(MavenPublication) {
version = rootProject.ext.versionForPublishing
version = findProperty('publishing.version')
from components.java
}
}
Expand Down
6 changes: 5 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ publishing.url=https://maven.pkg.github.com/nasa-ammos/aerie
publishing.usernameEnvironmentVariable=GITHUB_ACTOR
publishing.passwordEnvironmentVariable=GITHUB_TOKEN

# Left empty, is lazily set when building
publishing.version=

# Override for releases

# Change the version number here
version.number=0.13.2

# If you are publishing a release *manually* (i.e. not through github actions),
# override this on the command line with `./gradlew publish -Pversion.isRelease=true`.
version.isRelease=false // override this on the command line
version.isRelease=false
2 changes: 1 addition & 1 deletion merlin-driver/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ dependencies {
publishing {
publications {
library(MavenPublication) {
version = rootProject.ext.versionForPublishing
version = findProperty('publishing.version')
from components.java
}
}
Expand Down
2 changes: 1 addition & 1 deletion merlin-framework-junit/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ dependencies {
publishing {
publications {
library(MavenPublication) {
version = rootProject.ext.versionForPublishing
version = findProperty('publishing.version')
from components.java
}
}
Expand Down
2 changes: 1 addition & 1 deletion merlin-framework-processor/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dependencies {
publishing {
publications {
library(MavenPublication) {
version = rootProject.ext.versionForPublishing
version = findProperty('publishing.version')
from components.java
}
}
Expand Down
2 changes: 1 addition & 1 deletion merlin-framework/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ dependencies {
publishing {
publications {
library(MavenPublication) {
version = rootProject.ext.versionForPublishing
version = findProperty('publishing.version')
from components.java
}
}
Expand Down
2 changes: 1 addition & 1 deletion merlin-sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dependencies {
publishing {
publications {
library(MavenPublication) {
version = rootProject.ext.versionForPublishing
version = findProperty('publishing.version')
from components.java
}
}
Expand Down
2 changes: 1 addition & 1 deletion parsing-utilities/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ dependencies {
publishing {
publications {
library(MavenPublication) {
version = rootProject.ext.versionForPublishing
version = findProperty('publishing.version')
from components.java
}
}
Expand Down

0 comments on commit a9e87b1

Please sign in to comment.