Sam
05/04/2022, 12:44 PMkotlin("jvm")
plugin automatically apply the java-library
plugin? I'm sure I remember reading that somewhere but I can't find a reference for it. I'm trying to debug an issue where I'm getting intermittent (!) "unresolved reference" errors when pulling in another module as an api
dependency 😢 (both modules are libraries, consumed by a third separate module)ankushg
05/04/2022, 8:25 PMTo honour the JVM settings for this build a single-use Daemon process will be forked.
We’ve set up these environment variables:
JAVA_OPTS: '-Xmx3g -Xms1g'
GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx3g -Xms1g" -Dorg.gradle.daemon=false -Dkotlin.compiler.execution.strategy="in-process"'
Are we missing any options? Is there a way to get Gradle to give us more detailed error messages on exactly which settings are different?
We’re using ./gradlew
to start up the process, and noticed that it specifies defaults in DEFAULT_JVM_OPTS
. Are those possibly getting in the way?martmists
05/06/2022, 9:34 AMExecution failed for task ':setupMetadata'.
> Extension of type 'KPyExtension' does not exist. Currently registered extension types: [ExtraPropertiesExtension]
but in my plugin I have
// fun Project.setupExtensions(), called first
extensions.create<KPyExtension>("kpy") // register extension
// fun Project.setupTasks(), called later
task<Task>("setupMetadata") {
actions.add {
val target = kotlinExtension.targets.first { it is KotlinNativeTarget } as KotlinNativeTarget
val ext = the<KPyExtension>() // error here I'm assuming
// task action
}
}
I am able to use the kpy
keyword in my build.gradle.kts file to configure it and in other parts of the plugin it works fineAndré Martins
05/06/2022, 9:40 AMsourceSets.main.allJava
in the sources jar. When I use Go to definition
in any of the java code it works but on the kotlin it doesn’t, any ideia why?
My publish gradle script looks like this
apply plugin: 'maven-publish'
task sourcesJar(type: Jar) {
from sourceSets.main.allJava
classifier 'sources'
}
publishing {
repositories {
maven {
name 'myRepo'
url '<url>'
credentials {
username 'user'
password 'password'
}
}
}
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourcesJar
}
}
}
Sanendak
05/07/2022, 6:11 PMhandstandsam
05/09/2022, 2:36 PMkotlin-dsl
Script Plugin out of a gradle.kts
file into a normal .kt
file, I am saving ~55 seconds in the configuration phase under "Building included plugins."
NOTE: This is using the "Multiplatform Plugin" (see below post, but with JVM Only it still saves ~15 seconds)
Code & Gradle Build Scan Links: https://github.com/handstandsam/ShoppingApp/pull/58Exerosis
05/10/2022, 6:25 AMtasks.create("whatever") { dependsOn(tasks.build) }
would do the trick however it just runs build on the root project.janvladimirmostert
05/11/2022, 7:57 PMgradle shadowJar
, but only getting a jar with a Manifest in it
in my root build.gradle.kts
, I have the shadow plugin
plugins {
...
val shadowVersion = "7.1.2"
kotlin("multiplatform").version(kotlinVersion).apply(false)
kotlin("plugin.serialization").version(kotlinVersion).apply(false)
id("com.github.johnrengelman.shadow").version(shadowVersion).apply(false)
}
and then in my module
plugins {
application
kotlin("plugin.serialization")
kotlin("multiplatform")
id("com.github.johnrengelman.shadow")
}
application {
mainClass.set("com.blah.MyServer")
}
when running gradle shadowJar
, I get a fatjar which only contains a manifest, nothing else, not even a class file, but when hitting run in IntelliJ, it runs perfectly fine.
my jvm files are under module/src/jvmMain/kotlin/com/blah/*.kt
what is the alternative to build fat jars?
I've tried the zipping approach, but it too is doing the same
tasks.named<Jar>("jar") {
archiveFileName.set("foo.jar")
manifest {
attributes("Main-Class" to "com.blah.MyServer")
}
from(sourceSets.main.get().output)
dependsOn(configurations.runtimeClasspath)
from ({
configurations.runtimeClasspath.get().map { if (it.isDirectory) it else zipTree(it) }
})
}
ziv kesten
05/12/2022, 8:27 AMallprojects {
repositories {
google()
mavenCentral()
jcenter()
maven { url "file:/users/ziv.kesten" } // Local path to the folder into which you unzipped the SDK
}
}
To my project gradle file,
Anf that:
dependencies {
implementation 'com.google.android.gms:play-services-tapandpay:17.1.2'
}
To my grade.bulld
But i fail due to
Unable to resolve dependency for ':lemonade@staging/compileClasspath': Could not resolve com.google.android.gms:play-services-tapandpay:17.1.2.
Anyone knows what am i doing wrong?rkeazor
05/13/2022, 3:14 AMid("com.google.devtools.ksp") version "1.6.10-1.0.2"
Vivek Modi
05/13/2022, 1:34 PMmavelLocal
. I want to learn more. ThanksJavier
05/17/2022, 7:37 PMtargetCompatibility
and sourceCompatibility
?Vivek Modi
05/17/2022, 10:55 PMsettings.gradle.kts
pluginManagement {
repositories {
google()
gradlePluginPortal()
mavenCentral()
}
resolutionStrategy {
eachPlugin {
if (requested.id.namespace == "com.android") {
useModule("com.android.tools.build:gradle:4.1.2"). // How to update to latest version and what is the use of 4.1.2?
}
}
}
}
rootProject.name = "xyz"
I commented in my code. Can someone guide how can I update my gradle version to latest and what is the use of 4.1.2
that piece of code?
I tried to remove 4.1.2 below piece of code then I am getting issue
resolutionStrategy {
eachPlugin {
if (requested.id.namespace == "com.android") {
useModule("com.android.tools.build:gradle:4.1.2")
}
}
}
Error
Build file '/Users/vmodi/IdeaProjects/abc/build.gradle.kts' line: 1
Plugin [id: 'com.android.application'] was not found in any of the following sources:
Vivek Modi
05/18/2022, 12:42 PMVivek Modi
05/18/2022, 1:08 PMid("com.android.application")
and id("com.android.library")
in plugin ? I got this developer doc. I am new in learning gradle stuff. ThanksVivek Modi
05/18/2022, 9:08 PMdef githubPropertiesFile = rootProject.file("github.properties");
def githubProperties = new Properties()
githubProperties.load(new FileInputStream(githubPropertiesFile))
Jorge Castillo
05/19/2022, 4:17 PMJonathan Ellis
05/20/2022, 6:08 PM--max-workers=12
but it did not changeJakob K
05/26/2022, 4:48 PM1.7.0-RC
in a buildSrc project, the kotlin-dsl
plugin cannot be applied. Is there any way I can already use 1.7.0-RC
- or is it just not possible yet?
The exception is:
Caused by: java.lang.NoSuchFieldError: Companion
at org.jetbrains.kotlin.gradle.dsl.ToolchainSupport$Companion.createToolchain$kotlin_gradle_plugin(ToolchainDsl.kt:33)
at org.jetbrains.kotlin.gradle.dsl.KotlinTopLevelExtension.<init>(KotlinProjectExtension.kt:66)
at org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension.<init>(KotlinProjectExtension.kt:106)
Lucas Mo
05/27/2022, 2:01 PMtim
05/28/2022, 7:06 PMdarkmoon_uk
05/31/2022, 8:07 AMAlexandre Brown
06/02/2022, 2:03 AMbuildSrc
.
Is buildSrc
a 1-to1 replacement to subProjects
and which one do you recommend to start a new multi module project if you're not writing a gradle plugin.
I personally started using subProjects
+ gradle.properties.kt
to share dep versions and found it to be super easy to use and flexible.
Imagine a project where we share dependencies, you might have a root build.gradle, then 2 parents modules, then multiple sub module in each parent. Using subProjects we can have one in Parent A build.gradle.kts so that it doesn't impact sub modules of Parent B etc.
From my understanding buildSrc
is more for if you want to write a gradle plugin with logic and want to re-use kotlin kts script then you'd use the buildSrc and define kotlin files there instead of including scripts include("myScript.kts")
. Or if you have complex gradle build logic then you'd use buildSrc as a place to essentially write that build logic.
is that correct?
Thanksjannis
06/02/2022, 8:48 AMnuhkoca
06/02/2022, 5:37 PMplugins
declaration. Applying below in the root Gradle file
plugins {
id("com.android.application") version "7.2" apply false
id("com.android.library") version "7.2" apply false
}
But I also need to apply Gradle
plugin in buildSrc
so I have this in there
implementation("com.android.tools.build:gradle:7.2.0")
but then IDE throws an exception
Error resolving plugin [id: ‘com.android.application’, version: ‘7.2.0’, apply: false]
> The request for this plugin could not be satisfied because the plugin is already on the classpath with an unknown version, so compatibility cannot be checked.How do I have the same plugin works for the both places?
Norbi
06/02/2022, 6:49 PMCould not initialize class org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTargetPreset$WhenMappings
I try to upgrade my fairly complex multiplatform project to Kotlin 1.6.21 (and Compose/MP 1.2.0 alpha 😡) but my hair falls out, I always get different errors and failures 😞Endre Deak
06/03/2022, 3:34 PMdistribution
plugin? I have a service which has a part which generates some kotlin code from a yaml file (using snakeyaml
). But that’s only used manually by developers and isn’t required runtime. Yet, their dependencies defined compileOnly
still appear in build/install/service/lib
folder. I’ve tried to exlcude them by
application {
applicationdistribution.exclude("snakeyaml*.jar)
}
but that kept the jar in the lib folder.
I wonder what’s the right way to isolate these sub-distributions and include only the required dependencies.Akram Bensalem
06/04/2022, 3:57 PMNorbi
06/06/2022, 3:39 PM...
> Task :buildSrc:build UP-TO-DATE
...
FAILURE: Build failed with an exception.
* What went wrong:
Task 'assemble' not found in root project 'xxx'.
...
(See comment for stacktrace.)
Build works if I execute Tasks/build/build in the Gradle tool window.
Maybe is there a ticket to track this issue?
Environment: Idea CE 2022.1.2, Kotlin 1.6.21, Gradle 7.4.2Guido Perre
06/06/2022, 5:09 PMGuido Perre
06/06/2022, 5:09 PMVampire
06/06/2022, 5:55 PMGuido Perre
06/06/2022, 5:59 PMVampire
06/06/2022, 6:01 PMGuido Perre
06/06/2022, 6:15 PMbuildscript {
apply("gradle/classpath.gradle.kts")
}
but i have no luck 😞
I also created a plugin that sets the buildscript block but I get the following error message:
Cannot change dependencies of dependency configuration ':classpath' after it has been resolved.
Vampire
06/06/2022, 8:51 PMapply(from = "...")
and most likely outside the buildscript
block. But I strongly advise against traditional script plugins, especially with Kotlin DSL as you there do not get the type-safe accessors generated. Instead you should use precompiled script plugins in an included build or, if you prefer, buildSrc
. And you should read the documentation as it advised.
Just trying out stuff blindly of course does not work. But hey, an hour of trial and error can save you 5 minutes reading documentation. 😉Guido Perre
06/06/2022, 10:30 PMVampire
06/06/2022, 11:09 PM