My OSS Java library has a -kt
(Kotlin extension functions) variant module. When I publish to Maven, there are no build errors and it creates the artifacts I would expect.
I published this to Maven Central before discovering the issue. Is still occurs when publishing to Maven local.
The issue is that in projects that try to use the library as a dependency, Maven has the error that it cannot be resolved. If I use the non-kt version of the library as a dependency, it’s fine. I have verified in my local Maven directory that the artifact exists.
I’m at a complete loss. If the artifact exists and the error says it cannot be resolved, I am guessing the actual problem is manifesting as a different error. I’m not sure where to begin looking for what the actual issue might be. Am I missing some configuration for the Kotlin module for it to function as a Maven library?
// Resolves:
implementation "com.cyphercove.gdxtween:gdxtween:0.1.7"
// Doesn't resolve:
implementation "com.cyphercove.gdxtween:gdxtween-kt:0.1.7"
Here’s are my Gradle configurations for the project and the -kt
module, respectively:
plugins {
id 'java'
id 'java-library'
id 'maven-publish'
id 'signing'
}
project.ext {
librarySubProjects = subprojects.findAll{
it.name == 'gdxtween' || it.name == 'gdxtween-kt'
}
}
subprojects {
apply plugin: "idea"
apply plugin: "java"
group = libraryGroup
version = libraryVersion
repositories {
mavenLocal()
mavenCentral()
maven { url = "https://jitpack.io" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
dependencies {
implementation "com.badlogicgames.gdx:gdx:$gdxVersion"
}
}
publishing {
repositories {
maven {
name = "OSSRH"
url = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
credentials {
username = System.getenv("SONATYPE_USERNAME")
password = System.getenv("SONATYPE_PASSWORD")
}
}
}
}
configure(project.librarySubProjects) {
apply plugin: "java-library"
task sourcesJar(type: Jar) {
from sourceSets.main.allSource
archiveClassifier = 'sources'
}
task javadocJar(type: Jar) {
from javadoc
archiveClassifier = 'javadoc'
}
publishing {
publications {
"$projectId"(MavenPublication) {
groupId = libraryGroup
artifactId = projectId
version = libraryVersion
from components.java
artifact sourcesJar
artifact javadocJar
pom {
name = projectId
description = projectDescription
url = 'https://github.com/CypherCove/gdx-tween'
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
organization {
name = 'Cypher Cove'
url = 'www.cyphercove.com'
}
developers {
developer {
id = 'cypher-cove'
name = 'Cypher Cove'
email = 'contact@cyphercove.com'
}
}
scm {
connection = 'scm:git:git@github.com:cyphercove/gdx-tween.git'
developerConnection = 'scm:git:git@cyphercove/gdx-tween.git'
url = 'https://github.com/cyphercove/gdx-tween/'
}
}
}
}
}
signing {
sign publishing.publications."$projectId"
}
javadoc {
if(JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
}
}
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.8.20'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
compileKotlin {
compilerOptions {
jvmTarget = JvmTarget.JVM_1_8
}
}