Skip to content

Commit

Permalink
20240917
Browse files Browse the repository at this point in the history
  • Loading branch information
JesusMcCloud committed Sep 17, 2024
1 parent 1e8b233 commit 5b661bf
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 20 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# Dual-Version Kotlin 1.9.10 / 2.0.0
# Dual-Version Kotlin 1.9.10 / 2.0.20

## 20240917
* Coroutines 1.9.0
* Kotest plugin 6.0.0-20240905.065253-61
* Kotest dependencies 5.9.1
* Fix SNAPSHOT publishing
* Print out build date in plugin info

## 20240905
* Pin Kotest Snapshot version to 6.0.0-20240905.065253-61
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# A-SIT Plus Gradle Conventions Plugin

[![Version](https://img.shields.io/badge/Kotlin_1.9.10-+20240905-gray.svg?style=flat&logo=kotlin&labelColor=blue&logoColor=white)](CHANGELOG.md)
[![Version](https://img.shields.io/badge/Kotlin_2.0.20-+20240905-gray.svg?style=flat&logo=kotlin&labelColor=7463ce&logoColor=white)](CHANGELOG.md)
[![Version](https://img.shields.io/badge/Kotlin_2.0.20-+20240917-gray.svg?style=flat&logo=kotlin&labelColor=7463ce&logoColor=white)](CHANGELOG.md)
[![Version](https://img.shields.io/badge/Kotlin_1.9.10-+20240917-gray.svg?style=flat&logo=kotlin&labelColor=blue&logoColor=white)](CHANGELOG.md)
[![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-brightgreen.svg?style=flat&)](http://www.apache.org/licenses/LICENSE-2.0)

**Note: This plugin is used internally at A-SIT Plus and there are no guarantees whatsoever wrt. stability, reliability, and even making any sense at all.
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
buildDate=20240905
buildDate=20240917
groupId=at.asitplus.gradle
2 changes: 1 addition & 1 deletion k2/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ val buildDate: String by extra

val kotlinVersion = versions["kotlin"] as String
val ksp = "$kotlinVersion-${versions["ksp"]}"
val kotest = versions["kotest"]
val kotest = versions["kotest-plugin"]

version = "$kotlinVersion+$buildDate"
group = groupId
Expand Down
6 changes: 4 additions & 2 deletions k2/src/main/resources/k2versions.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
kotlin=2.0.20
ksp=1.0.24
kotest=6.0.0-20240905.065253-61
serialization=1.7.2
kotest=5.9.1
kotest-plugin=6.0.0-20240905.065253-61
serialization=1.7.2
coroutines=1.9.0
4 changes: 4 additions & 0 deletions legacy/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ private val versions = Properties().apply {
val groupId: String by extra
val buildDate: String by extra

project.file("src/main/kotlin/BuildDate.kt").bufferedWriter().use { writer ->
writer.write("package at.asitplus.gradle\nval buildDate = \"$buildDate\"")
}

val kotlinVersion = versions["kotlin"] as String
val ksp = "$kotlinVersion-${versions["ksp"]}"

Expand Down
49 changes: 36 additions & 13 deletions legacy/src/main/kotlin/at/asitplus/gradle/Plugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ class EnvExtraDelegate(private val project: Project) {
}

private val KEY_ASP_VERSIONS = Random.nextBits(32).toString(36)
private val KEY_ASP_STAGING = Random.nextBits(32).toString(36)
var Project.staging: Boolean?
get() = rootProject.extraProperties[KEY_ASP_STAGING] as Boolean?
set(value) {
rootProject.extraProperties[KEY_ASP_STAGING] = value
}

val Project.AspVersions: AspVersions get() = rootProject.extraProperties[KEY_ASP_VERSIONS] as AspVersions
val Project.env: EnvDelegate get() = EnvDelegate
Expand All @@ -70,7 +76,6 @@ private inline fun Project.hasMrJar() = plugins.hasPlugin("me.champeau.mrjar")
val Project.jvmTarget: String get() = runCatching { extraProperties["jdk.version"] as String }.getOrElse { AspVersions.jvm.defaultTarget }

open class AspLegacyConventions : Plugin<Project> {

protected open fun KotlinMultiplatformExtension.setupKotest() {
sourceSets {
val commonTest by getting {
Expand Down Expand Up @@ -100,13 +105,15 @@ open class AspLegacyConventions : Plugin<Project> {
override fun apply(target: Project) {
Logger = target.logger
target.supportLocalProperties()
if (target.rootProject == target)
if (target.rootProject == target) {
target.staging = null
AspVersions(target).let {
target.extraProperties[KEY_ASP_VERSIONS] = it
versionOverrides(it)
}
}
Logger.lifecycle(
"\n ASP Conventions ${H}${target.AspVersions.versions["kotlin"]}$R is using the following dependency versions for project ${
"\n ASP Conventions ${H}${target.AspVersions.versions["kotlin"]}+$buildDate$R is using the following dependency versions for project ${
if (target == target.rootProject) target.name
else "${target.rootProject.name}:${target.name}"
}:"
Expand Down Expand Up @@ -179,16 +186,6 @@ open class AspLegacyConventions : Plugin<Project> {
doLast { Logger.lifecycle("> Clean done") }
}
}

Logger.info(" Setting Nexus publishing URL to s01.oss.sonatype.org")
target.extensions.getByType<NexusPublishExtension>().apply {
repositories {
sonatype {
nexusUrl.set(java.net.URI("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(java.net.URI("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
}
}
}
}

var isMultiplatform = false
Expand Down Expand Up @@ -322,6 +319,32 @@ open class AspLegacyConventions : Plugin<Project> {
}
target.compileVersionCatalog()
target.setupSignDependency()

target.rootProject.extensions.getByType<NexusPublishExtension>().apply {
val isSnapshot = target.version.toString().endsWith("-SNAPSHOT")
if (staging == null) {
staging = isSnapshot
useStaging.set(false)
repositories.sonatype {
val releaseUrl = if (isSnapshot) "https://s01.oss.sonatype.org/content/repositories/snapshots/"
else "https://s01.oss.sonatype.org/service/local/"
if(isSnapshot)
Logger.lifecycle(" Working around Nexus Plugin SNAPSHOT workaround by setting Nexus publishing URL to $releaseUrl")
else
Logger.lifecycle(" Setting Nexus publishing URL to $releaseUrl")
nexusUrl.set(
java.net.URI(
releaseUrl
)
)
snapshotRepositoryUrl.set(java.net.URI("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
}
} else if (staging != isSnapshot)
Logger.warn("\n Publishing will not work, as some modules use snapshot versions, while others don't. Choose either for all!")
Logger.lifecycle("\n Project version for publishing: ${target.version}")
Logger.lifecycle(" Artefact ${target.name} will be published to ${if (useStaging.get()) "SNAPSHOT" else "release"} repository")
}

}
}
}.getOrElse {
Expand Down

0 comments on commit 5b661bf

Please sign in to comment.