简体   繁体   中英

Generate different artifactId when publish library in android

Hey I am publish library in kotlin multiplatform. I used this command ./gradlew clean assemble publish my three package is generated. I given the name var libraryArtifactId = "kmm-module" but I don't understand why other name is coming from.

1st package name is com.vivek.kmm-module

2nd package name is com.vivek.kotlinproject-android-debug

3rd package name is com.vivek.kotlinproject-android

I understand 1st package name, but I am not understanding where the 2nd and 3rd artificatId coming from?

build.gradle.kts

plugins {
    kotlin("multiplatform") version "1.6.21"
    id("com.android.library")
    id("maven-publish")
}

val libraryVersion = "0.0.1"
var libraryGroup = "com.vivek"
var libraryArtifactId = "kmm-module"

repositories {
    google()
    mavenCentral()
}

kotlin {
    android {
        publishLibraryVariants("release", "debug")
    }
    sourceSets {
        val commonMain by getting
        val androidMain by getting
    }
}

android {
    compileSdk = 21
    sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
    defaultConfig {
        minSdk = 21
        targetSdk = 31
    }
    @Suppress("UnstableApiUsage") compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
}

publishing {
    publications {
        group = libraryGroup
        publications.withType<MavenPublication> {
            groupId = libraryGroup
            artifactId = libraryArtifactId
            version = libraryVersion
        }

        repositories {
            maven {
                url = uri("https://maven.pkg.github.com/vivek-modi/kotlinmultiplatfromproject")
                credentials {
                    username = (System.getenv("GITHUB_USER") ?: project.properties["GITHUB_USER"]).toString()
                    password = (System.getenv("GITHUB_PERSONAL_ACCESS_TOKEN") ?: project.properties["GITHUB_PERSONAL_ACCESS_TOKEN"]).toString()
                }
            }
        }
    }
}

I am adding my github repository . I used github packages for publishing library. Thanks

在此处输入图像描述

you can remove this line to avoid the android artifact.

    android {
        publishLibraryVariants("release", "debug")
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM