Skip to content

Commit 06f1c41

Browse files
committed
PLABE-203 publish to Gradle Plugin Portal (pull request #33)
Approved-by: Cástor Rodríguez
1 parent 3d761aa commit 06f1c41

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

build.gradle.kts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import com.github.benmanes.gradle.versions.updates.gradle.GradleReleaseChannel.CURRENT
2+
import com.gradle.publish.PublishTask
23
import org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
34
import org.gradle.api.tasks.testing.logging.TestLogEvent.FAILED
45
import org.gradle.api.tasks.testing.logging.TestLogEvent.PASSED
@@ -43,13 +44,12 @@ gradlePlugin {
4344
}
4445
}
4546

47+
val isSnapshot = project.version.toString().endsWith("-SNAPSHOT")
48+
4649
publishing {
4750
repositories {
4851
val snapshotRepository by extra { project.findProperty("snapshotRepository")?.toString() ?: "" }
49-
val releaseRepository by extra { project.findProperty("releaseRepository")?.toString() ?: "" }
50-
maven {
51-
url = URI(if (project.version.toString().endsWith("-SNAPSHOT")) snapshotRepository else releaseRepository)
52-
}
52+
maven { url = URI(if (isSnapshot) snapshotRepository else "") }
5353
}
5454
}
5555

@@ -77,6 +77,15 @@ tasks {
7777
setDependsOn(withType<Test>())
7878
}
7979

80+
withType<PublishToMavenRepository>().configureEach {
81+
onlyIf("publishing SNAPSHOT release to the internal repository") { isSnapshot }
82+
setFinalizedBy(withType<PublishTask>())
83+
}
84+
85+
withType<PublishTask>().configureEach {
86+
onlyIf("publishing release to the Gradle Plugin Portal") { !isSnapshot }
87+
}
88+
8089
dependencyUpdates {
8190
resolutionStrategy {
8291
componentSelection {

0 commit comments

Comments
 (0)