russhwolf
12/16/2018, 11:35 PMdigital.wup.android-maven-publish
to publish the android part of a kotlin-multiplatform
project. It’s not clear to me how that can be consumed by another kotlin-multiplatform
project. Is there a sample of that anywhere?FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all files for configuration ':app:debugCompileClasspath'.
> Could not resolve com.example:AndroidLibraryDemo-android:0.0.1.
Required by:
project :app
> Unable to find a matching configuration of com.example:AndroidLibraryDemo-android:0.0.1: Configuration 'metadata-api':
- Found artifactType 'jar' but wasn't required.
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' but no value provided.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but no value provided.
- Found org.gradle.status 'release' but wasn't required.
- Required org.gradle.usage 'java-api' and found incompatible value 'kotlin-api'.
- Required org.jetbrains.kotlin.platform.type 'androidJvm' and found incompatible value 'common'.
> Could not resolve com.example:AndroidLibraryDemo:0.0.1.
Required by:
project :app
> Unable to find a matching configuration of com.example:AndroidLibraryDemo:0.0.1:
- Configuration 'ios-api':
- Found artifactType 'org.jetbrains.kotlin.klib' but wasn't required.
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' but no value provided.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but no value provided.
- Found org.gradle.status 'release' but wasn't required.
- Required org.gradle.usage 'java-api' and found incompatible value 'kotlin-api'.
- Found org.jetbrains.kotlin.native.target 'ios_x64' but wasn't required.
- Required org.jetbrains.kotlin.platform.type 'androidJvm' and found incompatible value 'native'.
- Configuration 'js-api':
- Found artifactType 'jar' but wasn't required.
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' but no value provided.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but no value provided.
- Found org.gradle.status 'release' but wasn't required.
- Required org.gradle.usage 'java-api' and found incompatible value 'kotlin-api'.
- Required org.jetbrains.kotlin.platform.type 'androidJvm' and found incompatible value 'js'.
- Configuration 'js-runtime':
- Found artifactType 'jar' but wasn't required.
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' but no value provided.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but no value provided.
- Found org.gradle.status 'release' but wasn't required.
- Required org.gradle.usage 'java-api' and found incompatible value 'kotlin-runtime'.
- Required org.jetbrains.kotlin.platform.type 'androidJvm' and found incompatible value 'js'.
- Configuration 'metadata-api':
- Found artifactType 'jar' but wasn't required.
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' but no value provided.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but no value provided.
- Found org.gradle.status 'release' but wasn't required.
- Required org.gradle.usage 'java-api' and found incompatible value 'kotlin-api'.
- Required org.jetbrains.kotlin.platform.type 'androidJvm' and found incompatible value 'common'.
~/.m2/repository/...
, but I don't understand how to reference it from the consuming module (eg an app which is using the library)drew
12/17/2018, 5:40 PM-patched
here: https://github.com/russhwolf/AndroidLibDemo/blob/50471065089ce70c31e9c4b006f1d3925d491769/build.gradle#L93), this may solve your issue. When you publish both the original android artifact and the custom one will be published. Consuming the custom artifact should work so far as that the library can be pulled.publications {
// Patch for MPP Android publishing
// <https://youtrack.jetbrains.com/issue/KT-27535>
// <https://kotlinlang.slack.com/archives/C3PQML5NU/p1543936551055500?thread_ts=1543861394.034600&cid=C3PQML5NU>
if (includeAndroid) {
mavenAar(MavenPublication) {
artifactId = project.name + '-android-patched'
from components.android
artifact("$buildDir/outputs/aar/${project.name}-release.aar")
artifacts.removeAll(artifacts.matching { !it.file.name.endsWith('aar') })
pom.withXml {
def dependenciesNode = asNode().appendNode('dependencies')
configurations.implementation.allDependencies.each {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
dependencyNode.appendNode('scope', 'compile')
}
}
}
}
}
russhwolf
12/17/2018, 5:44 PM-android-patched
rather than just -android
. It's strange to me that that would matter but I definitely don't have a deep understanding of this stuff. I'll give it a try when I get a chance.drew
12/17/2018, 5:54 PMjosephivie
12/17/2018, 6:48 PMapply plugin: 'digital.wup.android-maven-publish'
task androidSourceJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier "sources"
}
publishing {
publications {
mavenAar(MavenPublication) {
artifactId = project.name + "-android"
from components.android
artifacts.removeAll { it.file.name.endsWith('jar') }
artifact androidSourceJar
}
}
}
api 'com.lightningkite:koolui-android:0.0.2'
drew
12/17/2018, 10:52 PMjosephivie
12/17/2018, 10:53 PMapply plugin: 'digital.wup.android-maven-publish'
drew
12/17/2018, 10:54 PMjosephivie
12/17/2018, 10:54 PMdrew
12/17/2018, 10:55 PM