Vivek Modi
11/12/2021, 1:06 PMchristophsturm
11/15/2021, 1:51 PMCarlos Hernandez
11/15/2021, 3:25 PMegorand
11/15/2021, 10:57 PMcompileDebugKotlin
build performed by CI that populated the cache and a local build that consumed the cache print out different task class names, which seemingly results in a miss - CI says it ran KotlinCompileWithWorkers
and the dev machine says it ran KotlinCompile
(see the screenshot). Upon some investigation I landed on this code that seems to pick a different task based on whether build parallelization is enabled (controlled by kotlin.parallel.tasks.in.project
before 1.5.20 and IIUC by org.gradle.parallel
after that - please correct me if I’m wrong):
https://github.com/JetBrains/kotlin/blob/v1.5.31/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/TasksProvider.kt#L165-L166
I’m not sure if this is a red herring and our cache misses have a different cause, but I’m curious if it’s a known issue. I also noticed that the following commit removes the KotlinCompileWithWorkers
task, which seemingly will ship in 1.6.20:
https://github.com/JetBrains/kotlin/commit/904f9c72f2a8996511def90d76e054a2f9f98b0e
So far we’re planning to enable parallelization for our CI builds, but would love to know more about this issue.Jason5lee
11/16/2021, 1:44 AMScott Kruse
11/18/2021, 6:43 PMplastiv
11/19/2021, 6:50 PMCould not perform incremental compilation: Could not connect to Kotlin compile daemon
Could not connect to kotlin daemon. Using fallback strategy.
Is there a way to prevent switching to fallback strategy and just abort the build instead?Arpan Sarkar
11/21/2021, 2:59 PMmarked with @Incubating
warining is there any way to disable those warning project wide without using the @file:Suppress("UnstableApiUsage")
Ch8n
11/22/2021, 6:00 AMclasspath(kotlin("gradle-plugin", version = "1.5.10"))
and other KMP modules uses 1.5.31
Im trying to figure out if I can put a conditional if/else in buildscript depending on the module name or create new buildscript for cli module.
if there is any resource/example please shareAlex Spence
11/22/2021, 6:13 PMkotlin {
jvmToolchain {
(this as JavaToolchainSpec).apply {
languageVersion.set(JavaLanguageVersion.of(17))
}
}
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}
but I'm getting errors like this When I run gradle using Java 8
No matching variant of csdisco.athena.common:data:1.5.1 was found. The consumer was configured to find an API of a library compatible with Java 8, preferably in the form of class files, preferably optimized for standard JVMs, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' but:
- Variant 'apiElements' capability csdisco.athena.common:data:1.5.1 declares an API of a library, packaged as a jar, preferably optimized for standard JVMs, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm':
- Incompatible because this component declares a component compatible with Java 17 and the consumer needed a component compatible with Java 8
- Variant 'runtimeElements' capability csdisco.athena.common:data:1.5.1 declares a runtime of a library, packaged as a jar, preferably optimized for standard JVMs, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm':
- Incompatible because this component declares a component compatible with Java 17 and the consumer needed a component compatible with Java 8
I've tried to specify the kotlin / java toolchain blocks above per project, in allProjects or subProjects but those result in compile errors
What is the proper way to configure the toolchain for multi module projects?Roeniss Moon
11/23/2021, 4:43 AMandylamax
11/23/2021, 10:31 AMPending Approval
since I submitted an update. Is there a known hiccup??Roeniss Moon
11/23/2021, 3:04 PMkotlin-gradle-plugin
? https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-gradle-plugin
I can’t find sort of documentation of it….Slackbot
11/25/2021, 12:17 PMMiquel Àngel Román
11/26/2021, 10:14 PM./gradlew installDist
and call bin/app
it just exists successfully without doing anything else...Alexander Suraphel
11/27/2021, 1:07 PMedwinRNDR
11/28/2021, 8:22 PMursus
11/29/2021, 12:33 AM:fcm
module which hosts FcmService, which is a basically a callback for receiving push messages. There I route the messages to my push handlers from :push
I have 2 apps in a monorepo, both of which depend on the :fcm
module, ie. their push handling was identital
However, a new requirment came, for which I need to proxy push messages to a analytics library just for app A (app B fcm usage remains the same)
So I created a FcmServiceDelegate interface, and implement it differently in each app as needed. (or rather include a different delegate module)
My question is how to modularize this
would you either have root level :internal-fcm-delegate
, :analytics-fcm-delegate
which depends on :fcm
or, turn :fcm
into a plain folder, and nest the two delegates + module for original code inside it, i.e. :fcm:internal-delegate
, :fcm:analytics-delegate
, fcm:service
I do like nesting in general as it scales well, however I dont like that I have to create this "base" module under the folder, where the original impl will be moved to.
Is there a way I could still have :fcm
as a proper module, so it has the original FcmService class, and yet nest the :internal-delegate, analytics-delegate
under it?
(Because let's say a new requirement comes which needs app C to be created and use huawei push .. and there is no need for delegates as there is only one impl, the module would be naturally called :hcm
...and that's it..but thats not super symetrical with the fcm modules now..basically I'd want :fcm
module here as well, and only add the delegate module which give app uses (semantically)
something along the lines of
-- appA
implementation :fcm
implementation :fcm:internal-delegate
-- appB
implementation :fcm
implementation :fcm:analytics-delegate
-- appC
implementation :hcm
what I'm not so keen on
-- appA
implementation :fcm:service
implementation :fcm:internal-delegate
-- appB
implementation :fcm:service
implementation :fcm:analytics-delegate
-- appC
implementation :hcm
or maybe this? But it blows up root imo, i dont think its important to know theres multiple fcm impls when viewing root level
-- appA
implementation :fcm
implementation :fcm-delegate-internal
-- appB
implementation :fcm
implementation :fcm-delegate-analytics
-- appC
implementation :hcm
Thoughts? What's idiomatic?
I see retrofit is doing option 3 https://github.com/square/retrofit .. but it has just a few root folders, no a monorepo reallyChristian Dräger
11/30/2021, 6:27 AMPaul Woitaschek
11/30/2021, 2:57 PMreplaceFirstChar
. It seems that gradle (7.3) bundles an older kotlin version. Is it possible to change that version so the new functions are usable?Michael Grigoryan
11/30/2021, 8:21 PMsrc
with the following build.gradle.kts
fi
le?
plugins {
kotlin("jvm") version "1.6.0"
}
repositories {
mavenCentral()
}
tasks {
sourceSets {
main {
java.srcDirs("src")
}
}
}
Ben Tilford
12/02/2021, 5:26 PMsrc/testFixtures/kotlin
code from within the same project. Other projects declaring it as a dependency seem to work but examples of managing sourceSets that I’ve found don’t seem to work.eygraber
12/02/2021, 10:57 PMplugins.withType
to configure them all in one place?Tomas Kormanak
12/03/2021, 10:01 AMKotlin not configured
some times (usually after changing git branch). Sometime I can fix it by random things like clearing cache/reload gradle project/ remove the whole project. Any idea why IDEA can't load the gradle project correctly?
We have multiplatform project witin multiproject gradle structure.Rhiad Jaffar
12/03/2021, 2:02 PMnpm install <git-host>:<git-user>/<repo-name>
npm install <git repo url>
… and this will result in npm installing a dependency from a github repo/ref as if it was a standard npm module:
https://docs.npmjs.com/cli/v8/commands/npm-install
I’ve tried lots of different permutations of this in gradle + npm and no matter what I try it always errors in various ways e.g.
implementation(npm("username/repo#branchname"))
implementation(npm("username/repo#branchname", "*"))
implementation(npm("username/repo", "commitref"))
So question:
Is it possible to use gradle + npm to install npm dependencies from github locations?
Many thanks!Nick Halase
12/03/2021, 8:23 PMJoost Klitsie
12/04/2021, 10:09 AMPaul Woitaschek
12/06/2021, 1:53 PMColm Murphy
12/07/2021, 11:37 AMTomasz Krakowiak
12/08/2021, 5:02 AMTomasz Krakowiak
12/08/2021, 5:02 AMkotlin {
js("browser", IR) {
compilations["main"].defaultSourceSet.dependsOn(js(IR).compilations["main"].defaultSourceSet)
configurations[compilations["main"].apiConfigurationName].attributes.attribute(jsPlatformType, "browser")
configurations[compilations["main"].runtimeOnlyConfigurationName].attributes.attribute(jsPlatformType, "browser")
binaries.executable()
}
js("node", IR) {
nodejs { }
compilations["main"].defaultSourceSet.dependsOn(js(IR).compilations["main"].defaultSourceSet)
configurations[compilations["main"].apiConfigurationName].attributes.attribute(jsPlatformType, "node")
configurations[compilations["main"].runtimeOnlyConfigurationName].attributes.attribute(jsPlatformType, "node")
binaries.executable()
}
}
Error I am getting:
Execution failed for task ':app:generateMetadataFileForKotlinMultiplatformPublication'.
> Invalid publication 'kotlinMultiplatform':
- Variants 'browserApiElements-published' and 'jsApiElements-published' have the same attributes and capabilities. Please make sure either attributes or capabilities are different.
- Variants 'browserRuntimeElements-published' and 'jsRuntimeElements-published' have the same attributes and capabilities. Please make sure either attributes or capabilities are different.
- Variants 'browserApiElements-published' and 'nodeApiElements-published' have the same attributes and capabilities. Please make sure either attributes or capabilities are different.
- Variants 'browserRuntimeElements-published' and 'nodeRuntimeElements-published' have the same attributes and capabilities. Please make sure either attributes or capabilities are different.
Any ideas on how to solve it are welcome.kotlin {
js("browser", IR) {
compilations["main"].defaultSourceSet.dependsOn(js(IR).compilations["main"].defaultSourceSet)
configurations.all { if(name == compilations["main"].apiConfigurationName + "Elements-published") attributes.attribute(jsPlatformType, "browser") }
configurations.all { if(name == compilations["main"].runtimeOnlyConfigurationName + "Elements-published") attributes.attribute(jsPlatformType, "browser") }
binaries.executable()
}
js("node", IR) {
nodejs { }
compilations["main"].defaultSourceSet.dependsOn(js(IR).compilations["main"].defaultSourceSet)
configurations.all { if(name == compilations["main"].apiConfigurationName + "Elements-published") attributes.attribute(jsPlatformType, "node") }
configurations.all { if(name == compilations["main"].runtimeOnlyConfigurationName + "Elements-published") attributes.attribute(jsPlatformType, "node") }
binaries.executable()
}
}
I am getting slightly different error:
Execution failed for task ':app:generateMetadataFileForKotlinMultiplatformPublication'.
> Invalid publication 'kotlinMultiplatform':
- Variants 'browserRuntimeElements-published' and 'jsRuntimeElements-published' have the same attributes and capabilities. Please make sure either attributes or capabilities are different.
- Variants 'browserRuntimeElements-published' and 'nodeRuntimeElements-published' have the same attributes and capabilities. Please make sure either attributes or capabilities are different.
Variants 'browserRuntimeElements-published' and 'nodeRuntimeElements-published' have the same attributes and capabilities.
is now most confusing.Vampire
12/08/2021, 10:50 AMoutgoingVariants
can help you shed some light on itTomasz Krakowiak
12/08/2021, 5:51 PMkotlin {
js("browser", IR) {
compilations["main"].defaultSourceSet.dependsOn(js(IR).compilations["main"].defaultSourceSet)
configurations.all { if(name == compilations["main"].apiConfigurationName + "Elements") attributes.attribute(jsPlatformType, "browser") }
configurations.all { if(name == "browserRuntimeElements") attributes.attribute(jsPlatformType, "browser") }
binaries.executable()
}
js("node", IR) {
nodejs { }
compilations["main"].defaultSourceSet.dependsOn(js(IR).compilations["main"].defaultSourceSet)
configurations.all { if(name == compilations["main"].apiConfigurationName + "Elements") attributes.attribute(jsPlatformType, "node") }
configurations.all { if(name == "nodeRuntimeElements") attributes.attribute(jsPlatformType, "node") }
binaries.executable()
}
}