-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #113 from Strumenta/mavenpublishing
Setting up maven publishing and release process
- Loading branch information
Showing
13 changed files
with
187 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,28 @@ | ||
import com.strumenta.kotlinmultiplatform.gradle.ext.* | ||
import org.jetbrains.dokka.gradle.DokkaTask | ||
import java.net.URI | ||
import java.net.URL | ||
import com.vanniktech.maven.publish.SonatypeHost | ||
|
||
plugins { | ||
id("strumenta.jvm.library") | ||
id("org.jetbrains.dokka") | ||
id("com.vanniktech.maven.publish") | ||
} | ||
|
||
dependencies { | ||
api(libs.antlr4) | ||
} | ||
|
||
publishing { | ||
publications { | ||
create<MavenPublication>("mavenJava") { | ||
from(components["java"]) | ||
} | ||
} | ||
mavenPublishing { | ||
coordinates(project.group as String, project.name, project.version as String) | ||
setupPom(project, "Kotlin target for ANTLR") | ||
|
||
publishToMavenCentral(SonatypeHost.DEFAULT, true) | ||
|
||
signAllPublications() | ||
} | ||
|
||
tasks { | ||
findByName("generateMetadataFileForMavenPublication")?.dependsOn("kotlinSourcesJar") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,18 @@ | ||
package com.strumenta.kotlinmultiplatform.gradle.ext | ||
|
||
import org.gradle.api.Project | ||
import org.gradle.api.artifacts.dsl.RepositoryHandler | ||
import org.gradle.api.plugins.JavaPluginExtension | ||
import org.gradle.api.publish.PublishingExtension | ||
import org.gradle.api.publish.maven.MavenPublication | ||
import org.gradle.kotlin.dsl.create | ||
import org.gradle.kotlin.dsl.getByType | ||
import org.gradle.kotlin.dsl.repositories | ||
import org.gradle.kotlin.dsl.withType | ||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension | ||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension | ||
import java.net.URI | ||
import com.vanniktech.maven.publish.MavenPublishBaseExtension | ||
|
||
/** | ||
* Returns the Java project extension. | ||
|
@@ -34,13 +42,14 @@ fun Project.stringProperty(name: String): String? = | |
* Returns a project property as a boolean (`"true" == true`, else `false`). | ||
*/ | ||
fun Project.booleanProperty(name: String): Boolean = | ||
findProperty(name) == "true" | ||
(findProperty(name) as? String)?.trim()?.lowercase() == "true" | ||
|
||
/** | ||
* Returns whether we are building for a release, or not. | ||
*/ | ||
fun Project.releaseBuild(): Boolean = | ||
booleanProperty("repo.is.release") | ||
!(stringProperty("version")?.endsWith("-SNAPSHOT") | ||
?: throw IllegalStateException("Project version not specified")) | ||
|
||
/** | ||
* Returns the URL of the Maven repository to publish artifacts to, | ||
|
@@ -61,3 +70,61 @@ fun Project.mavenRepositoryUrl(): String? { | |
*/ | ||
fun Project.targetsNative(): Boolean = | ||
booleanProperty("target.is.native") | ||
|
||
fun Project.targetsJS(): Boolean = | ||
booleanProperty("target.is.js") | ||
|
||
|
||
fun PublishingExtension.addSonatypeRepository(project: Project) { | ||
repositories { | ||
maven { | ||
name = "oss" | ||
url = URI(project.mavenRepositoryUrl()) | ||
credentials { | ||
username = project.findProperty("ossrhUsername") as? String ?: "Unknown user" | ||
password = project.findProperty("ossrhPassword") as? String ?: "Unknown password" | ||
} | ||
} | ||
} | ||
} | ||
|
||
val Project.publicationName | ||
get() = project.name.replace("-", "_") | ||
|
||
fun MavenPublishBaseExtension.setupPom(project: Project, descriptionValue: String) { | ||
pom { | ||
name.set(project.name) | ||
description.set(descriptionValue) | ||
// version = project.version as String | ||
// packaging = "jar" | ||
url.set("https://github.com/Strumenta/antlr-kotlin") | ||
|
||
scm { | ||
connection.set("scm:git:https://github.com/Strumenta/antlr-kotlin.git") | ||
developerConnection.set("scm:git:[email protected]:Strumenta/antlr-kotlin.git") | ||
url.set("https://github.com/Strumenta/antlr-kotlin.git") | ||
} | ||
|
||
licenses { | ||
license { | ||
name.set("Apache Licenve V2.0") | ||
url.set("https://www.apache.org/licenses/LICENSE-2.0") | ||
distribution.set("repo") | ||
} | ||
} | ||
|
||
// The developers entry is strictly required by Maven Central | ||
developers { | ||
developer { | ||
id.set("ftomassetti") | ||
name.set("Federico Tomassetti") | ||
email.set("[email protected]") | ||
} | ||
developer { | ||
id.set("lppedd") | ||
name.set("Edoardo Luppi") | ||
email.set("[email protected]") | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.