From 9f2ae95397133fffa4c30e37b78c8f5e3b70eace Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Mon, 26 Jul 2021 13:51:22 -0500 Subject: [PATCH] Gradle task cache Gradle 7 prep --- gradle.properties | 4 ++++ gradle/java-module.gradle | 2 ++ gradle/wrapper/gradle-wrapper.properties | 2 +- hibernate-core/hibernate-core.gradle | 6 +++++- .../main/java/org/hibernate/orm/antlr/GeneratorTask.java | 5 +++++ settings.gradle | 5 +++++ tooling/metamodel-generator/hibernate-jpamodelgen.gradle | 4 +++- 7 files changed, 25 insertions(+), 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index b578ff579e..35389cb0fe 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,6 +6,10 @@ toolchain.launcher.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=256m -XX:+HeapDumpOnOutOf org.gradle.parallel=true +# enable Gradle's Task Cache. worst case: +# > rm -rf ~/.gradle/caches/build-cache-1 +org.gradle.caching=true + # JDK auto-detection is not quite ready yet in Gradle 6.7. # On Fedora in particular, if you have the package java-1.8.0-openjdk-headless-1.8.0.265.b01-1.fc32.x86_64 installed, # Gradle will look for the Java binaries in /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.265.b01-1.fc32.x86_64/bin/java diff --git a/gradle/java-module.gradle b/gradle/java-module.gradle index e6dec22956..0eb3896931 100644 --- a/gradle/java-module.gradle +++ b/gradle/java-module.gradle @@ -358,6 +358,8 @@ jar { 'Hibernate-JpaVersion': project.jpaVersion.name, // BND Plugin instructions (for OSGi): + '-reproducible': true, + '-noextraheaders': true, 'Bundle-Name': project.name, 'Bundle-SymbolicName': project.java9ModuleName, 'Bundle-Vendor': 'Hibernate.org', diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1f3fdbc528..7665b0fa93 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/hibernate-core/hibernate-core.gradle b/hibernate-core/hibernate-core.gradle index 6e7016e0d2..15ca8451ee 100644 --- a/hibernate-core/hibernate-core.gradle +++ b/hibernate-core/hibernate-core.gradle @@ -233,10 +233,14 @@ task copyBundleResources (type: Copy) { } } -processTestResources.dependsOn copyBundleResources +processTestResources { + dependsOn copyBundleResources + duplicatesStrategy = DuplicatesStrategy.WARN +} sourcesJar { duplicatesStrategy = DuplicatesStrategy.EXCLUDE + } task testJar(type: Jar, dependsOn: testClasses) { diff --git a/hibernate-orm-build/src/main/java/org/hibernate/orm/antlr/GeneratorTask.java b/hibernate-orm-build/src/main/java/org/hibernate/orm/antlr/GeneratorTask.java index c1dbe37e48..2ab50e96c4 100644 --- a/hibernate-orm-build/src/main/java/org/hibernate/orm/antlr/GeneratorTask.java +++ b/hibernate-orm-build/src/main/java/org/hibernate/orm/antlr/GeneratorTask.java @@ -14,13 +14,17 @@ import org.gradle.api.DefaultTask; import org.gradle.api.file.Directory; import org.gradle.api.file.RegularFile; import org.gradle.api.provider.Provider; +import org.gradle.api.tasks.CacheableTask; import org.gradle.api.tasks.InputFile; import org.gradle.api.tasks.OutputDirectory; +import org.gradle.api.tasks.PathSensitive; +import org.gradle.api.tasks.PathSensitivity; import org.gradle.api.tasks.TaskAction; /** * @author Steve Ebersole */ +@CacheableTask public abstract class GeneratorTask extends DefaultTask { private final Provider grammarFile; private final Provider outputDirectory; @@ -34,6 +38,7 @@ public abstract class GeneratorTask extends DefaultTask { } @InputFile + @PathSensitive( PathSensitivity.RELATIVE ) public Provider getGrammarFile() { return grammarFile; } diff --git a/settings.gradle b/settings.gradle index 69f97a3a2a..704e1b116f 100644 --- a/settings.gradle +++ b/settings.gradle @@ -30,6 +30,11 @@ if ( !JavaVersion.current().java8Compatible ) { throw new GradleException( "Gradle must be run with Java 8 or later" ) } +buildCache { + local { enabled = true } + remote(HttpBuildCache) { enabled = false } +} + gradle.ext.baselineJavaVersion = JavaLanguageVersion.of( 8 ) // Gradle does bytecode transformation on tests. diff --git a/tooling/metamodel-generator/hibernate-jpamodelgen.gradle b/tooling/metamodel-generator/hibernate-jpamodelgen.gradle index 41b1b3f63a..e47e8fd02a 100644 --- a/tooling/metamodel-generator/hibernate-jpamodelgen.gradle +++ b/tooling/metamodel-generator/hibernate-jpamodelgen.gradle @@ -59,7 +59,9 @@ task jaxb { package: 'org.hibernate.jpamodelgen.xml.jaxb', extension: 'true' ) { - schema ( dir: xsdDir.path, includes: "*.xsd" ) + project.ant.arg line: '-no-header' + project.ant.arg line: '-npa' + schema( dir: xsdDir.path, includes: "*.xsd" ) } } }