Skip to content

Commit

Permalink
Quick fix to avoid asking for the publishAllPublicationsToGitHubRepsi…
Browse files Browse the repository at this point in the history
…tory task, if there are no GitHub credentials, and it's not set up. (#215)
  • Loading branch information
lagergren authored May 9, 2024
1 parent 3d0bc68 commit b4080de
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
4 changes: 2 additions & 2 deletions build-logic/common-plugins/src/main/kotlin/XdkDistribution.kt
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ fun SigningExtension.mavenCentralSigning(): List<Sign> = project.run {
* property file.
*/
fun PublishingExtension.mavenGitHubPackages(project: Project): Boolean = project.run {
val gitHubToken = project.getXdkProperty("org.xtclang.repo.github.token", System.getenv("GITHUB_TOKEN") ?: "")
val gitHubToken = project.getXtclangGitHubMavenPackageRepositoryToken()
if (gitHubToken.isEmpty()) {
logger.warn("$prefix No GitHub token found, either in config or environment. publishRemote won't work.")
logger.warn("$prefix WARNING: No GitHub token found, either in config or environment. publishRemote won't work.")
return false
}

Expand Down
4 changes: 4 additions & 0 deletions build-logic/common-plugins/src/main/kotlin/XdkProperties.kt
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,7 @@ class XdkPropertiesImpl(project: Project): XdkProjectBuildLogic(project), XdkPro
return merge(to, local)
}
}

fun Project.getXtclangGitHubMavenPackageRepositoryToken(): String {
return getXdkProperty("org.xtclang.repo.github.token", System.getenv("GITHUB_TOKEN") ?: "")
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ plugins {
//id("io.github.gradle-nexus.publish-plugin") version "1.0.0"
}

val semanticVersion: SemanticVersion by extra
private val semanticVersion: SemanticVersion by extra
private val gitHubToken = getXtclangGitHubMavenPackageRepositoryToken()

publishing {
repositories {
Expand All @@ -30,8 +31,6 @@ tasks.withType<PublishToMavenRepository>().configureEach {

val publishAllPublicationsToMavenLocalRepository by tasks.existing

val publishAllPublicationsToGitHubRepository by tasks.existing

val publishLocal by tasks.registering {
group = PUBLISH_TASK_GROUP
description = "Task that publishes project publications to local repositories (e.g. GitHub and mavenCentral)."
Expand All @@ -41,7 +40,15 @@ val publishLocal by tasks.registering {
val publishRemote by tasks.registering {
group = PUBLISH_TASK_GROUP
description = "Task that publishes project publications to remote repositories (e.g. mavenLocal)."
dependsOn(publishAllPublicationsToGitHubRepository)

if (gitHubToken.isNotEmpty()) {
dependsOn("publishAllPublicationsToGitHubRepository")
}
doLast {
if (gitHubToken.isEmpty()) {
throw buildException("ERROR: No remote repositories for remote publication are configured.")
}
}
}

val listTags by tasks.registering {
Expand Down
2 changes: 1 addition & 1 deletion javatools/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ plugins {
alias(libs.plugins.tasktree)
}

val semanticVersion: SemanticVersion by extra
private val semanticVersion: SemanticVersion by extra

// TODO: Move these to common-plugins, the XDK composite build does use them in some different places.
val xdkJavaToolsProvider by configurations.registering {
Expand Down
2 changes: 1 addition & 1 deletion plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
alias(libs.plugins.tasktree)
}

val semanticVersion: SemanticVersion by extra
private val semanticVersion: SemanticVersion by extra

private val pprefix = "org.xtclang"

Expand Down

0 comments on commit b4080de

Please sign in to comment.