Cannot download or update snapshot dependency hosted on Github Package Registry using gradle - gradle

I have an issue with Github Package Registry when I try to push or download SNAPSHOT versions of ny gradle plugin.
When I first send publish my package everything works fine but then when I try to install or update this package, I get the following errors:
The usage of a fixed version (without snapshot) seems to work (even though the update does not work but that may be on purpose as it's a 422 error).
Here is my build.gradle.kts file if it helps.
group = "com.github.imflog"
version = "0.10.0-SNAPSHOT"
plugins {
kotlin("jvm").version("1.3.71")
id("java-gradle-plugin")
id("com.gradle.plugin-publish") version "0.11.0"
id("maven-publish")
id("com.github.ben-manes.versions") version "0.28.0"
}
repositories {
jcenter()
mavenCentral()
maven("http://packages.confluent.io/maven/")
}
java {
withSourcesJar()
}
// Dependencies versions
val confluentVersion = "5.4.1"
val avroVersion = "1.8.2"
dependencies {
implementation(gradleApi())
implementation(kotlin("stdlib"))
implementation("io.confluent", "kafka-schema-registry", confluentVersion) {
exclude("org.slf4j", "slf4j-log4j12")
}
}
// Test versions
val junitVersion = "5.6.1"
val mockkVersion = "1.9.3"
val wiremockVersion = "2.26.3"
val assertJVersion = "3.15.0"
dependencies {
testImplementation(gradleTestKit())
testImplementation("org.junit.jupiter", "junit-jupiter-api", junitVersion)
testImplementation("org.junit.jupiter", "junit-jupiter-engine", junitVersion)
testImplementation("org.assertj", "assertj-core", assertJVersion)
testImplementation("io.mockk", "mockk", mockkVersion)
testImplementation("com.github.tomakehurst", "wiremock-jre8", wiremockVersion)
}
tasks.withType<Test> {
useJUnitPlatform()
}
publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/ImFlog/schema-registry-plugin")
credentials {
username = System.getenv("GITHUB_USERNAME")
password = System.getenv("GITHUB_TOKEN")
}
}
}
}
val registryPluginName = "com.github.imflog.kafka-schema-registry-gradle-plugin"
gradlePlugin {
plugins {
create("schema-registry") {
id = registryPluginName
description = "A plugin to download, register and test schemas from a Kafka Schema Registry"
displayName = "Kafka schema registry gradle plugin"
version = version
implementationClass = "com.github.imflog.schema.registry.SchemaRegistryPlugin"
}
}
}
pluginBundle {
website = "https://github.com/ImFlog/schema-registry-plugin"
vcsUrl = "https://github.com/ImFlog/schema-registry-plugin.git"
tags = listOf("schema", "registry", "schema-registry", "kafka")
}
Thank you !

Related

Signing fails when trying to publish to Maven Central using Sonatype nexus (gradle-nexus.publish-plugin)

I'm trying to publish my library to Maven Central. I already set it up over at Sonatype Nexus, and now I'm trying to hook up Gradle to it (this library depends on Minecraft Forge, so using Maven isn't an option).
I saw that there was a plugin created called Gradle Nexus Publish Plugin and thought I could use it to make publishing easier.
Using the publishAllPublicationsToSonatypeRepository Gradle task, I could publish a repo to Nexus;
But once I call closeSonatypeStagingRepository, it fails with the following error:
Execution failed for task ':signMavenPublication'.
> Could not read PGP secret key
Cause: premature end of stream in PartialInputStream
Now, I added a println to see what key Gradle reads from signingKey, and turns out that no matter what I put there, it always retrieves the same key, even if I put in an invalid key (this is an altered key):
lQWGBGByDfwBDADB5pWxgBT04U0bDIv/Pv0zDEYqKXt2Dubj3RcvCDAveel3eYFt
(The password is being updated though)
Why is this happening?
This is my build.gradle.kts:
import net.minecraftforge.gradle.common.util.ModConfig
import net.minecraftforge.gradle.common.util.RunConfig
import net.minecraftforge.gradle.userdev.UserDevExtension
import java.time.Instant
import java.time.format.DateTimeFormatter
// BuildScript
buildscript {
repositories {
maven(url = "https://maven.minecraftforge.net/")
jcenter()
mavenCentral()
}
dependencies {
classpath(group = "net.minecraftforge.gradle", name = "ForgeGradle", version = "4.1.+")
}
}
plugins {
idea
id("io.github.gradle-nexus.publish-plugin") version "1.0.0"
`java-library`
`maven-publish`
signing
kotlin("jvm") version "1.5.0"
}
apply(plugin = "net.minecraftforge.gradle")
// Config -> Minecraft
val forgeVersion: String by extra
val minecraftVersion: String by extra
val kffVersion: String by extra
val modVersion: String by extra
// JVM Info
println(
"""
Java: ${System.getProperty("java.version")}
JVM: ${System.getProperty("java.vm.version")} (${System.getProperty("java.vendor")})
Arch: ${System.getProperty("os.arch")}
""".trimIndent()
)
// Minecraft
configure<UserDevExtension> {
mappings("official", minecraftVersion)
#Suppress("SpellCheckingInspection")
accessTransformer(file("src/main/resources/META-INF/accesstransformer.cfg"))
runs(closureOf<NamedDomainObjectContainer<RunConfig>> {
create("client") {
workingDirectory(file("run"))
taskName = "client"
// Recommended logging data for a userdev environment
property("forge.logging.markers", "SCAN,REGISTRIES,REGISTRYDUMP")
// Recommended logging level for the console
property("forge.logging.console.level", "debug")
mods(closureOf<NamedDomainObjectContainer<ModConfig>> {
create("loottables") {
source(sourceSets["main"])
}
})
}
create("server") {
workingDirectory(file("run"))
taskName = "server"
// Recommended logging data for a userdev environment
property("forge.logging.markers", "SCAN,REGISTRIES,REGISTRYDUMP")
// Recommended logging level for the console
property("forge.logging.console.level", "debug")
mods(closureOf<NamedDomainObjectContainer<ModConfig>> {
create("loottables") {
source(sourceSets["main"])
}
})
}
create("data") {
workingDirectory(file("run"))
taskName = "datagen"
// Recommended logging data for a userdev environment
property("forge.logging.markers", "SCAN,REGISTRIES,REGISTRYDUMP")
// Recommended logging level for the console
property("forge.logging.console.level", "debug")
// Specify the mod id for data generation, where to output the resulting resource, and where to look for existing resources.
args(
"--mod",
"loottables",
"--all",
"--output",
file("src/generated/resources/"),
"--existing",
file("src/main/resources/")
)
mods(closureOf<NamedDomainObjectContainer<ModConfig>> {
create("loottables") {
source(sourceSets["main"])
}
})
}
})
}
// Minecraft Dependency
// Note: Due to the way kotlin gradle works we need to define the minecraft dependency after we configure Minecraft
dependencies {
"minecraft"(group = "net.minecraftforge", name = "forge", version = "$minecraftVersion-$forgeVersion")
implementation(group = "thedarkcolour", name = "kotlinforforge", version = "latest.release")
testImplementation(
group = "org.jetbrains.kotlin",
name = "kotlin-test-junit5",
version = kotlin.coreLibrariesVersion
)
}
repositories {
maven {
name = "kotlinforforge"
url = uri("https://thedarkcolour.github.io/KotlinForForge/")
}
}
// Setup
project.group = "com.theonlytails"
project.version = modVersion
base.archivesBaseName = "loottables"
// Sets the toolchain to compile against OpenJDK 8
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
vendor.set(JvmVendorSpec.ADOPTOPENJDK)
}
}
// Finalize the jar by re-obfuscating
tasks.named<Jar>("jar") {
// Manifest
manifest {
attributes(
"Specification-Title" to "LootTables",
"Specification-Vendor" to "TheOnlyTails",
"Specification-Version" to "1",
"Implementation-Title" to "LootTables",
"Implementation-Version" to project.version,
"Implementation-Vendor" to "TheOnlyTails",
"Implementation-Timestamp" to DateTimeFormatter.ISO_INSTANT.format(Instant.now()),
"FMLModType" to "LIBRARY"
)
}
#Suppress("SpellCheckingInspection")
finalizedBy("reobfJar")
}
// Publishing to maven central
publishing {
publications {
create<MavenPublication>("maven") {
groupId = "com.theonlytails"
artifactId = "loottables"
version = modVersion
from(components["java"])
pom {
name.set("LootTables")
description.set("A Kotlin DSL for creating loot tables in Minecraft Forge mods")
url.set("https://github.com/theonlytails/loottables")
properties.set(mapOf("project.build.sourceEncoding" to "UTF-8"))
licenses {
license {
name.set("MIT License")
url.set("https://www.opensource.org/licenses/mit-license.php")
distribution.set("repo")
}
}
developers {
developer {
id.set("theonlytails")
name.set("TheOnlyTails")
url.set("https://theonlytails.com/")
}
}
issueManagement {
url.set("https://github.com/theonlytails/loottables/issues")
system.set("GitHub Issues")
}
scm {
connection.set("scm:git:git:github.com/theonlytails/loottables.git")
developerConnection.set("scm:git:git#github.com:theonlytails/loottables.git")
url.set("https://github.com/theonlytails/loottables")
}
}
}
}
}
java {
withJavadocJar()
withSourcesJar()
}
signing {
val signingPassword: String? by extra
val signingKey: String? by extra
println(signingKey) // this is for debbuging purposes only, I'm obviously going to remove this once done
println(signingPassword)
useInMemoryPgpKeys(
signingKey ?: throw GradleException("Couldn't find a signing password"),
signingPassword ?: throw GradleException("Couldn't find a signing key")
)
sign(publishing.publications["maven"])
}
nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
username.set(System.getenv("MAVEN_USERNAME"))
password.set(System.getenv("MAVEN_PASSWORD"))
}
}
}
// Testing
tasks.withType<Test> {
useJUnitPlatform()
}

Could not PUT https://oss.sonatype.org/service/local/staging/deploy/maven2/bom-plugin/

I'm trying to publish my first Gradle plugin to maven central (sonatype), but I'm receiving the following error:
Execution failed for task ':publishBom-pluginPluginMarkerMavenPublicationToMavenRepository'.
> Failed to publish publication 'bom-pluginPluginMarkerMaven' to repository 'maven'
> Could not PUT 'https://oss.sonatype.org/service/local/staging/deploy/maven2/bom-plugin/bom-plugin.gradle.plugin/0.3/bom-plugin.gradle.plugin-0.3.pom'.
Received status code 400 from server: Bad Request
It seems that for some reason, the publishing task is trying to publish my plugin at the root of the sonatype repository, it works when I do execute the task publishToMavenLocal, however, published this strange file in my m2 local: /.m2/repository/bom-plugin/bom-plugin.gradle.plugin and also publish the plugin here /.m2/repository/dev/thiagosouto/bom-plugin/0.3/
I think this is causing the issue but I don't have any clue to solve this problem.
My build.gradle.kts file
plugins {
java
`java-gradle-plugin`
`kotlin-dsl`
`maven-publish`
signing
kotlin("jvm") version "1.4.31"
id("com.gradle.plugin-publish") version "0.13.0"
}
group "dev.thiagosouto"
version "0.3"
buildscript {
repositories {
mavenCentral()
maven {
url = uri("https://plugins.gradle.org/m2/")
}
}
}
gradlePlugin {
plugins {
create("bom-plugin") {
id = "bom-plugin"
implementationClass = "dev.thiagosouto.plugins.bom.BomPlugin"
}
}
}
repositories {
mavenCentral()
}
dependencies {
implementation("com.squareup:kotlinpoet:1.7.2")
testImplementation("com.google.truth:truth:1.1.2")
testImplementation("junit:junit:4.13.2")
testImplementation("dev.thiagosouto:file-butler:0.3.0")
}
sourceSets.main {
java.srcDirs("src/main/kotlin")
}
sourceSets.test {
java.srcDirs("src/test/kotlin")
}
tasks.withType<GenerateModuleMetadata> {
enabled = false
}
publishing {
val ossrhUsername: String by project
val ossrhPassword: String by project
repositories {
maven(url = "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
credentials {
username = ossrhUsername
password = ossrhPassword
}
}
}
publications {
group = "dev.thiagosouto"
version = "0.3"
create<MavenPublication>("mavenJava") {
pom {
name.set("bom-plugin")
description.set("A library to help apply tdd through help functions");
url.set("https://thiagosouto.dev")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
scm {
connection.set("scm:git:git://github.com/othiagosouto/bom-plugin.git/")
developerConnection.set("scm:git:ssh://github.com:othiagosouto/bom-plugin.git")
url.set("https://github.com/othiagosouto/bom-plugin")
}
developers {
developer {
id.set("othiagosouto")
name.set("Thiago Souto silva de barros Santos")
email.set("soutosss#gmail.com")
}
}
}
}
}
}
afterEvaluate {
signing {
sign(publishing.publications["mavenJava"])
}
}

Publish Kotlin MPP metadata with Gradle Kotlin DSL

I have created a Kotlin MPP to share Json utilities between JVM and JS. All the code lies in the common source set and I have configured the necessary targets with their respective dependencies. Without further configuration I'm able to use the utilities from both JVM and JS but not from the common source set of another MPP, which has to do with the way Gradle handles metadata.
I already found the solution (taken from https://medium.com/xorum-io/crafting-and-publishing-kotlin-multiplatform-library-to-bintray-cbc00a4f770)
afterEvaluate {
project.publishing.publications.all {
groupId = group
if (it.name.contains('metadata')) {
artifactId = "$libraryName"
} else {
artifactId = "$libraryName-$name"
}
}
}
and I also got it to work with the Gradle Kotlin DSL:
afterEvaluate {
publishing.publications.all {
this as MavenPublication
artifactId = project.name + "-$name".takeUnless { "metadata" in name }.orEmpty()
}
}
However, this doesn't feel quite right yet.
There is no such code snippet in the official documentation.
The documentation advertises that a single dependency from the common source set should suffice to automatically resolve target specific dependencies: https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#metadata-publishing. I had to add the dependency for each target, respectively, for it to work.
this as MavenPublication is necessary because Publication has no field artifactId.
I use project.name instead of libraryName.
Is this even remotely the right way to do things or am I missing some other option which would make the whole process trivial?
Right now I'm using Kotlin 1.3.72 and Gradle 5.2.1 with enableFeaturePreview("GRADLE_METADATA") in settings.gradle.kts. I also tried it with Gradle 6.5.1 (latest) but it behaves exactly the same.
For now I'm glad that it's working at all but I suspect there is a cleaner way to do this. I'd really appreciate if someone with a bit more Gradle expertise could clear things up for me or point me into the right direction.
Edit:
gradle.build.kts for completeness. Although there isn't much going on here.
group = "org.example"
version = "1.0-SNAPSHOT"
plugins {
kotlin("multiplatform") version "1.3.72"
`maven-publish`
}
repositories {
mavenCentral()
}
kotlin {
jvm()
sourceSets {
val commonMain by getting {
dependencies {
implementation(kotlin("stdlib-common"))
}
}
val jvmMain by getting {
dependencies {
implementation(kotlin("stdlib"))
}
}
}
}
There wasn't really a problem after all. The solution is to simply add enableFeaturePreview("GRADLE_METADATA") to the consuming project too.
According to https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#metadata-publishing this shouldn't be necessary:
In earlier Gradle versions starting from 5.3, the module metadata is
used during dependency resolution, but publications don't include any
module metadata by default. To enable module metadata publishing, add
enableFeaturePreview("GRADLE_METADATA") to the root project's
settings.gradle file.
Weirdly it only works when both publishing project and consuming project have metadata enabled, even when both use the latest Gradle version.
enableFeaturePreview("GRADLE_METADATA") is enabled by default in latest gradle.
According to this you need to substitute "kotlinMultiplatform" by "" an empty string.
I finally managed to accomplish publishing to bintray with maven-publish plugin only, without outdated bintray library.
Here is my full maven.publish.gradle.kts:
import java.io.FileInputStream
import java.util.*
import org.gradle.api.publish.PublishingExtension
apply(plugin = "maven-publish")
val fis = FileInputStream("local.properties")
val properties = Properties().apply {
load(fis)
}
val bintrayUser = properties.getProperty("bintray.user")
val bintrayApiKey = properties.getProperty("bintray.apikey")
val bintrayPassword = properties.getProperty("bintray.gpg.password")
val libraryVersion: String by project
val publishedGroupId: String by project
val artifact: String by project
val bintrayRepo: String by project
val libraryName: String by project
val bintrayName: String by project
val libraryDescription: String by project
val siteUrl: String by project
val gitUrl: String by project
val licenseName: String by project
val licenseUrl: String by project
val developerOrg: String by project
val developerName: String by project
val developerEmail: String by project
val developerId: String by project
project.group = publishedGroupId
project.version = libraryVersion
afterEvaluate {
configure<PublishingExtension> {
publications.all {
val mavenPublication = this as? MavenPublication
mavenPublication?.artifactId =
"${project.name}${"-$name".takeUnless { "kotlinMultiplatform" in name }.orEmpty()}"
}
}
}
configure<PublishingExtension> {
publications {
withType<MavenPublication> {
groupId = publishedGroupId
artifactId = artifact
version = libraryVersion
pom {
name.set(libraryName)
description.set(libraryDescription)
url.set(siteUrl)
licenses {
license {
name.set(licenseName)
url.set(licenseUrl)
}
}
developers {
developer {
id.set(developerId)
name.set(developerName)
email.set(developerEmail)
}
}
organization {
name.set(developerOrg)
}
scm {
connection.set(gitUrl)
developerConnection.set(gitUrl)
url.set(siteUrl)
}
}
}
}
repositories {
maven("https://api.bintray.com/maven/${developerOrg}/${bintrayRepo}/${artifact}/;publish=1") {
credentials {
username = bintrayUser
password = bintrayApiKey
}
}
}
}
And build.gradle.kts:
plugins {
id("kotlin-multiplatform")
}
kotlin {
sourceSets {
jvm()
js() {
browser()
nodejs()
}
linuxX64()
linuxArm64()
mingwX64()
macosX64()
iosArm64()
iosX64()
val commonMain by getting {
dependencies {
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
val jsMain by getting {
dependencies {
}
}
val jsTest by getting {
dependencies {
implementation(kotlin("test-js"))
}
}
val jvmMain by getting {
dependencies {
}
}
val jvmTest by getting {
dependencies {
implementation(kotlin("test"))
implementation(kotlin("test-junit"))
}
}
val nativeMain by creating {
dependsOn(commonMain)
dependencies {
}
}
val linuxX64Main by getting {
dependsOn(nativeMain)
}
val linuxArm64Main by getting {
dependsOn(nativeMain)
}
val mingwX64Main by getting {
dependsOn(nativeMain)
}
val macosX64Main by getting {
dependsOn(nativeMain)
}
val iosArm64Main by getting {
dependsOn(nativeMain)
}
val iosX64Main by getting {
dependsOn(nativeMain)
}
}
}
apply(from = "maven.publish.gradle.kts")
Please note, there are bintray.user and bintray.apikey properties in local.properties file.
Also gradle.properties contains rest listed properties above:
libraryVersion = 0.5.22
libraryName = MultiplatformCommon
libraryDescription = Kotlin multiplatform extensions
publishedGroupId = com.olekdia
artifact = multiplatform-common
bintrayRepo = olekdia
bintrayName = multiplatform-common
siteUrl = https://gitlab.com/olekdia/common/libraries/multiplatform-common
gitUrl = https://gitlab.com/olekdia/common/libraries/multiplatform-common.git
.........
kotlin.mpp.enableGranularSourceSetsMetadata = true
systemProp.org.gradle.internal.publish.checksums.insecure = true
If you haven't created organisation in bintray you need to change in this url:
https://api.bintray.com/maven/${developerOrg}/${bintrayRepo}/${artifact}/;publish=1
developerOrg by bintrayUser, where the last one is your user name at bintray.com

Getting newly published package from JitPack fails

I'm trying to publish my java library to JitPack using the maven-publish plugin in Gradle. I have done all that the docs have said, and JitPack says publishing was a success, but it seems like I cannot install my library, even if I just copy and paste straight from JitPack's repository.
I tried pushing straight to master on the github repo. I also changed the artifact id to sertain-core and the version to 1.0.0, as that is what is specified in the publish block. I even checked the repository url and downloaded the jar manually, and it worked fine. It seems that the only problem is downloading the jar using it's maven coordinates.
Here's my library's build file (the dependencies block is in another file and works fine):
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
val ktlint by configurations.creating
plugins {
kotlin("jvm") version "1.3.50"
`maven-publish`
}
dependencies {
implementation(kotlin("stdlib-jdk8"))
implementation(kotlin("reflect", "1.3.50"))
implementation("org.jetbrains.kotlinx", "kotlinx-coroutines-core", "1.3.1")
implementation("org.jetbrains.kotlin", "kotlin-reflect", "1.3.50")
implementation("edu.wpi.first.wpilibj", "wpilibj-java", "2019.4.1")
implementation("edu.wpi.first.hal", "hal-java", "2019.4.1")
implementation("edu.wpi.first.ntcore", "ntcore-java", "2019.4.1")
implementation("com.ctre.phoenix", "api-java", "5.14.1")
ktlint("com.pinterest:ktlint:0.34.2")
}
tasks {
val ktlint by creating(JavaExec::class) {
group = "verification"
description = "Check Kotlin code style."
classpath = configurations["ktlint"]
main = "com.pinterest.ktlint.Main"
args = listOf("src/**/*.kt")
}
"check" {
dependsOn(ktlint)
}
create("ktlintFormat", JavaExec::class) {
group = "formatting"
description = "Fix Kotlin code style deviations."
classpath = configurations["ktlint"]
main = "com.pinterest.ktlint.Main"
args = listOf("-F", "src/**/*.kt")
}
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
kotlinOptions.freeCompilerArgs += setOf("-Xuse-experimental=kotlin.Experimental")
}
publishing {
publications {
create<MavenPublication>("maven") {
groupId = "org.sert2521.sertain"
artifactId = "sertain-core"
version = "1.0.0"
from(components["java"])
artifact("$buildDir/libs/${project.name}.jar")
}
}
}
And here's the build file of the project that should install the library
plugins {
id "org.jetbrains.kotlin.jvm" version "1.3.50"
id "edu.wpi.first.GradleRIO" version "2019.4.1"
}
ext.kotlinVersion = "1.3.50"
tasks.whenTaskAdded { task ->
if (task.name == "deploy" || task.name == "deployMain" || task.name == "simulateJava") task.dependsOn "assemble"
}
repositories {
google()
jcenter()
mavenCentral()
maven { url "https://jitpack.io" }
maven { url "http://first.wpi.edu/FRC/roborio/maven/release" }
maven { url "http://devsite.ctr-electronics.com/maven/release" }
maven { url "https://www.kauailabs.com/maven2" }
maven { url "http://www.revrobotics.com/content/sw/max/sdk/maven/" }
maven { url 'https://jitpack.io' }
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion"
compile "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.1"
compile "com.kauailabs.navx.frc:navx-java:3.1.344"
compile "org.jetbrains.kotlin:kotlin-reflect:1.3.50"
compile wpi.deps.wpilib()
compile wpi.deps.vendor.java()
nativeZip wpi.deps.vendor.jni(wpi.platforms.roborio)
nativeDesktopZip wpi.deps.vendor.jni(wpi.platforms.desktop)
implementation 'com.github.SouthEugeneRoboticsTeam:sertain:publishing-f3bdecc967-1'
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
deploy {
targets {
roboRIO("roborio") {
team = frc.getTeamOrDefault(2521)
}
}
artifacts {
frcJavaArtifact("frcJava") {
targets << "roborio"
debug = frc.getDebugOrDefault(false)
}
fileTreeArtifact("frcStaticFileDeploy") {
files = fileTree(dir: "src/main/deploy")
targets << "roborio"
directory = "/home/lvuser/deploy"
}
}
}
jar {
from configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
manifest {
attributes(
"Main-Class": "org.sert2521.example.MainKt"
)
}
}
wrapper {
gradleVersion = "5.0"
}
There are no error messages when publishing the library. When installing the library, there is only the usual error from gradle not being able to find a dependency.

Kotlin Multiplatform Library Project Upload Issue - POM Multiple Artifacts

We have a Kotlin multi-platform library project with a build script which builds for various platforms, i.e. common, JS & JVM, using the "old-style" sub-project structure and processes. Under this system, the artifacts produced can be successfully uploaded to our Sonatype Nexus repo (the root build.gradle is included below (1)).
We are now trying to convert to the "new-style" Kotlin multi-platform approach/structure (Building Multiplatform Projects with Gradle), but we are getting the following error when we try to upload the artifacts to the repo (the modified root build.gradle included below (2)):
BUILD FAILED in 0s
8 actionable tasks: 1 executed, 7 up-to-date
A POM cannot have multiple artifacts with the same type and classifier. Already have MavenArtifact objjson-metadata:jar.asc:asc:null, trying to add MavenArtifact objjson-metadata:jar.asc:asc:null.
10:36:52: Task execution finished 'uploadArchives'.
Does anyone know why we get this error?
The settings for each artifact created during the build seem to need to be updated in the script, but we are not sure how to do that.
Thanks in advance!
(1) Original ("old-style" multi-platform) root build.gradle:
buildscript {
ext.kotlinVersion = '1.2.61'
repositories {
jcenter()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath 'com.bmuschko:gradle-nexus-plugin:2.3.1'
}
}
plugins {
id 'io.codearte.nexus-staging' version '0.11.0'
}
allprojects {
group 'nz.salect.objJSON'
version '0.24-SNAPSHOT'
}
ext {
libraries = [
kotlin_stdlib : "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion",
kotlin_stdlib_common : "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlinVersion",
kotlin_stdlib_js : "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlinVersion",
kotlin_reflect_lib : "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion",
kotlin_test : "org.jetbrains.kotlin:kotlin-test:$kotlinVersion",
kotlin_test_common : "org.jetbrains.kotlin:kotlin-test-common:$kotlinVersion",
kotlin_test_js : "org.jetbrains.kotlin:kotlin-test-js:$kotlinVersion",
kotlin_test_annotations_common: "org.jetbrains.kotlin:kotlin-test-annotations-common:$kotlinVersion",
kotlin_test_junit : "org.jetbrains.kotlin:kotlin-test-junit:$kotlinVersion",
]
}
subprojects {
repositories {
jcenter()
mavenCentral()
}
//Nexus/Maven upload settings
apply plugin: 'com.bmuschko.nexus'
modifyPom {
project {
name 'objJSON'
description 'A JSON serialization library fully implemented in Kotlin.'
url 'https://bitbucket.org/objdict/objjson'
inceptionYear '2016'
scm {
url 'https://bitbucket.org/objdict/objjson'
connection 'scm:https://bitbucket.org/objdict/objjson.git'
developerConnection 'scm:git://bitbucket.org/objdict/objjson.git'
}
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
developers {
developer {
id 'xxx'
name 'xxx'
email 'xxx'
}
}
}
}
extraArchive {
sources = true
tests = true
javadoc = true
}
nexus {
sign = true
repositoryUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
snapshotRepositoryUrl = 'https://oss.sonatype.org/content/repositories/snapshots/'
}
//End Nexus/Maven upload settings
}
nexusStaging {
packageGroup = "nz.salect"
}
(2) Updated ("new-style" multi-platform) root build.gradle:
buildscript {
ext.kotlinVersion = "1.3.11"
repositories {
jcenter()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
classpath("com.bmuschko:gradle-nexus-plugin:2.3.1")
}
}
plugins {
// from the multiplatform reference file
id "kotlin-multiplatform" version "1.3.11"
id "maven-publish"
id "io.codearte.nexus-staging" version "0.11.0"
//Nexus/Maven upload settings
//id "bmuschko.nexus"
}
//Nexus/Maven upload settings
apply plugin: "com.bmuschko.nexus"
//ext { - all moved to buildSrc
// libraries = [
// kotlin_stdlib: "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion",
// kotlin_stdlib_common: "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlinVersion",
// kotlin_stdlib_js: "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlinVersion",
//
// kotlin_reflect_lib: "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion",
//
// kotlin_test: "org.jetbrains.kotlin:kotlin-test:$kotlinVersion",
// kotlin_test_common: "org.jetbrains.kotlin:kotlin-test-common:$kotlinVersion",
// kotlin_test_js: "org.jetbrains.kotlin:kotlin-test-js:$kotlinVersion",
// kotlin_test_annotations_common: "org.jetbrains.kotlin:kotlin-test-annotations-common:$kotlinVersion",
//
// kotlin_test_junit: "org.jetbrains.kotlin:kotlin-test-junit:$kotlinVersion",
// ]
//}
allprojects {
group "nz.salect.objJSON"
version Share.version
repositories {
jcenter()
mavenCentral()
}
modifyPom {
project {
name "objJSON"
description "A JSON serialization library fully implemented in Kotlin."
url "https://bitbucket.org/objdict/objjson"
inceptionYear "2016"
scm {
url "https://bitbucket.org/objdict/objjson"
connection "scm:https://bitbucket.org/objdict/objjson.git"
developerConnection "scm:git://bitbucket.org/objdict/objjson.git"
}
licenses {
license {
name "The Apache Software License, Version 2.0"
url "http://www.apache.org/licenses/LICENSE-2.0.txt"
distribution "repo"
}
}
developers {
developer {
id "xxx"
name "xxx"
email "xxx"
}
}
}
}
extraArchive {
sources = true
tests = true
javadoc = true
}
nexus {
sign = true
repositoryUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
snapshotRepositoryUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
}
//End Nexus/Maven upload settings
}
nexusStaging {
packageGroup = "nz.salect"
}
repositories {
mavenCentral()
}
kotlin {
targets {
fromPreset(presets.jvm, "jvm") {
mavenPublication {
artifactId = "objjson-jvm"
}
}
fromPreset(presets.js, "js") {
mavenPublication {
artifactId = "objjson-js"
}
}
// For ARM, preset should be changed to presets.iosArm32 or presets.iosArm64
// For Linux, preset should be changed to e.g. presets.linuxX64
// For MacOS, preset should be changed to e.g. presets.macosX64
//fromPreset(presets.mingwX64, "mingw")
}
sourceSets {
commonMain {
dependencies {
implementation("$Libraries.kotlin_stdlib_common")
implementation("$Libraries.kotlin_reflect_lib")
}
}
commonTest {
dependencies {
implementation("$Libraries.kotlin_test_common")
implementation("$Libraries.kotlin_test_annotations_common")
}
}
jvmMain {
dependencies {
implementation("$Libraries.kotlin_stdlib")
implementation("$Libraries.kotlin_reflect_lib")
}
}
jvmTest {
dependencies {
implementation("$Libraries.kotlin_test")
implementation("$Libraries.kotlin_test_junit")
}
}
jsMain {
dependencies {
implementation("$Libraries.kotlin_stdlib_js")
}
}
jsTest {
dependencies {
implementation("$Libraries.kotlin_test_js")
}
}
mingwMain {
}
mingwTest {
}
}
}

Resources