unable to resolve class org.jenkinsci.plugins.workflow.support.steps.build.DownstreamFailureCause - maven

I have the following build.gradle.kts
plugins {
id("com.mkobit.jenkins.pipelines.shared-library") version "0.10.1"
id("com.github.ben-manes.versions") version "0.21.0"
java
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
tasks.withType<Test> {
this.testLogging {
this.showStandardStreams = true
}
}
val log4jVersion = "2.11.2"
val slf4jVersion = "1.7.26"
val declarativePluginsVersion = "1.3.9"
dependencies {
// logging stuffs
testImplementation("org.slf4j:slf4j-api:$slf4jVersion")
testImplementation("org.apache.logging.log4j:log4j-api:$log4jVersion")
testImplementation("org.apache.logging.log4j:log4j-core:$log4jVersion")
testImplementation("org.apache.logging.log4j:log4j-slf4j-impl:$log4jVersion")
testImplementation("org.apache.logging.log4j:log4j-jul:$log4jVersion")
// general testing stuff
testImplementation("org.assertj:assertj-core:3.12.2")
testImplementation("com.lesfurets:jenkins-pipeline-unit:1.3")
testImplementation("junit:junit:4.12") // TODO: update to 5
// jenkins specific deps
testImplementation("org.jenkins-ci.plugins:pipeline-build-step:2.9")
testImplementation("org.jenkinsci.plugins:pipeline-model-api:$declarativePluginsVersion")
testImplementation("org.jenkinsci.plugins:pipeline-model-declarative-agent:1.1.1")
testImplementation("org.jenkinsci.plugins:pipeline-model-definition:$declarativePluginsVersion")
testImplementation("org.jenkinsci.plugins:pipeline-model-extensions:$declarativePluginsVersion")
testImplementation("org.jenkins-ci.plugins.workflow:workflow-cps-global-lib:2.8")
testImplementation("org.jenkins-ci.plugins.workflow:workflow-step-api:2.18")
}
jenkinsIntegration {
baseUrl.set(uri("http://localhost:5050").toURL())
authentication.set(providers.provider { com.mkobit.jenkins.pipelines.http.AnonymousAuthentication })
downloadDirectory.set(layout.projectDirectory.dir("jenkinsResources"))
}
sharedLibrary {
coreVersion.set(jenkinsIntegration.downloadDirectory.file("core-version.txt").map { it.asFile.readText().trim() })
pluginDependencies {
dependency("org.jenkins-ci.plugins", "pipeline-build-step", "2.9")
dependency("org.jenkinsci.plugins", "pipeline-model-api", declarativePluginsVersion)
dependency("org.jenkinsci.plugins", "pipeline-model-declarative-agent", "1.1.1")
dependency("org.jenkinsci.plugins", "pipeline-model-definition", declarativePluginsVersion)
dependency("org.jenkinsci.plugins", "pipeline-model-extensions", declarativePluginsVersion)
dependency("org.jenkins-ci.plugins.workflow", "workflow-step-api", "2.18")
}
}
when I do gradlew build
I got the following error on one of my groovy file:
unable to resolve class org.jenkinsci.plugins.workflow.support.steps.build.DownstreamFailureCause
To me the dependency should be solved in the pluginDependencies section.

I found a solution.
It seems that the class I was having a problem with was introduced in version 2.10
So you need to change
org.jenkins-ci.plugins:pipeline-build-step:2.9
to
org.jenkins-ci.plugins:pipeline-build-step:2.10

Related

Problem with the IntelliJ version in the plug-in

When I set an IntelliJ version as described below I have the following error
intellij {
version '2022.3'
}
A problem occurred configuring root project 'brs-plugin'.
Failed to notify project evaluation listener.
Failed to query the value of extension 'intellij' property 'version'.
> The value for the 'intellij.version' property was not specified, see:
https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#intellij-extension-version
But if I add the equal operator have the following
intellij {
version = '2022.3'
}
Caused by: org.gradle.internal.exceptions.DefaultMultiCauseException:
Could not resolve com.jetbrains.intellij.idea:ideaIC:2022.3.
This is my full version of the build.gradle. As you can see I have added several repos, but it's not helped. Full version of the project you can found on this link
How to fix my problem? Regards
buildscript {
repositories {
mavenCentral()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
maven {
url "https://plugins.gradle.org/m2/"
}
maven {
url "https://www.jetbrains.com/intellij-repository/releases"
}
maven {
url "https://www.jetbrains.com/intellij-repository/snapshots"
}
maven {
url "https://cache-redirector.jetbrains.com/intellij-dependencies"
}
}
}
plugins {
id "org.jetbrains.intellij" version "1.11.0"
id "org.jetbrains.grammarkit" version "2020.1"
}
configurations {
configurations.compileOnly.setCanBeResolved(true)
}
group 'com.interfaced'
version = '0.2.7'
apply plugin: 'kotlin'
apply plugin: 'org.jetbrains.intellij'
sourceSets {
all {
java.srcDirs += ['src/main/gen']
kotlin.srcDirs += ['src/main/kotlin']
resources.srcDirs = ['src/main/resources']
}
}
intellij {
version = '2022.3'
}
grammarKit {
jflexRelease = '1.7.0-2'
}
repositories {
mavenCentral()
maven {
url "https://cache-redirector.jetbrains.com/intellij-dependencies"
}
}
dependencies {
// https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-stdlib
implementation group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: '1.7.22'
implementation files('jars/grammar-kit.jar')
implementation group: 'junit', name: 'junit', version: '4.12'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7"
// https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-gradle-plugin
implementation group: 'org.jetbrains.kotlin', name: 'kotlin-gradle-plugin', version: '1.6.0'
}
import org.jetbrains.grammarkit.tasks.GenerateLexer
import org.jetbrains.grammarkit.tasks.GenerateParser
def GENERATE_GROUP = 'Generate'
task setConfiguration() {
configurations.compileOnly.setCanBeResolved(true)
}
task generateLexer(type: GenerateLexer) {
source = "src/main/grammar/BrightScript.flex"
targetDir = "src/main/gen/com/interfaced/brs/lang/lexer"
targetClass = "_BrsLexer"
skeleton = "src/main/grammar/idea-flex.skeleton"
purgeOldFiles = true
description = 'Generate Lexer Java sources for BrightScript'
group = GENERATE_GROUP
}
task generateParser(type: GenerateParser) {
source = "src/main/grammar/BrightScript.bnf"
targetRoot = 'src/main/gen'
pathToParser = 'src/main/gen/com/interfaced/brs/lang/BrsParser.java'
pathToPsiRoot = 'src/main/gen/com/interfaced/brs/lang/psi'
purgeOldFiles = true
description = 'Generate Parser Java sources for BrightScript'
group = GENERATE_GROUP
// patch up to date check
outputs.upToDateWhen { false }
}
compileKotlin {
kotlinOptions.jvmTarget = "17"
}
compileKotlin.dependsOn(setConfiguration, generateLexer, generateParser)

Gradle, use material3 in a compose multiplatform project

I'm doing a project with Jetpack Compose Multiplatform Desktop.
I'm not very familiar with Gradle, and I would like to use Material 3 in my project.
So, I added this line in build.gradle.kts file:
implementation("androidx.compose.material3:material3:1.0.0-alpha14")
But when I try to import the lib in a Kotlin file with:
import androidx.compose.material3.*
I've got an unresolved reference issue.
This is my build.gradle.kts file:
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
plugins {
kotlin("multiplatform")
id("org.jetbrains.compose")
}
group = "com.example"
version = "1.0-SNAPSHOT"
repositories {
google()
mavenCentral()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}
kotlin {
jvm {
compilations.all {
kotlinOptions {
jvmTarget = "18"
freeCompilerArgs = listOf("-opt-in=kotlin.RequiresOptIn")
}
}
withJava()
}
sourceSets {
val jvmMain by getting {
dependencies {
implementation(compose.desktop.currentOs)
implementation("androidx.compose.material3:material3:1.0.0-alpha14")
}
}
val jvmTest by getting
}
}
compose.desktop {
application {
mainClass = "MainKt"
jvmArgs += listOf("-Djava.library.path=./lib")
nativeDistributions {
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
packageName = "FanControl"
packageVersion = "1.0.0"
}
}
}
I think I should be able to use this lib since the release note indicate it support it.
Edit1:
I have this message from Gradle when I try to sync:
Could not resolve: androidx.compose.material3:material3:1.0.0-alpha14
Finally found what was the problem, it was the wrong library,
change
implementation("androidx.compose.material3:material3:1.0.0-alpha14")
with
implementation("org.jetbrains.compose.material3:material3-desktop:1.2.1")

Kotlin multiplatform publish with dokka and sources

I am struggling to publish a Kotlin multiplatform project properly to maven (for now mavenLocal). I can add the dependency to another multiplatform project and use the code but I don't get any documentation and I am not sure if I am doing something wrong or if that is simply not possible at the moment.
From what I understand you cannot use the normal javadoc because it is bound to Java which does not make sense in a multiplatform environment. I read somewhere that in that case you should use the html version of dokka. I can see that I get a "javadoc.jar" with content to my mavenLocal but still in the IDE in an example project where I add my KMP library as a dependency, I don't see any documentation.
Also, the code decompiling seems to be weird. I guess somehow the sources are also not properly resolved.
According to the documentation everything should automatically and perfectly work by simply adding the maven-publish and the dokka plugin. But it seems like this is not the case and actually nothing is working as I'd expect it :D
Does anyone know, how to properly set that up?
My gradle file looks like this:
plugins {
kotlin("multiplatform") version "1.6.21"
id("org.jetbrains.kotlinx.benchmark") version "0.4.2"
id("org.jetbrains.dokka") version "1.6.21"
`maven-publish`
signing
}
group = "io.github.quillraven.fleks"
version = "1.4-KMP-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_1_8
repositories {
mavenCentral()
}
kotlin {
targets {
jvm {
compilations {
all {
kotlinOptions {
jvmTarget = "1.8"
}
}
val main by getting { }
// custom benchmark compilation
val benchmarks by compilations.creating {
defaultSourceSet {
dependencies {
// Compile against the main compilation's compile classpath and outputs:
implementation(main.compileDependencyFiles + main.output.classesDirs)
}
}
}
}
withJava()
testRuns["test"].executionTask.configure {
useJUnitPlatform()
}
}
}
js(BOTH) {
browser { }
}
val hostOs = System.getProperty("os.name")
val isMingwX64 = hostOs.startsWith("Windows")
val nativeTarget = when {
hostOs == "Mac OS X" -> macosX64("native")
hostOs == "Linux" -> linuxX64("native")
isMingwX64 -> mingwX64("native")
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
}
sourceSets {
val commonMain by getting { }
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
val jvmMain by getting
val jvmTest by getting
val jvmBenchmarks by getting {
dependsOn(commonMain)
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-benchmark-runtime:0.4.2")
implementation("com.badlogicgames.ashley:ashley:1.7.4")
implementation("net.onedaybeard.artemis:artemis-odb:2.3.0")
}
}
val jsMain by getting
val jsTest by getting
val nativeMain by getting
val nativeTest by getting
}
}
benchmark {
targets {
register("jvmBenchmarks")
}
}
val javadocJar by tasks.registering(Jar::class) {
archiveClassifier.set("javadoc")
from(tasks.dokkaHtml)
}
publishing {
repositories {
maven {
url = if (project.version.toString().endsWith("SNAPSHOT")) {
uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
} else {
uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
}
credentials {
username = System.getenv("OSSRH_USERNAME")
password = System.getenv("OSSRH_TOKEN")
}
}
}
publications {
val kotlinMultiplatform by getting(MavenPublication::class) {
version = project.version.toString()
groupId = project.group.toString()
artifactId = "Fleks"
artifact(javadocJar)
pom {
name.set("Fleks")
description.set("A lightweight entity component system written in Kotlin.")
url.set("https://github.com/Quillraven/Fleks")
scm {
connection.set("scm:git:git#github.com:quillraven/fleks.git")
developerConnection.set("scm:git:git#github.com:quillraven/fleks.git")
url.set("https://github.com/quillraven/fleks/")
}
licenses {
license {
name.set("MIT License")
url.set("https://opensource.org/licenses/MIT")
}
}
developers {
developer {
id.set("Quillraven")
name.set("Simon Klausner")
email.set("quillraven#gmail.com")
}
}
}
}
signing {
useInMemoryPgpKeys(System.getenv("SIGNING_KEY"), System.getenv("SIGNING_PASSWORD"))
sign(kotlinMultiplatform)
}
}
}
// only sign if version is not a SNAPSHOT release.
// this makes it easier to publish to mavenLocal and test the packed version.
tasks.withType<Sign>().configureEach {
onlyIf { !project.version.toString().endsWith("SNAPSHOT") }
}
When I run the publishToMavenLocal gradle task then I get following directories in my .m2 folder:
When I then create an example project and add it as a dependency, then I don't see any quick documentation and also the decompiling is not working properly:
I was finally able to publish to mavenCentral. Not sure if this is the best way and correct way to do it, but it seems to work. Here is my build.gradle.kts. The important part is in the publications sections. For whatever reason it is not sufficient to have the "root" folder setup properly. I also had to adjust the pom, javadoc and signing of every single publication, too.
#file:Suppress("UNUSED_VARIABLE")
plugins {
kotlin("multiplatform") version "1.6.21"
id("org.jetbrains.kotlinx.benchmark") version "0.4.2"
id("org.jetbrains.dokka") version "1.6.21"
`maven-publish`
signing
}
group = "io.github.quillraven.fleks"
version = "1.4-KMP-RC1"
java.sourceCompatibility = JavaVersion.VERSION_1_8
repositories {
mavenCentral()
}
kotlin {
targets {
jvm {
compilations {
all {
kotlinOptions {
jvmTarget = "1.8"
}
}
val main by getting { }
// custom benchmark compilation
val benchmarks by compilations.creating {
defaultSourceSet {
dependencies {
// Compile against the main compilation's compile classpath and outputs:
implementation(main.compileDependencyFiles + main.output.classesDirs)
}
}
}
}
withJava()
testRuns["test"].executionTask.configure {
useJUnitPlatform()
}
}
}
js(BOTH) {
browser { }
}
val hostOs = System.getProperty("os.name")
val isMingwX64 = hostOs.startsWith("Windows")
val nativeTarget = when {
hostOs == "Mac OS X" -> macosX64("native")
hostOs == "Linux" -> linuxX64("native")
isMingwX64 -> mingwX64("native")
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
}
sourceSets {
val commonMain by getting { }
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
val jvmMain by getting
val jvmTest by getting
val jvmBenchmarks by getting {
dependsOn(commonMain)
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-benchmark-runtime:0.4.2")
implementation("com.badlogicgames.ashley:ashley:1.7.4")
implementation("net.onedaybeard.artemis:artemis-odb:2.3.0")
}
}
val jsMain by getting
val jsTest by getting
val nativeMain by getting
val nativeTest by getting
}
}
benchmark {
targets {
register("jvmBenchmarks")
}
}
val javadocJar by tasks.registering(Jar::class) {
archiveClassifier.set("javadoc")
from(tasks.dokkaHtml)
}
publishing {
repositories {
maven {
url = if (project.version.toString().endsWith("SNAPSHOT")) {
uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
} else {
uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
}
credentials {
username = System.getenv("OSSRH_USERNAME")
password = System.getenv("OSSRH_TOKEN")
}
}
}
publications {
val kotlinMultiplatform by getting(MavenPublication::class) {
// we need to keep this block up here because
// otherwise the different target folders like js/jvm/native are not created
version = project.version.toString()
groupId = project.group.toString()
artifactId = "Fleks"
}
}
publications.forEach {
if (it !is MavenPublication) {
return#forEach
}
// We need to add the javadocJar to every publication
// because otherwise maven is complaining.
// It is not sufficient to only have it in the "root" folder.
it.artifact(javadocJar)
// pom information needs to be specified per publication
// because otherwise maven will complain again that
// information like license, developer or url are missing.
it.pom {
name.set("Fleks")
description.set("A lightweight entity component system written in Kotlin.")
url.set("https://github.com/Quillraven/Fleks")
scm {
connection.set("scm:git:git#github.com:quillraven/fleks.git")
developerConnection.set("scm:git:git#github.com:quillraven/fleks.git")
url.set("https://github.com/quillraven/fleks/")
}
licenses {
license {
name.set("MIT License")
url.set("https://opensource.org/licenses/MIT")
}
}
developers {
developer {
id.set("Quillraven")
name.set("Simon Klausner")
email.set("quillraven#gmail.com")
}
}
}
signing {
useInMemoryPgpKeys(System.getenv("SIGNING_KEY"), System.getenv("SIGNING_PASSWORD"))
sign(it)
}
}
}
// only sign if version is not a SNAPSHOT release.
// this makes it easier to publish to mavenLocal and test the packed version.
tasks.withType<Sign>().configureEach {
onlyIf { !project.version.toString().endsWith("SNAPSHOT") }
}
Here is my example gradle file that publishes a kotlin multiplatform project with sources and javadocs to a maven repository.
The project source is here: https://github.com/danbrough/misc_demos/tree/master/kotlin_multiplatform_dokka
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("multiplatform")
id("org.jetbrains.dokka")
id("com.android.library")
`maven-publish`
}
group = "dokka.test"
version = "0.0.1"
buildscript {
repositories {
mavenCentral()
gradlePluginPortal()
}
}
repositories {
mavenCentral()
google()
}
kotlin {
jvm()
android()
linuxX64()
macosX64()
sourceSets {
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
}
val posixMain by sourceSets.creating {}
targets.withType<KotlinNativeTarget>() {
compilations["main"].defaultSourceSet.dependsOn(posixMain)
}
}
tasks.withType<AbstractTestTask>() {
testLogging {
events = setOf(
TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED
)
exceptionFormat = TestExceptionFormat.FULL
showStandardStreams = true
showStackTraces = true
}
outputs.upToDateWhen {
false
}
}
tasks.withType(KotlinCompile::class) {
kotlinOptions {
jvmTarget = "11"
}
}
tasks.dokkaHtml.configure {
outputDirectory.set(buildDir.resolve("dokka"))
}
val javadocJar by tasks.registering(Jar::class) {
archiveClassifier.set("javadoc")
from(tasks.dokkaHtml)
}
publishing {
repositories {
maven(project.buildDir.resolve("m2").toURI()) {
name = "m2"
}
}
publications.forEach {
if (it !is MavenPublication) {
return#forEach
}
it.artifact(javadocJar)
}
}
android {
compileSdk = 33
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
namespace = project.group.toString()
defaultConfig {
minSdk = 23
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
signingConfigs.register("release") {
storeFile = File(System.getProperty("user.home"), ".android/keystore")
keyAlias = "keyAlias"
storePassword = System.getenv("KEYSTORE_PASSWORD") ?: ""
keyPassword = System.getenv("KEYSTORE_PASSWORD") ?: ""
}
lint {
abortOnError = false
}
buildTypes {
getByName("debug") {
//debuggable(true)
}
getByName("release") {
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
)
signingConfig = signingConfigs.getByName("release")
}
}
}

Kotlin build FatFramework with defined minimum iOS version

I want to deploy my multiplatform project to .framework with supported iOS architecture using FatFramework using this gradle configuration. It's work but I founded in info.plist that it have default MinimumOSVersion to iOS 9 so I can't used my library below that version.
Is there any way / possible to configure the minimum iOS version for my lib ?
import org.jetbrains.kotlin.gradle.tasks.FatFrameworkTask
plugins {
id("org.jetbrains.kotlin.multiplatform") version "1.3.61"
id("maven-publish")
id("com.jfrog.bintray") version "1.8.4"
id("org.jetbrains.dokka") version "0.10.0"
}
group = "com.example.lib"
version = "1.0.0"
repositories {
mavenCentral()
jcenter()
}
kotlin {
jvm()
val iosX64 = iosX64("ios")
val iosArm64 = iosArm64("iosArm64")
val iosArm32 = iosArm32("iosArm32")
val frameworkName = "EXAMPLE-LIB"
configure(listOf(iosX64, iosArm64, iosArm32)) {
binaries.framework {
baseName = frameworkName
}
}
sourceSets {
named("commonMain") {
dependencies {
implementation(kotlin("stdlib-common"))
implementation(kotlin("stdlib-jdk7"))
implementation(kotlin("stdlib-jdk8"))
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.3.0-RC")
implementation(kotlin("reflect"))
}
}
named("commonTest") {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
implementation(kotlin("reflect"))
}
}
named("jvmMain") {
dependencies {
implementation(kotlin("stdlib-jdk8"))
}
}
named("jvmTest") {
dependencies {
implementation(kotlin("test"))
implementation(kotlin("test-junit"))
}
}
val iosMain by getting {
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-native:1.3.0-RC")
implementation("io.ktor:ktor-client-ios:1.2.6")
}
}
val iosArm64Main by getting {
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-native:1.3.0-RC")
implementation("io.ktor:ktor-client-ios:1.2.6")
}
}
val iosArm32Main by getting {
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-native:1.3.0-RC")
implementation("io.ktor:ktor-client-ios:1.2.6")
}
}
}
val debugFatFramework by tasks.creating(FatFrameworkTask::class) {
baseName = frameworkName
from(
iosArm32.binaries.getFramework("debug"),
iosArm64.binaries.getFramework("debug"),
iosX64.binaries.getFramework("debug")
)
destinationDir = buildDir.resolve("fat-framework/debug")
group = "Universal framework"
description = "Builds a debug universal (fat) framework"
}
val releaseFatFramework by tasks.creating(FatFrameworkTask::class) {
baseName = frameworkName
from(
iosArm32.binaries.getFramework("release"),
iosArm64.binaries.getFramework("release"),
iosX64.binaries.getFramework("release")
)
destinationDir = buildDir.resolve("fat-framework/release")
group = "Universal framework"
description = "Builds a release universal (fat) framework"
}
val zipDebugFatFramework by tasks.creating(Zip::class) {
dependsOn(debugFatFramework)
from(debugFatFramework)
from("LICENSE.md")
}
val zipReleaseFatFramework by tasks.creating(Zip::class) {
dependsOn(releaseFatFramework)
from(releaseFatFramework)
from("LICENSE.md")
}
}
tasks.register<Exec>("generateThriftModels") {
executable = "java"
args(
"-jar", "thrifty-compiler.jar",
"--lang", "kotlin",
"--omit-generated-annotations",
"--list-type=kotlin.collections.ArrayList",
"--set-type=kotlin.collections.LinkedHashSet",
"--out", "src/commonMain/kotlin",
"--path", "./thrift/",
"./thrift/nativeapp.thrift"
)
}
This parameter is derived from the Kotlin/Native's compiler properties list. It can be found there:~/.konan/kotlin-native-prebuilt-<hostname>-<version>/konan/konan.properties. The value responsible for the MinimumOSVersion is the osVersionMin.<target_name>. This should be set per target. It can be changed manually, and this new value will be used by all your projects. Also, after 1.4.30 there is a new way to specify compiler properties. See in this document for example. I would recommend using it as follows:
...
configure(listOf(iosX64, iosArm64, iosArm32)) {
binaries.framework {
freeCompilerArgs += listOf("-Xoverride-konan-properties=osVersionMin.ios_arm32=7;osVersionMin.ios_arm64=7;osVersionMin.ios_x64=7")
}
}
...

Gradle Configuration for Kotlin Multiplatform Project in Java and Js

Seems all ok! But...
I have created a Kotlin Multiplatform Project in Js and Java. I worked on create the right tests for all target and the right configuration for the build. Seems all go right, i managed to create the build and set it in the right way. Today i have opened the project and it stop, the build complete successfull but test and java compilations don't be executed.
So how i can configure it?
With code and result all will be more clear
build.gradle.kts
import com.moowork.gradle.node.npm.NpmTask
import com.moowork.gradle.node.task.NodeTask
import org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile
buildscript {
repositories {
mavenCentral()
jcenter()
maven {
url = uri("https://plugins.gradle.org/m2/")
}
}
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50")
}
}
plugins {
kotlin("multiplatform") version "1.3.50"
id("com.moowork.node") version "1.3.1"
}
repositories {
mavenCentral()
jcenter()
}
group = "com.example"
version = "0.0.1"
kotlin {
jvm()
js()
jvm {
withJava()
}
js {
nodejs()
}
sourceSets {
val commonMain by getting {
dependencies {
implementation(kotlin("stdlib-common"))
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
jvm {
compilations["main"].defaultSourceSet {
dependencies {
implementation(kotlin("stdlib-jdk8"))
}
}
compilations["test"].defaultSourceSet {
dependencies {
implementation(kotlin("test"))
implementation(kotlin("test-junit"))
}
}
}
js {
sequenceOf("", "Test").forEach {
tasks.getByName<KotlinJsCompile>("compile${it}KotlinJs") {
kotlinOptions {
moduleKind = "umd"
noStdlib = true
metaInfo = true
}
}
}
compilations["main"].defaultSourceSet {
dependencies {
implementation(kotlin("stdlib-js"))
}
}
compilations["test"].defaultSourceSet {
dependencies {
implementation(kotlin("test-js"))
}
}
}
}
}
val compileKotlinJs = tasks.getByName("compileKotlinJs")
val compileTestKotlinJs = tasks.getByName("compileTestKotlinJs")
val libDir = "$buildDir/lib"
val compileOutput = compileKotlinJs.getOutputs().getFiles()
val testOutput = compileTestKotlinJs.getOutputs().getFiles()
val populateNodeModules = tasks.create<Copy>("populateNodeModules") {
afterEvaluate {
from(compileOutput)
from(testOutput)
configurations["testCompile"].forEach {
if (it.exists() && !it.isDirectory) {
from(zipTree(it.absolutePath).matching { include("*.js") })
}
}
for (sourceSet in kotlin.sourceSets) {
from(sourceSet.resources)
}
into("$buildDir/node_modules")
}
dependsOn("compileKotlinJs")
}
node {
download = true;
}
tasks.create<NpmTask> ("installJest") {
setArgs(setOf("install", "jest"))
}
tasks.create<NodeTask> ("runJest") {
setDependsOn(setOf("installJest", "populateNodeModules", "compileTestKotlinJs"))
setScript(file("node_modules/jest/bin/jest.js"))
setArgs(compileTestKotlinJs.outputs.files.toMutableList().map {projectDir.toURI().relativize(it.toURI())})
}
tasks.getByName("test").dependsOn("runJest")
Look how many task are skiped! and how build Dir is created
buid result
build dir
I use jest to test in js.
Thanks in advance for support me

Resources