-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lazily acquire JDK storage locations #2263
Conversation
@@ -31,7 +33,8 @@ public class BaselineJavaVersionsExtension { | |||
private final Property<JavaLanguageVersion> libraryTarget; | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would hope to reuse this in gradle-jdks to have everything be ETE lazy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?