Closed abrolrahul closed 2 years ago
Can you share your build files?
build.gradle.kts
buildscript {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
dependencies {
classpath(Libraries.gradle)
classpath(Libraries.tools)
classpath(Libraries.serialization)
classpath("com.vanniktech:gradle-maven-publish-plugin:0.18.0")
}
}
repositories {
mavenCentral()
google()
}
plugins {
id("com.diffplug.spotless")
.version(Versions.spotless)
id("org.owasp.dependencycheck")
.version(Versions.owasp)
}
val cvssScore get() = (System.getenv("cvssScore") ?: "11.0").toFloat()
val autoUpdate get() = (System.getenv("autoUpdate") ?: "true").toBoolean()
dependencyCheck {
failBuildOnCVSS = cvssScore
autoUpdate = autoUpdate
suppressionFile = "$rootDir/owasp/suppressions.xml"
}
allprojects {
apply(plugin = "com.diffplug.spotless")
spotless {
kotlin {
target("**/*.kt")
ktlint(Versions.ktlint).userData(mapOf("disabled_rules" to "no-wildcard-imports,no-unused-imports"))
}
kotlinGradle {
target("*.gradle.kts", "additionalScripts/*.gradle.kts")
ktlint()
}
}
subprojects {
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().all {
kotlinOptions {
allWarningsAsErrors = true
jvmTarget = "11"
}
}
}
}
shared/build.gradle.kts
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import java.util.Properties
plugins {
kotlin("multiplatform")
id("com.android.library")
id("kotlinx-serialization")
id("com.vanniktech.maven.publish")
}
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
val versionName: Any
get() = findProperty("VERSION_NAME") as Any
val githubPackagesUrl: String?
get() = findProperty("POM_URL") as String?
val pomGroupId: String?
get() = findProperty("GROUP") as String?
val localProperties = Properties()
version = versionName
kotlin {
android {
publishLibraryVariants("release")
}
targets.all {
compilations.all {
kotlinOptions {
allWarningsAsErrors = true
}
}
}
android()
ios {
binaries {
framework {
baseName = "shared" // TODO: proper library name
}
}
}
sourceSets {
all {
languageSettings.apply {
optIn("kotlin.RequiresOptIn")
optIn("kotlinx.coroutines.ExperimentalCoroutinesApi")
}
}
val commonMain by getting {
dependencies {
implementation(Libraries.Ktor.commonCore)
implementation(Libraries.Ktor.commonJson)
implementation(Libraries.Ktor.commonLogging)
implementation(Libraries.Ktor.commonSerialization)
implementation(Libraries.Coroutines.common) {
version {
strictly(Versions.coroutines)
}
}
implementation(Libraries.napier)
implementation(Libraries.serializationRuntime)
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
val androidMain by getting {
dependencies {
implementation(Libraries.Android.material)
implementation(Libraries.Ktor.jvmCore)
implementation(Libraries.Ktor.jvmJson)
implementation(Libraries.Ktor.jvmLogging)
implementation(Libraries.Coroutines.android)
implementation(Libraries.Ktor.androidSerialization)
implementation(Libraries.Ktor.okhttp)
implementation(Libraries.Ktor.cio)
}
}
val androidTest by getting {
dependencies {
implementation(kotlin("test-junit"))
implementation(Libraries.Testing.junit)
implementation(Libraries.Coroutines.test)
}
}
val iosMain by getting {
dependencies {
implementation(Libraries.Ktor.ios)
implementation(Libraries.Coroutines.common) {
version {
strictly(Versions.coroutines)
}
}
}
}
val iosTest by getting
}
}
android {
compileSdk = Versions.compileSdk
buildToolsVersion = Versions.buildTools
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
defaultConfig {
minSdk = Versions.minSdk
targetSdk = Versions.targetSdk
consumerProguardFiles("consumer-rules.pro")
}
buildTypes {
getByName("release") {
isMinifyEnabled = false
}
}
buildFeatures {
buildConfig = false
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
}
mavenPublish {
releaseSigningEnabled = false
sonatypeHost = null
}
extensions.getByType<PublishingExtension>().apply {
publications {
all {
if (this !is MavenPublication) {
println("this is not a maven publication $this")
return@all
}
groupId = pomGroupId
}
}
repositories {
maven {
setUrl(githubPackagesUrl!!)
credentials {
username = localProperties["gpr.usr"]?.toString() ?: System.getenv("GPR_USER")
password = localProperties["gpr.key"]?.toString() ?: System.getenv("GPR_API_KEY")
}
}
}
}
val packForXcode by tasks.creating(Sync::class) {
group = "build"
val mode = System.getenv("CONFIGURATION") ?: "DEBUG"
val sdkName = System.getenv("SDK_NAME") ?: "iphonesimulator"
val targetName = "ios" + if (sdkName.startsWith("iphoneos")) "Arm64" else "X64"
val framework =
kotlin.targets.getByName<KotlinNativeTarget>(targetName).binaries.getFramework(mode)
inputs.property("mode", mode)
dependsOn(framework.linkTask)
val targetDir = File(buildDir, "xcode-frameworks")
from({ framework.outputDirectory })
into(targetDir)
}
tasks.getByName("build").dependsOn(packForXcode)
shared/gradle.properties
#Vanniktech Maven Publish
POM_ARTIFACT_ID=graphql
POM_NAME=GraphQL
POM_PACKAGING=aar
VERSION_NAME=1.0.3
gradle.properties
#Vanniktech Maven Publish
GROUP=com.*****
POM_DESCRIPTION=A modern api for GraphQL Client
POM_URL=*******
POM_LICENCE_NAME=The Apache Software License, Version 2.0
POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
POM_LICENCE_DIST=repo
POM_DEVELOPER_ID=priceline
POM_DEVELOPER_NAME=Priceline, Inc.
RELEASE_SIGNING_ENABLED=false
@gabrielittner Please look into it.
From #330 I assume this issue was resolved?
Hi there, First of all thanks for this amazing plugin. I am facing an issue with my Kotlin Multiplatform Project while uploading aar to Github packages. I am able to successfully run the command
./gradlew clean publish --no-daemon --no-parallel --warning-mode all
but the aar files are not found in GitHub packages.Please help me to fix this issue.