Ashu Tyagi
03/21/2023, 1:51 PMshared:commonMain
) & published it as a package on Github packages.
Then I added it as a gradle dependency in my commonMain but it is not accessible in my project's commonMain package.
It is accessible in the androidMain package. I guess the reason is the artifact is being published as .arr
Any idea on how to fix this? I want to be able to access the published library from commonMain.mkrussel
03/21/2023, 1:52 PMAshu Tyagi
03/21/2023, 1:53 PMmkrussel
03/21/2023, 1:54 PMPablichjenkov
03/21/2023, 1:57 PMmkrussel
03/21/2023, 1:58 PMAshu Tyagi
03/21/2023, 1:59 PMmkrussel
03/21/2023, 1:59 PMPablichjenkov
03/21/2023, 2:00 PMAshu Tyagi
03/21/2023, 2:01 PMPablichjenkov
03/21/2023, 2:02 PMAshu Tyagi
03/21/2023, 2:10 PMimport java.io.FileInputStream
import java.util.*
@Suppress("DSL_SCOPE_VIOLATION")
plugins {
alias(libs.plugins.gradleVersions)
alias(libs.plugins.kotlinSerialization)
id("com.android.library") version libs.versions.android.gradle.plugin.get() apply false
kotlin("multiplatform") version libs.versions.kotlin.get() apply false
id("maven-publish")
}
val properties = File(rootDir, "gradle.properties").inputStream().use {
Properties().apply { load(it) }
}
val githubProperties = Properties()
githubProperties.load(FileInputStream(rootProject.file("github.properties")))
fun getLibGroupId(): String = "com.internal.library"
fun getLibArtifactId(): String = "core-network"
fun getLibVersion(): String = "0.0.1"
allprojects {
repositories {
google()
mavenCentral()
}
}
tasks.register("clean", Delete::class) {
delete(rootProject.buildDir)
}
afterEvaluate {
publishing {
publications {
create<MavenPublication>("release") {
run {
groupId = getLibGroupId()
artifactId = getLibArtifactId()
version = getLibVersion()
artifact("$rootDir/shared/build/outputs/aar/shared-release.aar")
}
}
}
repositories {
maven {
name = "GitHubPackages"
url = uri("<https://maven.pkg.github.com/Demo/Core-Network>")
credentials {
username = githubProperties.getProperty("gprUser") ?: System.getenv("GPR_USER")
password =
githubProperties.getProperty("gprKey") ?: System.getenv("GPR_API_KEY")
}
}
}
}
}
mkrussel
03/21/2023, 2:15 PMpsh
03/21/2023, 2:15 PM.m2/repository
folder.Ashu Tyagi
03/21/2023, 2:23 PMmkrussel
03/21/2023, 2:31 PMkotlin {
android {
publishLibraryVariants("release", "debug")
}
}
Pablichjenkov
03/21/2023, 2:38 PMmkrussel
03/21/2023, 2:50 PMAshu Tyagi
03/21/2023, 2:54 PMPablichjenkov
03/21/2023, 3:02 PMAshu Tyagi
03/21/2023, 3:19 PMartifact
from the build script then only .pom file is being published, nothing else.mkrussel
03/21/2023, 3:20 PMAshu Tyagi
03/21/2023, 3:20 PMPablichjenkov
03/21/2023, 3:21 PMmkrussel
03/21/2023, 3:24 PMAshu Tyagi
03/21/2023, 3:28 PMAlso, did you apply the maven publish plugin to your shared project?
This was the missing piece. Now everything is working as expected.