Chris
08/16/2023, 6:26 PMconfiguations.creating
. I found an old issue for this, but it was closed by the bot: https://github.com/gradle/gradle/issues/9242 Does anyone know if there is a live issue for this, and whether there are plans to fix it?Endre Deak
08/24/2023, 2:52 AMjib
to create some containers. Multiple modules uses it, and there are lots of commonalities. Is there a way to extract those out to a common place and then reuse?
So instead of having:
module1/build.gradle.kts
jib {
...
}
module2/build.gradle.kts
jib {
...
}
I would just do something like
module1/build.gradle.kts
commonJibTask(paramsForModule1)
module2/build.gradle.kts
commonJibTask(paramsForModule2)
Francis West
09/03/2023, 4:42 PMtasks.withType<Test> {
useJUnitPlatform()
testLogging {
events = setOf(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED)
}
}
Francis West
09/03/2023, 4:43 PMGuilherme Delgado
09/08/2023, 11:38 AM#!/bin/bash
echo "> Yay!"
task:
tasks.register<Exec>("runBashScript") {
standardOutput = ByteArrayOutputStream()
errorOutput = ByteArrayOutputStream()
commandLine("bash", "-c", "./script.sh > >(tee -a ${standardOutput}) 2> >(tee -a ${errorOutput})")
doFirst {
println("> Executing runBashScript task")
}
doLast {
println("Command Output:")
println(standardOutput.toString())
println("Command Error:")
println(errorOutput.toString())
}
}
But I’m always getting:
Execution failed for task ':runBashScript'.
> Process 'command 'bash'' finished with non-zero exit value 127
I’m lost 😕archie
09/18/2023, 12:10 AMsrc
directory from being made.
I tried clearing the source set to no avail.
sourceSets {
main {
java.srcDirs()
kotlin.srcDirs()
}
}
The src/ directories keep re-appearing when I make a new modulesamuel
10/02/2023, 1:01 PM./gradlew myTask --console=plain
Is there a way to configure my task to have the flag --console=plain
built in so i can get the same result just by running ./gradlew myTask
I tried something like this but it did not seem to have an effect:
abstract class MyTask: DefaultTask() {
@Option(option = "console", description = "")
@Input
val taskOption: String = "plain"
@TaskAction
fun action(){
// My action
}
}
Kelvin Chung
10/13/2023, 10:36 PMval service = project.gradle.sharedServices.registrations.named<BuildServiceRegistration<MyService, *>>("myService").flatMap { it.getService } // OK
val service2 = project.gradle.sharedServices.registrations.named<BuildServiceRegistration<MyService, *>>("myService").flatMap { it.service } // Error
Both of these should be Provider<MyService>
, but the second one errors due to not having type information on the parameters object or somesuch. Why is that?Martins Albert
11/08/2023, 5:44 AMGiuseppe Barbieri
11/16/2023, 10:35 AMifPresent { }
available on Property
(maybe even better on Provider
) to execute some code if .isPresent == true
Martin
11/17/2023, 11:12 AMimport
statements that are situated before the plugins {}
block?// this symbol is in the com.example jar
import com.example.Symbol
plugins {
id("com.example")
}
// do stuff with Symbol
Dilan
11/19/2023, 12:29 AMTask 'run' not found in root project 'FlippingTileProject'.
I was suggested to do this, but this doesn't work, errors on both application and mainClass.
plugins {
id("java")
id("application")
}
group = "org.fliptile"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
testImplementation(platform("org.junit:junit-bom:5.9.1"))
testImplementation("org.junit.jupiter:junit-jupiter")
}
tasks.test {
useJUnitPlatform()
}
application {
mainClass.set("org.fliptile.Main")
}
Would appreciate any help.
Edit:✅ Fixed, thank you Adam.
Problem was with Scanner trying to read elements that were never there, also I put this into the build.gradle.kts so input actually worked correctly.
tasks.named<JavaExec>("run") {
standardInput = System.`in`
}
Abe
11/22/2023, 11:13 PMjvmTarget
in a central location:
kotlin {
compilerOptions {
jvmTarget.set(JvmTarget.fromTarget("11")) // fails
// jvmTarget.set(JvmTarget.JVM_11) // works
}
}
> > No signature of method: static org.jetbrains.kotlin.gradle.dsl.JvmTarget.fromTarget() is applicable for argument types: (String) values: [11]
> Possible solutions: getTarget()
Why cannot I use the fromTarget
function in my Groovy script?
https://github.com/JetBrains/kotlin/blob/1.8.0/libraries/tools/kotlin-gradle-compi[…]c/generated/kotlin/org/jetbrains/kotlin/gradle/dsl/JvmTarget.ktKelvin Chung
11/30/2023, 9:17 PMProvider
is not meant to be nullable, correct? I'm just wondering why I sometimes get Provider<T?>
type inferences.JoshuA
12/08/2023, 2:28 PMJoshuA
12/08/2023, 2:28 PMKelvin Chung
12/08/2023, 5:02 PMProvider.isNotPresent
or Provider.filterNot
, in line with how there are extensions like these in the Kotlin standard library.Nuh Koca
12/08/2023, 8:50 PMGroovy
to combine jacoco reports from sub modules. However, we are migrating into Kotlin DSL
and tried to 1:1 conversion but it is not working and throwing `Error while creating jacoco report`(Please find the entire stacktrace and both versions in 🧵). Is there something wrong with it?Abdullah Zubair
12/19/2023, 3:56 PMDarryl Miles
01/22/2024, 6:43 PMtask explodedWar(type: Sync) {
into "${buildDir}/libs/exploded/yourWar.war"
with war
}
// my efforts get to
tasks.register<Sync>("explodedWar") {
into("${layout.buildDirectory}/libs/exploded/yourWar.war")
with(war)
// ^^^ --- red error markers
}
// can't find anything with the correct type on content assist
It wants a CopySpec
which I assume needs to be all the standard outputs in the WAR tree format
There is an implicit configuration called archives
that produces the non-exploded WAR file. So this must clearly have configuration with all the data in some format necessary (input file -> output file, mappings)
Without the with()
part, nothing appears to happen, I also don't get the default configuration action for archives
anymore, when really I would like it to always emit the standard output artifacts, but in addition produce an exploded. (edited)Vampire
01/28/2024, 4:48 PMorg.gradle.kotlin.dsl.normalization.CompileAvoidanceException: class .../CachedProviderKt: inline fun cached(): compile avoidance is not supported with public inline functions
want to tell me?
Or better asked, what can I do about it besides not using a library in build logic that provides a public inline function?István Mészáros
02/04/2024, 12:19 PMdependencies {
implementation("group:name:version") // pulls in the main dep
implementation("group:name:version") {
capabilities {
requireCapability("group:name-cap1:version") // pulls in cap1 of main dep
}
}
implementation("group:name:version") {
capabilities {
requireCapability("group:name-cap2:version") // pulls in cap2 of main dep
}
}
}
I could make it a bit more readable:
dependencies {
"group:name:version".let {
implementation(it)
implementation(it) {
capabilities {
requireCapability("$group:$name-cap1:$version")
}
}
implementation(it) {
capabilities {
requireCapability("$group:$name-cap2:$version")
}
}
}
}
However, something like this would be nice:
dependencies {
implementation("group:name:version", withCapabilities = "cap1", "cap2)
}
Does anything like that exist?Mohammed Mahmood Ahmed
02/11/2024, 11:41 AMapplicationVariants.forEach { variant ->
variant.outputs.forEach { output ->
val SEP = "_"
val date = Date()
val dateFormat = SimpleDateFormat("dd_MM_yy_hh_mm")
val formattedDate = dateFormat.format(date)
var gitBranch = getGitBranch()
gitBranch = gitBranch.take(gitBranch.length - 1)
val apkName = variant.name + SEP + output.versionCode + SEP + gitBranch + SEP + formattedDate + ".apk"
// output.outputFileName = apkName
}
}
the last line of code ie output.outputFileName gives error that its a val and cant be reassigned... however there's a blog post https://narendranathchatterjee.medium.com/make-your-build-apks-tell-you-more-f51f2c038831 which does this
Is it due to the fact that I am using kotlin gradle or is it something else... Also how do I resolve this?Omico
02/21/2024, 10:59 AMpublish
or publishToMavenLocal
?
tasks.withType<AbstractPublishToMaven> {
dependsOn(tasks.build)
}
tasks.withType<AbstractPublishToMaven>().configureEach {
dependsOn(tasks.build)
}
tasks.withType<AbstractPublishToMaven>().all {
dependsOn(tasks.build)
}
Caleb Cushing
02/29/2024, 6:20 PMimport org.gradle.accessors.dm.LibrariesForLibs
val asciidoclet by configurations.creating {}
val libs = the<LibrariesForLibs>()
dependencies {
asciidoclet(libs.plugin.asciidoc.javadoc)
}
tasks.withType<Javadoc> {
options {
docletpath(*asciidoclet.files.toTypedArray())
doclet = "org.asciidoctor.Asciidoclet"
jFlags("-baseDir", project.layout.projectDirectory.asFile.name)
}
}
Shalom Ben-Zvi Kazaz
03/20/2024, 7:59 PMAndré Martins
03/22/2024, 6:00 PMgradle bootRun -Dspring.profiles.active=local
the profile is not set, it only works if I set env var like SPRING_PROFILES_ACTIVE=local gradle bootRun
why is that? Does -D<prop>=<value>
not work with Kotlin DSL?JRF IBITF
03/26/2024, 7:39 AMRun with --info or --debug option to get more log output.
Run with --scan to get full insights.
Get more help at https://help.gradle.org.* Exception is: org.gradle.api.plugins.UnknownPluginException: Plugin [id: 'com.android.application', version: '8.3.1', apply: false] was not found in any of the following sources: can u help me?
Shalom Ben-Zvi Kazaz
03/27/2024, 10:25 PMcom.squareup.retrofit2:retrofit:2.9.0
-- com.squareup.okhttp3:okhttp:3.14.9
now I want to add a direct dependency on com.squareup.okhttp3:logging-interceptor, and i want it to be the same version of okhttp that retrofit brings,3.14.9.
of course i can declare com.squareup.okhttp3:logging-interceptor to the same version, but i want to know if there is a way to do it using some resolution strategy?
so if i declare com.squareup.okhttp3logging interceptor4.12.0 i want to force it to the same version of okhttp 3.14.9.André Martins
04/27/2024, 7:57 PM(code in comment)
This is working currently, but I do have two questions/concerns:
• Do I always need to setup everything inside project.afterEvaluate
?
• Is there a more convenient type instead of Property for specifying a function? In order to avoid .get()()
Thanks in advance ✌️