Skip to content

Commit

Permalink
Update Gradle to 8.0-rc-2
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 Jan 18, 2023
1 parent 60db7b5 commit 9f7160f
Show file tree
Hide file tree
Showing 17 changed files with 91 additions and 38 deletions.
9 changes: 9 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import org.gradle.plugins.ide.eclipse.model.AccessRule
import org.gradle.plugins.ide.eclipse.model.EclipseJdt
import org.gradle.plugins.ide.eclipse.model.SourceFolder
import org.gradle.api.Project;
import org.gradle.api.internal.tasks.testing.junit.JUnitTestFramework
import org.gradle.process.ExecResult;
import org.gradle.util.DistributionLocator
import org.gradle.util.GradleVersion
Expand Down Expand Up @@ -409,6 +410,14 @@ gradle.projectsEvaluated {
}

project.tasks.withType(Test) { task ->
// This is so hacky: now, by default, test tasks uses JUnit framework and always includes 'junit'
// JARs from the Gradle distribution (no ways to override this behavior). It causes JAR hell on test
// classpath, example of the report:
//
// jar1: /home/ubuntu/.gradle/caches/modules-2/files-2.1/junit/junit/4.13.2/8ac9e16d933b6fb43bc7f576336b8f4d7eb5ba12/junit-4.13.2.jar
// jar2: /home/ubuntu/.gradle/wrapper/dists/gradle-8.0-rc-1-all/2p8rgxxewg8l61n1p3vrzr9s8/gradle-8.0-rc-1/lib/junit-4.13.2.jar
//
task.getTestFrameworkProperty().convention(getProviderFactory().provider(() -> new JUnitTestFramework(task, task.getFilter(), false)));
if (task != null) {
if (BuildParams.runtimeJavaVersion > JavaVersion.VERSION_17) {
task.jvmArgs += ["-Djava.security.manager=allow"]
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ dependencies {
api 'commons-codec:commons-codec:1.15'
api 'org.apache.commons:commons-compress:1.22'
api 'org.apache.ant:ant:1.10.12'
api 'com.netflix.nebula:gradle-extra-configurations-plugin:8.0.0'
api 'com.netflix.nebula:gradle-extra-configurations-plugin:9.0.0'
api 'com.netflix.nebula:nebula-publishing-plugin:19.2.0'
api 'com.netflix.nebula:gradle-info-plugin:12.0.0'
api 'org.apache.rat:apache-rat:0.15'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.gradle.api.Task;
import org.gradle.api.provider.Provider;
import org.gradle.api.services.internal.BuildServiceRegistryInternal;
import org.gradle.api.services.internal.BuildServiceProvider;
import org.gradle.api.tasks.CacheableTask;
import org.gradle.api.tasks.Internal;
import org.gradle.api.tasks.Nested;
Expand Down Expand Up @@ -123,7 +124,7 @@ public List<ResourceLock> getSharedResources() {
serviceRegistry,
TestClustersPlugin.THROTTLE_SERVICE_NAME
);
SharedResource resource = serviceRegistry.forService(throttleProvider);
SharedResource resource = serviceRegistry.forService((BuildServiceProvider<TestClustersThrottle, ?>) throttleProvider);

int nodeCount = clusters.stream().mapToInt(cluster -> cluster.getNodes().size()).sum();
if (nodeCount > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
package org.opensearch.gradle;

import org.opensearch.gradle.test.GradleUnitTestCase;

import java.util.UUID;

import org.gradle.api.NamedDomainObjectContainer;
import org.gradle.api.Project;
import org.gradle.testfixtures.ProjectBuilder;
Expand Down Expand Up @@ -148,7 +151,8 @@ private void createJdk(Project project, String name, String vendor, String versi
}

private Project createProject() {
Project project = ProjectBuilder.builder().withParent(rootProject).build();
final String name = UUID.randomUUID().toString();
Project project = ProjectBuilder.builder().withName(name).withParent(rootProject).build();
project.getPlugins().apply("opensearch.jdk-download");
return project;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.gradle.api.Action;
import org.gradle.api.GradleException;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.Dependency;
import org.gradle.api.file.FileCollection;
import org.gradle.api.plugins.JavaPlugin;
Expand Down Expand Up @@ -95,7 +96,7 @@ public void givenProjectWithoutLicensesDirButWithDependenciesThenShouldThrowExce
expectedException.expect(GradleException.class);
expectedException.expectMessage(containsString("does not exist, but there are dependencies"));

project.getDependencies().add("compileClasspath", dependency);
project.getDependencies().add("someCompileConfiguration", dependency);
task.get().checkDependencies();
}

Expand All @@ -113,7 +114,7 @@ public void givenProjectWithDependencyButNoShaFileThenShouldReturnException() th
createFileIn(licensesDir, "groovy-LICENSE.txt", PERMISSIVE_LICENSE_TEXT);
createFileIn(licensesDir, "groovy-NOTICE.txt", "");

project.getDependencies().add("compileClasspath", project.getDependencies().localGroovy());
project.getDependencies().add("someCompileConfiguration", project.getDependencies().localGroovy());
task.get().checkDependencies();
}

Expand All @@ -122,7 +123,7 @@ public void givenProjectWithDependencyButNoLicenseFileThenShouldReturnException(
expectedException.expect(GradleException.class);
expectedException.expectMessage(containsString("Missing LICENSE for "));

project.getDependencies().add("compileClasspath", project.getDependencies().localGroovy());
project.getDependencies().add("someCompileConfiguration", project.getDependencies().localGroovy());

getLicensesDir(project).mkdir();
updateShas.updateShas();
Expand All @@ -134,7 +135,7 @@ public void givenProjectWithDependencyButNoNoticeFileThenShouldReturnException()
expectedException.expect(GradleException.class);
expectedException.expectMessage(containsString("Missing NOTICE for "));

project.getDependencies().add("compileClasspath", dependency);
project.getDependencies().add("someCompileConfiguration", dependency);

createFileIn(getLicensesDir(project), "groovy-LICENSE.txt", PERMISSIVE_LICENSE_TEXT);

Expand All @@ -147,7 +148,7 @@ public void givenProjectWithStrictDependencyButNoSourcesFileThenShouldReturnExce
expectedException.expect(GradleException.class);
expectedException.expectMessage(containsString("Missing SOURCES for "));

project.getDependencies().add("compileClasspath", dependency);
project.getDependencies().add("someCompileConfiguration", dependency);

createFileIn(getLicensesDir(project), "groovy-LICENSE.txt", STRICT_LICENSE_TEXT);
createFileIn(getLicensesDir(project), "groovy-NOTICE.txt", "");
Expand All @@ -158,7 +159,7 @@ public void givenProjectWithStrictDependencyButNoSourcesFileThenShouldReturnExce

@Test
public void givenProjectWithStrictDependencyAndEverythingInOrderThenShouldReturnSilently() throws Exception {
project.getDependencies().add("compileClasspath", dependency);
project.getDependencies().add("someCompileConfiguration", dependency);

createFileIn(getLicensesDir(project), "groovy-LICENSE.txt", STRICT_LICENSE_TEXT);
createFileIn(getLicensesDir(project), "groovy-NOTICE.txt", "");
Expand All @@ -174,7 +175,7 @@ public void givenProjectWithStrictDependencyAndEverythingInOrderThenShouldReturn

@Test
public void givenProjectWithDependencyAndEverythingInOrderThenShouldReturnSilently() throws Exception {
project.getDependencies().add("compileClasspath", dependency);
project.getDependencies().add("someCompileConfiguration", dependency);

File licensesDir = getLicensesDir(project);

Expand All @@ -187,7 +188,7 @@ public void givenProjectWithALicenseButWithoutTheDependencyThenShouldThrowExcept
expectedException.expect(GradleException.class);
expectedException.expectMessage(containsString("Unused license "));

project.getDependencies().add("compileClasspath", dependency);
project.getDependencies().add("someCompileConfiguration", dependency);

File licensesDir = getLicensesDir(project);
createAllDefaultDependencyFiles(licensesDir, "groovy", "javaparser-core");
Expand All @@ -201,7 +202,7 @@ public void givenProjectWithANoticeButWithoutTheDependencyThenShouldThrowExcepti
expectedException.expect(GradleException.class);
expectedException.expectMessage(containsString("Unused notice "));

project.getDependencies().add("compileClasspath", dependency);
project.getDependencies().add("someCompileConfiguration", dependency);

File licensesDir = getLicensesDir(project);
createAllDefaultDependencyFiles(licensesDir, "groovy", "javaparser-core");
Expand All @@ -215,7 +216,7 @@ public void givenProjectWithAShaButWithoutTheDependencyThenShouldThrowException(
expectedException.expect(GradleException.class);
expectedException.expectMessage(containsString("Unused sha files found: \n"));

project.getDependencies().add("compileClasspath", dependency);
project.getDependencies().add("someCompileConfiguration", dependency);

File licensesDir = getLicensesDir(project);
createAllDefaultDependencyFiles(licensesDir, "groovy", "javaparser-core");
Expand All @@ -229,7 +230,7 @@ public void givenProjectWithADependencyWithWrongShaThenShouldThrowException() th
expectedException.expect(GradleException.class);
expectedException.expectMessage(containsString("SHA has changed! Expected "));

project.getDependencies().add("compileClasspath", dependency);
project.getDependencies().add("someCompileConfiguration", dependency);

File licensesDir = getLicensesDir(project);
createAllDefaultDependencyFiles(licensesDir, "groovy");
Expand All @@ -243,7 +244,7 @@ public void givenProjectWithADependencyWithWrongShaThenShouldThrowException() th

@Test
public void givenProjectWithADependencyMappingThenShouldReturnSilently() throws Exception {
project.getDependencies().add("compileClasspath", dependency);
project.getDependencies().add("someCompileConfiguration", dependency);

File licensesDir = getLicensesDir(project);
createAllDefaultDependencyFiles(licensesDir, "groovy", "javaparser");
Expand All @@ -258,7 +259,7 @@ public void givenProjectWithADependencyMappingThenShouldReturnSilently() throws

@Test
public void givenProjectWithAIgnoreShaConfigurationAndNoShaFileThenShouldReturnSilently() throws Exception {
project.getDependencies().add("compileClasspath", dependency);
project.getDependencies().add("someCompileConfiguration", dependency);

File licensesDir = getLicensesDir(project);
createFileIn(licensesDir, "groovy-LICENSE.txt", PERMISSIVE_LICENSE_TEXT);
Expand Down Expand Up @@ -297,6 +298,11 @@ private Project createProject() {
Project project = ProjectBuilder.builder().build();
project.getPlugins().apply(JavaPlugin.class);

Configuration compileClasspath = project.getConfigurations().getByName("compileClasspath");
Configuration someCompileConfiguration = project.getConfigurations().create("someCompileConfiguration");
// Declare a configuration that is going to resolve the compile classpath of the application
project.getConfigurations().add(compileClasspath.extendsFrom(someCompileConfiguration));

return project;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.gradle.api.Action;
import org.gradle.api.GradleException;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.Dependency;
import org.gradle.api.file.FileCollection;
import org.gradle.api.plugins.JavaPlugin;
Expand Down Expand Up @@ -86,7 +87,7 @@ public void whenDependencyDoesntExistThenShouldDeleteDependencySha() throws IOEx

@Test
public void whenDependencyExistsButShaNotThenShouldCreateNewShaFile() throws IOException, NoSuchAlgorithmException {
project.getDependencies().add("compileClasspath", dependency);
project.getDependencies().add("someCompileConfiguration", dependency);

getLicensesDir(project).mkdir();
task.updateShas();
Expand All @@ -99,7 +100,7 @@ public void whenDependencyExistsButShaNotThenShouldCreateNewShaFile() throws IOE

@Test
public void whenDependencyAndWrongShaExistsThenShouldNotOverwriteShaFile() throws IOException, NoSuchAlgorithmException {
project.getDependencies().add("compileClasspath", dependency);
project.getDependencies().add("someCompileConfiguration", dependency);

File groovyJar = task.getParentTask().getDependencies().getFiles().iterator().next();
String groovyShaName = groovyJar.getName() + ".sha1";
Expand All @@ -122,6 +123,11 @@ private Project createProject() {
Project project = ProjectBuilder.builder().build();
project.getPlugins().apply(JavaPlugin.class);

Configuration compileClasspath = project.getConfigurations().getByName("compileClasspath");
Configuration someCompileConfiguration = project.getConfigurations().create("someCompileConfiguration");
// Declare a configuration that is going to resolve the compile classpath of the application
project.getConfigurations().add(compileClasspath.extendsFrom(someCompileConfiguration));

return project;
}

Expand Down
4 changes: 2 additions & 2 deletions buildSrc/src/testKit/thirdPartyAudit/sample_jars/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ dependencies {
["0.0.1"].forEach { v ->
["opensearch", "other"].forEach { p ->
tasks.register("broken-log4j-${p}-${v}", Jar) {
destinationDir = file("${buildDir}/testrepo/org/${p}/gradle/broken-log4j/${v}/")
destinationDirectory = file("${buildDir}/testrepo/org/${p}/gradle/broken-log4j/${v}/")
archiveFileName = "broken-log4j-${v}.jar"
from sourceSets.main.output
include "**/TestingLog4j.class"
Expand All @@ -51,7 +51,7 @@ dependencies {
}

tasks.register("jarhellJdk", Jar) {
destinationDir = file("${buildDir}/testrepo/org/other/gradle/jarhellJdk/0.0.1/")
destinationDirectory = file("${buildDir}/testrepo/org/other/gradle/jarhellJdk/0.0.1/")
archiveFileName = "jarhellJdk-0.0.1.jar"
from sourceSets.main.output
include "**/String.class"
Expand Down
4 changes: 2 additions & 2 deletions distribution/packages/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ import java.util.regex.Pattern
*/

plugins {
id "nebula.ospackage-base" version "9.1.1"
id "com.netflix.nebula.ospackage-base" version "11.0.0"
}

void addProcessFilesTask(String type, boolean jdk) {
Expand Down Expand Up @@ -290,7 +290,7 @@ Closure commonPackageConfig(String type, boolean jdk, String architecture) {
}
}

apply plugin: 'nebula.ospackage-base'
apply plugin: 'com.netflix.nebula.ospackage-base'

// this is package indepdendent configuration
ospackage {
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-7.6-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-rc-2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionSha256Sum=312eb12875e1747e05c2f81a4789902d7e4ec5defbd1eefeaccc08acf096505d
distributionSha256Sum=a087ac457494858b9b322f39b61f157e6bd4793f32e3397567e1c60b7d151ff6
18 changes: 14 additions & 4 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand All @@ -80,10 +80,10 @@ do
esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
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"'
Expand Down Expand Up @@ -143,12 +143,16 @@ fi
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -205,6 +209,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \
"$@"

# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi

# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
Expand Down
15 changes: 9 additions & 6 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
Expand All @@ -25,7 +25,8 @@
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand All @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Expand Down Expand Up @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
if %ERRORLEVEL% equ 0 goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%

:mainEnd
if "%OS%"=="Windows_NT" endlocal
Expand Down
2 changes: 1 addition & 1 deletion modules/lang-painless/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ test {
}

shadowJar {
classifier = null
archiveClassifier.set('')
relocate 'org.objectweb', 'org.opensearch.repackage.org.objectweb'
dependencies {
include(dependency("org.ow2.asm:asm:${versions.asm}"))
Expand Down
Loading

0 comments on commit 9f7160f

Please sign in to comment.