Robert Elliot
04/14/2025, 12:43 PMbuild.gradle
to build.gradle.kts
. The file has been going for 14 years, so there's the inevitable layers of fine-then-bad-practice-now stuff.
I'm wondering how best to prove I have migrated all the tasks and logic identically. In an ideal world I could export the configured model for all the tasks, I guess, and check it hadn't changed. Does anyone have any tips on implementing such a test? It feels very 20th century to just leap in, start changing things and hope I spot what breaks - some of these tasks are run rarely.Albert ten Napel
04/15/2025, 12:51 PMArga
04/16/2025, 8:47 AMNiels Doucet
04/16/2025, 12:29 PMextraProperties
abstraction?Jonathing
04/16/2025, 3:46 PM@DelegatesTo
and/or @ClosureParams
. Is there a good reason for this or is this just a result of how long Gradle has been around? And would you be open to contributions that add these annotations? I'd appreciate the additional IDE support.Chris
04/16/2025, 11:10 PMmelix
04/18/2025, 9:12 AMpublic interface CreateLayerOptions extends LayerOptions {
@Input
@Optional
ListProperty<String> getPackages();
@Classpath
@Optional
ConfigurableFileCollection getJars();
@Input
ListProperty<String> getModules();
}
there is, in my code, a single call to `getJars()`:
var classpath = create.getJars();
boolean hasJars = !classpath.getFiles().isEmpty();
The interface is implemented and added to a domain object set using:
@Override
public void createLayer(Action<? super CreateLayerOptions> spec) {
var layer = objects.newInstance(CreateLayerOptions.class);
var binaryName = getName();
if (!binaryName.startsWith("lib")) {
throw new IllegalArgumentException("Binary name for a layer must start with 'lib'");
}
layer.getLayerName().convention(binaryName);
spec.execute(layer);
layers(options -> options.add(layer));
}
and the user code to configure it currently has (this is all a spike, so hopefully I can make this nicer):
createLayer {
val externalJars = configurations.nativeImageClasspath.get()
.incoming
.artifactView {
lenient(false)
componentFilter { this is ModuleComponentIdentifier }
}
.artifacts
modules = listOf("java.base", "jdk.unsupported", "java.sql")
jars.from(externalJars.resolvedArtifacts
.map { artifacts -> artifacts.map { it.file } }
)
...
When I debug, I can see that after spec.execute(layer)
is called, layer.getFrom()
contains one element as expected. However, when my code to get this list of jars is called, the list is empty oO. I have verified and it's the same instance. Only "something" make the contents go away. The suspect is input evaluation, but I'm 🤨Ivan CLOVIS Canet
04/20/2025, 3:36 PMtest {
onOutput { descriptor, event ->
if (event.destination == TestOutputEvent.Destination.StdErr) {
logger.error("Test: " + descriptor + ", error: " + event.message)
}
}
}
I'm struggling on onOuput
. I guess it's something like
onOutput(closureOf<???> {})
but I don't know what the type is.Jonathing
04/21/2025, 12:20 PMGábor Török
04/21/2025, 9:11 PMJavaExec
tasks by presetting some properties like system properties, env properties, classpath, etc, and i am wondering what's the best way for for it would be. these values need to be different based on which environment we want to run in.
i have come up with something like this:
abstract class ExecInStaging : JavaExec() {
init {
systemProperty("appconfig", "config/staging.properties")
systemProperty("log4j.configurationFile", "log4j2-local.xml")
environment("CONSUL_HOST", STAGING_CONSUL)
classpath = project.extensions
.getByType<JavaPluginExtension>()
.sourceSets
.getByName("main")
.runtimeClasspath
}
}
this works - but i am wondering if there are some best practices around this that i am missing? doing all this configuration in the constructor feels a bit weird - especially since now i am getting a bunch of IDE warnings due to Calling non-final function {} in constructor
...
is there a better way to do this?Philip W
04/22/2025, 8:50 AMChris
04/22/2025, 12:45 PMAdam
04/22/2025, 5:53 PMsystemProperty("...", "...")
work, but these are eager and I want to avoid them.
Weirdly when I print all properties in the application they appear under a different property - sun.java.command=org.example.AppKt -DsecretFile=/Users/dev/my-project/secret-file
.
I think it's weird there's an inconsistency. I would expect both approaches to work the same.
Also, I think it's weird that logging commandLine
returns a null
as the first element: [:run] running task [null, -DsecretFile=/Users/dev/my-project/secret-file]
plugins {
kotlin("jvm") version "2.1.20"
application
}
tasks.run.configure {
val secretFile = layout.projectDirectory.file("secret-file")
inputs.file(secretFile)
argumentProviders += CommandLineArgumentProvider {
listOf("-DsecretFile=${secretFile.asFile.absoluteFile.invariantSeparatorsPath}")
}
systemProperty("secretFileWorks", secretFile.asFile.absoluteFile.invariantSeparatorsPath)
doFirst {
println("[$path] running task $commandLine")
}
}
Gradle version is 8.13Philip W
04/22/2025, 8:01 PMlifecycle.afterProject
. But the project does not find the plugin this way, but it finds the plugin if I apply it directly in my build.gradle.kts script.Ayanda Mtungwa
04/23/2025, 11:34 AMKur'an Ögrenme
04/23/2025, 12:52 PMMartin
04/24/2025, 5:24 PM8.13
and not 8.13.0
? Gets me every time 😅Sergej Koščejev
04/25/2025, 2:31 PMif (someCondition) { into(...) { ... } }
but where someCondition is a boolean Property?Giuseppe Barbieri
04/25/2025, 3:58 PMorg.jogamp.gluegen:gluegen-rt
, org.jogamp.joal:joal
, etc
code here, I can work around for the configurations and the publications, but the javaComponent
is a problem, or does anyone see a way?fantastic Dev
04/25/2025, 4:41 PM% ./gradle
Error occurred during initialization of VM
Could not resolve "ZIP_Open": /Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home/lib/libzip.dylib
Eli Graber
04/25/2025, 4:45 PMjava.lang.System::load
warnings with Gradle 8.14 and Java 24? I would think not because of #31625, but not sure.Eli Graber
04/25/2025, 5:24 PM--enable-native-access=ALL-UNNAMED
to my jvm args until all of these libraries/tools migrate off of JNI (so probably never)?
WARNING: A restricted method in java.lang.System has been called
WARNING: java.lang.System::load has been called by com.android.layoutlib.bridge.Bridge in an unnamed module (file:/home/eli/.gradle/caches/8.14/transforms/7ddbbeceffb506f2342ae2f7da76cf06/transformed/layoutlib-15.1.4.jar)
WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for callers in this module
WARNING: Restricted methods will be blocked in a future release unless native access is enabled
Sebastian Schuberth
04/27/2025, 8:11 AMBob Shalom
04/27/2025, 8:17 AMVladimir Sitnikov
04/28/2025, 7:22 AMConfigurableFileCollection
vs ListProperty<RegularFile>
Is there anything like “prefer ConfigurableFileCollection
in newer code” or “prefer ListProperty<RegularFile>
in newer code” ?
I assume the answer should be the same for both task properties and extension properties, however, it would be great to learn if there’s a difference.Giuseppe Barbieri
04/28/2025, 12:20 PMorg.jogamp.gluegen:gluegen-rt
and the natives as variants
now I'm on the consumer side, with a test project, expanding the runtime configuration for each variant, adding the corresponding file underneath, but Gradle complains:
Could not resolve org.jogamp.gluegen:gluegen-rt:0.0.8 for variant-tester:main
Could not resolve org.jogamp.gluegen:gluegen-rt:0.0.8 for variant-tester:test
hissam ud din
04/29/2025, 12:58 AMA problem occurred configuring project ':gradle'.> Multiple build operations failed. Could not isolate parameters org.gradle.api.internal.initialization.transform.MergeInstrumentationAnalysisTransform$Parameters_Decorated@50814c83 of artifact transform MergeInstrumentationAnalysisTransform Could not isolate parameters org.gradle.api.internal.initialization.transform.MergeInstrumentationAnalysisTransform$Parameters_Decorated@50814c83 of artifact transform MergeInstrumentationAnalysisTransform Could not isolate parameters org.gradle.api.internal.initialization.transform.MergeInstrumentationAnalysisTransform$Parameters_Decorated@50814c83 of artifact transform MergeInstrumentationAnalysisTransform Could not isolate parameters org.gradle.api.internal.initialization.transform.MergeInstrumentationAnalysisTransform$Parameters_Decorated@50814c83 of artifact transform MergeInstrumentationAnalysisTransform Could not isolate parameters org.gradle.api.internal.initialization.transform.MergeInstrumentationAnalysisTransform$Parameters_Decorated@50814c83 of artifact transform MergeInstrumentationAnalysisTransform Could not isolate parameters org.gradle.api.internal.initialization.transform.MergeInstrumentationAnalysisTransform$Parameters_Decorated@50814c83 of artifact transform MergeInstrumentationAnalysisTransform Could not isolate parameters org.gradle.api.internal.initialization.transform.MergeInstrumentationAnalysisTransform$Parameters_Decorated@50814c83 of artifact transform MergeInstrumentationAnalysisTransform Could not isolate parameters org.gradle.api.internal.initialization.transform.MergeInstrumentationAnalysisTransform$Parameters_Decorated@50814c83 of artifact transform MergeInstrumentationAnalysisTransform Could not isolate parameters org.gradle.api.internal.initialization.transform.MergeInstrumentationAnalysisTransform$Parameters_Decorated@50814c83 of artifact transform MergeInstrumentationAnalysisTransform Could not isolate parameters org.gradle.api.internal.initialization.transform.MergeInstrumentationAnalysisTransform$Parameters_Decorated@50814c83 of artifact transform MergeInstrumentationAnalysisTransform ...and 20 more failures. > Could not isolate parameters org.gradle.api.internal.initialization.transform.MergeInstrumentationAnalysisTransform$Parameters_Decorated@50814c83 of artifact transform MergeInstrumentationAnalysisTransform > Could not isolate value org.gradle.api.internal.initialization.transform.MergeInstrumentationAnalysisTransform$Parameters_Decorated@50814c83 of type MergeInstrumentationAnalysisTransform.Parameters > Multiple build operations failed. Could not move temporary workspace (C:\Users\dell\.gradle\caches\8.10.2\transforms\904c97b439784601ff0eee25e3c43bac-84c63b27-7c61-4f8e-b3c9-ac04c14f9c94) to immutable location (C:\Users\dell\.gradle\caches\8.10.2\transforms\904c97b439784601ff0eee25e3c43bac) Could not move temporary workspace (C:\Users\dell\.gradle\caches\8.10.2\transforms\4c75e264bb05f340dad2540f720bcb1b-9fc2d5c5-fbc6-4b93-8074-75ef4d405d09) to immutable location (C:\Users\dell\.gradle\caches\8.10.2\transforms\4c75e264bb05f340dad2540f720bcb1b) > Could not move temporary workspace (C:\Users\dell\.gradle\caches\8.10.2\transforms\904c97b439784601ff0eee25e3c43bac-84c63b27-7c61-4f8e-b3c9-ac04c14f9c94) to immutable location (C:\Users\dell\.gradle\caches\8.10.2\transforms\904c97b439784601ff0eee25e3c43bac) > Could not move temporary workspace (C:\Users\dell\.gradle\caches\8.10.2\transforms\4c75e264bb05f340dad2540f720bcb1b-9fc2d5c5-fbc6-4b93-8074-75ef4d405d09) to immutable location (C:\Users\dell\.gradle\caches\8.10.2\transforms\4c75e264bb05f340dad2540f720bcb1b) * Try:
Run with --stacktrace option to get the stack trace.
Run 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.BUILD FAILED in 1m 38s Error: Gradle task assembleDebug failed with exit code 1
Kaan Avdan
04/29/2025, 8:27 AMKen Yee
04/29/2025, 7:18 PMtasks.register("updateModuleCapabilitiesIndex") {
val watchFiles = fileTree(project.rootDir) {
include("**/build.gradle", "**/build.gradle.kts")
}.files
val moduleIndexFile = "${layout.buildDirectory.get()}/moduleCapabilities.json"
val moduleIndexCmdLine = listOf(
"./gradlew",
"...",
)
inputs.files(watchFiles)
doLast {
providers.exec {
commandLine = moduleIndexCmdLine
}
}
dependsOn("build")
}
Command removed for simplification, but I'm trying to write something that parses the gradle files and then saves the info into another file in a cacheable way.
The doLast{...} bit unfortunately contains a gradle script which is not serializable... Tried to search in this slack but configuration cache gets a lot of unrelated hits 😂SettingDust
04/30/2025, 3:13 AMCircular dependency between the following tasks:
work action Dependencies for XXXXXX
? Looks like the transform action depends on each other?
The image is the cycle shows in debugger. Looks like the states of different transform is looping. How can I avoid that?
https://github.com/SettingDust/cloche/blob/feature/extract-includes/src/main/kotlin/earth/terrarium/cloche/target/TargetCompilation.kt#L122-L148
Circular dependency between the following tasks:
work action Dependencies for dev.su5ed.sinytra.fabric-api:fabric-api-deprecated:0.92.2+1.11.11+1.20.1 {earth.terrarium.cloche.modState=none}