Raed Ghazal
01/03/2024, 9:28 AMCLOVIS
01/03/2024, 9:38 AMRaed Ghazal
01/03/2024, 9:39 AMRaed Ghazal
01/03/2024, 9:39 AMCLOVIS
01/03/2024, 9:40 AMincludeBuild("../path/to/the/library")
in the downstream project's settings.gradle.kts
Reload IDEA, and it will recognize both projects together (so you can control click on a symbol of the library to get to it and edit its code)CLOVIS
01/03/2024, 9:43 AMCLOVIS
01/03/2024, 9:45 AM./gradlew publishToMavenLocal
and then add
repositories {
mavenCentral()
mavenLocal()
}
to all modules of the downstream project, and change the version number to match whatever you published it as.
However, this is exactly how an external repository would act, so each time you change the library you have to re-publish it with the same version number, etc
This way is more useful to debug "why isn't that file included in the maven repository", while the includBuild
way is more useful for "ah, there's a bug in one of my functions and I want an actual example to see how it happens"Raed Ghazal
01/03/2024, 9:46 AMRaed Ghazal
01/03/2024, 9:47 AMCLOVIS
01/03/2024, 9:47 AMRaed Ghazal
01/03/2024, 9:48 AMCLOVIS
01/03/2024, 9:48 AMRaed Ghazal
01/03/2024, 9:48 AMandroid-library
plugin from the library but I need to checkRaed Ghazal
01/03/2024, 9:49 AMGradle slack itselfdidn’t know they have slack 👀 good to know!
CLOVIS
01/03/2024, 9:49 AMRaed Ghazal
01/03/2024, 9:50 AMCLOVIS
01/03/2024, 9:51 AMkotlin {
jvm()
}
or
kotlin {
android()
}
?Raed Ghazal
01/03/2024, 9:51 AMkotlin {
androidTarget {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
}
}
}
iosX64()
iosArm64()
iosSimulatorArm64()
cocoapods {
summary = "Some description for the Shared Module"
homepage = "Link to the Shared Module homepage"
version = "1.0"
ios.deploymentTarget = "16.0"
framework {
baseName = "shared"
isStatic = true
}
}
sourceSets {
commonMain.dependencies {
implementation(commonlibs.kotlinx.datetime)
}
commonTest.dependencies {
implementation(libs.kotlin.test)
}
}
}
CLOVIS
01/03/2024, 9:51 AMandroid
in their nameRaed Ghazal
01/03/2024, 9:52 AMRaed Ghazal
01/03/2024, 9:53 AMCLOVIS
01/03/2024, 9:54 AM- Variant 'SOME NAME'
is the start of a decision block. You can ignore all variants that don't have 'android' or 'jvm' in their name, since it's complaining about not finding an Android variant, so it's normal all the others failRaed Ghazal
01/03/2024, 9:54 AM- Doesn't say anything about com.android.build.api.attributes.AgpVersionAttr (required '8.1.0')
- Doesn't say anything about com.android.build.api.attributes.BuildTypeAttr (required 'debug')
- Doesn't say anything about its target Java environment (preferred optimized for Android)
CLOVIS
01/03/2024, 9:55 AMCLOVIS
01/03/2024, 9:55 AMRaed Ghazal
01/03/2024, 9:56 AMCLOVIS
01/03/2024, 9:57 AMRaed Ghazal
01/03/2024, 9:57 AM- Variant
162 are iosSomething
and 36 are metadataSomething
CLOVIS
01/03/2024, 9:57 AMCLOVIS
01/03/2024, 9:57 AMRaed Ghazal
01/03/2024, 9:57 AMWell that answers that, the Android variant is not publishedany idea why that might be the case?
Raed Ghazal
01/03/2024, 9:57 AM198 ?? 😅told ya, 20 pages long 😅
CLOVIS
01/03/2024, 9:59 AM./gradlew publishToMavenLocal
and open ~/.m2/repository/
you should find all the binaries it produced, there should be one per module × each platform it supports.
It's probably something in the config of maven-publish
(the publishing
block), but you're probably better off creating a new thread so other people look at itRaed Ghazal
01/03/2024, 9:59 AMplugins {
//trick: for the same plugin versions in all sub-modules
alias(libs.plugins.androidLibrary).apply(false)
alias(libs.plugins.kotlinMultiplatform).apply(false)
alias(libs.plugins.kotlinCocoapods).apply(false)
alias(libs.plugins.kotlinAndroid).apply(false)
alias(libs.plugins.mavenPublish).apply(false)
}
shared’s build.gradle file
plugins {
alias(libs.plugins.kotlinMultiplatform)
alias(libs.plugins.kotlinCocoapods)
alias(libs.plugins.androidLibrary)
alias(libs.plugins.mavenPublish)
}
mavenPublishing {
publishToMavenCentral(com.vanniktech.maven.publish.SonatypeHost.S01)
signAllPublications()
coordinates("com.raedghazal", "kotlinx_datetime_ext", "1.0.0")
pom {
name.set("Kotlinx datetime ext")
description.set("A KMM library that provides extensions and helper functions for kotlinx-datetime ")
inceptionYear.set("2023")
url.set("<https://github.com/RaedGhazal/kmm-kotlinx-datetime-ext>")
developers {
developer {
id.set("RaedGhazal")
name.set("Raed Ghazal")
url.set("<https://github.com/RaedGhazal>")
}
}
licenses {
license {
name.set("MIT License")
url.set("<https://opensource.org/license/mit/>")
distribution.set("<https://opensource.org/license/mit/>")
}
}
scm {
url.set("<https://github.com/RaedGhazal>")
connection.set("scm:git:<git://github.com/RaedGhazal/kmm-kotlinx-datetime-ext.git>")
developerConnection.set("scm:git:<ssh://git@github.com/RaedGhazal/kmm-kotlinx-datetime-ext.git>")
}
}
}
kotlin {
androidTarget {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
}
}
}
iosX64()
iosArm64()
iosSimulatorArm64()
cocoapods {
summary = "Some description for the Shared Module"
homepage = "Link to the Shared Module homepage"
version = "1.0"
ios.deploymentTarget = "16.0"
framework {
baseName = "shared"
isStatic = true
}
}
sourceSets {
commonMain.dependencies {
implementation(commonlibs.kotlinx.datetime)
}
commonTest.dependencies {
implementation(libs.kotlin.test)
}
}
}
android {
namespace = "com.raedghazal.kotlinx_datetime_ext"
compileSdk = 34
defaultConfig {
minSdk = 26
}
}
dependencies {
implementation(commonlibs.androidx.core.ktx)
}
ephemient
01/04/2024, 3:04 AMephemient
01/04/2024, 3:04 AMRaed Ghazal
01/04/2024, 8:33 AM