Peter
11/12/2023, 8:12 PM:A -> :B -> :C
.
I know it's not ideal, but I don't want to burden my team on a time constrained project. It brings some challenges, that we're not used to.
Is it still worth doing, or should I simply keep it a monolith?
I'm guessing it would be better for the future, to at least same some basic module structure, so it could potentially be refactored a bit easier, if needed.Vishnu Shrikar
11/12/2023, 11:08 PMtasks.register("test") {
dependsOn("desktopTest")
}
Result:Vishnu Shrikar
11/12/2023, 11:09 PMtasks.replace("test").dependsOn("desktopTest")
Result shown below, can someone help me figure out wtf happens here because I am very stumped thanksMiguel Oliveira
11/13/2023, 2:04 PM1.9.20
, AGP from 7.2.1 to 7.4.2
and Gradle from 7.6.1 to 8.4
.
After publishing the library version with the updates, a client reported that he can no longer build using the library due to:
e: C:/.../.gradle/caches/transforms-3/c84840751d0bf885b57987b97ba24946/transformed/jetified-kotlin-stdlib-1.9.20.jar!/META-INF/kotlin-stdlib-jdk7.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.
even after deleting all caches.
I have multiple android-only and multiplatform modules that are published, none has explicit declaration of kotlin-stdlib and I'm declaring:
Android-only modules `build.gradle`:
android {
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
languageVersion = '1.7'
apiVersion = '1.7'
jvmTarget = "1.8"
}
}
Multiplaform modules `build.gradle.kts`:
kotlin {
androidTarget {
compilations.all {
kotlinOptions {
languageVersion = "1.7"
apiVersion = "1.7"
jvmTarget = "1.8"
}
}
}
sourceSets {
all {
languageSettings {
languageVersion = "1.7"
apiVersion = "1.7"
}
}
}
}
Does any one know what could be causing this? And am I missing something to keep the library compatible with Kotlin 1.7?kqr
11/16/2023, 9:38 AMtasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict", "-Xallow-any-scripts-in-source-roots")
}
}
and
kotlin {
compilerOptions {
freeCompilerArgs.add("-Xjsr305=strict")
freeCompilerArgs.add("-Xallow-any-scripts-in-source-roots")
}
}
or to be more precise why the latter one does not work ?:)jean
11/16/2023, 9:00 PMbuild.gradle.kts
file inside a module (called logic
)?
This code returns null
for both tasks even though I can find them in the GUI of android studio
val compileDebugKotlinAndroidTask = tasks.findByPath(":logic:compileDebugKotlinAndroid")
val kspCommonMainKotlinMetadataTask = tasks.findByPath(":logic:kspCommonMainKotlinMetadata")
println("compileDebugKotlinAndroidTask exists: $compileDebugKotlinAndroidTask")
println("kspCommonMainKotlinMetadataTask exists: $kspCommonMainKotlinMetadataTask")
compileDebugKotlinAndroidTask?.dependsOn(kspCommonMainKotlinMetadataTask)
...
compileDebugKotlinAndroidTask exists: null
kspCommonMainKotlinMetadataTask exists: null
mudasar187
11/17/2023, 9:34 AMFAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':compileKotlin'.
> Unknown Kotlin JVM target: 21
kotlin {
jvmToolchain {
languageVersion.set(JavaLanguageVersion.of(21))
}
}
Anyone know how I can solve this issues?Christian Sciberras
11/19/2023, 6:52 PMmateusz.kwiecinski
11/20/2023, 9:21 PMorg.jetbrains.kotlin:kotlin-gradle-plugin-api
artifact. Does it have dedicated documentation page somewhere where one can learn more about it? Does -api
come with extra stability? Should I aim to migrate my Gradle plugins to call only classes from -api
(meaning it's worth reporting issues if some apis don't seem available?)ritesh
11/20/2023, 10:21 PMjetified-kotlin-reflect-1.8.22.jar
as an input to kapt tasks as compared to other.
Any thoughts? Ideally - build with jetifier disabled should perform better.statmark56
11/20/2023, 11:45 PMtasks.register<ExampleTask>("example")
abstract class ExampleTask : DefaultTask() {
@TaskAction
fun initialize() {
println("Hello World")
}
}
But when I run it ./gradlew example
I got:
Could not create task :example
Could not create task of type ExampleTask
Class Build_gradle.ExampleTask is a non-static inner class.
What do I miss? Thanksscirner
11/21/2023, 3:08 AMmartmists
11/21/2023, 7:39 AMval javacpp by configurations.creating
not being a valid configuration in the androidMain sourceset dependencies.
How would I solve this?Nick Kleban
11/21/2023, 9:03 AMbuild-logic
(included build) inside app/build.gradle.kts
in the plugins { }
block?
I have function that looks like
fun isCI() = System.getenv("GITLAB_CI").toBoolean()
And I can use it in the app/build.gradle.kts
everywhere except plugins
block where I get “Unresolved reference” error
plugins {
alias(libs.plugins...) apply isCI()
}
Nathan Bedell
11/21/2023, 1:17 PMhfhbd
11/23/2023, 10:14 AMEdoardo Luppi
11/23/2023, 2:32 PMjava {
sourceSets {
main {
java.srcDir("src/jvmMain/gen")
}
}
}
Edit2: not really working in case of Java sources sad panda
Edit: I can answer myself
kotlin {
sourceSets {
jvmMain {
kotlin {
srcDir("src/jvmMain/gen")
}
}
}
}
Maybe dumb question, but how do I add a `gen`erated source folder, which will be ignored but part of the classpath, under src/jvmMain
?
The project is multiplatform.eygraber
11/23/2023, 7:54 PMwithWasm
in applyDefaultHierarchyTemplate
specifically for wasmJs
?Matej Drobnič
11/24/2023, 6:06 AMAdemir Queiroga
11/24/2023, 6:40 PMAdemir Queiroga
11/24/2023, 6:46 PMstatmark56
11/26/2023, 2:26 AMandroid {
...
defaultConfig {
...
resourceConfiguration += listOf("en", "hdpi")
}
}
Will also help improve unit test compile speed?geepawhill
11/26/2023, 3:53 AMAlexei Artsimovich
11/27/2023, 11:38 AMinternal
keyword plays a role in this. Should classes and methods that are not intended to be used outside a module be marked with the internal visibility so that changes to their signature do not cause dependent modules to be recompiled?eygraber
11/27/2023, 11:09 PM> Task :integration-tests:ksp:kspTestKotlinWasmJs FAILED
w: duplicate library name: kotlin
e: warnings found and -Werror specified
Djuro
11/28/2023, 1:22 PMbuild.gradle.kts
file. I need maven-publish
plugin for that. Here is how the task looks
abstract class MyTask : DefaultTask() {
@get:Input
abstract val moduleName: Property<String>
@get:Input
abstract val moduleArtifactId: Property<String>
@get:Input
abstract val repositoryUrl: Property<String>
@TaskAction
fun execute() {
print("hello from my task, my name is ${moduleName.get()}, ${moduleArtifactId.get()}, ${repositoryUrl.get()}") //${name.get()}")
project.publishing {
publications {
create<MavenPublication>("release") {
groupId = project.properties["groupId"] as String
version = project.properties["version"] as String
artifactId = moduleArtifactId.get()
project.afterEvaluate {
from(components["release"])
}
artifact("$buildDir/outputs/aar/$artifactId-release.aar") {
classifier = "release"
}
}
}
repositories {
maven {
this.name = moduleName.get()
this.url = uri(repositoryUrl.get())
credentials {
username = "my-user-name"
password = "my-password"
}
}
}
}
}
}
and I register it in build.gradle.kts
in the following manner:
tasks.register<MyTask>("mytask") {
moduleName.set("module's name")
moduleArtifactId.set("artifact's id")
repositoryUrl.set("remote repo's url")
}
Error I am getting is:
* What went wrong:
A problem occurred configuring project ':sdk:modulename'.
> Could not create task ':sdk:modulename:mytask'.
> Could not create task of type 'MyTask'.
> Class Build_gradle.MyTask is a non-static inner class.
I need a task for this since I want the exact same logic for all the modules. I just change some of things dynamically, like url
and artifactId
Arkadii Ivanov
11/29/2023, 7:27 PMCiaran Sloan
11/29/2023, 7:42 PMKspConfiguration
. I somehow don't seem to be able to resolve that in my plugin, where could I be going wrong?
class ExamplePlugin: Plugin<Project> {
override fun apply(target: Project) {
with(target) {
pluginManager.apply("com.google.devtools.ksp")
// KspExtension doesn't resolve
extensions.configure<KspExtension> {}
// ksp bloc doesnt resolve
ksp {
}
}
}
ianbrandt
11/30/2023, 1:18 AMKotlinCompileDaemon
process to the mix. Does that exclusively handle the compilation of Kotlin sources, or are compileJava
tasks executed by that as well (instead of the usual Gradle Daemon/Worker processes)?
I'm trying to understand whether the standard Gradle suggestions and features for optimizing Java compilation, such as forking `JavaCompile` tasks, and the new persistent Java compiler daemon feature, apply any differently when the Kotlin Gradle Plugin is used.
Just as background, I work primarily on a sizable project that mixes Java and Kotlin, and optimizing build times is a constant challenge. I currently apply the KGP to all my Gradle subprojects via a convention plugin, regardless of whether they contain only Java, only Kotlin, or a mix of both.Adam S
11/30/2023, 11:41 AM.
└── foo-project/
├── submodule1 (Kotlin JVM)
└── submodule2 (Kotlin JVM)
When I try and get KotlinProjectExtension I get an exception
val ke = project.extensions.findByType<org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension>()
// Type org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension not present
I find I need to have kotlin("jvm") version "1.8.22" apply false
on the root project, otherwise Dokkatoo can't fetch the Kotlin org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
in the subprojects, even though they have applied the Kotlin JVM plugin.
I tried falling back to fetching org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
, but that also fails with the same error, "Type org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension not present"
If I debug print the available extensions, I can see that KotlinJvmProjectExtension is present
logger.warn("extensions: ${project.extensions.extensionsSchema.elements.joinToString { "${it.name} ${it.publicType}" }}")
// extensions: kotlin org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension (...)