Nayeem Zen
02/12/2022, 11:40 PMcompileKotlin
is ultra slow on IntelliJ? It seems to be fast enough when running through the CLI.scana
02/14/2022, 11:38 AMlibs.versions.toml
catalogue? It does not auto updates and it makes editing kts files not that pleasant 😞iamraghavawasthi
02/16/2022, 6:50 AMjean
02/17/2022, 8:56 PMMiquel Àngel Román
02/18/2022, 5:11 PMplugins {
id("org.hidetake.ssh")
}
remotes {
create("raspberry") {
host = "192.168.1.36"
user = "pi"
password = "doesntmatter"
}
}
But when I start declaring the gradle task all falls apart:
tasks.register("deploy-to-pi") {
doLast{
ssh.run {
session(remotes["raspberry"]) {
}
}
}
}
With:
Unresolved reference: session
Eric
02/21/2022, 2:09 PMinline fun <reified T : Any> PluginManager.apply() = apply(T::class.java)
inline fun <reified T : Plugin<*>> PluginContainer.getPlugin(): T = getPlugin(T::class.java)
inline fun <reified T : Task> TaskContainer.withType(): TaskCollection<T> = withType(T::class.java)
inline fun <reified T : Any> ExtensionContainer.findByType(): T? = findByType(T::class.java)
inline fun <reified T : Any> ExtensionContainer.configure(action: Action<T>) = configure(T::class.java, action)
Searching is difficult because because I just get hits on “how to write plugins” etc.
Then I can write more “Kotlin-esque” code like this:
plugin.pluginManager.apply<DetektPlugin>()
plugin.extensions.configure<DetektExtension> { detekt ->
// ...
}
val detekt = target.tasks.withType<Detekt>().first()
Filip Piechowski
02/21/2022, 3:40 PMmain
, adapter
and port
, where port
I want to take advantage of kotlin internal
access modifier to hide adapter
declarations from port
.
This is my current buildscript:
plugins {
kotlin("jvm") version "1.6.10"
}
group = "hex"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
implementation(kotlin("stdlib"))
}
kotlin {
sourceSets {
val ports by creating {
}
val adapters by creating {
dependsOn(ports)
}
main.get().apply {
dependsOn(ports)
dependsOn(adapters)
}
}
}
After importing gradle project in intellij I see that it recognizes new sourcesets but internal declarations in adapter
are accessible from port
sources so it’s not treated as a module described here https://kotlinlang.org/docs/visibility-modifiers.html#modules
It looks like source sets are created in gradle model, but they are used by kotlin as one collective source set, at least that’s what i think is happening.
So i want to achieve a gradle build with one project (just root, no subprojects), one compilation, but 3 source sets (depending on each other as shown by dependsOn
s). What am I missing to get that working as I expect?Eric
02/21/2022, 7:03 PMjean
02/21/2022, 9:11 PM[plugins]
kotlin-android = {id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
but I get the following error Error resolving plugin [id: 'org.jetbrains.kotlin.android', version: '1.5.30']
when checking mvnrepository.com I can see it exists implementation("org.jetbrains.kotlin.android:org.jetbrains.kotlin.android.gradle.plugin:1.5.30")
but I guess I’m not using the correct string in the id
property?Vaios Tsitsonis
02/24/2022, 8:35 AMtestBuildType
field (else they will run in the debug
buildType). Let's say that I have a buildType with the name buildTypeA
and write testBuildType="buildTypeA"
, then everything works as expected. The problem is that when the name of the buildType is calculated by a function this does not seem to work. The strange thing is that testBuildType=calculateBuildType()
assigns the correct value but in Android Studio I get Nothing here
when I try to run them. Even if we define a pretty dummy calculate function the tests wont run (calculateBuildType(): String = "buildTypeA"
<-- this does not work :S). Is this expected behaviour? My goal is to be able to run tests on the current buildType, without having to switch to the debug buildType which is counterproductive.Travis Reitter
02/24/2022, 5:51 PMgradle/
, gradlew
, and gradle.bat
both at the project top-level and within android/
. I noticed because I had to update my gradle version in two separate gradle/wrapper/gradle-wrapper.properties
. But if I delete these files under android/
, I get Task 'wrapper' not found in project ':android'.
. What other changes would I need to make? Or do I have to keep both sets? If so, is there any way I can factor out the Gradle version into a single file?Pablichjenkov
02/25/2022, 3:14 AMlibrary
module the app
module is not able to see that specific variant of the library
.
library build.gradle:
buildTypes {
release {
isMinifyEnabled = true
isTestCoverageEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"<http://proguard-rules.pro|proguard-rules.pro>"
)
}
debug {
isJniDebuggable = true
isTestCoverageEnabled = true
}
create("customVariant") {
isJniDebuggable = true
isTestCoverageEnabled = true
matchingFallbacks += listOf("debug", "release")
}
}
sample module build.gradle:
dependencies {
implementation("androidx.appcompat:appcompat:1.4.0")
implementation ("com.google.android.material:material:1.4.0")
//Lingo SDK
implementation(project(":library", "customVariant"))
}
When trying to compile I get:
Could not determine the dependencies of task ':sample:compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':sample:debugCompileClasspath'.
> Could not resolve project :library.
Required by:
project :sample
> Project :sample declares a dependency from configuration 'implementation' to configuration 'customVariant' which is not declared in the descriptor for project :library
Has anyone experienced something similar?
Thanks in advanceMrPowerGamerBR
02/25/2022, 3:14 PM.yml
files for localization files, if there is a key commands.hello: "Hello {user}!"
, a class + function is generated named I18nKeysData.Commands.Hello(name: Any)
Currently what I'm doing is this
// HACKY WORKAROUND!!!
// This makes the generateI18nKeys task to always be ran before the compileKotlin step
// We need to do this (instead of using withType) because, for some reason, it doesn't work and the task isn't executed.
//
// We need to keep it within the "afterEvaluate" block because, if it isn't, the compile*InsertStuffHere* tasks won't exist!
// <https://stackoverflow.com/a/58763804/7271796>
project.afterEvaluate {
project.tasks.filter { it.name.startsWith("compileKotlin") }.forEach {
it.dependsOn(task)
}
}
But I think it is very hacky and it broke in Kotlin 1.6.20-M1 because they added a new compileCommonMainKotlinMetadata
task, so I wonder if there is a better solution for thisAyfri
02/27/2022, 11:29 AMcafonsomota
03/03/2022, 3:10 AMPartho Paul
03/03/2022, 5:50 AMorg.gradle.api.tasks.TaskExecutionException: Execution failed for task ':compileProductionExecutableKotlinJs'
error while compiling my project. I tried deleting build and gradle folder and rebuilding but it didn't fix the issue. Attached in the thread is a snippet of the complete stack trace. Has anyone experienced something similar?
Thanks in advanceVivek Modi
03/07/2022, 10:06 PMval packForXcode by tasks.creating(Sync::class) {
val targetDir = File(buildDir, "xcode-frameworks")
/// selecting the right configuration for the iOS
/// framework depending on the environment
/// variables set by Xcode build
val mode = System.getenv("CONFIGURATION") ?: "DEBUG"
val framework = kotlin.targets
.getByName<KotlinNativeTarget>("ios")
.binaries.getFramework(mode)
inputs.property("mode", mode)
dependsOn(framework.linkTask)
from({ framework.outputDirectory })
into(targetDir)
/// generate a helpful ./gradlew wrapper with embedded Java path
doLast {
val gradlew = File(targetDir, "gradlew")
gradlew.writeText("#!/bin/bash\n"
+ "export 'JAVA_HOME=${System.getProperty("java.home")}'\n"
+ "cd '${rootProject.rootDir}'\n"
+ "./gradlew \$@\n")
gradlew.setExecutable(true)
}
}
tasks.getByName("build").dependsOn(packForXcode)
build.gradle.ktsManoj
03/08/2022, 11:49 AMPablichjenkov
03/09/2022, 1:22 AMfat aar
with gradle subprojects. Tried a couple of plugins online but they did not work.Sean Proctor
03/09/2022, 12:49 PMdarkmoon_uk
03/11/2022, 6:57 AMplugin
declaration in the toml
file
• Need to put the plugin on the class-path because it's not found with ID alone (e.g:`"com.android.application"`)
• Gradle refuses version specification when plugin is already on the classpath
Catch 22!? Is anyone declaring the com.android.application / library
plugin with Version Catalogs successfully?Eric
03/11/2022, 1:37 PMdix
03/15/2022, 6:31 PM./gradlew test
from a command line, i see the cache being used for everything including tests, but if I use intellij to run the same gradle task the cache is not respected, is that something others have come acrossJason Ankers
03/18/2022, 8:10 AMKClass.objectInstance
from working in fullMode? The error message is a bit cryptic:
Kotlin reflection implementation is not found at runtime. Make sure you have kotlin-reflect.jar in the classpath
I am already -keep
ing the class which I call objectInstance
on, and kotlin-reflect
is specified as part of my dependencies. It only breaks when fullMode
is turned onAndré Martins
03/18/2022, 4:28 PMjanvladimirmostert
03/20/2022, 2:30 PMmodule-info.java
to my src/main/kotlin
directory, any examples of how the gradle config should be done to make the module-info.java
be included?
I've tried adding module-info.java
to src/main/java
but then it doesn't find the kotlin classesMarcelo Hernandez
03/22/2022, 9:50 PMbuildSrc
with *.gradle.kts
files in a multi-module Android project. I notice that with this change, the Kotlin Gradle DSL seems to be overriding the kotlin-stdlib
to 1.5.31
for my actual project even though the project declares the following in the root build.gradle
dependencies {
…
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"
The buildSrc/build.gradle.kts
file is registering the kotlin-dsl
plugin and declares the following in the dependencies
block:
dependencies {
…
implementation(kotlin("gradle-plugin"))
}
Eric
03/23/2022, 1:37 PMorg.springframework.boot:spring-boot-dependencies
(bom) to my bom I’m publishing so that only 1 line of
implementation(platform("com.example:common-bom:1.0-SNAPSHOT"))
is needed instead of needing both platforms like this:
implementation(platform("com.example:common-bom:1.0-SNAPSHOT"))
implementation(platform("org.springframework.boot:spring-boot-dependencies:2.5.10"))
Is there a doc showing how to do that?André Martins
03/24/2022, 6:16 PMeygraber
03/24/2022, 11:22 PM-Xopt-in
and Kotlin 1.6.20-RC while using Gradle Kotlin DSL?
https://youtrack.jetbrains.com/issue/KT-51708eygraber
03/24/2022, 11:22 PM-Xopt-in
and Kotlin 1.6.20-RC while using Gradle Kotlin DSL?
https://youtrack.jetbrains.com/issue/KT-51708Albert Chang
03/25/2022, 2:04 AM-opt-in=kotlin.RequiresOptIn
. The -opt-in kotlin.RequiresOptIn
syntax is only valid in CLI (i.e. when you invoke kotlin compiler on the command line).ephemient
03/25/2022, 2:31 AMlistOf("-opt-in", "kotlin.RequiresOptIn")
would work like the CLI too. but a single argument with a space in it is definitely not rightlanguageSettings
kotlin.sourceSets.all {
languageSettings.optIn(...)
}
eygraber
03/25/2022, 2:15 PMUseIf I use-opt-in=kotlin.RequiresOptIn
-opt-in=Kotlin.RequiresOptIn
I get an error that says:
e: Invalid argument: -opt-in=kotlin.RequiresOptIn
listOf("-opt-in", "kotlin.RequiresOptIn")Results in an error that says:
e: Invalid argument: -opt-in
The Gradle field is inThat was it, thanks! I thought it was inlanguageSettings
kotlinOptions
because of https://youtrack.jetbrains.com/issue/KT-47099ephemient
03/25/2022, 3:11 PMeygraber
03/25/2022, 5:07 PM