Skip to content
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

Update to Gradle 7.5 #3594

Merged
merged 1 commit into from
Jul 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
package org.opensearch.gradle.testclusters;

import groovy.lang.Closure;

import org.opensearch.gradle.FileSystemOperationsAware;
import org.opensearch.gradle.test.Fixture;
import org.opensearch.gradle.util.GradleUtils;
Expand All @@ -46,6 +47,8 @@
import org.gradle.internal.resources.ResourceLock;
import org.gradle.internal.resources.SharedResource;

import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -124,12 +127,32 @@ public List<ResourceLock> getSharedResources() {

int nodeCount = clusters.stream().mapToInt(cluster -> cluster.getNodes().size()).sum();
if (nodeCount > 0) {
locks.add(resource.getResourceLock(Math.min(nodeCount, resource.getMaxUsages())));
locks.add(getResourceLock(resource, Math.min(nodeCount, resource.getMaxUsages())));
}

return Collections.unmodifiableList(locks);
}

private ResourceLock getResourceLock(SharedResource resource, int nUsages) {
try {
try {
// The getResourceLock(int) is used by Gradle pre-7.5
return (ResourceLock) MethodHandles.publicLookup()
.findVirtual(SharedResource.class, "getResourceLock", MethodType.methodType(ResourceLock.class, int.class))
.bindTo(resource)
.invokeExact(nUsages);
} catch (NoSuchMethodException | IllegalAccessException ex) {
// The getResourceLock() is used by Gradle post-7.4
return (ResourceLock) MethodHandles.publicLookup()
.findVirtual(SharedResource.class, "getResourceLock", MethodType.methodType(ResourceLock.class))
.bindTo(resource)
.invokeExact();
}
} catch (Throwable ex) {
throw new IllegalStateException("Unable to find suitable ResourceLock::getResourceLock", ex);
}
}

@Override
public Task dependsOn(Object... dependencies) {
super.dependsOn(dependencies);
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionSha256Sum=e6d864e3b5bc05cc62041842b306383fc1fefcec359e70cebb1d470a6094ca82
distributionSha256Sum=97a52d145762adc241bad7fd18289bf7f6801e08ece6badf80402fe2b9f250b1