Skip to content

Commit

Permalink
Update to Gradle 8.1
Browse files Browse the repository at this point in the history
Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
  • Loading branch information
reta committed Mar 23, 2023
1 parent 4d78bbf commit 9f95ca7
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 8 deletions.
2 changes: 1 addition & 1 deletion buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Properties props = VersionPropertiesLoader.loadBuildSrcVersion(project.file('ver
version = props.getProperty("opensearch")

def generateVersionProperties = tasks.register("generateVersionProperties", WriteProperties) {
outputFile = "${buildDir}/version.properties"
destinationFile = file("${buildDir}/version.properties")
comment = 'Generated version properties'
properties(props)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,19 @@
import org.opensearch.gradle.test.ErrorReportingTestListener;
import org.opensearch.gradle.util.Util;
import org.gradle.api.Action;
import org.gradle.api.ExtensiblePolymorphicDomainObjectContainer;
import org.gradle.api.JavaVersion;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.file.FileCollection;
import org.gradle.api.plugins.jvm.JvmTestSuite;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.SourceSetContainer;
import org.gradle.api.tasks.testing.Test;
import org.gradle.testing.base.TestingExtension;
import org.gradle.testing.base.TestSuite;

import java.io.File;
import java.util.HashMap;
Expand Down Expand Up @@ -223,7 +227,24 @@ public void execute(Task t) {
// Add the shadow JAR artifact itself
FileCollection shadowJar = project.files(project.getTasks().named("shadowJar"));

test.setClasspath(test.getClasspath().minus(mainRuntime).plus(shadowConfig).plus(shadowJar));
// See please https://docs.gradle.org/8.1-rc-1/userguide/upgrading_version_8.html#test_task_default_classpath
boolean isClasspathSet = false;
final TestingExtension testing = project.getExtensions().findByType(TestingExtension.class);
if (testing != null) {
final ExtensiblePolymorphicDomainObjectContainer<TestSuite> testSuites = testing.getSuites();
final TestSuite suite = testSuites.findByName("test");
if (suite != null && suite instanceof JvmTestSuite) {
final JvmTestSuite jvmTestSuite = (JvmTestSuite) suite;
test.setClasspath(
jvmTestSuite.getSources().getRuntimeClasspath().minus(mainRuntime).plus(shadowConfig).plus(shadowJar)
);
isClasspathSet = true;
}
}

if (!isClasspathSet) {
test.setClasspath(test.getClasspath().minus(mainRuntime).plus(shadowConfig).plus(shadowJar));
}
});
});
}
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
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-8.0.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-rc-1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionSha256Sum=47a5bfed9ef814f90f8debcbbb315e8e7c654109acd224595ea39fca95c5d4da
distributionSha256Sum=8deb6070b6b84977e80e1605d4ac4f3a7fe6681e788f8295bc4d4f087dcdee30
7 changes: 4 additions & 3 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ done
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum

Expand Down Expand Up @@ -197,6 +194,10 @@ if "$cygwin" || "$msys" ; then
done
fi


# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
Expand Down
3 changes: 2 additions & 1 deletion plugins/repository-hdfs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ for (String integTestTaskName : ['integTestHa', 'integTestSecure', 'integTestSec
.resolve("ports")
}
nonInputProperties.systemProperty "test.hdfs-fixture.ports", file("$portsFileDir/ports")
classpath += files(portsFileDir)
// See please https://docs.gradle.org/8.1-rc-1/userguide/upgrading_version_8.html#test_task_default_classpath
classpath = testing.suites.test.sources.runtimeClasspath + files(portsFileDir)
// Copy ports file to separate location which is placed on the test classpath
doFirst {
mkdir(portsFileDir)
Expand Down

0 comments on commit 9f95ca7

Please sign in to comment.