Lazily acquire JDK storage locations#2263
Conversation
| private final Property<JavaLanguageVersion> distributionTarget; | ||
| private final Property<JavaLanguageVersion> runtime; | ||
| private final MapProperty<JavaLanguageVersion, JavaInstallationMetadata> jdks; | ||
| private final LazilyConfiguredMapping<JavaLanguageVersion, AtomicReference<JavaInstallationMetadata>> jdks = |
There was a problem hiding this comment.
Why use an AtomicReference here? I wanted to make a general type I could reuse in gradle-jdks to configure the versions/distributions, which would involve modifying extension objects in the regular gradle style. So we use an AtomicReference here just to make it act like a box you can store data in.
| import java.util.function.Supplier; | ||
| import org.gradle.api.Action; | ||
|
|
||
| public final class LazilyConfiguredMapping<K, V> { |
There was a problem hiding this comment.
I would hope to reuse this in gradle-jdks to have everything be ETE lazy.
There was a problem hiding this comment.
perhaps move to the extensions package and make package private?
|
|
||
| public final class LazilyConfiguredMapping<K, V> { | ||
| private final Supplier<V> valueFactory; | ||
| private final List<LazyValues<K, V>> values = new ArrayList<>(); |
There was a problem hiding this comment.
It might have been easier to set this as just a single function you have to replace - but I'm concerned that just leads to everything becoming confusing if you "override" the value in custom gradle for example to test a new JDK major version that hasn't been fully released yet.
| } | ||
|
|
||
| public interface LazyJdks { | ||
| Optional<JavaInstallationMetadata> jdkFor(JavaLanguageVersion javaLanguageVersion); |
There was a problem hiding this comment.
This is basically making it fully lazy.
|
Released 4.133.0 |
###### _excavator_ is a bot for automating changes across repositories. Changes produced by the roomba/latest-baseline-oss check. # Release Notes ## 4.132.0 | Type | Description | Link | | ---- | ----------- | ---- | | Improvement | Safety analysis checks superinterfaces (in addition to superclasses) | palantir/gradle-baseline#2267 | ## 4.133.0 | Type | Description | Link | | ---- | ----------- | ---- | | Fix | More lazily acquire JDK storage locations | palantir/gradle-baseline#2263 | ## 4.134.0 | Type | Description | Link | | ---- | ----------- | ---- | | Fix | Fix concurrency issue in LazilyConfiguredMapping | palantir/gradle-baseline#2268 | To enable or disable this check, please contact the maintainers of Excavator.
Before this PR
You must know about all the JDK versions you need to set before the baseline-java-versions plugin uses them. This can make being a lazy as possible harder, and complicates the logic slightly.
After this PR
==COMMIT_MSG==
More lazily acquire JDK storage locations
==COMMIT_MSG==
Possible downsides?