Support Gradle 7 (#1609)
Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
This commit is contained in:
parent
74943c43c6
commit
8bf6fa6b4f
|
@ -313,7 +313,7 @@ allprojects {
|
|||
}
|
||||
}
|
||||
boolean hasShadow = project.plugins.hasPlugin(ShadowPlugin)
|
||||
project.configurations.compile.dependencies
|
||||
project.configurations.implementation.dependencies
|
||||
.findAll()
|
||||
.toSorted(sortClosure)
|
||||
.each({ c -> depJavadocClosure(hasShadow, c) })
|
||||
|
|
|
@ -124,7 +124,7 @@ dependencies {
|
|||
testFixturesApi gradleTestKit()
|
||||
testImplementation 'com.github.tomakehurst:wiremock-jre8-standalone:2.23.2'
|
||||
testImplementation "org.mockito:mockito-core:${props.getProperty('mockito')}"
|
||||
integTestImplementation('org.spockframework:spock-core:1.3-groovy-2.5') {
|
||||
integTestImplementation('org.spockframework:spock-core:2.0-groovy-3.0') {
|
||||
exclude module: "groovy"
|
||||
}
|
||||
}
|
||||
|
@ -260,6 +260,9 @@ if (project != rootProject) {
|
|||
*/
|
||||
afterEvaluate {
|
||||
generatePomFileForPluginMavenPublication.enabled = false
|
||||
tasks.named("validatePluginMavenPom").configure {
|
||||
dependsOn("generatePomFileForNebulaPublication")
|
||||
}
|
||||
}
|
||||
|
||||
publishing.publications.named("nebula").configure {
|
||||
|
|
|
@ -82,7 +82,7 @@ public class LoggedExec extends Exec implements FileSystemOperationsAware {
|
|||
doLast(new Action<Task>() {
|
||||
@Override
|
||||
public void execute(Task task) {
|
||||
if (LoggedExec.this.getExecResult().getExitValue() != 0) {
|
||||
if (LoggedExec.this.getExecutionResult().get().getExitValue() != 0) {
|
||||
try {
|
||||
LoggedExec.this.getLogger().error("Output for " + LoggedExec.this.getExecutable() + ":");
|
||||
outputLogger.accept(LoggedExec.this.getLogger());
|
||||
|
@ -94,7 +94,7 @@ public class LoggedExec extends Exec implements FileSystemOperationsAware {
|
|||
"Process '%s %s' finished with non-zero exit value %d",
|
||||
LoggedExec.this.getExecutable(),
|
||||
LoggedExec.this.getArgs(),
|
||||
LoggedExec.this.getExecResult().getExitValue()
|
||||
LoggedExec.this.getExecutionResult().get().getExitValue()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ public class OpenSearchTestBasePlugin implements Plugin<Project> {
|
|||
File heapdumpDir = new File(project.getBuildDir(), "heapdump");
|
||||
|
||||
project.getTasks().withType(Test.class).configureEach(test -> {
|
||||
File testOutputDir = new File(test.getReports().getJunitXml().getDestination(), "output");
|
||||
File testOutputDir = new File(test.getReports().getJunitXml().getOutputLocation().getAsFile().get(), "output");
|
||||
|
||||
ErrorReportingTestListener listener = new ErrorReportingTestListener(test.getTestLogging(), test.getLogger(), testOutputDir);
|
||||
test.getExtensions().add("errorReportingTestListener", listener);
|
||||
|
|
|
@ -41,11 +41,10 @@ import org.gradle.api.Project;
|
|||
import org.gradle.api.logging.Logger;
|
||||
import org.gradle.api.logging.Logging;
|
||||
import org.gradle.api.model.ObjectFactory;
|
||||
import org.gradle.api.provider.Provider;
|
||||
import org.gradle.api.provider.ProviderFactory;
|
||||
import org.gradle.internal.jvm.Jvm;
|
||||
import org.gradle.jvm.toolchain.JavaInstallation;
|
||||
import org.gradle.jvm.toolchain.JavaInstallationRegistry;
|
||||
import org.gradle.internal.jvm.inspection.JvmInstallationMetadata;
|
||||
import org.gradle.internal.jvm.inspection.JvmMetadataDetector;
|
||||
import org.gradle.util.GradleVersion;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
@ -77,13 +76,13 @@ public class GlobalBuildInfoPlugin implements Plugin<Project> {
|
|||
private static final String DEFAULT_VERSION_JAVA_FILE_PATH = "server/src/main/java/org/opensearch/Version.java";
|
||||
private static Integer _defaultParallel = null;
|
||||
|
||||
private final JavaInstallationRegistry javaInstallationRegistry;
|
||||
private final JvmMetadataDetector jvmMetadataDetector;
|
||||
private final ObjectFactory objects;
|
||||
private final ProviderFactory providers;
|
||||
|
||||
@Inject
|
||||
public GlobalBuildInfoPlugin(JavaInstallationRegistry javaInstallationRegistry, ObjectFactory objects, ProviderFactory providers) {
|
||||
this.javaInstallationRegistry = javaInstallationRegistry;
|
||||
public GlobalBuildInfoPlugin(JvmMetadataDetector jvmMetadataDetector, ObjectFactory objects, ProviderFactory providers) {
|
||||
this.jvmMetadataDetector = jvmMetadataDetector;
|
||||
this.objects = objects;
|
||||
this.providers = providers;
|
||||
}
|
||||
|
@ -115,7 +114,7 @@ public class GlobalBuildInfoPlugin implements Plugin<Project> {
|
|||
params.setRuntimeJavaHome(runtimeJavaHome);
|
||||
params.setRuntimeJavaVersion(determineJavaVersion("runtime java.home", runtimeJavaHome, minimumRuntimeVersion));
|
||||
params.setIsRutimeJavaHomeSet(runtimeJavaHomeOpt.isPresent());
|
||||
params.setRuntimeJavaDetails(getJavaInstallation(runtimeJavaHome).getImplementationName());
|
||||
params.setRuntimeJavaDetails(getJavaInstallation(runtimeJavaHome).getDisplayName());
|
||||
params.setJavaVersions(getAvailableJavaVersions(minimumCompilerVersion));
|
||||
params.setMinimumCompilerVersion(minimumCompilerVersion);
|
||||
params.setMinimumRuntimeVersion(minimumRuntimeVersion);
|
||||
|
@ -160,14 +159,14 @@ public class GlobalBuildInfoPlugin implements Plugin<Project> {
|
|||
final String osVersion = System.getProperty("os.version");
|
||||
final String osArch = System.getProperty("os.arch");
|
||||
final Jvm gradleJvm = Jvm.current();
|
||||
final String gradleJvmDetails = getJavaInstallation(gradleJvm.getJavaHome()).getImplementationName();
|
||||
final String gradleJvmDetails = getJavaInstallation(gradleJvm.getJavaHome()).getDisplayName();
|
||||
|
||||
LOGGER.quiet("=======================================");
|
||||
LOGGER.quiet("OpenSearch Build Hamster says Hello!");
|
||||
LOGGER.quiet(" Gradle Version : " + GradleVersion.current().getVersion());
|
||||
LOGGER.quiet(" OS Info : " + osName + " " + osVersion + " (" + osArch + ")");
|
||||
if (BuildParams.getIsRuntimeJavaHomeSet()) {
|
||||
String runtimeJvmDetails = getJavaInstallation(BuildParams.getRuntimeJavaHome()).getImplementationName();
|
||||
String runtimeJvmDetails = getJavaInstallation(BuildParams.getRuntimeJavaHome()).getDisplayName();
|
||||
LOGGER.quiet(" Runtime JDK Version : " + BuildParams.getRuntimeJavaVersion() + " (" + runtimeJvmDetails + ")");
|
||||
LOGGER.quiet(" Runtime java.home : " + BuildParams.getRuntimeJavaHome());
|
||||
LOGGER.quiet(" Gradle JDK Version : " + gradleJvm.getJavaVersion() + " (" + gradleJvmDetails + ")");
|
||||
|
@ -182,8 +181,8 @@ public class GlobalBuildInfoPlugin implements Plugin<Project> {
|
|||
}
|
||||
|
||||
private JavaVersion determineJavaVersion(String description, File javaHome, JavaVersion requiredVersion) {
|
||||
JavaInstallation installation = getJavaInstallation(javaHome);
|
||||
JavaVersion actualVersion = installation.getJavaVersion();
|
||||
JvmInstallationMetadata installation = getJavaInstallation(javaHome);
|
||||
JavaVersion actualVersion = installation.getLanguageVersion();
|
||||
if (actualVersion.isCompatibleWith(requiredVersion) == false) {
|
||||
throwInvalidJavaHomeException(
|
||||
description,
|
||||
|
@ -196,15 +195,8 @@ public class GlobalBuildInfoPlugin implements Plugin<Project> {
|
|||
return actualVersion;
|
||||
}
|
||||
|
||||
private JavaInstallation getJavaInstallation(File javaHome) {
|
||||
JavaInstallation installation;
|
||||
if (isCurrentJavaHome(javaHome)) {
|
||||
installation = javaInstallationRegistry.getInstallationForCurrentVirtualMachine().get();
|
||||
} else {
|
||||
installation = javaInstallationRegistry.installationForDirectory(objects.directoryProperty().fileValue(javaHome)).get();
|
||||
}
|
||||
|
||||
return installation;
|
||||
private JvmInstallationMetadata getJavaInstallation(File javaHome) {
|
||||
return jvmMetadataDetector.getMetadata(javaHome);
|
||||
}
|
||||
|
||||
private List<JavaHome> getAvailableJavaVersions(JavaVersion minimumCompilerVersion) {
|
||||
|
@ -214,11 +206,9 @@ public class GlobalBuildInfoPlugin implements Plugin<Project> {
|
|||
String javaHomeEnvVarName = getJavaHomeEnvVarName(Integer.toString(version));
|
||||
if (System.getenv(javaHomeEnvVarName) != null) {
|
||||
File javaHomeDirectory = new File(findJavaHome(Integer.toString(version)));
|
||||
Provider<JavaInstallation> javaInstallationProvider = javaInstallationRegistry.installationForDirectory(
|
||||
objects.directoryProperty().fileValue(javaHomeDirectory)
|
||||
);
|
||||
JvmInstallationMetadata javaInstallation = jvmMetadataDetector.getMetadata(javaHomeDirectory);
|
||||
JavaHome javaHome = JavaHome.of(version, providers.provider(() -> {
|
||||
int actualVersion = Integer.parseInt(javaInstallationProvider.get().getJavaVersion().getMajorVersion());
|
||||
int actualVersion = Integer.parseInt(javaInstallation.getLanguageVersion().getMajorVersion());
|
||||
if (actualVersion != version) {
|
||||
throwInvalidJavaHomeException("env variable " + javaHomeEnvVarName, javaHomeDirectory, version, actualVersion);
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.opensearch.gradle.LoggedExec;
|
|||
import org.gradle.api.Action;
|
||||
import org.gradle.api.GradleException;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.Task;
|
||||
import org.gradle.api.logging.LogLevel;
|
||||
import org.gradle.api.provider.Provider;
|
||||
import org.gradle.api.tasks.TaskProvider;
|
||||
|
@ -80,77 +81,83 @@ public class BwcSetupExtension {
|
|||
}
|
||||
|
||||
private TaskProvider<LoggedExec> createRunBwcGradleTask(Project project, String name, Action<LoggedExec> configAction) {
|
||||
return project.getTasks().register(name, LoggedExec.class, loggedExec -> {
|
||||
// TODO revisit
|
||||
loggedExec.dependsOn("checkoutBwcBranch");
|
||||
loggedExec.setSpoolOutput(true);
|
||||
loggedExec.setWorkingDir(checkoutDir.get());
|
||||
loggedExec.doFirst(t -> {
|
||||
// Execution time so that the checkouts are available
|
||||
String javaVersionsString = readFromFile(new File(checkoutDir.get(), ".ci/java-versions.properties"));
|
||||
loggedExec.environment(
|
||||
"JAVA_HOME",
|
||||
getJavaHome(
|
||||
Integer.parseInt(
|
||||
Arrays.asList(javaVersionsString.split("\n"))
|
||||
.stream()
|
||||
.filter(l -> l.trim().startsWith("OPENSEARCH_BUILD_JAVA="))
|
||||
.map(l -> l.replace("OPENSEARCH_BUILD_JAVA=java", "").trim())
|
||||
.map(l -> l.replace("OPENSEARCH_BUILD_JAVA=openjdk", "").trim())
|
||||
.collect(Collectors.joining("!!"))
|
||||
)
|
||||
)
|
||||
);
|
||||
loggedExec.environment(
|
||||
"RUNTIME_JAVA_HOME",
|
||||
getJavaHome(
|
||||
Integer.parseInt(
|
||||
Arrays.asList(javaVersionsString.split("\n"))
|
||||
.stream()
|
||||
.filter(l -> l.trim().startsWith("OPENSEARCH_RUNTIME_JAVA="))
|
||||
.map(l -> l.replace("OPENSEARCH_RUNTIME_JAVA=java", "").trim())
|
||||
.map(l -> l.replace("OPENSEARCH_RUNTIME_JAVA=openjdk", "").trim())
|
||||
.collect(Collectors.joining("!!"))
|
||||
)
|
||||
)
|
||||
);
|
||||
});
|
||||
return project.getTasks().register(name, LoggedExec.class, new Action<LoggedExec>() {
|
||||
@Override
|
||||
public void execute(LoggedExec loggedExec) {
|
||||
// TODO revisit
|
||||
loggedExec.dependsOn("checkoutBwcBranch");
|
||||
loggedExec.setSpoolOutput(true);
|
||||
loggedExec.setWorkingDir(checkoutDir.get());
|
||||
loggedExec.doFirst(new Action<Task>() {
|
||||
@Override
|
||||
public void execute(Task t) {
|
||||
// Execution time so that the checkouts are available
|
||||
String javaVersionsString = readFromFile(new File(checkoutDir.get(), ".ci/java-versions.properties"));
|
||||
loggedExec.environment(
|
||||
"JAVA_HOME",
|
||||
getJavaHome(
|
||||
Integer.parseInt(
|
||||
Arrays.asList(javaVersionsString.split("\n"))
|
||||
.stream()
|
||||
.filter(l -> l.trim().startsWith("OPENSEARCH_BUILD_JAVA="))
|
||||
.map(l -> l.replace("OPENSEARCH_BUILD_JAVA=java", "").trim())
|
||||
.map(l -> l.replace("OPENSEARCH_BUILD_JAVA=openjdk", "").trim())
|
||||
.collect(Collectors.joining("!!"))
|
||||
)
|
||||
)
|
||||
);
|
||||
loggedExec.environment(
|
||||
"RUNTIME_JAVA_HOME",
|
||||
getJavaHome(
|
||||
Integer.parseInt(
|
||||
Arrays.asList(javaVersionsString.split("\n"))
|
||||
.stream()
|
||||
.filter(l -> l.trim().startsWith("OPENSEARCH_RUNTIME_JAVA="))
|
||||
.map(l -> l.replace("OPENSEARCH_RUNTIME_JAVA=java", "").trim())
|
||||
.map(l -> l.replace("OPENSEARCH_RUNTIME_JAVA=openjdk", "").trim())
|
||||
.collect(Collectors.joining("!!"))
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
|
||||
loggedExec.executable("cmd");
|
||||
loggedExec.args("/C", "call", new File(checkoutDir.get(), "gradlew").toString());
|
||||
} else {
|
||||
loggedExec.executable(new File(checkoutDir.get(), "gradlew").toString());
|
||||
}
|
||||
if (project.getGradle().getStartParameter().isOffline()) {
|
||||
loggedExec.args("--offline");
|
||||
}
|
||||
// TODO resolve
|
||||
String buildCacheUrl = System.getProperty("org.opensearch.build.cache.url");
|
||||
if (buildCacheUrl != null) {
|
||||
loggedExec.args("-Dorg.opensearch.build.cache.url=" + buildCacheUrl);
|
||||
}
|
||||
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
|
||||
loggedExec.executable("cmd");
|
||||
loggedExec.args("/C", "call", new File(checkoutDir.get(), "gradlew").toString());
|
||||
} else {
|
||||
loggedExec.executable(new File(checkoutDir.get(), "gradlew").toString());
|
||||
}
|
||||
if (project.getGradle().getStartParameter().isOffline()) {
|
||||
loggedExec.args("--offline");
|
||||
}
|
||||
// TODO resolve
|
||||
String buildCacheUrl = System.getProperty("org.opensearch.build.cache.url");
|
||||
if (buildCacheUrl != null) {
|
||||
loggedExec.args("-Dorg.opensearch.build.cache.url=" + buildCacheUrl);
|
||||
}
|
||||
|
||||
loggedExec.args("-Dbuild.snapshot=true");
|
||||
loggedExec.args("-Dscan.tag.NESTED");
|
||||
final LogLevel logLevel = project.getGradle().getStartParameter().getLogLevel();
|
||||
List<LogLevel> nonDefaultLogLevels = Arrays.asList(LogLevel.QUIET, LogLevel.WARN, LogLevel.INFO, LogLevel.DEBUG);
|
||||
if (nonDefaultLogLevels.contains(logLevel)) {
|
||||
loggedExec.args("--" + logLevel.name().toLowerCase(Locale.ENGLISH));
|
||||
loggedExec.args("-Dbuild.snapshot=true");
|
||||
loggedExec.args("-Dscan.tag.NESTED");
|
||||
final LogLevel logLevel = project.getGradle().getStartParameter().getLogLevel();
|
||||
List<LogLevel> nonDefaultLogLevels = Arrays.asList(LogLevel.QUIET, LogLevel.WARN, LogLevel.INFO, LogLevel.DEBUG);
|
||||
if (nonDefaultLogLevels.contains(logLevel)) {
|
||||
loggedExec.args("--" + logLevel.name().toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
final String showStacktraceName = project.getGradle().getStartParameter().getShowStacktrace().name();
|
||||
assert Arrays.asList("INTERNAL_EXCEPTIONS", "ALWAYS", "ALWAYS_FULL").contains(showStacktraceName);
|
||||
if (showStacktraceName.equals("ALWAYS")) {
|
||||
loggedExec.args("--stacktrace");
|
||||
} else if (showStacktraceName.equals("ALWAYS_FULL")) {
|
||||
loggedExec.args("--full-stacktrace");
|
||||
}
|
||||
if (project.getGradle().getStartParameter().isParallelProjectExecutionEnabled()) {
|
||||
loggedExec.args("--parallel");
|
||||
}
|
||||
loggedExec.setStandardOutput(new IndentingOutputStream(System.out, unreleasedVersionInfo.get().version));
|
||||
loggedExec.setErrorOutput(new IndentingOutputStream(System.err, unreleasedVersionInfo.get().version));
|
||||
configAction.execute(loggedExec);
|
||||
}
|
||||
final String showStacktraceName = project.getGradle().getStartParameter().getShowStacktrace().name();
|
||||
assert Arrays.asList("INTERNAL_EXCEPTIONS", "ALWAYS", "ALWAYS_FULL").contains(showStacktraceName);
|
||||
if (showStacktraceName.equals("ALWAYS")) {
|
||||
loggedExec.args("--stacktrace");
|
||||
} else if (showStacktraceName.equals("ALWAYS_FULL")) {
|
||||
loggedExec.args("--full-stacktrace");
|
||||
}
|
||||
if (project.getGradle().getStartParameter().isParallelProjectExecutionEnabled()) {
|
||||
loggedExec.args("--parallel");
|
||||
}
|
||||
loggedExec.setStandardOutput(new IndentingOutputStream(System.out, unreleasedVersionInfo.get().version));
|
||||
loggedExec.setErrorOutput(new IndentingOutputStream(System.err, unreleasedVersionInfo.get().version));
|
||||
configAction.execute(loggedExec);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -33,9 +33,11 @@
|
|||
package org.opensearch.gradle.internal;
|
||||
|
||||
import org.opensearch.gradle.BwcVersions;
|
||||
import org.opensearch.gradle.LoggedExec;
|
||||
import org.opensearch.gradle.Version;
|
||||
import org.opensearch.gradle.info.BuildParams;
|
||||
import org.opensearch.gradle.info.GlobalBuildInfoPlugin;
|
||||
import org.gradle.api.Action;
|
||||
import org.gradle.api.InvalidUserDataException;
|
||||
import org.gradle.api.Plugin;
|
||||
import org.gradle.api.Project;
|
||||
|
@ -204,24 +206,30 @@ public class InternalDistributionBwcSetupPlugin implements Plugin<Project> {
|
|||
TaskProvider<Task> bwcTaskProvider
|
||||
) {
|
||||
String bwcTaskName = buildBwcTaskName(projectName);
|
||||
bwcSetupExtension.bwcTask(bwcTaskName, c -> {
|
||||
c.getInputs().file(new File(project.getBuildDir(), "refspec"));
|
||||
c.getOutputs().files(projectArtifact);
|
||||
c.getOutputs().cacheIf("BWC distribution caching is disabled on 'master' branch", task -> {
|
||||
String gitBranch = System.getenv("GIT_BRANCH");
|
||||
return BuildParams.isCi() && (gitBranch == null || gitBranch.endsWith("master") == false);
|
||||
});
|
||||
c.args(projectPath.replace('/', ':') + ":assemble");
|
||||
if (project.getGradle().getStartParameter().isBuildCacheEnabled()) {
|
||||
c.args("--build-cache");
|
||||
}
|
||||
c.doLast(task -> {
|
||||
if (projectArtifact.exists() == false) {
|
||||
throw new InvalidUserDataException(
|
||||
"Building " + bwcVersion.get() + " didn't generate expected file " + projectArtifact
|
||||
);
|
||||
bwcSetupExtension.bwcTask(bwcTaskName, new Action<LoggedExec>() {
|
||||
@Override
|
||||
public void execute(LoggedExec c) {
|
||||
c.getInputs().file(new File(project.getBuildDir(), "refspec"));
|
||||
c.getOutputs().files(projectArtifact);
|
||||
c.getOutputs().cacheIf("BWC distribution caching is disabled on 'master' branch", task -> {
|
||||
String gitBranch = System.getenv("GIT_BRANCH");
|
||||
return BuildParams.isCi() && (gitBranch == null || gitBranch.endsWith("master") == false);
|
||||
});
|
||||
c.args(projectPath.replace('/', ':') + ":assemble");
|
||||
if (project.getGradle().getStartParameter().isBuildCacheEnabled()) {
|
||||
c.args("--build-cache");
|
||||
}
|
||||
});
|
||||
c.doLast(new Action<Task>() {
|
||||
@Override
|
||||
public void execute(Task task) {
|
||||
if (projectArtifact.exists() == false) {
|
||||
throw new InvalidUserDataException(
|
||||
"Building " + bwcVersion.get() + " didn't generate expected file " + projectArtifact
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
bwcTaskProvider.configure(t -> t.dependsOn(bwcTaskName));
|
||||
}
|
||||
|
|
|
@ -53,9 +53,16 @@ public class JarHellPrecommitPlugin extends PrecommitPlugin {
|
|||
|
||||
TaskProvider<JarHellTask> jarHell = project.getTasks().register("jarHell", JarHellTask.class);
|
||||
jarHell.configure(t -> {
|
||||
SourceSet testSourceSet = Util.getJavaTestSourceSet(project).get();
|
||||
final Task testClassesTask = project.getTasks().getByName("testClasses");
|
||||
final SourceSet testSourceSet = Util.getJavaTestSourceSet(project).get();
|
||||
t.setClasspath(testSourceSet.getRuntimeClasspath().plus(jarHellConfig));
|
||||
t.dependsOn(jarHellConfig);
|
||||
t.dependsOn(jarHellConfig, testClassesTask);
|
||||
|
||||
// if this a plugin, we need to add dependency on pluginProperties task
|
||||
project.getPluginManager().withPlugin("opensearch.opensearchplugin", plugin -> {
|
||||
Task propertiesTask = project.getTasks().getByName("pluginProperties");
|
||||
t.dependsOn(jarHellConfig, testClassesTask, propertiesTask);
|
||||
});
|
||||
});
|
||||
|
||||
return jarHell;
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
package org.opensearch.gradle.precommit;
|
||||
|
||||
import org.opensearch.gradle.LoggedExec;
|
||||
|
||||
import org.gradle.api.file.FileCollection;
|
||||
import org.gradle.api.tasks.CacheableTask;
|
||||
import org.gradle.api.tasks.CompileClasspath;
|
||||
|
@ -56,7 +57,7 @@ public class JarHellTask extends PrecommitTask {
|
|||
public void runJarHellCheck() {
|
||||
LoggedExec.javaexec(getProject(), spec -> {
|
||||
spec.environment("CLASSPATH", getClasspath().getAsPath());
|
||||
spec.setMain("org.opensearch.bootstrap.JarHell");
|
||||
spec.getMainClass().set("org.opensearch.bootstrap.JarHell");
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ public class LoggerUsageTask extends PrecommitTask {
|
|||
@TaskAction
|
||||
public void runLoggerUsageTask() {
|
||||
LoggedExec.javaexec(getProject(), spec -> {
|
||||
spec.setMain("org.opensearch.test.loggerusage.OpenSearchLoggerUsageChecker");
|
||||
spec.getMainClass().set("org.opensearch.test.loggerusage.OpenSearchLoggerUsageChecker");
|
||||
spec.classpath(getClasspath());
|
||||
getClassDirectories().forEach(spec::args);
|
||||
});
|
||||
|
|
|
@ -281,10 +281,6 @@ public class ThirdPartyAuditTask extends DefaultTask {
|
|||
getLogger().error("Forbidden APIs output:\n{}==end of forbidden APIs==", forbiddenApisOutput);
|
||||
}
|
||||
|
||||
private void throwNotConfiguredCorrectlyException() {
|
||||
throw new IllegalArgumentException("Audit of third party dependencies is not configured correctly");
|
||||
}
|
||||
|
||||
private void extractJars(Set<File> jars) {
|
||||
File jarExpandDir = getJarExpandDir();
|
||||
// We need to clean up to make sure old dependencies don't linger
|
||||
|
@ -360,7 +356,7 @@ public class ThirdPartyAuditTask extends DefaultTask {
|
|||
);
|
||||
spec.jvmArgs("-Xmx1g");
|
||||
spec.jvmArgs(LoggedExec.shortLivedArgs());
|
||||
spec.setMain("de.thetaphi.forbiddenapis.cli.CliMain");
|
||||
spec.getMainClass().set("de.thetaphi.forbiddenapis.cli.CliMain");
|
||||
spec.args("-f", getSignatureFile().getAbsolutePath(), "-d", getJarExpandDir(), "--allowmissingclasses");
|
||||
spec.setErrorOutput(errorOut);
|
||||
if (getLogger().isInfoEnabled() == false) {
|
||||
|
@ -390,7 +386,7 @@ public class ThirdPartyAuditTask extends DefaultTask {
|
|||
getProject().getConfigurations().getByName(CompileOnlyResolvePlugin.RESOLVEABLE_COMPILE_ONLY_CONFIGURATION_NAME)
|
||||
);
|
||||
|
||||
spec.setMain(JDK_JAR_HELL_MAIN_CLASS);
|
||||
spec.getMainClass().set(JDK_JAR_HELL_MAIN_CLASS);
|
||||
spec.args(getJarExpandDir());
|
||||
spec.setIgnoreExitValue(true);
|
||||
if (javaHome != null) {
|
||||
|
|
|
@ -1381,25 +1381,27 @@ public class OpenSearchNode implements TestClusterConfiguration {
|
|||
return distributions.get(currentDistro).getExtracted().getSingleFile().toPath();
|
||||
}
|
||||
|
||||
private List<File> getInstalledFileSet(Action<? super PatternFilterable> filter) {
|
||||
return Stream.concat(plugins.stream().map(Provider::get), modules.stream().map(Provider::get))
|
||||
.filter(File::exists)
|
||||
// TODO: We may be able to simplify this with Gradle 5.6
|
||||
// https://docs.gradle.org/nightly/release-notes.html#improved-handling-of-zip-archives-on-classpaths
|
||||
.map(zipFile -> archiveOperations.zipTree(zipFile).matching(filter))
|
||||
.flatMap(tree -> tree.getFiles().stream())
|
||||
.sorted(Comparator.comparing(File::getName))
|
||||
private List<Provider<List<File>>> getInstalledFileSet(Action<? super PatternFilterable> filter) {
|
||||
return Stream.concat(plugins.stream(), modules.stream()).map(p -> p.map(f -> {
|
||||
if (f.exists()) {
|
||||
final FileTree tree = archiveOperations.zipTree(f).matching(filter);
|
||||
return tree.getFiles();
|
||||
} else {
|
||||
return new HashSet<File>();
|
||||
}
|
||||
}))
|
||||
.map(p -> p.map(f -> f.stream().sorted(Comparator.comparing(File::getName)).collect(Collectors.toList())))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Classpath
|
||||
public List<File> getInstalledClasspath() {
|
||||
public List<Provider<List<File>>> getInstalledClasspath() {
|
||||
return getInstalledFileSet(filter -> filter.include("**/*.jar"));
|
||||
}
|
||||
|
||||
@InputFiles
|
||||
@PathSensitive(PathSensitivity.RELATIVE)
|
||||
public List<File> getInstalledFiles() {
|
||||
public List<Provider<List<File>>> getInstalledFiles() {
|
||||
return getInstalledFileSet(filter -> filter.exclude("**/*.jar"));
|
||||
}
|
||||
|
||||
|
|
|
@ -112,27 +112,42 @@ public class TestFixturesPlugin implements Plugin<Project> {
|
|||
project.getPluginManager().apply(BasePlugin.class);
|
||||
project.getPluginManager().apply(DockerComposePlugin.class);
|
||||
|
||||
TaskProvider<Task> preProcessFixture = project.getTasks().register("preProcessFixture", t -> {
|
||||
t.getOutputs().dir(testfixturesDir);
|
||||
t.doFirst(t2 -> {
|
||||
try {
|
||||
Files.createDirectories(testfixturesDir.toPath());
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
});
|
||||
TaskProvider<Task> preProcessFixture = project.getTasks().register("preProcessFixture", new Action<Task>() {
|
||||
@Override
|
||||
public void execute(Task t) {
|
||||
t.getOutputs().dir(testfixturesDir);
|
||||
t.doFirst(new Action<Task>() {
|
||||
@Override
|
||||
public void execute(Task t2) {
|
||||
{
|
||||
try {
|
||||
Files.createDirectories(testfixturesDir.toPath());
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
TaskProvider<Task> buildFixture = project.getTasks().register("buildFixture", new Action<Task>() {
|
||||
@Override
|
||||
public void execute(Task t) {
|
||||
t.dependsOn(preProcessFixture, tasks.named("composeUp"));
|
||||
}
|
||||
});
|
||||
TaskProvider<Task> buildFixture = project.getTasks()
|
||||
.register("buildFixture", t -> t.dependsOn(preProcessFixture, tasks.named("composeUp")));
|
||||
|
||||
TaskProvider<Task> postProcessFixture = project.getTasks().register("postProcessFixture", task -> {
|
||||
task.dependsOn(buildFixture);
|
||||
configureServiceInfoForTask(
|
||||
task,
|
||||
project,
|
||||
false,
|
||||
(name, port) -> task.getExtensions().getByType(ExtraPropertiesExtension.class).set(name, port)
|
||||
);
|
||||
TaskProvider<Task> postProcessFixture = project.getTasks().register("postProcessFixture", new Action<Task>() {
|
||||
@Override
|
||||
public void execute(Task task) {
|
||||
task.dependsOn(buildFixture);
|
||||
configureServiceInfoForTask(
|
||||
task,
|
||||
project,
|
||||
false,
|
||||
(name, port) -> task.getExtensions().getByType(ExtraPropertiesExtension.class).set(name, port)
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
maybeSkipTask(dockerSupport, preProcessFixture);
|
||||
|
|
|
@ -187,9 +187,9 @@ public abstract class GradleUtils {
|
|||
*/
|
||||
public static void extendSourceSet(Project project, String parentSourceSetName, String childSourceSetName) {
|
||||
final List<Function<SourceSet, String>> configNameFunctions = Arrays.asList(
|
||||
SourceSet::getCompileConfigurationName,
|
||||
SourceSet::getCompileClasspathConfigurationName,
|
||||
SourceSet::getImplementationConfigurationName,
|
||||
SourceSet::getRuntimeConfigurationName,
|
||||
SourceSet::getRuntimeClasspathConfigurationName,
|
||||
SourceSet::getRuntimeOnlyConfigurationName
|
||||
);
|
||||
SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class);
|
||||
|
|
|
@ -95,7 +95,7 @@ public class DependencyLicensesTaskTests extends GradleUnitTestCase {
|
|||
expectedException.expect(GradleException.class);
|
||||
expectedException.expectMessage(containsString("does not exist, but there are dependencies"));
|
||||
|
||||
project.getDependencies().add("compile", dependency);
|
||||
project.getDependencies().add("compileClasspath", dependency);
|
||||
task.get().checkDependencies();
|
||||
}
|
||||
|
||||
|
@ -110,10 +110,10 @@ public class DependencyLicensesTaskTests extends GradleUnitTestCase {
|
|||
expectedException.expectMessage(containsString("Missing SHA for "));
|
||||
|
||||
File licensesDir = getLicensesDir(project);
|
||||
createFileIn(licensesDir, "groovy-all-LICENSE.txt", PERMISSIVE_LICENSE_TEXT);
|
||||
createFileIn(licensesDir, "groovy-all-NOTICE.txt", "");
|
||||
createFileIn(licensesDir, "groovy-LICENSE.txt", PERMISSIVE_LICENSE_TEXT);
|
||||
createFileIn(licensesDir, "groovy-NOTICE.txt", "");
|
||||
|
||||
project.getDependencies().add("compile", project.getDependencies().localGroovy());
|
||||
project.getDependencies().add("compileClasspath", project.getDependencies().localGroovy());
|
||||
task.get().checkDependencies();
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ public class DependencyLicensesTaskTests extends GradleUnitTestCase {
|
|||
expectedException.expect(GradleException.class);
|
||||
expectedException.expectMessage(containsString("Missing LICENSE for "));
|
||||
|
||||
project.getDependencies().add("compile", project.getDependencies().localGroovy());
|
||||
project.getDependencies().add("compileClasspath", project.getDependencies().localGroovy());
|
||||
|
||||
getLicensesDir(project).mkdir();
|
||||
updateShas.updateShas();
|
||||
|
@ -134,9 +134,9 @@ public class DependencyLicensesTaskTests extends GradleUnitTestCase {
|
|||
expectedException.expect(GradleException.class);
|
||||
expectedException.expectMessage(containsString("Missing NOTICE for "));
|
||||
|
||||
project.getDependencies().add("compile", dependency);
|
||||
project.getDependencies().add("compileClasspath", dependency);
|
||||
|
||||
createFileIn(getLicensesDir(project), "groovy-all-LICENSE.txt", PERMISSIVE_LICENSE_TEXT);
|
||||
createFileIn(getLicensesDir(project), "groovy-LICENSE.txt", PERMISSIVE_LICENSE_TEXT);
|
||||
|
||||
updateShas.updateShas();
|
||||
task.get().checkDependencies();
|
||||
|
@ -147,10 +147,10 @@ public class DependencyLicensesTaskTests extends GradleUnitTestCase {
|
|||
expectedException.expect(GradleException.class);
|
||||
expectedException.expectMessage(containsString("Missing SOURCES for "));
|
||||
|
||||
project.getDependencies().add("compile", dependency);
|
||||
project.getDependencies().add("compileClasspath", dependency);
|
||||
|
||||
createFileIn(getLicensesDir(project), "groovy-all-LICENSE.txt", STRICT_LICENSE_TEXT);
|
||||
createFileIn(getLicensesDir(project), "groovy-all-NOTICE.txt", "");
|
||||
createFileIn(getLicensesDir(project), "groovy-LICENSE.txt", STRICT_LICENSE_TEXT);
|
||||
createFileIn(getLicensesDir(project), "groovy-NOTICE.txt", "");
|
||||
|
||||
updateShas.updateShas();
|
||||
task.get().checkDependencies();
|
||||
|
@ -158,11 +158,15 @@ public class DependencyLicensesTaskTests extends GradleUnitTestCase {
|
|||
|
||||
@Test
|
||||
public void givenProjectWithStrictDependencyAndEverythingInOrderThenShouldReturnSilently() throws Exception {
|
||||
project.getDependencies().add("compile", dependency);
|
||||
project.getDependencies().add("compileClasspath", dependency);
|
||||
|
||||
createFileIn(getLicensesDir(project), "groovy-all-LICENSE.txt", STRICT_LICENSE_TEXT);
|
||||
createFileIn(getLicensesDir(project), "groovy-all-NOTICE.txt", "");
|
||||
createFileIn(getLicensesDir(project), "groovy-all-SOURCES.txt", "");
|
||||
createFileIn(getLicensesDir(project), "groovy-LICENSE.txt", STRICT_LICENSE_TEXT);
|
||||
createFileIn(getLicensesDir(project), "groovy-NOTICE.txt", "");
|
||||
createFileIn(getLicensesDir(project), "groovy-SOURCES.txt", "");
|
||||
|
||||
createFileIn(getLicensesDir(project), "javaparser-core-LICENSE.txt", STRICT_LICENSE_TEXT);
|
||||
createFileIn(getLicensesDir(project), "javaparser-core-NOTICE.txt", "");
|
||||
createFileIn(getLicensesDir(project), "javaparser-core-SOURCES.txt", "");
|
||||
|
||||
updateShas.updateShas();
|
||||
task.get().checkDependencies();
|
||||
|
@ -170,11 +174,11 @@ public class DependencyLicensesTaskTests extends GradleUnitTestCase {
|
|||
|
||||
@Test
|
||||
public void givenProjectWithDependencyAndEverythingInOrderThenShouldReturnSilently() throws Exception {
|
||||
project.getDependencies().add("compile", dependency);
|
||||
project.getDependencies().add("compileClasspath", dependency);
|
||||
|
||||
File licensesDir = getLicensesDir(project);
|
||||
|
||||
createAllDefaultDependencyFiles(licensesDir, "groovy-all");
|
||||
createAllDefaultDependencyFiles(licensesDir, "groovy", "javaparser-core");
|
||||
task.get().checkDependencies();
|
||||
}
|
||||
|
||||
|
@ -183,10 +187,10 @@ public class DependencyLicensesTaskTests extends GradleUnitTestCase {
|
|||
expectedException.expect(GradleException.class);
|
||||
expectedException.expectMessage(containsString("Unused license "));
|
||||
|
||||
project.getDependencies().add("compile", dependency);
|
||||
project.getDependencies().add("compileClasspath", dependency);
|
||||
|
||||
File licensesDir = getLicensesDir(project);
|
||||
createAllDefaultDependencyFiles(licensesDir, "groovy-all");
|
||||
createAllDefaultDependencyFiles(licensesDir, "groovy", "javaparser-core");
|
||||
createFileIn(licensesDir, "non-declared-LICENSE.txt", "");
|
||||
|
||||
task.get().checkDependencies();
|
||||
|
@ -197,10 +201,10 @@ public class DependencyLicensesTaskTests extends GradleUnitTestCase {
|
|||
expectedException.expect(GradleException.class);
|
||||
expectedException.expectMessage(containsString("Unused notice "));
|
||||
|
||||
project.getDependencies().add("compile", dependency);
|
||||
project.getDependencies().add("compileClasspath", dependency);
|
||||
|
||||
File licensesDir = getLicensesDir(project);
|
||||
createAllDefaultDependencyFiles(licensesDir, "groovy-all");
|
||||
createAllDefaultDependencyFiles(licensesDir, "groovy", "javaparser-core");
|
||||
createFileIn(licensesDir, "non-declared-NOTICE.txt", "");
|
||||
|
||||
task.get().checkDependencies();
|
||||
|
@ -211,10 +215,10 @@ public class DependencyLicensesTaskTests extends GradleUnitTestCase {
|
|||
expectedException.expect(GradleException.class);
|
||||
expectedException.expectMessage(containsString("Unused sha files found: \n"));
|
||||
|
||||
project.getDependencies().add("compile", dependency);
|
||||
project.getDependencies().add("compileClasspath", dependency);
|
||||
|
||||
File licensesDir = getLicensesDir(project);
|
||||
createAllDefaultDependencyFiles(licensesDir, "groovy-all");
|
||||
createAllDefaultDependencyFiles(licensesDir, "groovy", "javaparser-core");
|
||||
createFileIn(licensesDir, "non-declared.sha1", "");
|
||||
|
||||
task.get().checkDependencies();
|
||||
|
@ -225,10 +229,10 @@ public class DependencyLicensesTaskTests extends GradleUnitTestCase {
|
|||
expectedException.expect(GradleException.class);
|
||||
expectedException.expectMessage(containsString("SHA has changed! Expected "));
|
||||
|
||||
project.getDependencies().add("compile", dependency);
|
||||
project.getDependencies().add("compileClasspath", dependency);
|
||||
|
||||
File licensesDir = getLicensesDir(project);
|
||||
createAllDefaultDependencyFiles(licensesDir, "groovy-all");
|
||||
createAllDefaultDependencyFiles(licensesDir, "groovy");
|
||||
|
||||
Path groovySha = Files.list(licensesDir.toPath()).filter(file -> file.toFile().getName().contains("sha")).findFirst().get();
|
||||
|
||||
|
@ -239,14 +243,14 @@ public class DependencyLicensesTaskTests extends GradleUnitTestCase {
|
|||
|
||||
@Test
|
||||
public void givenProjectWithADependencyMappingThenShouldReturnSilently() throws Exception {
|
||||
project.getDependencies().add("compile", dependency);
|
||||
project.getDependencies().add("compileClasspath", dependency);
|
||||
|
||||
File licensesDir = getLicensesDir(project);
|
||||
createAllDefaultDependencyFiles(licensesDir, "groovy");
|
||||
createAllDefaultDependencyFiles(licensesDir, "groovy", "javaparser");
|
||||
|
||||
Map<String, String> mappings = new HashMap<>();
|
||||
mappings.put("from", "groovy-all");
|
||||
mappings.put("to", "groovy");
|
||||
mappings.put("from", "javaparser-core");
|
||||
mappings.put("to", "javaparser");
|
||||
|
||||
task.get().mapping(mappings);
|
||||
task.get().checkDependencies();
|
||||
|
@ -254,13 +258,30 @@ public class DependencyLicensesTaskTests extends GradleUnitTestCase {
|
|||
|
||||
@Test
|
||||
public void givenProjectWithAIgnoreShaConfigurationAndNoShaFileThenShouldReturnSilently() throws Exception {
|
||||
project.getDependencies().add("compile", dependency);
|
||||
project.getDependencies().add("compileClasspath", dependency);
|
||||
|
||||
File licensesDir = getLicensesDir(project);
|
||||
createFileIn(licensesDir, "groovy-all-LICENSE.txt", PERMISSIVE_LICENSE_TEXT);
|
||||
createFileIn(licensesDir, "groovy-all-NOTICE.txt", "");
|
||||
createFileIn(licensesDir, "groovy-LICENSE.txt", PERMISSIVE_LICENSE_TEXT);
|
||||
createFileIn(licensesDir, "groovy-NOTICE.txt", "");
|
||||
|
||||
createFileIn(licensesDir, "javaparser-core-LICENSE.txt", PERMISSIVE_LICENSE_TEXT);
|
||||
createFileIn(licensesDir, "javaparser-core-NOTICE.txt", "");
|
||||
|
||||
task.get().ignoreSha("groovy");
|
||||
task.get().ignoreSha("groovy-ant");
|
||||
task.get().ignoreSha("groovy-astbuilder");
|
||||
task.get().ignoreSha("groovy-console");
|
||||
task.get().ignoreSha("groovy-datetime");
|
||||
task.get().ignoreSha("groovy-dateutil");
|
||||
task.get().ignoreSha("groovy-groovydoc");
|
||||
task.get().ignoreSha("groovy-json");
|
||||
task.get().ignoreSha("groovy-nio");
|
||||
task.get().ignoreSha("groovy-sql");
|
||||
task.get().ignoreSha("groovy-templates");
|
||||
task.get().ignoreSha("groovy-test");
|
||||
task.get().ignoreSha("groovy-xml");
|
||||
task.get().ignoreSha("javaparser-core");
|
||||
|
||||
task.get().ignoreSha("groovy-all");
|
||||
task.get().checkDependencies();
|
||||
}
|
||||
|
||||
|
@ -279,9 +300,11 @@ public class DependencyLicensesTaskTests extends GradleUnitTestCase {
|
|||
return project;
|
||||
}
|
||||
|
||||
private void createAllDefaultDependencyFiles(File licensesDir, String dependencyName) throws IOException, NoSuchAlgorithmException {
|
||||
createFileIn(licensesDir, dependencyName + "-LICENSE.txt", PERMISSIVE_LICENSE_TEXT);
|
||||
createFileIn(licensesDir, dependencyName + "-NOTICE.txt", "");
|
||||
private void createAllDefaultDependencyFiles(File licensesDir, String... dependencyNames) throws IOException, NoSuchAlgorithmException {
|
||||
for (final String dependencyName : dependencyNames) {
|
||||
createFileIn(licensesDir, dependencyName + "-LICENSE.txt", PERMISSIVE_LICENSE_TEXT);
|
||||
createFileIn(licensesDir, dependencyName + "-NOTICE.txt", "");
|
||||
}
|
||||
|
||||
updateShas.updateShas();
|
||||
}
|
||||
|
@ -316,6 +339,12 @@ public class DependencyLicensesTaskTests extends GradleUnitTestCase {
|
|||
@Override
|
||||
public void execute(DependencyLicensesTask dependencyLicensesTask) {
|
||||
dependencyLicensesTask.setDependencies(getDependencies(project));
|
||||
|
||||
final Map<String, String> mappings = new HashMap<>();
|
||||
mappings.put("from", "groovy-.*");
|
||||
mappings.put("to", "groovy");
|
||||
|
||||
dependencyLicensesTask.mapping(mappings);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -323,6 +352,6 @@ public class DependencyLicensesTaskTests extends GradleUnitTestCase {
|
|||
}
|
||||
|
||||
private FileCollection getDependencies(Project project) {
|
||||
return project.getConfigurations().getByName("compile");
|
||||
return project.getConfigurations().getByName("compileClasspath");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,19 +86,19 @@ public class UpdateShasTaskTests extends GradleUnitTestCase {
|
|||
|
||||
@Test
|
||||
public void whenDependencyExistsButShaNotThenShouldCreateNewShaFile() throws IOException, NoSuchAlgorithmException {
|
||||
project.getDependencies().add("compile", dependency);
|
||||
project.getDependencies().add("compileClasspath", dependency);
|
||||
|
||||
getLicensesDir(project).mkdir();
|
||||
task.updateShas();
|
||||
|
||||
Path groovySha = Files.list(getLicensesDir(project).toPath()).findFirst().get();
|
||||
|
||||
assertTrue(groovySha.toFile().getName().startsWith("groovy-all"));
|
||||
assertTrue(groovySha.toFile().getName().startsWith("groovy-"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenDependencyAndWrongShaExistsThenShouldNotOverwriteShaFile() throws IOException, NoSuchAlgorithmException {
|
||||
project.getDependencies().add("compile", dependency);
|
||||
project.getDependencies().add("compileClasspath", dependency);
|
||||
|
||||
File groovyJar = task.getParentTask().getDependencies().getFiles().iterator().next();
|
||||
String groovyShaName = groovyJar.getName() + ".sha1";
|
||||
|
@ -163,6 +163,6 @@ public class UpdateShasTaskTests extends GradleUnitTestCase {
|
|||
}
|
||||
|
||||
private FileCollection getDependencies(Project project) {
|
||||
return project.getConfigurations().getByName("compile");
|
||||
return project.getConfigurations().getByName("compileClasspath");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,6 +43,8 @@ public class GradleThreadsFilter implements ThreadFilter {
|
|||
|
||||
@Override
|
||||
public boolean reject(Thread t) {
|
||||
return t.getName().startsWith("Exec process") || t.getName().startsWith("File watcher consumer");
|
||||
return t.getName().startsWith("Exec process")
|
||||
|| t.getName().startsWith("Memory manager")
|
||||
|| t.getName().startsWith("File watcher consumer");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ import java.util.regex.Pattern
|
|||
*/
|
||||
|
||||
plugins {
|
||||
id "nebula.ospackage-base" version "8.3.0"
|
||||
id "nebula.ospackage-base" version "9.0.0"
|
||||
}
|
||||
|
||||
void addProcessFilesTask(String type, boolean jdk) {
|
||||
|
@ -136,9 +136,9 @@ Closure commonPackageConfig(String type, boolean jdk, String architecture) {
|
|||
// SystemPackagingTask overrides default archive task convention mappings, but doesn't provide a setter so we have to override the convention mapping itself
|
||||
// Deb convention uses a '_' for final separator before architecture, rpm uses a '.'
|
||||
if (type == 'deb') {
|
||||
conventionMapping.archiveFile = { objects.fileProperty().fileValue(file("${destinationDirectory.get()}/${packageName}-min_${project.version}${jdkString}_${archString}.${type}")) }
|
||||
archiveFileName.value(project.provider({ "${destinationDirectory.get()}/${packageName}-min_${project.version}${jdkString}_${archString}.${type}" }))
|
||||
} else {
|
||||
conventionMapping.archiveFile = { objects.fileProperty().fileValue(file("${destinationDirectory.get()}/${packageName}-min-${project.version}${jdkString}.${archString}.${type}")) }
|
||||
archiveFileName.value(project.provider({ "${destinationDirectory.get()}/${packageName}-min-${project.version}${jdkString}.${archString}.${type}" }))
|
||||
}
|
||||
|
||||
String packagingFiles = "build/packaging/${jdk ? '' : 'no-jdk-'}${type}"
|
||||
|
|
|
@ -22,6 +22,7 @@ allprojects {
|
|||
def codeCoverageReportTask = tasks.register("codeCoverageReport", JacocoReport) {
|
||||
description = 'Generates aggregate report from all subprojects.'
|
||||
executionData.setFrom fileTree(dir: '.', include: '**/build/jacoco/*.exec')
|
||||
dependsOn subprojects.findAll(s -> s.tasks.findByName('check') != null).check
|
||||
}
|
||||
|
||||
tasks.register("codeCoverageReportForUnitTest", JacocoReport) {
|
||||
|
@ -46,10 +47,12 @@ tasks.withType(JacocoReport).configureEach {
|
|||
def projectsWithJavaPlugin = subprojects.findAll { it.pluginManager.hasPlugin('java') }
|
||||
def projectsWithUnitTest = projectsWithJavaPlugin.findAll { it.tasks.findByName('test').enabled }
|
||||
def projectsWithIntegTest = projectsWithJavaPlugin.findAll {it.tasks.findByName('integTest')}
|
||||
def projectsWithAsyncIntegTest = projectsWithJavaPlugin.findAll {it.tasks.findByName('asyncIntegTest')}
|
||||
def projectsWithInternalClusterTest = projectsWithJavaPlugin.findAll {it.tasks.findByName('internalClusterTest')}
|
||||
def projectsWithPooledInternalClusterTest = projectsWithJavaPlugin.findAll {it.tasks.findByName('pooledInternalClusterTest')}
|
||||
def projectsWithJavaRestTest = projectsWithJavaPlugin.findAll {it.tasks.findByName('javaRestTest')}
|
||||
def projectsWithYamlRestTest = projectsWithJavaPlugin.findAll {it.tasks.findByName('yamlRestTest')}
|
||||
def projectsWithIntegrationTest = projectsWithIntegTest + projectsWithInternalClusterTest + projectsWithJavaRestTest + projectsWithYamlRestTest
|
||||
def projectsWithIntegrationTest = projectsWithIntegTest + projectsWithAsyncIntegTest + projectsWithInternalClusterTest + projectsWithPooledInternalClusterTest + projectsWithJavaRestTest + projectsWithYamlRestTest
|
||||
def projectsWithTest = projectsWithUnitTest + projectsWithIntegrationTest
|
||||
|
||||
def selectedProjects
|
||||
|
@ -60,7 +63,9 @@ tasks.withType(JacocoReport).configureEach {
|
|||
break
|
||||
case "codeCoverageReportForIntegrationTest":
|
||||
dependsOn projectsWithIntegTest.integTest
|
||||
dependsOn projectsWithAsyncIntegTest.asyncIntegTest
|
||||
dependsOn projectsWithInternalClusterTest.internalClusterTest
|
||||
dependsOn projectsWithPooledInternalClusterTest.pooledInternalClusterTest
|
||||
dependsOn projectsWithJavaRestTest.javaRestTest
|
||||
dependsOn projectsWithYamlRestTest.yamlRestTest
|
||||
selectedProjects = projectsWithIntegrationTest
|
||||
|
@ -68,20 +73,23 @@ tasks.withType(JacocoReport).configureEach {
|
|||
default:
|
||||
dependsOn projectsWithUnitTest.test
|
||||
dependsOn projectsWithIntegTest.integTest
|
||||
dependsOn projectsWithAsyncIntegTest.asyncIntegTest
|
||||
dependsOn projectsWithInternalClusterTest.internalClusterTest
|
||||
dependsOn projectsWithPooledInternalClusterTest.pooledInternalClusterTest
|
||||
dependsOn projectsWithJavaRestTest.javaRestTest
|
||||
dependsOn projectsWithYamlRestTest.yamlRestTest
|
||||
selectedProjects = projectsWithTest
|
||||
selectedProjects = projectsWithJavaPlugin
|
||||
break
|
||||
}
|
||||
|
||||
sourceDirectories.setFrom files(selectedProjects.sourceSets.main.allSource.srcDirs)
|
||||
classDirectories.setFrom files(selectedProjects.sourceSets.main.output)
|
||||
|
||||
reports {
|
||||
// Code coverage report in HTML and CSV formats are on demand, in case they take extra disk space.
|
||||
xml.enabled System.getProperty('tests.coverage.report.xml', 'true').toBoolean()
|
||||
html.enabled System.getProperty('tests.coverage.report.html', 'false').toBoolean()
|
||||
csv.enabled System.getProperty('tests.coverage.report.csv', 'false').toBoolean()
|
||||
xml.getRequired().set(System.getProperty('tests.coverage.report.xml', 'true').toBoolean())
|
||||
html.getRequired().set(System.getProperty('tests.coverage.report.html', 'false').toBoolean())
|
||||
csv.getRequired().set(System.getProperty('tests.coverage.report.csv', 'false').toBoolean())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*/
|
||||
|
||||
import javax.annotation.Nullable
|
||||
import org.gradle.internal.jvm.Jvm
|
||||
|
||||
/**
|
||||
* Checks for missing javadocs.
|
||||
|
@ -300,9 +301,7 @@ class MissingJavadocTask extends DefaultTask {
|
|||
|
||||
def javadocCmd = {
|
||||
if (executable == null) {
|
||||
JavaInstallationRegistry registry = project.extensions.getByType(JavaInstallationRegistry)
|
||||
JavaInstallation currentJvm = registry.installationForCurrentVirtualMachine.get()
|
||||
return currentJvm.jdk.get().javadocExecutable.asFile
|
||||
return Jvm.current().javadocExecutable
|
||||
} else {
|
||||
return project.file(executable)
|
||||
}
|
||||
|
|
Binary file not shown.
|
@ -11,7 +11,7 @@
|
|||
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-all.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionSha256Sum=11657af6356b7587bfb37287b5992e94a9686d5c8a0a1b60b87b9928a2decde5
|
||||
distributionSha256Sum=00b273629df4ce46e68df232161d5a7c4e495b9a029ce6e0420f071e21316867
|
||||
|
|
|
@ -92,3 +92,7 @@ forbiddenPatterns {
|
|||
exclude '**/*.p12'
|
||||
}
|
||||
|
||||
tasks.named("bundlePlugin").configure {
|
||||
dependsOn("copyParentJoinMetadata")
|
||||
dependsOn("copyTransportNetty4Metadata")
|
||||
}
|
||||
|
|
|
@ -124,6 +124,13 @@ testClusters.integTest {
|
|||
String realm = "BUILD.OPENSEARCH.ORG"
|
||||
String krb5conf = project(':test:fixtures:krb5kdc-fixture').ext.krb5Conf("hdfs")
|
||||
|
||||
|
||||
project(':test:fixtures:krb5kdc-fixture').tasks.preProcessFixture {
|
||||
dependsOn tasks.named("jarHell")
|
||||
dependsOn tasks.named("testingConventions")
|
||||
}
|
||||
|
||||
|
||||
// Create HDFS File System Testing Fixtures for HA/Secure combinations
|
||||
for (String fixtureName : ['hdfsFixture', 'haHdfsFixture', 'secureHdfsFixture', 'secureHaHdfsFixture']) {
|
||||
def tsk = project.tasks.register(fixtureName, org.opensearch.gradle.test.AntFixture) {
|
||||
|
|
|
@ -92,7 +92,7 @@ configurations {
|
|||
}
|
||||
|
||||
TaskProvider testJar = tasks.register("testJar", Jar) {
|
||||
appendix 'test'
|
||||
archiveAppendix = 'test'
|
||||
from sourceSets.test.output
|
||||
}
|
||||
|
||||
|
|
|
@ -115,7 +115,7 @@ configurations {
|
|||
}
|
||||
|
||||
def testJar = tasks.register("testJar", Jar) {
|
||||
appendix 'test'
|
||||
archiveAppendix = 'test'
|
||||
from sourceSets.test.output
|
||||
}
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ configurations {
|
|||
}
|
||||
|
||||
task testJar(type: Jar) {
|
||||
appendix 'test'
|
||||
archiveAppendix = 'test'
|
||||
from sourceSets.test.output
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue