Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish using vaniktech maven plugin #357

Merged
merged 2 commits into from
Nov 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 23 additions & 60 deletions fladle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import com.vanniktech.maven.publish.SonatypeHost
import org.gradle.api.tasks.testing.logging.TestLogEvent

group = "com.osacky.flank.gradle"
Expand All @@ -14,6 +15,7 @@ plugins {
`kotlin-dsl`
`java-gradle-plugin`
alias(libs.plugins.gradle.plugin.publish)
alias(libs.plugins.vanniktech.maven.publish)
alias(libs.plugins.kotlinter)
`maven-publish`
signing
Expand Down Expand Up @@ -71,68 +73,29 @@ tasks.register<Jar>("javadocJar") {
archiveClassifier.set("javadoc")
}

val isReleaseBuild : Boolean = !version.toString().endsWith("SNAPSHOT")

val sonatypeUsername : String? by project
val sonatypePassword : String? by project

publishing {
repositories {
repositories {
maven {
val releasesRepoUrl = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
val snapshotsRepoUrl = uri("https://oss.sonatype.org/content/repositories/snapshots/")
url = if (isReleaseBuild) releasesRepoUrl else snapshotsRepoUrl
credentials {
username = sonatypeUsername
password = sonatypePassword
mavenPublishing {
publishToMavenCentral(SonatypeHost.DEFAULT)
signAllPublications()
pom {
url.set("https://github.com/runningcode/fladle")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("runningcode")
name.set("Nelson Osacky")
}
}
scm {
connection.set("scm:git:git://github.com/runningcode/fladle.git")
developerConnection.set("scm:git:ssh://github.com/runningcode/fladle.git")
url.set("https://github.com/runningcode/fladle")
}
}
}
}
publications {
afterEvaluate {
named<MavenPublication>("fladlePluginMarkerMaven") {
pom.configureForFladle("Fladle")
}

named<MavenPublication>("pluginMaven") {
artifact(tasks["sourcesJar"])
artifact(tasks["javadocJar"])
pom.configureForFladle("Fladle")
}
named<MavenPublication>("fulladlePluginMarkerMaven") {
pom.configureForFladle("Fulladle")
}
}
}
}

signing {
isRequired = isReleaseBuild
}

fun org.gradle.api.publish.maven.MavenPom.configureForFladle(pluginName: String) {
name.set(pluginName)
description.set(project.description)
url.set("https://github.com/runningcode/fladle")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("runningcode")
name.set("Nelson Osacky")
}
}
scm {
connection.set("scm:git:git://github.com/runningcode/fladle.git")
developerConnection.set("scm:git:ssh://github.com/runningcode/fladle.git")
url.set("https://github.com/runningcode/fladle")
}
}

tasks.withType(Test::class.java).configureEach {
Expand Down
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ kotlinter = { id = "org.jmailen.kotlinter", version = "3.9.0" }

gradle-plugin-publish = {id = "com.gradle.plugin-publish", version = "1.2.1" }

vanniktech-maven-publish = {id = "com.vanniktech.maven.publish", version = "0.25.3" }

kgp = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin"}
agp = { id = "com.android.application", version.ref = "agp-version"}

Expand Down
Loading