https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
a

Andrei Marshalov

05/13/2020, 8:11 AM
Hello, I’m using
maven-publish
to publish my multiplatphorm library to
maven
repo. My publishing config looks like:
Copy code
project.afterEvaluate {
    publishing {
        publications {
            create<MavenPublication>("maven") {
                groupId = projectGroup
                artifactId = projectArtifactName
                version = "${android.defaultConfig.versionName}"

                tasks.getByName("bundle${buildType.capitalize()}Aar").outputs.files.forEach {
                    artifact(it)
                }
            }
        }

        repositories {
            mavenLocal()
        }
    }
}
As a result of publishing i get several modules:
Copy code
└── repository
    └── com
        └── example
            ├── lib-ios
            │   ├── 1.0.0
            ├── lib-iossim
            │   ├── 1.0.0
            ├── lib-macos
            │   ├── 1.0.0
            ├── lib-metadata
            │   ├── 1.0.0
            └── lib
                ├── 1.0.0
After that i use this library in Android app as:
Copy code
dependencies {
    implementation("com.example:lib:1.0.0")
}
So it looks like i need to publish to
maven
only Android part of my library, since i use
carthage
to publish iOS part. How can i skip all target except Android for my publication?
https://stackoverflow.com/questions/61769633/how-can-i-skip-all-target-except-android-for-multiplatform-kotlin-library-public/61770317#61770317
Check your grade > lib > publishing tasks. There should be:
PublishAndroidPublicationToMavenLocal
 and
PublishAndroidPublicationToMavenRepository
This should publish only Android part of the library.
Looks like a good solution
k

Kris Wong

05/13/2020, 12:44 PM
only specify the Android publications in your maven repo configuration
looks like this for Artifactory:
Copy code
defaults(delegateClosureOf<groovy.lang.GroovyObject> {
            invokeMethod("publications", arrayOf("androidDebug", "androidRelease"))
        })
a

Andrei Marshalov

05/13/2020, 3:45 PM
Thank you, I’ll try!
3 Views