diff --git a/build.gradle.kts b/build.gradle.kts index d1b3259..31937c6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -104,107 +104,116 @@ val javadocsJar by tasks.creating(Jar::class) { from(tasks.dokkaHtml) } -afterEvaluate { - publishing { - val vcs = "https://github.com/mipt-npm/gradle-tools" +val emptyJavadocJar by tasks.creating(Jar::class) { + group = JavaBasePlugin.DOCUMENTATION_GROUP + archiveBaseName.set("empty") + archiveClassifier.set("javadoc") +} - // Process each publication we have in this project - publications { - create("catalog") { - from(components["versionCatalog"]) - artifactId = "version-catalog" - pom { - name.set("version-catalog") - } +val emptySourcesJar by tasks.creating(Jar::class) { + archiveClassifier.set("sources") + archiveBaseName.set("empty") +} + +publishing { + val vcs = "https://github.com/mipt-npm/gradle-tools" + + // Process each publication we have in this project + publications { + create("catalog") { + from(components["versionCatalog"]) + artifactId = "version-catalog" + + pom { + name.set("version-catalog") } + } - withType { - artifact(sourcesJar) - artifact(javadocsJar) + withType { + // thanks @vladimirsitnikv for the fix + artifact(if (name == "catalog") emptySourcesJar else sourcesJar) + artifact(if (name == "catalog") emptyJavadocJar else javadocsJar) - pom { - name.set(project.name) - description.set(project.description) + + pom { + name.set(project.name) + description.set(project.description) + url.set(vcs) + + licenses { + license { + name.set("The Apache Software License, Version 2.0") + url.set("https://www.apache.org/licenses/LICENSE-2.0.txt") + distribution.set("repo") + } + } + + developers { + developer { + id.set("MIPT-NPM") + name.set("MIPT nuclear physics methods laboratory") + organization.set("MIPT") + organizationUrl.set("https://npm.mipt.ru") + } + } + + scm { url.set(vcs) - - licenses { - license { - name.set("The Apache Software License, Version 2.0") - url.set("https://www.apache.org/licenses/LICENSE-2.0.txt") - distribution.set("repo") - } - } - - developers { - developer { - id.set("MIPT-NPM") - name.set("MIPT nuclear physics methods laboratory") - organization.set("MIPT") - organizationUrl.set("https://npm.mipt.ru") - } - } - - scm { - url.set(vcs) - tag.set(project.version.toString()) - } + tag.set(project.version.toString()) } } } + } - val spaceRepo = "https://maven.pkg.jetbrains.space/spc/p/sci/maven" - val spaceUser: String? = findProperty("publishing.space.user") as? String - val spaceToken: String? = findProperty("publishing.space.token") as? String + val spaceRepo = "https://maven.pkg.jetbrains.space/spc/p/sci/maven" + val spaceUser: String? = findProperty("publishing.space.user") as? String + val spaceToken: String? = findProperty("publishing.space.token") as? String - if (spaceUser != null && spaceToken != null) { - project.logger.info("Adding mipt-npm Space publishing to project [${project.name}]") + if (spaceUser != null && spaceToken != null) { + project.logger.info("Adding mipt-npm Space publishing to project [${project.name}]") - repositories.maven { - name = "space" - url = uri(spaceRepo) + repositories.maven { + name = "space" + url = uri(spaceRepo) - credentials { - username = spaceUser - password = spaceToken - } + credentials { + username = spaceUser + password = spaceToken + } + } + } + + val sonatypeUser: String? = project.findProperty("publishing.sonatype.user") as? String + val sonatypePassword: String? = project.findProperty("publishing.sonatype.password") as? String + + if (sonatypeUser != null && sonatypePassword != null) { + val sonatypeRepo: String = if (project.version.toString().contains("dev")) { + "https://oss.sonatype.org/content/repositories/snapshots" + } else { + "https://oss.sonatype.org/service/local/staging/deploy/maven2" + } + + repositories.maven { + name = "sonatype" + url = uri(sonatypeRepo) + + credentials { + username = sonatypeUser + password = sonatypePassword } } - val sonatypeUser: String? = project.findProperty("publishing.sonatype.user") as? String - val sonatypePassword: String? = project.findProperty("publishing.sonatype.password") as? String - - if (sonatypeUser != null && sonatypePassword != null) { - val sonatypeRepo: String = if (project.version.toString().contains("dev")) { - "https://oss.sonatype.org/content/repositories/snapshots" - } else { - "https://oss.sonatype.org/service/local/staging/deploy/maven2" - } - - repositories.maven { - name = "sonatype" - url = uri(sonatypeRepo) - - credentials { - username = sonatypeUser - password = sonatypePassword - } - } - - if (plugins.findPlugin("signing") == null) { - apply() - } - - signing { - //useGpgCmd() - sign(publications) - } + signing { + //useGpgCmd() + sign(publications) } } } -kotlin{ - jvmToolchain{ + +kotlin { + jvmToolchain { languageVersion.set(JavaLanguageVersion.of(11)) } } @@ -212,4 +221,9 @@ kotlin{ tasks.processResources.configure { duplicatesStrategy = DuplicatesStrategy.INCLUDE from("gradle/libs.versions.toml") +} + +// Workaround for https://github.com/gradle/gradle/issues/15568 +tasks.withType().configureEach { + mustRunAfter(tasks.withType()) } \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index efe2f8c..fb846f7 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,11 +1,11 @@ [versions] -tools = "0.14.3-kotlin-1.8.10" -kotlin = "1.8.10" +tools = "0.14.4-kotlin-1.8.20-RC" +kotlin = "1.8.20-RC" atomicfu = "0.19.0" binary-compatibility-validator = "0.12.1" changelog = "2.0.0" dokka = "1.7.20" -kotlin-jupyter = "0.11.0-225" +kotlin-jupyter = "0.11.0-317" kotlinx-benchmark = "0.4.7" kotlinx-cli = "0.3.5" kotlinx-coroutines = "1.6.4" @@ -17,7 +17,7 @@ kotlinx-serialization = "1.4.1" ktor = "2.2.3" xmlutil = "0.84.3" yamlkt = "0.12.0" -jsBom = "1.0.0-pre.491" +jsBom = "1.0.0-pre.509" junit = "5.9.2" compose = "1.3.0" logback = "1.4.5" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 070cb70..e1bef7e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/kotlin/space/kscience/gradle/KScienceProjectPlugin.kt b/src/main/kotlin/space/kscience/gradle/KScienceProjectPlugin.kt index 4918dab..b979c69 100644 --- a/src/main/kotlin/space/kscience/gradle/KScienceProjectPlugin.kt +++ b/src/main/kotlin/space/kscience/gradle/KScienceProjectPlugin.kt @@ -5,7 +5,9 @@ import kotlinx.validation.BinaryCompatibilityValidatorPlugin import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.publish.maven.MavenPom +import org.gradle.api.publish.maven.tasks.AbstractPublishToMaven import org.gradle.kotlin.dsl.* +import org.gradle.plugins.signing.Sign import org.jetbrains.changelog.ChangelogPlugin import org.jetbrains.changelog.ChangelogPluginExtension import org.jetbrains.dokka.gradle.AbstractDokkaTask @@ -108,6 +110,11 @@ public open class KScienceProjectPlugin : Plugin { maven("https://repo.kotlin.link") maven("https://maven.pkg.jetbrains.space/spc/p/sci/dev") } + + // Workaround for https://github.com/gradle/gradle/issues/15568 + tasks.withType().configureEach { + mustRunAfter(tasks.withType()) + } } afterEvaluate { diff --git a/src/main/kotlin/space/kscience/gradle/internal/publishing.kt b/src/main/kotlin/space/kscience/gradle/internal/publishing.kt index 372fcf6..969bc79 100644 --- a/src/main/kotlin/space/kscience/gradle/internal/publishing.kt +++ b/src/main/kotlin/space/kscience/gradle/internal/publishing.kt @@ -34,14 +34,12 @@ internal fun Project.setupPublication(mavenPomConfiguration: MavenPom.() -> Unit } } - afterEvaluate { - publications.create("js") { - kotlin.targets.flatMap { it.components }.forEach { - from(it) - } - - artifact(sourcesJar) + publications.create("js") { + kotlin.targets.flatMap { it.components }.forEach { + from(it) } + + artifact(sourcesJar) } } @@ -56,14 +54,12 @@ internal fun Project.setupPublication(mavenPomConfiguration: MavenPom.() -> Unit } } - afterEvaluate { - publications.create("jvm") { - kotlin.target.components.forEach { - from(it) - } - - artifact(sourcesJar) + publications.create("jvm") { + kotlin.target.components.forEach { + from(it) } + + artifact(sourcesJar) } }