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

Unable to publish .aar when jvm publication is included in Kotlin Multiplatform library #705

Closed
y9vad9 opened this issue Jan 6, 2024 · 3 comments · Fixed by #736
Closed
Labels

Comments

@y9vad9
Copy link

y9vad9 commented Jan 6, 2024

Versions

Kotlin version: 1.9.202.0.0-Beta2
Publish plugin version: 0.25.30.26.0
Gradle version: 8.5

Description

I'm trying to publish my library with three targets: js, jvm and android, but android target is not publishing while jvm is included. When I remove jvm from the build, android target seems to be publishing normally.

build.gradle.kts
import org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode

plugins {
    kotlin("multiplatform")
    id("com.android.library")
    id("com.vanniktech.maven.publish")
}

kotlin {
    jvm {
        testRuns.named("test") {
            executionTask.configure {
                useJUnitPlatform()
            }
        }
    }

    androidTarget()

    js {
        browser {
            commonWebpackConfig {
                cssSupport {
                    enabled.set(true)
                }
            }
        }
    }
    jvmToolchain(11)

    explicitApi = ExplicitApiMode.Strict
}


android {
    compileSdk = libs.versions.android.compile.sdk.get().toInt()
    namespace = "io.timemates.credentials"

    defaultConfig {
        minSdk = libs.versions.android.min.sdk.get().toInt()
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_11
        targetCompatibility = JavaVersion.VERSION_11
    }
}

mavenPublishing {
    coordinates(
        groupId = "io.timemates.credentials",
        artifactId = "credentials-manager",
        version = System.getenv("LIB_VERSION") ?: return@mavenPublishing,
    )

    pom {
       // ommited
    }
}

publishing {
    repositories {
        maven {
            name = "TimeMates"

            url = uri(
                "sftp://${System.getenv("SSH_HOST")}:22/${System.getenv("SSH_DEPLOY_PATH")}"
            )

            credentials {
                username = System.getenv("SSH_USER")
                password = System.getenv("SSH_PASSWORD")
            }
        }
    }
}

Steps to reproduce

  1. Open project from sources.
  2. Run publishToMavenLocal/ publishAllPublicationsTo.. / publish (but needs configuration, result is the same)
  3. Check maven local folder for .aar

  1. Remove jvm from build as a target
  2. Publish again and check maven local folder
@gabrielittner
Copy link
Collaborator

You need to enable publishing for the Android target inside the Kotlin DSL: https://kotlinlang.org/docs/multiplatform-publish-lib.html#publish-an-android-library

We can add this directly to the plugin though so that it won't be needed anymore in the future.

@y9vad9
Copy link
Author

y9vad9 commented Jan 8, 2024

You need to enable publishing for the Android target inside the Kotlin DSL: https://kotlinlang.org/docs/multiplatform-publish-lib.html#publish-an-android-library

We can add this directly to the plugin though so that it won't be needed anymore in the future.

Oh, thanks. But yet no answer why does it work without jvm subsystem included 👀.

Anyway, would be great to have it by default

@gabrielittner
Copy link
Collaborator

Maybe the Kotlin Multiplatform plugin automatically enables the Android publishing if there is no jvm target. Either way I'll add this in the next release so that it'll always work by default

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants