File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change 11import com.github.benmanes.gradle.versions.updates.gradle.GradleReleaseChannel.CURRENT
2+ import com.gradle.publish.PublishTask
23import org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
34import org.gradle.api.tasks.testing.logging.TestLogEvent.FAILED
45import 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+
4649publishing {
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 {
You can’t perform that action at this time.
0 commit comments