Skip to content

Commit

Permalink
Extracted library publishing commons to buildlogic.java-library-conve…
Browse files Browse the repository at this point in the history
…ntions.gradle.kts
  • Loading branch information
jlink committed Dec 9, 2024
1 parent f118564 commit f658d00
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 47 deletions.
50 changes: 4 additions & 46 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
plugins {
id("buildlogic.java-api-conventions")
id("buildlogic.java-library-conventions")
}

description = "Jqwik2 core module"

val jqwik2Version: String = "${rootProject.extra.get("jqwik2Version")}"
val isSnapshotRelease = isSnapshotRelease(jqwik2Version)
val artifactName = "jqwik2-core"

fun isSnapshotRelease(versionString: String): Boolean {
return versionString.endsWith("SNAPSHOT")
}

dependencies {
api(libs.apiguardian)
//implementation(project(":utilities"))
Expand All @@ -21,50 +16,13 @@ dependencies {
}

tasks.jar {
archiveBaseName.set("jqwik2-core")
archiveBaseName.set(artifactName)
archiveVersion.set("${rootProject.extra.get("jqwik2Version")}")
manifest {
attributes("Automatic-Module-Name" to "net.jqwik2.core")
}
}

publishing {
publications {
create<MavenPublication>("jqwik2Core") {
groupId = "net.jqwik"
artifactId = artifactName
from(components["java"])
pom {
version = jqwik2Version
groupId = "net.jqwik"
name = artifactId
description = "$description"
url = "https://github.org/jqwik-team/jqwik2"
licenses {
license {
name = "Eclipse Public License - v 2.0"
url = "http://www.eclipse.org/legal/epl-v20.html"
}
}
developers {
developer {
id = "jlink"
name = "Johannes Link"
email = "[email protected]"
}
}
scm {
connection = "scm:git:git://github.com/jqwik-team/jqwik2.git"
developerConnection = "scm:git:git://github.com/jqwik-team/jqwik2.git"
url = "https://github.com/jqwik-team/jqwik2"
}
}
}
}
}

signing {
if (!isSnapshotRelease) {
sign(publishing.publications["jqwik2Core"])
}
publishLibrary {
artifactId = artifactName
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import groovy.lang.ExpandoMetaClassCreationHandle.disable

plugins {
id("buildlogic.java-common-conventions")
`java-library`
Expand All @@ -19,6 +21,14 @@ tasks.withType<Javadoc> {
val jqwik2Version: String = "${rootProject.extra.get("jqwik2Version")}"
val isSnapshotRelease = jqwik2Version.endsWith("SNAPSHOT")


interface PublishLibraryExtension {
val artifactId: Property<String>
}

val publishLibraryExtension = project.extensions.create<PublishLibraryExtension>("publishLibrary")
publishLibraryExtension.artifactId.convention("artifactId-not-set")

publishing {
repositories {
maven {
Expand All @@ -33,7 +43,54 @@ publishing {

val releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
val snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
url = uri(if (isSnapshotRelease) { snapshotsRepoUrl } else { releasesRepoUrl })
url = uri(
if (isSnapshotRelease) {
snapshotsRepoUrl
} else {
releasesRepoUrl
}
)
}
}
publications {
create<MavenPublication>("jqwikModule") {
groupId = "net.jqwik"
artifactId = "placeholder"
from(components["java"])
pom {
version = jqwik2Version
groupId = "net.jqwik"
name = artifactId
description = "$description"
url = "https://github.org/jqwik-team/jqwik2"
licenses {
license {
name = "Eclipse Public License - v 2.0"
url = "http://www.eclipse.org/legal/epl-v20.html"
}
}
developers {
developer {
id = "jlink"
name = "Johannes Link"
email = "[email protected]"
}
}
scm {
connection = "scm:git:git://github.com/jqwik-team/jqwik2.git"
developerConnection = "scm:git:git://github.com/jqwik-team/jqwik2.git"
url = "https://github.com/jqwik-team/jqwik2"
}
}
afterEvaluate {
artifactId = publishLibraryExtension.artifactId.get()
}
}
}
}

signing {
if (!isSnapshotRelease) {
sign(publishing.publications["jqwikModule"])
}
}

0 comments on commit f658d00

Please sign in to comment.