1- import com.vanniktech.maven.publish.SonatypeHost
21import org.gradle.api.tasks.testing.logging.TestLogEvent
32
43group = " com.osacky.flank.gradle"
@@ -15,7 +14,6 @@ plugins {
1514 `kotlin- dsl`
1615 `java- gradle- plugin`
1716 alias(libs.plugins.gradle.plugin.publish)
18- alias(libs.plugins.vanniktech.maven.publish)
1917 alias(libs.plugins.kotlinter)
2018 `maven- publish`
2119 signing
@@ -73,29 +71,68 @@ tasks.register<Jar>("javadocJar") {
7371 archiveClassifier.set(" javadoc" )
7472}
7573
76- mavenPublishing {
77- publishToMavenCentral(SonatypeHost .DEFAULT )
78- signAllPublications()
79- pom {
80- url.set(" https://github.com/runningcode/fladle" )
81- licenses {
82- license {
83- name.set(" The Apache License, Version 2.0" )
84- url.set(" http://www.apache.org/licenses/LICENSE-2.0.txt" )
85- }
86- }
87- developers {
88- developer {
89- id.set(" runningcode" )
90- name.set(" Nelson Osacky" )
91- }
92- }
93- scm {
94- connection.set(" scm:git:git://github.com/runningcode/fladle.git" )
95- developerConnection.set(" scm:git:ssh://github.com/runningcode/fladle.git" )
96- url.set(" https://github.com/runningcode/fladle" )
74+ val isReleaseBuild : Boolean = ! version.toString().endsWith(" SNAPSHOT" )
75+
76+ val sonatypeUsername : String? by project
77+ val sonatypePassword : String? by project
78+
79+ publishing {
80+ repositories {
81+ repositories {
82+ maven {
83+ val releasesRepoUrl = uri(" https://oss.sonatype.org/service/local/staging/deploy/maven2/" )
84+ val snapshotsRepoUrl = uri(" https://oss.sonatype.org/content/repositories/snapshots/" )
85+ url = if (isReleaseBuild) releasesRepoUrl else snapshotsRepoUrl
86+ credentials {
87+ username = sonatypeUsername
88+ password = sonatypePassword
9789 }
90+ }
9891 }
92+ }
93+ publications {
94+ afterEvaluate {
95+ named<MavenPublication >(" fladlePluginMarkerMaven" ) {
96+ pom.configureForFladle(" Fladle" )
97+ }
98+
99+ named<MavenPublication >(" pluginMaven" ) {
100+ artifact(tasks[" sourcesJar" ])
101+ artifact(tasks[" javadocJar" ])
102+ pom.configureForFladle(" Fladle" )
103+ }
104+ named<MavenPublication >(" fulladlePluginMarkerMaven" ) {
105+ pom.configureForFladle(" Fulladle" )
106+ }
107+ }
108+ }
109+ }
110+
111+ signing {
112+ isRequired = isReleaseBuild
113+ }
114+
115+ fun org.gradle.api.publish.maven.MavenPom.configureForFladle (pluginName : String ) {
116+ name.set(pluginName)
117+ description.set(project.description)
118+ url.set(" https://github.com/runningcode/fladle" )
119+ licenses {
120+ license {
121+ name.set(" The Apache License, Version 2.0" )
122+ url.set(" http://www.apache.org/licenses/LICENSE-2.0.txt" )
123+ }
124+ }
125+ developers {
126+ developer {
127+ id.set(" runningcode" )
128+ name.set(" Nelson Osacky" )
129+ }
130+ }
131+ scm {
132+ connection.set(" scm:git:git://github.com/runningcode/fladle.git" )
133+ developerConnection.set(" scm:git:ssh://github.com/runningcode/fladle.git" )
134+ url.set(" https://github.com/runningcode/fladle" )
135+ }
99136}
100137
101138tasks.withType(Test ::class .java).configureEach {
0 commit comments