Kotlin Multiplatform Library Project Upload Issue - POM Multiple Artifacts - gradle

We have a Kotlin multi-platform library project with a build script which builds for various platforms, i.e. common, JS & JVM, using the "old-style" sub-project structure and processes. Under this system, the artifacts produced can be successfully uploaded to our Sonatype Nexus repo (the root build.gradle is included below (1)).
We are now trying to convert to the "new-style" Kotlin multi-platform approach/structure (Building Multiplatform Projects with Gradle), but we are getting the following error when we try to upload the artifacts to the repo (the modified root build.gradle included below (2)):
BUILD FAILED in 0s
8 actionable tasks: 1 executed, 7 up-to-date
A POM cannot have multiple artifacts with the same type and classifier. Already have MavenArtifact objjson-metadata:jar.asc:asc:null, trying to add MavenArtifact objjson-metadata:jar.asc:asc:null.
10:36:52: Task execution finished 'uploadArchives'.
Does anyone know why we get this error?
The settings for each artifact created during the build seem to need to be updated in the script, but we are not sure how to do that.
Thanks in advance!
(1) Original ("old-style" multi-platform) root build.gradle:
buildscript {
ext.kotlinVersion = '1.2.61'
repositories {
jcenter()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath 'com.bmuschko:gradle-nexus-plugin:2.3.1'
}
}
plugins {
id 'io.codearte.nexus-staging' version '0.11.0'
}
allprojects {
group 'nz.salect.objJSON'
version '0.24-SNAPSHOT'
}
ext {
libraries = [
kotlin_stdlib : "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion",
kotlin_stdlib_common : "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlinVersion",
kotlin_stdlib_js : "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlinVersion",
kotlin_reflect_lib : "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion",
kotlin_test : "org.jetbrains.kotlin:kotlin-test:$kotlinVersion",
kotlin_test_common : "org.jetbrains.kotlin:kotlin-test-common:$kotlinVersion",
kotlin_test_js : "org.jetbrains.kotlin:kotlin-test-js:$kotlinVersion",
kotlin_test_annotations_common: "org.jetbrains.kotlin:kotlin-test-annotations-common:$kotlinVersion",
kotlin_test_junit : "org.jetbrains.kotlin:kotlin-test-junit:$kotlinVersion",
]
}
subprojects {
repositories {
jcenter()
mavenCentral()
}
//Nexus/Maven upload settings
apply plugin: 'com.bmuschko.nexus'
modifyPom {
project {
name 'objJSON'
description 'A JSON serialization library fully implemented in Kotlin.'
url 'https://bitbucket.org/objdict/objjson'
inceptionYear '2016'
scm {
url 'https://bitbucket.org/objdict/objjson'
connection 'scm:https://bitbucket.org/objdict/objjson.git'
developerConnection 'scm:git://bitbucket.org/objdict/objjson.git'
}
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
developers {
developer {
id 'xxx'
name 'xxx'
email 'xxx'
}
}
}
}
extraArchive {
sources = true
tests = true
javadoc = true
}
nexus {
sign = true
repositoryUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
snapshotRepositoryUrl = 'https://oss.sonatype.org/content/repositories/snapshots/'
}
//End Nexus/Maven upload settings
}
nexusStaging {
packageGroup = "nz.salect"
}
(2) Updated ("new-style" multi-platform) root build.gradle:
buildscript {
ext.kotlinVersion = "1.3.11"
repositories {
jcenter()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
classpath("com.bmuschko:gradle-nexus-plugin:2.3.1")
}
}
plugins {
// from the multiplatform reference file
id "kotlin-multiplatform" version "1.3.11"
id "maven-publish"
id "io.codearte.nexus-staging" version "0.11.0"
//Nexus/Maven upload settings
//id "bmuschko.nexus"
}
//Nexus/Maven upload settings
apply plugin: "com.bmuschko.nexus"
//ext { - all moved to buildSrc
// libraries = [
// kotlin_stdlib: "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion",
// kotlin_stdlib_common: "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlinVersion",
// kotlin_stdlib_js: "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlinVersion",
//
// kotlin_reflect_lib: "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion",
//
// kotlin_test: "org.jetbrains.kotlin:kotlin-test:$kotlinVersion",
// kotlin_test_common: "org.jetbrains.kotlin:kotlin-test-common:$kotlinVersion",
// kotlin_test_js: "org.jetbrains.kotlin:kotlin-test-js:$kotlinVersion",
// kotlin_test_annotations_common: "org.jetbrains.kotlin:kotlin-test-annotations-common:$kotlinVersion",
//
// kotlin_test_junit: "org.jetbrains.kotlin:kotlin-test-junit:$kotlinVersion",
// ]
//}
allprojects {
group "nz.salect.objJSON"
version Share.version
repositories {
jcenter()
mavenCentral()
}
modifyPom {
project {
name "objJSON"
description "A JSON serialization library fully implemented in Kotlin."
url "https://bitbucket.org/objdict/objjson"
inceptionYear "2016"
scm {
url "https://bitbucket.org/objdict/objjson"
connection "scm:https://bitbucket.org/objdict/objjson.git"
developerConnection "scm:git://bitbucket.org/objdict/objjson.git"
}
licenses {
license {
name "The Apache Software License, Version 2.0"
url "http://www.apache.org/licenses/LICENSE-2.0.txt"
distribution "repo"
}
}
developers {
developer {
id "xxx"
name "xxx"
email "xxx"
}
}
}
}
extraArchive {
sources = true
tests = true
javadoc = true
}
nexus {
sign = true
repositoryUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
snapshotRepositoryUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
}
//End Nexus/Maven upload settings
}
nexusStaging {
packageGroup = "nz.salect"
}
repositories {
mavenCentral()
}
kotlin {
targets {
fromPreset(presets.jvm, "jvm") {
mavenPublication {
artifactId = "objjson-jvm"
}
}
fromPreset(presets.js, "js") {
mavenPublication {
artifactId = "objjson-js"
}
}
// For ARM, preset should be changed to presets.iosArm32 or presets.iosArm64
// For Linux, preset should be changed to e.g. presets.linuxX64
// For MacOS, preset should be changed to e.g. presets.macosX64
//fromPreset(presets.mingwX64, "mingw")
}
sourceSets {
commonMain {
dependencies {
implementation("$Libraries.kotlin_stdlib_common")
implementation("$Libraries.kotlin_reflect_lib")
}
}
commonTest {
dependencies {
implementation("$Libraries.kotlin_test_common")
implementation("$Libraries.kotlin_test_annotations_common")
}
}
jvmMain {
dependencies {
implementation("$Libraries.kotlin_stdlib")
implementation("$Libraries.kotlin_reflect_lib")
}
}
jvmTest {
dependencies {
implementation("$Libraries.kotlin_test")
implementation("$Libraries.kotlin_test_junit")
}
}
jsMain {
dependencies {
implementation("$Libraries.kotlin_stdlib_js")
}
}
jsTest {
dependencies {
implementation("$Libraries.kotlin_test_js")
}
}
mingwMain {
}
mingwTest {
}
}
}

Related

Signing fails when trying to publish to Maven Central using Sonatype nexus (gradle-nexus.publish-plugin)

I'm trying to publish my library to Maven Central. I already set it up over at Sonatype Nexus, and now I'm trying to hook up Gradle to it (this library depends on Minecraft Forge, so using Maven isn't an option).
I saw that there was a plugin created called Gradle Nexus Publish Plugin and thought I could use it to make publishing easier.
Using the publishAllPublicationsToSonatypeRepository Gradle task, I could publish a repo to Nexus;
But once I call closeSonatypeStagingRepository, it fails with the following error:
Execution failed for task ':signMavenPublication'.
> Could not read PGP secret key
Cause: premature end of stream in PartialInputStream
Now, I added a println to see what key Gradle reads from signingKey, and turns out that no matter what I put there, it always retrieves the same key, even if I put in an invalid key (this is an altered key):
lQWGBGByDfwBDADB5pWxgBT04U0bDIv/Pv0zDEYqKXt2Dubj3RcvCDAveel3eYFt
(The password is being updated though)
Why is this happening?
This is my build.gradle.kts:
import net.minecraftforge.gradle.common.util.ModConfig
import net.minecraftforge.gradle.common.util.RunConfig
import net.minecraftforge.gradle.userdev.UserDevExtension
import java.time.Instant
import java.time.format.DateTimeFormatter
// BuildScript
buildscript {
repositories {
maven(url = "https://maven.minecraftforge.net/")
jcenter()
mavenCentral()
}
dependencies {
classpath(group = "net.minecraftforge.gradle", name = "ForgeGradle", version = "4.1.+")
}
}
plugins {
idea
id("io.github.gradle-nexus.publish-plugin") version "1.0.0"
`java-library`
`maven-publish`
signing
kotlin("jvm") version "1.5.0"
}
apply(plugin = "net.minecraftforge.gradle")
// Config -> Minecraft
val forgeVersion: String by extra
val minecraftVersion: String by extra
val kffVersion: String by extra
val modVersion: String by extra
// JVM Info
println(
"""
Java: ${System.getProperty("java.version")}
JVM: ${System.getProperty("java.vm.version")} (${System.getProperty("java.vendor")})
Arch: ${System.getProperty("os.arch")}
""".trimIndent()
)
// Minecraft
configure<UserDevExtension> {
mappings("official", minecraftVersion)
#Suppress("SpellCheckingInspection")
accessTransformer(file("src/main/resources/META-INF/accesstransformer.cfg"))
runs(closureOf<NamedDomainObjectContainer<RunConfig>> {
create("client") {
workingDirectory(file("run"))
taskName = "client"
// Recommended logging data for a userdev environment
property("forge.logging.markers", "SCAN,REGISTRIES,REGISTRYDUMP")
// Recommended logging level for the console
property("forge.logging.console.level", "debug")
mods(closureOf<NamedDomainObjectContainer<ModConfig>> {
create("loottables") {
source(sourceSets["main"])
}
})
}
create("server") {
workingDirectory(file("run"))
taskName = "server"
// Recommended logging data for a userdev environment
property("forge.logging.markers", "SCAN,REGISTRIES,REGISTRYDUMP")
// Recommended logging level for the console
property("forge.logging.console.level", "debug")
mods(closureOf<NamedDomainObjectContainer<ModConfig>> {
create("loottables") {
source(sourceSets["main"])
}
})
}
create("data") {
workingDirectory(file("run"))
taskName = "datagen"
// Recommended logging data for a userdev environment
property("forge.logging.markers", "SCAN,REGISTRIES,REGISTRYDUMP")
// Recommended logging level for the console
property("forge.logging.console.level", "debug")
// Specify the mod id for data generation, where to output the resulting resource, and where to look for existing resources.
args(
"--mod",
"loottables",
"--all",
"--output",
file("src/generated/resources/"),
"--existing",
file("src/main/resources/")
)
mods(closureOf<NamedDomainObjectContainer<ModConfig>> {
create("loottables") {
source(sourceSets["main"])
}
})
}
})
}
// Minecraft Dependency
// Note: Due to the way kotlin gradle works we need to define the minecraft dependency after we configure Minecraft
dependencies {
"minecraft"(group = "net.minecraftforge", name = "forge", version = "$minecraftVersion-$forgeVersion")
implementation(group = "thedarkcolour", name = "kotlinforforge", version = "latest.release")
testImplementation(
group = "org.jetbrains.kotlin",
name = "kotlin-test-junit5",
version = kotlin.coreLibrariesVersion
)
}
repositories {
maven {
name = "kotlinforforge"
url = uri("https://thedarkcolour.github.io/KotlinForForge/")
}
}
// Setup
project.group = "com.theonlytails"
project.version = modVersion
base.archivesBaseName = "loottables"
// Sets the toolchain to compile against OpenJDK 8
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
vendor.set(JvmVendorSpec.ADOPTOPENJDK)
}
}
// Finalize the jar by re-obfuscating
tasks.named<Jar>("jar") {
// Manifest
manifest {
attributes(
"Specification-Title" to "LootTables",
"Specification-Vendor" to "TheOnlyTails",
"Specification-Version" to "1",
"Implementation-Title" to "LootTables",
"Implementation-Version" to project.version,
"Implementation-Vendor" to "TheOnlyTails",
"Implementation-Timestamp" to DateTimeFormatter.ISO_INSTANT.format(Instant.now()),
"FMLModType" to "LIBRARY"
)
}
#Suppress("SpellCheckingInspection")
finalizedBy("reobfJar")
}
// Publishing to maven central
publishing {
publications {
create<MavenPublication>("maven") {
groupId = "com.theonlytails"
artifactId = "loottables"
version = modVersion
from(components["java"])
pom {
name.set("LootTables")
description.set("A Kotlin DSL for creating loot tables in Minecraft Forge mods")
url.set("https://github.com/theonlytails/loottables")
properties.set(mapOf("project.build.sourceEncoding" to "UTF-8"))
licenses {
license {
name.set("MIT License")
url.set("https://www.opensource.org/licenses/mit-license.php")
distribution.set("repo")
}
}
developers {
developer {
id.set("theonlytails")
name.set("TheOnlyTails")
url.set("https://theonlytails.com/")
}
}
issueManagement {
url.set("https://github.com/theonlytails/loottables/issues")
system.set("GitHub Issues")
}
scm {
connection.set("scm:git:git:github.com/theonlytails/loottables.git")
developerConnection.set("scm:git:git#github.com:theonlytails/loottables.git")
url.set("https://github.com/theonlytails/loottables")
}
}
}
}
}
java {
withJavadocJar()
withSourcesJar()
}
signing {
val signingPassword: String? by extra
val signingKey: String? by extra
println(signingKey) // this is for debbuging purposes only, I'm obviously going to remove this once done
println(signingPassword)
useInMemoryPgpKeys(
signingKey ?: throw GradleException("Couldn't find a signing password"),
signingPassword ?: throw GradleException("Couldn't find a signing key")
)
sign(publishing.publications["maven"])
}
nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
username.set(System.getenv("MAVEN_USERNAME"))
password.set(System.getenv("MAVEN_PASSWORD"))
}
}
}
// Testing
tasks.withType<Test> {
useJUnitPlatform()
}

Could not PUT https://oss.sonatype.org/service/local/staging/deploy/maven2/bom-plugin/

I'm trying to publish my first Gradle plugin to maven central (sonatype), but I'm receiving the following error:
Execution failed for task ':publishBom-pluginPluginMarkerMavenPublicationToMavenRepository'.
> Failed to publish publication 'bom-pluginPluginMarkerMaven' to repository 'maven'
> Could not PUT 'https://oss.sonatype.org/service/local/staging/deploy/maven2/bom-plugin/bom-plugin.gradle.plugin/0.3/bom-plugin.gradle.plugin-0.3.pom'.
Received status code 400 from server: Bad Request
It seems that for some reason, the publishing task is trying to publish my plugin at the root of the sonatype repository, it works when I do execute the task publishToMavenLocal, however, published this strange file in my m2 local: /.m2/repository/bom-plugin/bom-plugin.gradle.plugin and also publish the plugin here /.m2/repository/dev/thiagosouto/bom-plugin/0.3/
I think this is causing the issue but I don't have any clue to solve this problem.
My build.gradle.kts file
plugins {
java
`java-gradle-plugin`
`kotlin-dsl`
`maven-publish`
signing
kotlin("jvm") version "1.4.31"
id("com.gradle.plugin-publish") version "0.13.0"
}
group "dev.thiagosouto"
version "0.3"
buildscript {
repositories {
mavenCentral()
maven {
url = uri("https://plugins.gradle.org/m2/")
}
}
}
gradlePlugin {
plugins {
create("bom-plugin") {
id = "bom-plugin"
implementationClass = "dev.thiagosouto.plugins.bom.BomPlugin"
}
}
}
repositories {
mavenCentral()
}
dependencies {
implementation("com.squareup:kotlinpoet:1.7.2")
testImplementation("com.google.truth:truth:1.1.2")
testImplementation("junit:junit:4.13.2")
testImplementation("dev.thiagosouto:file-butler:0.3.0")
}
sourceSets.main {
java.srcDirs("src/main/kotlin")
}
sourceSets.test {
java.srcDirs("src/test/kotlin")
}
tasks.withType<GenerateModuleMetadata> {
enabled = false
}
publishing {
val ossrhUsername: String by project
val ossrhPassword: String by project
repositories {
maven(url = "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
credentials {
username = ossrhUsername
password = ossrhPassword
}
}
}
publications {
group = "dev.thiagosouto"
version = "0.3"
create<MavenPublication>("mavenJava") {
pom {
name.set("bom-plugin")
description.set("A library to help apply tdd through help functions");
url.set("https://thiagosouto.dev")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
scm {
connection.set("scm:git:git://github.com/othiagosouto/bom-plugin.git/")
developerConnection.set("scm:git:ssh://github.com:othiagosouto/bom-plugin.git")
url.set("https://github.com/othiagosouto/bom-plugin")
}
developers {
developer {
id.set("othiagosouto")
name.set("Thiago Souto silva de barros Santos")
email.set("soutosss#gmail.com")
}
}
}
}
}
}
afterEvaluate {
signing {
sign(publishing.publications["mavenJava"])
}
}

Getting newly published package from JitPack fails

I'm trying to publish my java library to JitPack using the maven-publish plugin in Gradle. I have done all that the docs have said, and JitPack says publishing was a success, but it seems like I cannot install my library, even if I just copy and paste straight from JitPack's repository.
I tried pushing straight to master on the github repo. I also changed the artifact id to sertain-core and the version to 1.0.0, as that is what is specified in the publish block. I even checked the repository url and downloaded the jar manually, and it worked fine. It seems that the only problem is downloading the jar using it's maven coordinates.
Here's my library's build file (the dependencies block is in another file and works fine):
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
val ktlint by configurations.creating
plugins {
kotlin("jvm") version "1.3.50"
`maven-publish`
}
dependencies {
implementation(kotlin("stdlib-jdk8"))
implementation(kotlin("reflect", "1.3.50"))
implementation("org.jetbrains.kotlinx", "kotlinx-coroutines-core", "1.3.1")
implementation("org.jetbrains.kotlin", "kotlin-reflect", "1.3.50")
implementation("edu.wpi.first.wpilibj", "wpilibj-java", "2019.4.1")
implementation("edu.wpi.first.hal", "hal-java", "2019.4.1")
implementation("edu.wpi.first.ntcore", "ntcore-java", "2019.4.1")
implementation("com.ctre.phoenix", "api-java", "5.14.1")
ktlint("com.pinterest:ktlint:0.34.2")
}
tasks {
val ktlint by creating(JavaExec::class) {
group = "verification"
description = "Check Kotlin code style."
classpath = configurations["ktlint"]
main = "com.pinterest.ktlint.Main"
args = listOf("src/**/*.kt")
}
"check" {
dependsOn(ktlint)
}
create("ktlintFormat", JavaExec::class) {
group = "formatting"
description = "Fix Kotlin code style deviations."
classpath = configurations["ktlint"]
main = "com.pinterest.ktlint.Main"
args = listOf("-F", "src/**/*.kt")
}
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
kotlinOptions.freeCompilerArgs += setOf("-Xuse-experimental=kotlin.Experimental")
}
publishing {
publications {
create<MavenPublication>("maven") {
groupId = "org.sert2521.sertain"
artifactId = "sertain-core"
version = "1.0.0"
from(components["java"])
artifact("$buildDir/libs/${project.name}.jar")
}
}
}
And here's the build file of the project that should install the library
plugins {
id "org.jetbrains.kotlin.jvm" version "1.3.50"
id "edu.wpi.first.GradleRIO" version "2019.4.1"
}
ext.kotlinVersion = "1.3.50"
tasks.whenTaskAdded { task ->
if (task.name == "deploy" || task.name == "deployMain" || task.name == "simulateJava") task.dependsOn "assemble"
}
repositories {
google()
jcenter()
mavenCentral()
maven { url "https://jitpack.io" }
maven { url "http://first.wpi.edu/FRC/roborio/maven/release" }
maven { url "http://devsite.ctr-electronics.com/maven/release" }
maven { url "https://www.kauailabs.com/maven2" }
maven { url "http://www.revrobotics.com/content/sw/max/sdk/maven/" }
maven { url 'https://jitpack.io' }
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion"
compile "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.1"
compile "com.kauailabs.navx.frc:navx-java:3.1.344"
compile "org.jetbrains.kotlin:kotlin-reflect:1.3.50"
compile wpi.deps.wpilib()
compile wpi.deps.vendor.java()
nativeZip wpi.deps.vendor.jni(wpi.platforms.roborio)
nativeDesktopZip wpi.deps.vendor.jni(wpi.platforms.desktop)
implementation 'com.github.SouthEugeneRoboticsTeam:sertain:publishing-f3bdecc967-1'
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
deploy {
targets {
roboRIO("roborio") {
team = frc.getTeamOrDefault(2521)
}
}
artifacts {
frcJavaArtifact("frcJava") {
targets << "roborio"
debug = frc.getDebugOrDefault(false)
}
fileTreeArtifact("frcStaticFileDeploy") {
files = fileTree(dir: "src/main/deploy")
targets << "roborio"
directory = "/home/lvuser/deploy"
}
}
}
jar {
from configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
manifest {
attributes(
"Main-Class": "org.sert2521.example.MainKt"
)
}
}
wrapper {
gradleVersion = "5.0"
}
There are no error messages when publishing the library. When installing the library, there is only the usual error from gradle not being able to find a dependency.

IntelliJ Kotlin multiplatform project Gradle sync very long

I've created a new Kotlin Multiplatform project for Andrid and iOS (Mobile shared Library). The project works fine but every time I run Gradle sync, it takes more than 5 minutes every time. It always get stuck on the same line:
Gradle: Build model 'org.jetbrains.kotlin.gradle.KotlinMPPGradleModel' for root project 'MyProject'
Why is it taking so long evey time?
I'm using Gradle version 5.1.
Here is my build.gradle file:
buildscript {
ext.kotlin_version = '1.3.11'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.8.1"
}
}
plugins {
id 'kotlin-multiplatform' version '1.3.11'
}
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://jitpack.io' }
}
repositories {
mavenCentral()
}
group 'com.example'
version '0.0.1'
apply plugin: "com.android.library"
apply plugin: "com.jfrog.artifactory"
apply plugin: 'maven-publish'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName version
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions.incremental = false
}
kotlin {
targets {
fromPreset(presets.android, 'android')
// This preset is for iPhone emulator
// Switch here to presets.iosArm64 to build library for iPhone device
fromPreset(presets.iosX64, 'ios') {
compilations.main.outputKinds('FRAMEWORK')
}
}
sourceSets {
commonMain {
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib-common'
}
}
commonTest {
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-test-common'
implementation 'org.jetbrains.kotlin:kotlin-test-annotations-common'
}
}
androidMain {
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib'
}
}
androidTest {
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-test'
implementation 'org.jetbrains.kotlin:kotlin-test-junit'
}
}
iosMain {
}
iosTest {
}
}
}
configurations {
compileClasspath
}
Screenshot of the problem:
There's a known issue where Kotlin/Native dependencies are re-fetched every sync, which may be what you're seeing. You can see details and follow it here.
As posted to that issue, there's a workaround you may be able to try which essentially involves adding { content { excludeGroup("Kotlin/Native" } } to every item in your repositories block.
As #Brucelet pointed out this is a known issue. To supplement his answer, here is a full implementation of the workaround in Groovy:
repositories {
mavenCentral().content() {
excludeGroup "Kotlin/Native"
}
google().content() {
excludeGroup "Kotlin/Native"
}
jcenter() {
content {
excludeGroup("Kotlin/Native")
}
}
maven {
url 'https://jitpack.io'
content {
excludeGroup("Kotlin/Native")
}
}
}
and in Kotlin DSL:
repositories {
mavenLocal().apply {
content {
excludeGroup("Kotlin/Native")
}
}
maven {
url = uri("https://dl.bintray.com/soywiz/soywiz")
content {
includeGroup("com.soywiz")
excludeGroup("Kotlin/Native")
}
}
jcenter() {
content {
excludeGroup("Kotlin/Native")
}
}
google().apply {
content {
excludeGroup("Kotlin/Native")
}
}
}
Try to run the Gradle task from command lines with --parallel option.
Otherwise, fllow this guide to profile Gradle execution https://guides.gradle.org/performance/

How to publish(deploy) multiple zip files to artifactory using gradle?

I would like to upload multiple zip files(from different directories) to artifactory using gradle script. I was able to upload single distribution using below code.
distributions {
main {
baseName = 'sample'
contents {
from{'src/main/dist/sample'}
}
}
}
publishing {
repositories {
maven {
url "${artifactoryURL}/myFiles"
credentials {
username artifactoryUser
password artifactoryPassword
}
}
}
publications {
distribution(MavenPublication) {
groupId 'com.test'
artifactId 'sample'
version version
artifact (distZip) {
}
}
}
}
Please help in uploading multiple zip files from different source ("src/main/dist/second").
This is full example of build.gragle. To publish zips you should run distZip artifactoryPublish
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:3.1.1"
}
}
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'maven-publish'
apply plugin: 'distribution'
//Defining list of our distributions, every value is map which contains value and version of every distribution
def dists = [
[name:'sample', version: 1],
[name:'second', version: 1]
]
distributions {
//Creating distribution from each value of the distributions list defined above
dists.each { dist ->
"$dist.name" {
baseName = "$dist.name"
contents {
from{"src/main/dist/${dist.name}"}
}
}
}
}
//Every new distribution creates task "${distributionName}DistZip" so we make posible to run them with base task distZip
distZip.dependsOn {
tasks.findAll{ task -> task.name.endsWith('DistZip') }
}
publishing {
publications {
//Again iterating list to make publication for every distribution
dists.each { dist ->
//Every publication has name of the distibution
"$dist.name"(MavenPublication) {
groupId "test"
version = dist.version
artifactId = dist.name
artifact("$buildDir/distributions/${dist.name}.zip")
}
}
}
}
artifactory {
contextUrl = "$URL"
publish {
repository {
repoKey = 'REPO_KEY'
username = USER_NAME
password = PASSWORD
}
defaults {
//Publish every distribution to Artifactory
dists.each { dist ->
publications(dist.name)
}
}
}
}

Resources