Edoardo Luppi
02/18/2024, 1:56 PMJoel Denke
02/19/2024, 9:20 AMMichael Krussel
02/19/2024, 2:51 PMOleg Nenashev
02/21/2024, 9:48 AM@GTaskAction(
description = "cooks the most delicious ratatouille with the help of the tiniest chef",
group = "recipes"
)
internal fun cook(
recipe: GInputFile,
ingredients: Ingredients,
outputFile: GOutputFile
) {
TODO()
}
More info:
• GitHub Repo and documentation: https://github.com/GradleUp/gratatouille
• Discuss on Gradle forums: https://discuss.gradle.org/t/rfc-gratatouille-cook-yourself-delicious-gradle-plugins-generating-tasks-from-kotlin-functions-using-ksp/47718
TL;DR: G 🤝🏻🐭👉🧑🍳 // 🙂Bekzod
02/21/2024, 11:17 AMCristhian Escobar
02/21/2024, 12:13 PMlocal.properties
, but I'm not very satisfied with it. I also saw this project https://github.com/yshrsmz/BuildKonfig, but I'm not thrilled with it either. I'm wondering if there's something better out there.
sourcesSets {
val commonMain by getting {
val packageName = "io.company.shared.generated"
val localProperties = project.getLocalProperties()
val configDirectory = File(project.buildDir, "main/kotlin/generated")
// Generate build config for both platforms
generateBuildConfig(localProperties, packageName, configDirectory)
kotlin.srcDir(configDirectory)
...
}
}
fun Project.getLocalProperties(): Properties {
val properties = Properties()
val localPropertiesFile = rootProject.file("local.properties")
if (localPropertiesFile.exists()) {
properties.load(localPropertiesFile.inputStream())
}
return properties
}
// TODO: turn this into a plugin or find a better and scalable alternative
fun generateBuildConfig(properties: Properties, packageName: String, outputDir: File) {
val content = buildString {
appendLine("package $packageName")
appendLine()
appendLine("object SharedBuildConfig {")
properties.forEach { key, value ->
// Skip the SDK.DIR property
if (key.toString() != "sdk.dir") {
// Remove extra quotes from the property value if present
val cleanValue = value.toString().trim().removeSurrounding("\"")
// Properly escape the string and surround with quotes for the Kotlin file
appendLine(" const val ${key.toString().replace(".", "_")
.uppercase(Locale.getDefault())} = \"${cleanValue.replace("\\", "\\\\")}\"")
}
}
appendLine("}")
}
outputDir.apply {
mkdirs()
resolve("SharedBuildConfig.kt").writeText(content)
}
}
enighma
02/22/2024, 12:46 AMreactormonk
02/22/2024, 4:42 PMdependencyResolutionManagement {
// repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url "<https://jitpack.io>" }
// TODO replace by includeBuild <https://stackoverflow.com/questions/72543519/gradle-sync-failed-when-upgrade-to-7-3-3-and-agp-7-2-0-cannot-initiate-v1-model>
mavenLocal {
content {
includeGroup("no.entur.android.nfc")
includeGroup("net.folivo")
}
}
}
}
And this code:
implementation("net.folivo:trixnity-client:4.2.6-LOCAL")
and
~/.m2/repository/net/folivo/trixnity-client $ cat maven-metadata-local.xml
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>net.folivo</groupId>
<artifactId>trixnity-client</artifactId>
<versioning>
<latest>4.2.6-LOCAL</latest>
<release>4.2.6-LOCAL</release>
<versions>
<version>4.2.6-LOCAL</version>
</versions>
<lastUpdated>20240222160142</lastUpdated>
</versioning>
</metadata>
But I get
Failed to resolve: net.folivo:trixnity-client:4.2.6-LOCAL
Paul Meshkovsky
02/22/2024, 7:12 PMSlackbot
02/25/2024, 3:26 PMursus
02/25/2024, 3:26 PMritesh
02/26/2024, 12:24 AMOleg Nenashev
02/26/2024, 10:36 AM#declarative-gradle
- on the Gradle Community Slack
• Category on Discourse - on Gradle Forums
In the coming weeks/months, we will share much more about the project and its progress. You are welcome to join the channels and the discussions there!Giovanny Velez
02/26/2024, 6:55 PMaar
and a Java JAR
library?
I’ve been messing with targetSources the Android and Java plugins, but no success 😞
For more detailed context, what I need is a module just with the Compose Multiplatform dependencies and my own composables. And to add it as a dependency in the compatible targets (I can’t add it to comonMain since I’m also using a Kotlin JS target which can’t manage Compose Multiplatform), so I’ll add it manually to the Android, iOS and Desktop targets.arekolek
02/27/2024, 11:09 AMRepositoryHandler.myProxy()
in settings.gradle.kts
?
fun RepositoryHandler.myProxy(repository: String, fallbackUrl: String? = null, vararg includeGroups: String) {
maven("<https://example.com/$repository/>") {
content { includeGroups.forEach(::includeGroup) }
credentials {
username = providers.gradleProperty("MY_PROXY_USERNAME").get()
password = providers.gradleProperty("MY_PROXY_PASSWORD").get()
}
}
if (fallbackUrl == null) return
maven(fallbackUrl) {
content { includeGroups.forEach(::includeGroup) }
}
}
I would like to use it like:
pluginManagement {
repositories {
gradlePluginPortal()
google()
myProxy("maven-central")
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
myProxy("jitpack-io", "<https://jitpack.io>", "com.example")
google()
myProxy("maven-central")
mavenCentral()
}
}
but I would have to repeat the definition in both pluginManagement
and dependencyResolutionManagement
is there any way to re-use the same definition in both? I don't see why that should be impossible (since it works if I just duplicate it)CLOVIS
02/27/2024, 4:47 PMjsMain
source set doesn't depend on the commonMain
source set?
I first learned of this here, but we couldn't find any documentation explaining why that is.ursus
03/03/2024, 3:01 AMagp
to 8.3.0
after a release build I see baseline profiles generated at `build/outputs/apk/release/flavor/baselineProfiles`with 2 .dm
files
Uhm.. why? Didn't it use to need to launch some emulator tests etc?
Or is this not new?Patrik Aradi
03/04/2024, 1:54 AMCsászár Ákos
03/07/2024, 1:30 PMAlexander Zhirkevich
03/10/2024, 10:16 PM./gradlew B:assebmle --continue --dependency-verification off
fails with unresolved dependency error. Why Gradle tries to resolve dependency for the module that is not required for the requested task? Can i disable it in any other way than excluding A from the project?CLOVIS
03/11/2024, 7:32 PMkotlinExtension.sourceSets.named { it == "jsMain" }.configureEach {
println("The JS source set exists")
}
then the build fails with
> Configure project :core
e: Please initialize at least one Kotlin target in 'core (:core)'.
Read more <https://kotl.in/set-up-targets>
w: The following Kotlin source sets were configured but not added to any Kotlin compilation:
* commonMain
* commonTest
where :core
is just:
plugins {
kotlin("multiplatform")
id("my.plugin.here")
id("maven-publish")
}
kotlin {
jvm()
js(IR) {
browser()
}
}
My understanding is that .named { … }.configureEach { … }
is lazy and thus shouldn't impact the build configuration at all, and certainly not which platforms are declared.
I also tried
kotlinExtension.sourceSets.configureEach {
if (it.name != "jsMain") return@configureEach
println("The JS source set exists")
}
to the same result.Albert Chang
03/13/2024, 2:57 AMkotlin-dsl
plugin to the module. When I try to use Enum.entries
in the module, I get two errors:
• The feature "enum entries" is only available since language version 1.9
• This declaration needs opt-in. Its usage must be marked with '@kotlin.ExperimentalStdlibApi' or '@OptIn(kotlin.ExperimentalStdlibApi::class)'
Even if I add @OptIn(kotlin.ExperimentalStdlibApi::class)
, the first error still persists.
But if I use embedded-kotlin
instead of kotlin-dsl
, the errors go away. Any reasons why?
I'm using Gradle 8.6 and the bundled Kotlin version is 1.9.20.Joel Denke
03/13/2024, 7:11 AMeygraber
03/13/2024, 5:49 PMapplyDefaultHierarchyTemplate
?eygraber
03/15/2024, 3:53 AMallTests
should it be running android unit tests?Jon Bailey
03/15/2024, 1:02 PMAndroid75
03/16/2024, 6:16 AMimplementation project(":data")
Arjan van Wieringen
03/16/2024, 6:16 PMplugins {
`java-gradle-plugin`
`kotlin-dsl`
}
sourceSets {
main {
kotlin {
srcDir("src/main/kotlin")
}
}
}
https://docs.gradle.org/current/userguide/custom_plugins.html#sec:custom_plugins_standalone_project
EDIT: well.... actually that just works, after removing kotlin-dsl
. I am a bit uncertain whether or not kotlin-dsl was needed. I suppose it wasnt. A plugin is 'just' another project.Raimund Klein
03/16/2024, 10:39 PMidea {
module {
downloadJavadoc = true
downloadSources = true
}
}
Hristijan
03/18/2024, 12:34 PM