Eli Graber
08/29/2023, 4:43 PMgetDependencyHandler()
.createArtifactResolutionQuery()
.forComponents(componentIds)
.withArtifacts(MavenModule.class, MavenPomArtifact.class)
.execute()
.getResolvedComponents()
Jason Atwood
08/31/2023, 6:34 PMAndrew Grosner
09/13/2023, 1:15 PMCalculating task graph as configuration cache cannot be reused because init script '../../../../../../private/var/folders/33/6f08jd6s2wl0348f3hl8khqc0000gp/T/ijtestinit.gradle' has been removed.
also conversely saw this fail for it getting added. is this a bug or a feature? (gradle 8.0) not exactly sure what triggers itAndrew Grosner
09/14/2023, 8:55 PMCalculating task graph as configuration cache cannot be reused because the set of Gradle properties has changed.
- is there a way to print out the properties that have changed or at least mention the keys here? Its difficult to gauge what exactly has changed and fix it so it remains relatively stable.Rubydesic
09/26/2023, 5:20 PMif (getState().getExecuting()) {
throw new GradleException("You cannot add child specs at execution time. Consider configuring this task during configuration time or using a separate task to do the configuration.");
}
)
I feel like I have run into a bit of a chicken & egg problem here. Is there any way to do this with configuration cache?
Specifically: I want to configure the exclude
filter for my jar task using the runtimeClasspath
, but I can't resolve that during configuration phase, so it needs to go in a separate task.Javi
10/05/2023, 8:26 AMExec::standardOutput
compatible with configuration cache?
- Task `:someTask` of type `org.gradle.api.tasks.Exec`: cannot serialize object of type 'java.io.ByteArrayOutputStream', a subtype of 'java.io.OutputStream', as these are not supported with the configuration cache.
René
10/05/2023, 8:26 PMtony
10/11/2023, 4:34 AM1 problem was found storing the configuration cache.
Gradle runtime: support for using a Java agent with TestKit builds is not yet implemented with the configuration cache. See <https://docs.gradle.org/7.6.3/userguide/configuration_cache.html#config_cache:not_yet_implemented:testkit_build_with_java_agent>
I can disable the agent in this case. My question is, is this restriction lifted in later versions of Gradle?tony
10/11/2023, 10:10 PM--configuration-cache
, gradle is failing to find the task class itself.
I note the issue doesn't happen with 8.4. Unfortunately it would be nontrivial to update the entire build to that version of Gradle. Is this a known bug? Is there a workaround?
Caused by: java.lang.ClassNotFoundException: com.squareup.cash.classcompatibilitychecker.protos.CheckProtoUsagesTask
at org.gradle.configurationcache.serialization.DefaultReadContext.readClass(Contexts.kt:285)
at org.gradle.configurationcache.serialization.codecs.TaskNodeCodec.readTask(TaskNodeCodec.kt:514)
at org.gradle.configurationcache.serialization.codecs.TaskNodeCodec.decode(TaskNodeCodec.kt:75)
at org.gradle.configurationcache.serialization.codecs.BindingsBackedCodec.decode(BindingsBackedCodec.kt:59)
at org.gradle.configurationcache.serialization.DefaultReadContext.read(Contexts.kt:259)
at org.gradle.configurationcache.serialization.CodecKt.readNonNull(Codec.kt:96)
...
where
abstract class CheckProtoUsagesTask @Inject constructor(private val layout: ProjectLayout) : DefaultTask()
@get:PathSensitive(PathSensitivity.NONE)
@get:InputFiles
abstract val compiledFiles: ConfigurableFileCollection
@get:Classpath
abstract val jarFiles: ConfigurableFileCollection
@get:Nested
abstract val checkFilters: ListProperty<CheckFilter>
@get:Input
abstract val dependencyIdLookup: MapProperty<String, String>
@get:OutputFile
abstract val output: RegularFileProperty
It uses only Gradle managed properties, and CheckFilter
is a custom type that is Serializable
.Carter
10/12/2023, 4:53 PMCarter
10/12/2023, 4:58 PMinputs.property("gitInfo", provider { // call jgit here })
Although it errors with:
- Class `org.eclipse.jgit.util.FS`: external process started '/usr/bin/git config --system --show-origin --list -z'
* Try:
See <https://docs.gradle.org/8.4/userguide/configuration_cache.html#config_cache:requirements:external_processes>
> Run with --stacktrace option to get the stack trace.
Doni
10/13/2023, 2:41 AMfun setBuildReporterListener(buildReporterListener: BuildReporterListener){
buildReporterListenerInternal = buildReporterListener
}
When configuration cache reused, it is null. Is it required to use BuildServiceParameters to pass object to my service?Aviral Jain
10/15/2023, 5:59 PM.gradle/configuration-cache
. I’m trying to make a project where I’m looking to create a central registry server, where I can upload this cache generated by a userA. Then userB can fetch this configuration-cache to speed up it’s first build, by skipping the configuration phase using this cache from registry. However, I’m not sure that how does this cache account for all the libraries and plugins that are installed in the configuration phase. Is there some way to do that?
I tried to build an open-source project as an experiment with gradle remote cache server running and my settings.gradle contains configs to connect to this server. I ran build for this project. The build time was around 2m40s. The cache was uploaded.
Then I setup the same project on another laptop with same configs to remote cache server and ran the build (the first build on this new machine). It was faster - 50s. However, I noticed one thing -> out of the 50s, around 35-40s were used in the configuration phase itself. The execution phase has been optimised to a great extent using the remote cache, but I’m not able to use the configuration cache between multiple machine. Hope this makes the problem statement clearIvan CLOVIS Canet
10/22/2023, 10:21 AMExec
task. I don't want to make my task extend Exec
because that would pollute its API, and it's not safe for users to override the configuration. Previously, I found this forum thread which recommends using `project.exec`in the task action.
However, this crashes the build because org.gradle.api.InvalidUserCodeException: Invocation of 'Task.project' by task ':demo:viteBuild' at execution time is unsupported.
What is the configuration-cache-friendly way to achieve this?Miłosz Lewandowski
10/26/2023, 8:24 AMCalculating task graph as configuration cache cannot be reused because an input to task ':mytask' has changed.
and what exactly is the reason (value changed/file missing/something else?)tony
10/31/2023, 6:24 PM0 problems were found storing the configuration cache.
See the complete report at file:///<redacted>/build/reports/configuration-cache/7jka10r755932lrcjqtcuhngu/c4125sj6k0fr47q1d3nwijaev/configuration-cache-report.html
BUILD SUCCESSFUL in 2m 6s
44 actionable tasks: 14 executed, 30 up-to-date
Configuration cache entry discarded.
René
11/01/2023, 8:31 PMpublic abstract class RestCompatTestTransformTask extends DefaultTask {
...
...
@Nested public abstract ListProperty<RestTestTransform<?>> getTransformations();
...
...
@Inject
public RestCompatTestTransformTask(FileSystemOperations fileSystemOperations, ObjectFactory objectFactory) {
...
...
getTransformations().add(new InjectHeaders(headers, Set.of(RestCompatTestTransformTask::doesNotHaveCatOperation)));
}
private static boolean doesNotHaveCatOperation(ObjectNode doNodeValue) {
final Iterator<String> fieldNamesIterator = doNodeValue.fieldNames();
while (fieldNamesIterator.hasNext()) {
final String fieldName = fieldNamesIterator.next();
if (fieldName.startsWith("cat.")) {
return false;
}
}
return true;
}
}
public class InjectHeaders extends FeatureInjector implements RestTestTransformByParentObject, Serializable {
private static JsonNodeFactory jsonNodeFactory = JsonNodeFactory.withExactBigDecimals(false);
private Map<String, String> headers;
private Set<SerializableFunction<ObjectNode, Boolean>> applyConditions;
public InjectHeaders(Map<String, String> headers, Set<SerializableFunction<ObjectNode, Boolean>> applyConditions) {
this.headers = headers;
this.applyConditions = applyConditions;
}
...
...
}
This results in a build error when running with configuration cache enabled:
FAILURE: Build failed with an exception.
* What went wrong:
Could not load the value of field `applyConditions` of `org.elasticsearch.gradle.internal.test.rest.transform.headers.InjectHeaders` bean found in field `__transformations__` of task `:rest-api-spec:yamlRestTestV7CompatTransform` of type `org.elasticsearch.gradle.internal.test.rest.compat.compat.RestCompatTestTransformTask`.
> java.lang.reflect.InvocationTargetException (no error message)
...
...
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:119)
at org.gradle.configurationcache.serialization.codecs.jos.JavaObjectSerializationCodec.readResolve(JavaObjectSerializationCodec.kt:194)
at org.gradle.configurationcache.serialization.codecs.jos.JavaObjectSerializationCodec.decode(JavaObjectSerializationCodec.kt:109)
at org.gradle.configurationcache.serialization.codecs.BindingsBackedCodec.decode(BindingsBackedCodec.kt:59)
at org.gradle.configurationcache.serialization.DefaultReadContext.read(Contexts.kt:269)
at org.gradle.configurationcache.serialization.beans.BeanPropertyReaderKt.readPropertyValue(BeanPropertyReader.kt:106)
... 170 more
Caused by: java.io.InvalidObjectException: null array
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
... 175 more
I'm running out of ideas how to fix this. Does any of you have any pointer how to resolve this or whats the root problem here?Charbel Sadaka
11/09/2023, 12:48 PMKarim Houari
11/30/2023, 9:37 AMDirectoryScanner.removeDefaultExclude("**/.gitignore")
in my settings.gradle.kts file, and when running my build I get some errors with message "Cannot change default excludes during the build ... Configure default excludes in the settings script instead." Any idea how I can resolve this? Thank you.Javi
12/04/2023, 8:26 AMsetFileMode
method.
tasks.register('foo', Copy) {
from(layout.projectDirectory.dir("foo")) {
eachFile {
setFileMode(0775)
}
}
into layout.projectDirectory.dir("foo/bar")
doLast {
....
}
}
The exception:
Execution failed for task ':foo'.
> No signature of method: org.gradle.api.Project.setFileMode() is applicable for argument types: () values: []
I have tried
• Set the from
and/or into
inside doFirst
, it doesn't crash but then the task doesn't copy the files.
• Wrap the mode value with a provider, I get the same exception.A Abhishek
12/04/2023, 9:46 AMAdam
12/07/2023, 10:41 AMnotCompatibleWithConfigurationCache
, yet I get this warning after every build. Configuration cache entry discarded because incompatible task was found: $myTask
. How can I tell Gradle to entirely ignore this task and config cache everything else?Jendrik Johannes
12/11/2023, 8:13 AMzipTree(...)
inside a Provider.map { }
function on Configuration.elements
as part of some CopySpec (jmh-gradle-plugin/pull/261). The following does not work with CC:
from(runtimeConfiguration.elements.map {
it.collect { it.asFile }.collect { it.directory ? it : project.zipTree(it) }
})
If my understanding is correct, the problem here is that not the result of the calculation is cached, but the mapping closure – everything in map { }
– itself. Which makes sense, as the dependency resolution (including running artifact transforms) needs to take place before the files can be inspected.
So that code effectively runs at execution time and thus project.zipTree
is not allowed.
In this concrete case, the code is part of the configuration of a Jar
task. The only solution I came up with is to sublcass the task, to inject ArchiveOperations
and then use that subtype for the task we (luckily in this case) register ourselves. Then we can use archives.zipTree()
.
static abstract class JarWithArchiveOperations extends Jar {
@Inject
abstract protected ArchiveOperations getArchives()
}
My question is if there is any other way to get hold of the ArchiveOperations
in such a case. For one, defining the subclass feels like a hack here. And, more problematic, what would I do if the task would be already registered? Or if I would write the spec as a part of an independent copySpec {}
that I would like to use in multiple places? I have that issue in the build setup of another project.Jendrik Johannes
12/11/2023, 11:32 AMruntimeConfiguration.elements
, it riggers the artifact transforms early. Which will then attempt to work on locally built Jar files, which do not yet exist. My transforms are called for files that are not yet present.
Is this a known issue?Vibin Reddy
12/13/2023, 10:02 AMpproject-root>/.gradle/configuration-cache
is 80 MB. It's an Android project containing 238 modules.A Abhishek
12/14/2023, 9:51 AMVibin Reddy
12/16/2023, 3:09 PMSergey Lapin
12/20/2023, 12:09 PMhash-1
in build/reports/configuration-cached/{hash-1}/{hash-2}/configuration-cache-report.html
is calculated?
Context:
Before stabilization of CC in 8.1 I’ve managed to successfully relocate CC across CI runners and it worked just fine. Ever since 8.1 I don’t see CC cache hits although for 2 subsequent runs {hash-2}
s from path above are the same and the content of the reports are similar.
I’ve double checked all the env vars and system properties, they stay the same across runs.
Absolute paths are not the issue, as runners are stateless and dir structure is the same for each and every one. The only difference that I notice is this {hash-1}
part of the CC report path, so I wonder now from what is it calculated, maybe this would help me to identify the issue.Ryan Schmitt
12/21/2023, 9:46 PMCalculating task graph as configuration cache cannot be reused because environment variable 'JAVA_MAIN_CLASS_41102' has changed.
There's a comment in Jvm.java
stating that this is one of several environment variables known to change across builds, so I'm not sure why it's invalidating the configuration cache entryIvan CLOVIS Canet
01/07/2024, 11:13 AMproject
captured by the configuration cache in this task?
transitiveJsResources
is a Configuration
, extractionDirectory
is a File
, none of them should capture the project?