Skip to content

Conversation

@snazy
Copy link
Contributor

@snazy snazy commented Nov 17, 2025

This prevents some unnecessary allocations during runtime.

Follow up #1849.


  • CHANGELOG's "Unreleased" section has been updated, if applicable.

This prevents some unnecessary allocations during runtime.
Comment on lines 20 to 21
@get:Internal
internal open val patternSpec: Spec<FileTreeElement> by lazy(LazyThreadSafetyMode.NONE) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@get:Internal
internal open val patternSpec: Spec<FileTreeElement> by lazy(LazyThreadSafetyMode.NONE) {
private val patternSpec: Spec<FileTreeElement> by lazy(LazyThreadSafetyMode.NONE) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer, but that prevents overriding it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shouldn't be overridden. We can just mark it public if necessary.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed it's useful for #1855, we can mark it as protected.

…nsformers/PatternFilterableResourceTransformer.kt
Comment on lines -29 to -30
assertThat(transformer.canTransformResource("META-INF/LICENSE.txt")).isTrue()
assertThat(transformer.canTransformResource("META-INF/LICENSE.log")).isFalse()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't update these tests, they are unrelated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooops, I see, the conditions are cached.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it's a consequence of the by lazy, updating the includes/excludes don't change the spec.

@Goooler Goooler changed the title Add lazy for PatternSet.asSpec Cache patternSet.asSpec by lazy Nov 17, 2025
…nsformers/ApacheLicenseResourceTransformerTest.kt
…nsformers/ApacheNoticeResourceTransformerTest.kt
@Goooler Goooler enabled auto-merge (squash) November 17, 2025 12:02
…nsformers/PatternFilterableResourceTransformer.kt
@Goooler Goooler merged commit 5a785c2 into GradleUp:main Nov 17, 2025
6 checks passed
@snazy snazy deleted the ps-spec branch November 17, 2025 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants