Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release7x' into release
Browse files Browse the repository at this point in the history
* origin/release7x:
  Fix issue with ant builder throwing exception on call()
  Ignore failing M9JavaConfigurabilityCrossVersionSpec on Gradle 2.x
  Revert some unnecessary changes
  Reformat to one sentence per line
  Fix deprecation message
  Fix test
  Do not expose named domain object list (backport #23050 & #23112)
  Remove exceptional M1 Mac toolchain handling
  Fix test
  Consider IBM and IBM_SEMERU vendors identical, deprecate the later
  Fix the issue of provisioning the same toolchain multiple times (backport #23024)
  Check Java Toolchain install folder for left-overs (backport #22819)
  Remove cygwin gcc
  Prepare for 7.6.1 release
  Fix upgrade note following Groovy update
  Attempt to reduce GC pressure by not holding expensive this references in ThreadLocals
  Refactor ArtifactSelector to avoid capturing the full component metadata in the lambda
  • Loading branch information
big-guy committed Dec 20, 2022
2 parents cd75e01 + d1a0b6e commit 2f90694
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 25 deletions.
Expand Up @@ -74,12 +74,14 @@ private void writeObject(java.io.ObjectOutputStream out) throws IOException {
}

private ThreadLocal<Boolean> threadLocal() {
return new ThreadLocal<Boolean>() {
@Override
protected Boolean initialValue() {
return false;
}
};
return new HideStacktrace();
}

private static class HideStacktrace extends ThreadLocal<Boolean> {
@Override
protected Boolean initialValue() {
return false;
}
}

@Override
Expand Down
Expand Up @@ -19,12 +19,13 @@
import org.gradle.api.Action;

public class DefaultMutationGuard extends AbstractMutationGuard {
private final ThreadLocal<Boolean> mutationGuardState = new ThreadLocal<Boolean>() {
private final ThreadLocal<Boolean> mutationGuardState = new GuardState();
private static class GuardState extends ThreadLocal<Boolean> {
@Override
protected Boolean initialValue() {
return Boolean.TRUE;
}
};
}

@Override
public boolean isMutationAllowed() {
Expand Down
Expand Up @@ -67,9 +67,11 @@ public ArtifactSet resolveArtifacts(LocalFileDependencyMetadata fileDependencyMe

@Override
public ArtifactSet resolveArtifacts(ComponentResolveMetadata component, @Nullable Map<VariantResolveMetadata.Identifier, ResolvedVariant> resolvedVariantCache, Supplier<Set<? extends VariantResolveMetadata>> allVariants, Set<? extends VariantResolveMetadata> legacyVariants, ExcludeSpec exclusions, ImmutableAttributes overriddenAttributes) {
ModuleVersionIdentifier moduleVersionId = component.getModuleVersionId();
ModuleSources sources = component.getSources();

ImmutableSet<ResolvedVariant> legacyResolvedVariants = buildResolvedVariants(component, legacyVariants, exclusions, resolvedVariantCache);
ComponentArtifactResolveVariantState componentArtifactResolveVariantState = () -> buildResolvedVariants(component, allVariants.get(), exclusions, resolvedVariantCache);
ImmutableSet<ResolvedVariant> legacyResolvedVariants = buildResolvedVariants(moduleVersionId, sources, legacyVariants, exclusions, resolvedVariantCache);
ComponentArtifactResolveVariantState componentArtifactResolveVariantState = () -> buildResolvedVariants(moduleVersionId, sources, allVariants.get(), exclusions, resolvedVariantCache);

for (OriginArtifactSelector selector : selectors) {
ArtifactSet artifacts = selector.resolveArtifacts(component, componentArtifactResolveVariantState, legacyResolvedVariants, exclusions, overriddenAttributes);
Expand All @@ -80,10 +82,10 @@ public ArtifactSet resolveArtifacts(ComponentResolveMetadata component, @Nullabl
throw new IllegalStateException("No artifacts selected.");
}

private ImmutableSet<ResolvedVariant> buildResolvedVariants(ComponentResolveMetadata component, Set<? extends VariantResolveMetadata> allVariants, ExcludeSpec exclusions, @Nullable Map<VariantResolveMetadata.Identifier, ResolvedVariant> resolvedVariantCache) {
private ImmutableSet<ResolvedVariant> buildResolvedVariants(ModuleVersionIdentifier moduleVersionId, ModuleSources sources, Set<? extends VariantResolveMetadata> allVariants, ExcludeSpec exclusions, @Nullable Map<VariantResolveMetadata.Identifier, ResolvedVariant> resolvedVariantCache) {
ImmutableSet.Builder<ResolvedVariant> resolvedVariantBuilder = ImmutableSet.builder();
for (VariantResolveMetadata variant : allVariants) {
ResolvedVariant resolvedVariant = toResolvedVariant(variant.getIdentifier(), variant.asDescribable(), variant.getAttributes(), variant.getArtifacts(), variant.getCapabilities(), exclusions, component.getModuleVersionId(), component.getSources(), resolvedVariantCache);
ResolvedVariant resolvedVariant = toResolvedVariant(variant.getIdentifier(), variant.asDescribable(), variant.getAttributes(), variant.getArtifacts(), variant.getCapabilities(), exclusions, moduleVersionId, sources, resolvedVariantCache);
resolvedVariantBuilder.add(resolvedVariant);
}
return resolvedVariantBuilder.build();
Expand Down
Expand Up @@ -673,7 +673,7 @@ tasks.withType<KotlinCompile>().configureEach {

Groovy has been updated to https://groovy-lang.org/changelogs/changelog-3.0.13.html[Groovy 3.0.13].

Since the previous version was 3.0.11, the https://groovy-lang.org/changelogs/changelog-3.0.12.html[3.0.12 changes] are also included.
Since the previous version was 3.0.10, the https://groovy-lang.org/changelogs/changelog-3.0.11.html[3.0.11] and https://groovy-lang.org/changelogs/changelog-3.0.12.html[3.0.12] changes are also included.

==== Upgrade to CodeNarc 3.1.0

Expand Down Expand Up @@ -1151,6 +1151,7 @@ The same is true for `link:{javadocPath}/org/gradle/api/tasks/TaskInputs.html#di
==== Using LazyPublishArtifact without a FileResolver is deprecated

When using a LazyPublishArtifact without a FileResolver, a different file resolution strategy is used, which duplicates some logic in the FileResolver.

To improve consistency, LazyPublishArtifact should be used with a FileResolver, and will require it in the future.

This also affects other internal APIs that use LazyPublishArtifact, which now also have deprecation warnings where needed.
Expand All @@ -1169,6 +1170,7 @@ This way, Gradle is able to apply optimizations like up-to-date checks instead o
==== Unique attribute sets

The set of link:{javadocPath}/org/gradle/api/attributes/Attribute.html[Attribute]s associated with a _consumable_ configuration within a project, must be unique across all other configurations within that project which share the same set of link:{javadocPath}/org/gradle/api/capabilities/Capability.html[Capability]s.

This will be checked at the end of configuring variant configurations, as they are locked against further mutation.

If the set of attributes is shared across configurations, consider adding an additional attribute to one of the variants for the sole purpose of disambiguation.
Expand Down Expand Up @@ -1275,6 +1277,7 @@ These methods were changed to improve the consistency between the `libs.versions
==== Application order of plugins in the `plugins` block

The order in which plugins in the `plugins` block were actually applied was inconsistent and depended on how a plugin was added to the class path.

Now the plugins are always applied in the same order they are declared in the `plugins` block which in rare cases might change behavior of existing builds.

==== Effects of exclusion on substituted dependencies in dependency resolution
Expand Down
Expand Up @@ -17,7 +17,6 @@
package org.gradle.jvm.toolchain.internal;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Supplier;
import org.gradle.api.GradleException;
import org.gradle.api.logging.Logger;
import org.gradle.api.logging.Logging;
Expand All @@ -36,6 +35,7 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.stream.Collectors;


Expand Down Expand Up @@ -151,12 +151,12 @@ public BuildOperationDescriptor.Builder description() {

private static class Installations {

private final Supplier<Set<InstallationLocation>> initialiser;
private final Supplier<Set<InstallationLocation>> initializer;

private Set<InstallationLocation> locations = null;

Installations(Supplier<Set<InstallationLocation>> initialiser) {
this.initialiser = initialiser;
Installations(Supplier<Set<InstallationLocation>> initializer) {
this.initializer = initializer;
}

synchronized Set<InstallationLocation> get() {
Expand All @@ -171,7 +171,7 @@ synchronized void add(InstallationLocation location) {

private void initIfNeeded() {
if (locations == null) {
locations = initialiser.get();
locations = initializer.get();
}
}

Expand Down
Expand Up @@ -18,6 +18,7 @@ package org.gradle.internal.extensibility


import org.gradle.integtests.fixtures.AbstractIntegrationSpec
import spock.lang.Issue

class CallablePropertyIntegrationTest extends AbstractIntegrationSpec {

Expand Down Expand Up @@ -95,4 +96,19 @@ class CallablePropertyIntegrationTest extends AbstractIntegrationSpec {
"Inside Project.configure" | "configure(container.foo) { prop() }"
"Inside NDOC.configure" | "container.configure { foo { prop() } }"
}
@Issue('https://github.com/gradle/gradle/issues/23111')
def "can configure dynamic property without call method"() {
buildFile << """
task test {
doLast {
ant { echo(message: 'hello world!') }
}
}
"""
expect:
args('--stacktrace')
succeeds("test")
}
}
Expand Up @@ -56,7 +56,9 @@ public DynamicInvokeResult tryInvokeMethod(String name, Object... arguments) {
return DynamicInvokeResult.found();
}
DynamicObject dynamicObject = DynamicObjectUtil.asDynamicObject(property);
return dynamicObject.tryInvokeMethod("call", arguments);
if (dynamicObject.hasMethod("call", arguments)) {
return dynamicObject.tryInvokeMethod("call", arguments);
}
}
return DynamicInvokeResult.notFound();
}
Expand Down
Expand Up @@ -24,12 +24,7 @@

public class RuleContext {

private static final ThreadLocal<Deque<ModelRuleDescriptor>> STACK = new ThreadLocal<Deque<ModelRuleDescriptor>>() {
@Override
protected Deque<ModelRuleDescriptor> initialValue() {
return new ArrayDeque<ModelRuleDescriptor>();
}
};
private static final ThreadLocal<Deque<ModelRuleDescriptor>> STACK = ThreadLocal.withInitial(ArrayDeque::new);

@Nullable
public static ModelRuleDescriptor get() {
Expand Down

0 comments on commit 2f90694

Please sign in to comment.