Skip to content

Commit

Permalink
Excavator: Update to Gradle 7 (#1875)
Browse files Browse the repository at this point in the history
  • Loading branch information
svc-excavator-bot authored Aug 16, 2021
1 parent 2351209 commit 00f34d5
Show file tree
Hide file tree
Showing 18 changed files with 113 additions and 111 deletions.
34 changes: 17 additions & 17 deletions baseline-error-prone/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@ apply plugin: 'java-library'
apply plugin: 'com.palantir.external-publish-jar'

dependencies {
compile 'com.google.errorprone:error_prone_core'
compile 'org.mockito:mockito-errorprone'
compile 'org.immutables:value::annotations'
implementation 'com.google.errorprone:error_prone_core'
implementation 'org.mockito:mockito-errorprone'
implementation 'org.immutables:value::annotations'

testCompile gradleApi()
testCompile 'com.palantir.tokens:auth-tokens'
testCompile 'com.fasterxml.jackson.core:jackson-annotations'
testCompile 'com.google.errorprone:error_prone_test_helpers'
testCompile 'com.palantir.safe-logging:preconditions'
testCompile 'com.palantir.safe-logging:safe-logging'
testCompile 'com.palantir.safe-logging:logger'
testCompile 'org.slf4j:slf4j-api'
testCompile 'org.apache.commons:commons-lang3'
testCompile 'commons-lang:commons-lang'
testCompile 'org.assertj:assertj-core'
testCompile 'org.jooq:jooq'
testCompile 'com.palantir.tritium:tritium-registry'
testCompile 'com.palantir.conjure.java:conjure-lib'
testImplementation gradleApi()
testImplementation 'com.palantir.tokens:auth-tokens'
testImplementation 'com.fasterxml.jackson.core:jackson-annotations'
testImplementation 'com.google.errorprone:error_prone_test_helpers'
testImplementation 'com.palantir.safe-logging:preconditions'
testImplementation 'com.palantir.safe-logging:safe-logging'
testImplementation 'com.palantir.safe-logging:logger'
testImplementation 'org.slf4j:slf4j-api'
testImplementation 'org.apache.commons:commons-lang3'
testImplementation 'commons-lang:commons-lang'
testImplementation 'org.assertj:assertj-core'
testImplementation 'org.jooq:jooq'
testImplementation 'com.palantir.tritium:tritium-registry'
testImplementation 'com.palantir.conjure.java:conjure-lib'
testCompileOnly 'org.immutables:value::annotations'
testImplementation 'org.junit.jupiter:junit-jupiter'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-migrationsupport'
Expand Down
4 changes: 2 additions & 2 deletions baseline-refaster-javac-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apply plugin: 'java-library'
apply plugin: 'com.palantir.external-publish-jar'

dependencies {
compile 'com.google.errorprone:error_prone_refaster'
compile 'org.slf4j:slf4j-api'
implementation 'com.google.errorprone:error_prone_refaster'
implementation 'org.slf4j:slf4j-api'

annotationProcessor 'com.google.auto.service:auto-service'
compileOnly 'com.google.auto.service:auto-service'
Expand Down
6 changes: 3 additions & 3 deletions baseline-refaster-rules/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ dependencies {
implementation 'org.mockito:mockito-core'
implementation 'com.palantir.tritium:tritium-registry'

testCompile 'junit:junit'
testCompile project(':baseline-refaster-testing')
testCompile 'org.immutables:value::annotations'
testImplementation 'junit:junit'
testImplementation project(':baseline-refaster-testing')
testImplementation 'org.immutables:value::annotations'

compileOnly 'org.immutables:value::annotations'
}
Expand Down
10 changes: 5 additions & 5 deletions baseline-refaster-testing/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ apply plugin: 'java-library'
apply plugin: 'com.palantir.external-publish-jar'

dependencies {
compile 'com.google.errorprone:error_prone_refaster'
compile 'com.google.errorprone:error_prone_test_helpers'
api 'com.google.errorprone:error_prone_refaster'
api 'com.google.errorprone:error_prone_test_helpers'

compile 'com.google.guava:guava'
compile 'junit:junit'
compile 'org.assertj:assertj-core'
api 'com.google.guava:guava'
api 'junit:junit'
api 'org.assertj:assertj-core'
}
34 changes: 19 additions & 15 deletions gradle-baseline-java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ apply plugin: 'com.palantir.external-publish-jar'
apply plugin: 'com.palantir.external-publish-gradle-plugin'

dependencies {
compile project(':gradle-junit-reports')
compile gradleApi()
compile 'org.apache.commons:commons-lang3'
compile 'com.diffplug.spotless:spotless-plugin-gradle'
compile 'com.google.errorprone:error_prone_refaster'
compile 'com.google.guava:guava'
compile 'net.ltgt.gradle:gradle-errorprone-plugin'
compile 'org.apache.maven.shared:maven-dependency-analyzer'
compile 'org.github.ngbinh.scalastyle:gradle-scalastyle-plugin_2.11'
implementation project(':gradle-junit-reports')
implementation gradleApi()
implementation 'org.apache.commons:commons-lang3'
implementation 'com.diffplug.spotless:spotless-plugin-gradle'
implementation 'com.google.errorprone:error_prone_refaster'
implementation 'com.google.guava:guava'
implementation 'net.ltgt.gradle:gradle-errorprone-plugin'
implementation 'org.apache.maven.shared:maven-dependency-analyzer'
implementation 'org.github.ngbinh.scalastyle:gradle-scalastyle-plugin_2.11'
implementation 'commons-lang:commons-lang'
implementation 'com.palantir.javaformat:palantir-java-format-spi'
// Add an explicit dependency to ensure consumers can use JDK14 source compat
Expand All @@ -21,12 +21,12 @@ dependencies {

runtimeOnly 'com.palantir.javaformat:gradle-palantir-java-format'

testCompile gradleTestKit()
testCompile 'com.github.stefanbirkner:system-rules'
testCompile 'com.netflix.nebula:nebula-test' // for better temp directory junit rule only
testCompile 'junit:junit'
testCompile 'net.lingala.zip4j:zip4j'
testCompile 'org.assertj:assertj-core'
testImplementation gradleTestKit()
testImplementation 'com.github.stefanbirkner:system-rules'
testImplementation 'com.netflix.nebula:nebula-test' // for better temp directory junit rule only
testImplementation 'junit:junit'
testImplementation 'net.lingala.zip4j:zip4j'
testImplementation 'org.assertj:assertj-core'

annotationProcessor 'org.inferred:freebuilder'
compileOnly 'org.inferred:freebuilder'
Expand Down Expand Up @@ -128,6 +128,10 @@ pluginBundle {
}
}

tasks.named('processResources').configure {
duplicatesStrategy 'include'
}

// Run `./gradlew test -Drecreate=true` to recreate all the expected
// generated code that we have checked into the repo.
tasks.withType(Test) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.collect.ImmutableSet;
import com.palantir.baseline.tasks.CheckImplicitDependenciesParentTask;
import com.palantir.baseline.tasks.CheckImplicitDependenciesTask;
Expand Down Expand Up @@ -199,7 +198,7 @@ private static void configureSourceSet(
checkUnusedDependencies.configure(task -> task.dependsOn(sourceSetUnusedDependencies));
TaskProvider<CheckImplicitDependenciesTask> sourceSetCheckImplicitDependencies = project.getTasks()
.register(
GUtil.toLowerCamelCase("checkImplicitDependencies " + sourceSet.getName()),
"checkImplicitDependencies" + StringUtils.capitalize(sourceSet.getName()),
CheckImplicitDependenciesTask.class,
task -> {
task.dependsOn(sourceSet.getClassesTaskName());
Expand All @@ -216,7 +215,7 @@ private static void configureSourceSet(
}

static String checkUnusedDependenciesNameForSourceSet(SourceSet sourceSet) {
return GUtil.toLowerCamelCase("checkUnusedDependencies " + sourceSet.getName());
return "checkUnusedDependencies" + StringUtils.capitalize(sourceSet.getName());
}

/**
Expand All @@ -232,14 +231,10 @@ private static String getCompileConfigurationName(SourceSet sourceSet) {
}

private static Map<String, String> excludeRuleAsMap(ExcludeRule rule) {
Builder<String, String> excludeRule = ImmutableMap.builder();
if (rule.getGroup() != null) {
excludeRule.put("group", rule.getGroup());
}
if (rule.getModule() != null) {
excludeRule.put("module", rule.getModule());
}
return excludeRule.build();
return ImmutableMap.<String, String>builder()
.put("group", rule.getGroup())
.put("module", rule.getModule())
.build();
}

/** Given a {@code com/palantir/product/Foo.class} file, what other classes does it import/reference. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,21 +132,23 @@ private JavaVersion getRawSourceCompat() {
org.gradle.api.plugins.internal.DefaultJavaPluginConvention convention =
(org.gradle.api.plugins.internal.DefaultJavaPluginConvention)
getProject().getConvention().getPlugin(JavaPluginConvention.class);
return convention.getRawSourceCompatibility();

try {
Method getRawSourceCompatibility =
org.gradle.api.plugins.internal.DefaultJavaPluginConvention.class.getMethod(
"getRawSourceCompatibility");
return (JavaVersion) getRawSourceCompatibility.invoke(convention);
} catch (Exception e) {
throw new RuntimeException(
"Error calling DefaultJavaPluginConvention#getRawSourceCompatibility for "
+ GradleVersion.current(),
e);
}
}

// TODO(fwindheuser): Don't use reflection after building with Gradle 7
org.gradle.api.plugins.internal.DefaultJavaPluginExtension extension =
(org.gradle.api.plugins.internal.DefaultJavaPluginExtension)
getProject().getExtensions().getByType(JavaPluginExtension.class);
try {
Method rawSourceCompat = org.gradle.api.plugins.internal.DefaultJavaPluginExtension.class.getMethod(
"getRawSourceCompatibility");
return (JavaVersion) rawSourceCompat.invoke(extension);
} catch (Exception e) {
throw new RuntimeException(
"Error calling DefaultJavaPluginExtension#getRawSourceCompatibility for " + GradleVersion.current(),
e);
}
return extension.getRawSourceCompatibility();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ repositories {
sourceCompatibility = 1.8

dependencies {
testCompile 'junit:junit:4.12'
testCompile 'org.assertj:assertj-core:3.10.0'
testImplementation 'junit:junit:4.12'
testImplementation 'org.assertj:assertj-core:3.10.0'
}

tasks.withType(Checkstyle) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ repositories {
sourceCompatibility = 1.7

dependencies {
testCompile 'junit:junit:4.12'
testCompile 'org.assertj:assertj-core:3.10.0'
testImplementation 'junit:junit:4.12'
testImplementation 'org.assertj:assertj-core:3.10.0'
}

tasks.withType(Checkstyle) {
Expand Down
4 changes: 2 additions & 2 deletions gradle-junit-reports/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apply plugin: 'java-library'
apply plugin: 'com.palantir.external-publish-jar'

dependencies {
compile gradleApi()
compile 'com.google.guava:guava'
api gradleApi()
api 'com.google.guava:guava'

annotationProcessor 'org.immutables:value'
annotationProcessor 'org.inferred:freebuilder'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.gradle.api.tasks.OutputFile;
import org.gradle.api.tasks.TaskAction;
import org.gradle.api.tasks.TaskProvider;
import org.gradle.util.GUtil;
import org.w3c.dom.Document;

public abstract class JunitReportsFinalizer extends DefaultTask {
Expand All @@ -48,21 +47,16 @@ public static void registerFinalizer(
Provider<Directory> reportDir) {
TaskProvider<Task> wrappedTask = project.getTasks().named(taskName);
TaskProvider<JunitReportsFinalizer> finalizer = project.getTasks()
.register(
GUtil.toLowerCamelCase(taskName + " junitReportsFinalizer"),
JunitReportsFinalizer.class,
task -> {
task.getWrappedDidWork()
.set(project.provider(
() -> wrappedTask.get().getDidWork()));
task.getWrappedTaskName().set(taskName);
task.getDurationNanos()
.set(project.provider(() -> taskTimer.getTaskTimeNanos(wrappedTask.get())));
task.setFailuresSupplier(failuresSupplier);
task.getTargetFile()
.set(reportDir.map(dir -> dir.file(project.getName() + "-" + taskName + ".xml")));
task.getReportDir().set(reportDir);
});
.register(taskName + "JunitReportsFinalizer", JunitReportsFinalizer.class, task -> {
task.getWrappedDidWork()
.set(project.provider(() -> wrappedTask.get().getDidWork()));
task.getWrappedTaskName().set(taskName);
task.getDurationNanos().set(project.provider(() -> taskTimer.getTaskTimeNanos(wrappedTask.get())));
task.setFailuresSupplier(failuresSupplier);
task.getTargetFile()
.set(reportDir.map(dir -> dir.file(project.getName() + "-" + taskName + ".xml")));
task.getReportDir().set(reportDir);
});

wrappedTask.configure(task -> {
task.finalizedBy(finalizer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import org.gradle.api.Action;
import org.gradle.api.Project;
Expand Down Expand Up @@ -55,7 +56,9 @@ private XmlReportFailuresSupplier(

@Override
public List<Failure> getFailures() throws IOException {
File sourceReport = reporting.getReports().findByName("xml").getDestination();
File sourceReport = Optional.ofNullable(reporting.getReports().findByName("xml"))
.map(report -> report.getOutputLocation().getAsFile().getOrNull())
.orElseThrow(() -> new RuntimeException("Could not find junit reports"));
try {
return XmlUtils.parseXml(reportHandler, new FileInputStream(sourceReport))
.failures();
Expand All @@ -73,12 +76,12 @@ public RuntimeException handleInternalFailure(Path reportDir, RuntimeException e
throw new RuntimeException(e);
}
for (SingleFileReport rawReport : reporting.getReports()) {
if (rawReport.isEnabled()) {
rawReport
.getDestination()
.renameTo(rawReportsDir
.resolve(rawReport.getDestination().getName())
.toFile());
if (rawReport.getRequired().get()) {
File rawReportFile = Optional.ofNullable(
rawReport.getOutputLocation().getAsFile().getOrNull())
.orElseThrow(() -> new IllegalStateException("Could not get raw report file: " + rawReport));
rawReportFile.renameTo(
rawReportsDir.resolve(rawReportFile.getName()).toFile());
}
}
return new RuntimeException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private Checkstyle createCheckstyleTask(Project project) throws IOException {
File modifiedReportFile = projectDir.newFile();
Files.write(modifiedReportXml.getBytes(StandardCharsets.UTF_8), modifiedReportFile);

xmlReport.setDestination(modifiedReportFile);
xmlReport.getOutputLocation().set(modifiedReportFile);
return checkstyle;
}
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ case "`uname`" in
Darwin* )
darwin=true
;;
MINGW* )
MSYS* | MINGW* )
msys=true
;;
NONSTOP* )
Expand Down
Loading

0 comments on commit 00f34d5

Please sign in to comment.