Skip to content

Commit

Permalink
Manual Config
Browse files Browse the repository at this point in the history
  • Loading branch information
TheArchitect123 committed Jan 28, 2025
1 parent 89765e4 commit 8e74a49
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 78 deletions.
12 changes: 9 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#Gradle
org.gradle.jvmargs=-Xmx2048M -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options\="-Xmx2048M" -Djansi.tmpdir=/tmp
org.gradle.jvmargs=-Xmx2048M -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options\="-Xmx2048M"
org.gradle.caching=true
org.gradle.configuration-cache=false
org.gradle.configuration-cache=true
org.gradle.configureondemand=false
org.gradle.parallel=true

#Kotlin
kotlin.code.style=official
Expand All @@ -10,4 +12,8 @@ kotlin.code.style=official
android.useAndroidX=true
android.enableJetifier=true
android.nonTransitiveRClass=true
kotlin.mpp.enableCInteropCommonization=true
kotlin.mpp.enableCInteropCommonization=true
kotlin.mpp.stability.nowarn=true
kotlin.native.cacheKind.iosX64=none
kotlin.native.cacheKind.iosSimulatorArm64=none
kotlin.native.disableCompilerDaemon=true
153 changes: 78 additions & 75 deletions shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ plugins {

id("org.gradle.maven-publish")
id("signing")
id("com.vanniktech.maven.publish") version "0.30.0"
id("maven-publish")
id("com.vanniktech.maven.publish") version "0.28.0"

kotlin("plugin.serialization") version "2.0.0"
id("com.google.devtools.ksp")
Expand All @@ -15,12 +16,6 @@ plugins {

val ktorVersion = "3.0.0"

repositories {
google()
mavenCentral()
gradlePluginPortal()
}

kotlin {
androidTarget {
compilations.all {
Expand All @@ -30,15 +25,18 @@ kotlin {
}
}

// listOf(
// iosArm64(),
// //iosSimulatorArm64() // Uncomment if needed
// ).forEach {
// it.binaries.framework {
// baseName = "shared"
// isStatic = true
// }
// }
// needs to be added into a build pipeline to automate creation of the static libraries (merged universal library)
//lipo -create “libApplicationInsightsObjectiveC.a” “libApplicationInsightsObjectiveC.a” -output “libApplicationInsightsObjectiveC.a”
listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64()
).forEach {
it.binaries.framework {
baseName = "shared"
isStatic = true
}
}

sourceSets {
val commonMain by getting {
Expand All @@ -54,6 +52,7 @@ kotlin {

implementation("io.github.thearchitect123:kmpEssentials:1.8.5")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.0")

}
}

Expand All @@ -64,89 +63,93 @@ kotlin {
}
}

// val iosArm64Main by getting
// // val iosSimulatorArm64Main by getting
// val iosMain by creating {
// dependsOn(commonMain)
// iosArm64Main.dependsOn(this)
// // iosSimulatorArm64Main.dependsOn(this)
// dependencies {
// implementation(libs.ktor.client.darwin)
// }
// }
// // iOS Targets
val iosArm64Main by getting
val iosX64Main by getting
val iosSimulatorArm64Main by getting
val iosMain by creating {
dependsOn(commonMain)
iosX64Main.dependsOn(this)
iosArm64Main.dependsOn(this)
iosSimulatorArm64Main.dependsOn(this)
dependencies {
implementation(libs.ktor.client.darwin)
}
}
}
}

mavenPublishing {
// Automatically configures Sonatype repository and credentials
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)

coordinates(
groupId = "io.github.thearchitect123",
artifactId = "appInsights",
version = "0.7.0"
)

pom {
name.set("KmpAppInsights")
description.set("An AppInsights Client for Kotlin Multiplatform. Supports both iOS & Android")
inceptionYear.set("2024")
url.set("https://github.com/TheArchitect123/KmpAppInsights")

licenses {
license {
name.set("MIT")
url.set("https://opensource.org/licenses/MIT")

afterEvaluate {
mavenPublishing {
// Define coordinates for the published artifact
coordinates(
groupId = "io.github.thearchitect123",
artifactId = "appInsights",
version = "0.6.1"
)

// Configure POM metadata for the published artifact
pom {
name.set("KmpAppInsights")
description.set("An AppInsights Client for Kotlin Multiplatform. Supports both iOS & Android")
inceptionYear.set("2024")
url.set("https://github.com/TheArchitect123/KmpAppInsights")

licenses {
license {
name.set("MIT")
url.set("https://opensource.org/licenses/MIT")
}
}
}

developers {
developer {
id.set("Dan Gerchcovich")
name.set("TheArchitect123")
email.set("[email protected]")
// Specify developers information
developers {
developer {
id.set("Dan Gerchcovich")
name.set("TheArchitect123")
email.set("[email protected]")
}
}
}

scm {
connection.set("scm:git:git://github.com/TheArchitect123/KmpAppInsights.git")
developerConnection.set("scm:git:ssh://git@github.com:TheArchitect123/KmpAppInsights.git")
url.set("https://github.com/TheArchitect123/KmpAppInsights")
// Specify SCM information
scm {
url.set("https://github.com/TheArchitect123/KmpAppInsights")
}
}

// Configure publishing to Maven Central
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)

// Enable GPG signing for all publications
signAllPublications()
}
}

signing {
val privateKey = System.getenv("GPG_PRIVATE_KEY")
val passphrase = System.getenv("GPG_PASSPHRASE")
val privateKeyFile = project.properties["signing.privateKeyFile"] as? String
?: error("No Private key file found")
val passphrase = project.properties["signing.password"] as? String
?: error("No Passphrase found for signing")

if (privateKey.isNullOrBlank() || passphrase.isNullOrBlank()) {
throw GradleException("GPG signing key and passphrase must be provided as environment variables")
}
// Read the private key from the file
val privateKey = File(privateKeyFile).readText(Charsets.UTF_8)

useInMemoryPgpKeys(privateKey, passphrase)
sign(publishing.publications)
}

//tasks.named("sourcesJar").configure { dependsOn(":shared:kspCommonMainKotlinMetadata") }
tasks.register("buildAllPlatformsAndPublish") {
dependsOn(
"clean",
"assembleRelease",
//":shared:linkReleaseFrameworkIosArm64",
":shared:publishToMavenCentral"
)
}

dependencies {
with("de.jensklingenberg.ktorfit:ktorfit-ksp:2.0.1") {
add("kspAndroid", this)
//add("kspIosArm64", this)
//add("kspIosSimulatorArm64", this)
//add("kspIosX64", this)
add("kspIosArm64", this)
add("kspIosSimulatorArm64", this)
add("kspIosX64", this)
}
}

tasks.named("sourcesJar").configure { dependsOn(":shared:kspCommonMainKotlinMetadata") }

ksp {
arg("moduleName", project.name)
}
Expand Down

0 comments on commit 8e74a49

Please sign in to comment.