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

Apply kotlinx-atomicfu plugin by id #443

Merged
merged 5 commits into from
Jun 27, 2024
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
*.iml
*/target/*
build
.gradle
.gradle
.kotlin
20 changes: 20 additions & 0 deletions atomicfu-gradle-plugin/build.gradle.kts
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's usually a good idea not to apply Kotlin/JVM in Gradle plugins. Try this instead:

plugins {
//    id("kotlin-jvm-conventions")
    id("java-gradle-plugin")
    id("publish-conventions")
    id("common-conventions")
    id("kotlin-base-conventions")
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dkrasnoff We could look at making this neater as part of #421, e.g. create a kotlin-gradle-plugin convention.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, without kotlin("jvm") I get an error: Extension of type 'KotlinProjectExtension' does not exist.
And because of that I can not apply kotlin-base-conventions plugin.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh yes, that makes sense. So yes, remove kotlin-base-conventions from the Atomicfu Gradle Plugin.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iirc kotlin-base-conventions has been reworked in @dkrasnoff's branch.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/

plugins {
alias(libs.plugins.gradle.pluginPublish)
id("kotlin-jvm-conventions")
id("java-gradle-plugin")
}
Expand Down Expand Up @@ -40,3 +41,22 @@ tasks.processResources {
expand("atomicfuVersion" to project.version)
}
}

signing {
// disable signing if private key isn't passed
isRequired = findProperty("libs.sign.key.private") != null
}

gradlePlugin {
website.set("https://github.com/Kotlin/kotlinx-atomicfu")
vcsUrl.set("https://github.com/Kotlin/kotlinx-atomicfu.git")

plugins {
create("Atomicfu") {
id = "kotlinx-atomicfu"
implementationClass = "kotlinx.atomicfu.plugin.gradle.AtomicFUGradlePlugin"
displayName = "Gradle plugin for kotlinx-atomicfu library"
description = "Enables efficient use of atomic operations in Kotlin multiplatform projects."
}
}
}

This file was deleted.

2 changes: 1 addition & 1 deletion atomicfu-maven-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

plugins {
`maven-publish`
id("kotlin-jvm-conventions")
id("kotlin-jvm-publish-conventions")
}

dependencies {
Expand Down
2 changes: 1 addition & 1 deletion atomicfu-transformer/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/

plugins {
id("kotlin-jvm-conventions")
id("kotlin-jvm-publish-conventions")
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ plugins {
signing
}

val javadocJar by tasks.register<Jar>("javadocJar") {
description = "Create a Javadoc JAR. Empty by default."
// Create an empty Javadoc JAR to satisfy Maven Central requirements.
archiveClassifier.set("javadoc")
}

publishing {
repositories {
maven {
Expand Down Expand Up @@ -52,15 +46,6 @@ publishing {


signPublicationIfKeyPresent(project, this)
// TODO(Dmitrii Krasnov): https://github.com/Kotlin/kotlinx-atomicfu/issues/421
// Figure out if there's an alternative to string-based config
// (if the name changes this config will silently stop working).
// Maybe the Javadoc JAR can always be added?
// add empty javadocs

if (name != "kotlinMultiplatform") { // The root module gets the JVM's javadoc JAR
artifact(javadocJar)
}
}

tasks.withType<AbstractPublishToMaven>().configureEach {
Expand Down
18 changes: 1 addition & 17 deletions buildSrc/src/main/kotlin/kotlin-jvm-conventions.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,11 @@ plugins {
// Regular java modules need 'java-library' plugin for proper publication
`java-library`
kotlin("jvm")
id("publish-conventions")
id("base-publish-conventions")
id("common-conventions")
id("kotlin-base-conventions")
}

// MPP projects pack their sources automatically, java libraries need to explicitly pack them
val sourcesJar by tasks.registering(Jar::class) {
archiveClassifier.set("sources")
from("src/main/kotlin")
}

publishing {
// Configure java publications for non-MPP projects
publications {
create<MavenPublication>("maven") {
from(components["java"])
artifact(sourcesJar)
}
}
}

kotlin {
jvmToolchain(8)
}
20 changes: 20 additions & 0 deletions buildSrc/src/main/kotlin/kotlin-jvm-publish-conventions.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
plugins {
id("kotlin-jvm-conventions")
id("publish-with-javadoc-conventions")
}

// MPP projects pack their sources automatically, java libraries need to explicitly pack them
val sourcesJar by tasks.registering(Jar::class) {
archiveClassifier.set("sources")
from("src/main/kotlin")
}

publishing {
// Configure java publications for non-MPP projects
publications {
create<MavenPublication>("maven") {
from(components["java"])
artifact(sourcesJar)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import groovy.util.Node
import groovy.util.NodeList

plugins {
id("publish-conventions")
id("publish-with-javadoc-conventions")
}

afterEvaluate {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
plugins {
id("base-publish-conventions")
}

val javadocJar by tasks.register<Jar>("javadocJar") {
description = "Create a Javadoc JAR. Empty by default."
// Create an empty Javadoc JAR to satisfy Maven Central requirements.
archiveClassifier.set("javadoc")
}

publishing {
publications.withType<MavenPublication>().configureEach {
if (name != "kotlinMultiplatform") { // The root module gets the JVM's javadoc JAR
artifact(javadocJar)
}
}
}
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,7 @@ maven = "3.5.3"
maven-pluginTools = "3.5"
node-gradle = "3.1.1"
rhino = "1.7.10"
gradle-plugin-publish = "1.2.1"

[libraries]

Expand Down Expand Up @@ -50,4 +51,5 @@ maven = ["maven-core", "maven-pluginApi", "maven-pluginAnnotations"]
gradle-nodePlugin = { id = "com.github.node-gradle.node", version.ref = "node-gradle" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlinx-binaryCompatibilityValidator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "kotlinx-binaryCompatibilityValidator"}
gradle-pluginPublish = { id = "com.gradle.plugin-publish", version.ref = "gradle-plugin-publish" }

2 changes: 1 addition & 1 deletion integration-testing/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.jetbrains.kotlin.gradle.utils.NativeCompilerDownloader

plugins {
id("kotlin-jvm-conventions")
id("kotlin-jvm-publish-conventions")
}

java {
Expand Down
17 changes: 1 addition & 16 deletions integration-testing/examples/jdk-compatibility/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,29 +1,14 @@
import org.jetbrains.kotlin.config.JvmTarget

buildscript {
repositories {
mavenLocal()
mavenCentral()
}

dependencies {
val atomicfuVersion = libs.versions.atomicfuVersion.get()
val kotlinVersion = libs.versions.kotlinVersion.get()
classpath("org.jetbrains.kotlinx:atomicfu-gradle-plugin:$atomicfuVersion")
classpath("org.jetbrains.kotlin:atomicfu:$kotlinVersion")
}
}

group = "kotlinx.atomicfu.examples"
version = "DUMMY_VERSION"

plugins {
kotlin("jvm") version libs.versions.kotlinVersion.get()
id("kotlinx-atomicfu") version libs.versions.atomicfuVersion.get()
`maven-publish`
}

apply(plugin = "kotlinx-atomicfu")

repositories {
mavenCentral()
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev")
Expand Down
13 changes: 1 addition & 12 deletions integration-testing/examples/jvm-sample/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
buildscript {
repositories {
mavenLocal()
mavenCentral()
}

dependencies {
val atomicfuVersion = libs.versions.atomicfuVersion.get()
classpath("org.jetbrains.kotlinx:atomicfu-gradle-plugin:$atomicfuVersion")
}
}

group = "kotlinx.atomicfu.examples"
version = "DUMMY_VERSION"

plugins {
application
kotlin("jvm") version libs.versions.kotlinVersion.get()
id("kotlinx-atomicfu") version libs.versions.atomicfuVersion.get()
`maven-publish`
}

Expand Down
15 changes: 1 addition & 14 deletions integration-testing/examples/mpp-sample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,15 @@

import org.jetbrains.kotlin.gradle.dsl.KotlinCompile

buildscript {
repositories {
mavenLocal()
mavenCentral()
}

dependencies {
val atomicfuVersion = libs.versions.atomicfuVersion.get()
classpath("org.jetbrains.kotlinx:atomicfu-gradle-plugin:$atomicfuVersion")
}
}

group = "kotlinx.atomicfu.examples"
version = "DUMMY_VERSION"

plugins {
kotlin("multiplatform") version libs.versions.kotlinVersion.get()
`maven-publish`
id("kotlinx-atomicfu") version libs.versions.atomicfuVersion.get()
}

apply(plugin = "kotlinx-atomicfu")

repositories {
mavenCentral()
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@

import org.jetbrains.kotlin.gradle.dsl.KotlinCompile

buildscript {
dependencies {
classpath(libs.atomicfuGradlePlugin)
}
}

repositories {
mavenCentral()
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev")
Expand All @@ -18,10 +12,9 @@ repositories {

plugins {
alias(libs.plugins.kotlinMultiplatform)
id("kotlinx-atomicfu") version libs.versions.atomicfu.get()
}

apply (plugin = "kotlinx-atomicfu")

kotlin {

jvm()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
buildscript {
repositories {
mavenLocal()
mavenCentral()
}

dependencies {
val atomicfuVersion = libs.versions.atomicfuVersion.get()
classpath("org.jetbrains.kotlinx:atomicfu-gradle-plugin:$atomicfuVersion")
}
}

plugins {
kotlin("multiplatform") version libs.versions.kotlinVersion.get()
id("kotlinx-atomicfu") version libs.versions.atomicfuVersion.get()
}

apply(plugin = "kotlinx-atomicfu")

repositories {
mavenLocal()
mavenCentral()
Expand Down