Skip to content

Commit

Permalink
PLABE-203 publish to Gradle Plugin Portal (pull request #33)
Browse files Browse the repository at this point in the history
Approved-by: Cástor Rodríguez
  • Loading branch information
capitaorev committed Apr 10, 2024
1 parent 3d761aa commit 06f1c41
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import com.github.benmanes.gradle.versions.updates.gradle.GradleReleaseChannel.CURRENT
import com.gradle.publish.PublishTask
import org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
import org.gradle.api.tasks.testing.logging.TestLogEvent.FAILED
import org.gradle.api.tasks.testing.logging.TestLogEvent.PASSED
Expand Down Expand Up @@ -43,13 +44,12 @@ gradlePlugin {
}
}

val isSnapshot = project.version.toString().endsWith("-SNAPSHOT")

publishing {
repositories {
val snapshotRepository by extra { project.findProperty("snapshotRepository")?.toString() ?: "" }
val releaseRepository by extra { project.findProperty("releaseRepository")?.toString() ?: "" }
maven {
url = URI(if (project.version.toString().endsWith("-SNAPSHOT")) snapshotRepository else releaseRepository)
}
maven { url = URI(if (isSnapshot) snapshotRepository else "") }
}
}

Expand Down Expand Up @@ -77,6 +77,15 @@ tasks {
setDependsOn(withType<Test>())
}

withType<PublishToMavenRepository>().configureEach {
onlyIf("publishing SNAPSHOT release to the internal repository") { isSnapshot }
setFinalizedBy(withType<PublishTask>())
}

withType<PublishTask>().configureEach {
onlyIf("publishing release to the Gradle Plugin Portal") { !isSnapshot }
}

dependencyUpdates {
resolutionStrategy {
componentSelection {
Expand Down

0 comments on commit 06f1c41

Please sign in to comment.