From 3e47bfb7b433b61df83c9f8cb1b4d263b9a4449e Mon Sep 17 00:00:00 2001 From: Dawid Weiss Date: Mon, 31 Aug 2020 15:35:14 +0200 Subject: [PATCH] Cleanup remaining scripts to use script-relative resource location. --- gradle/documentation/render-javadoc.gradle | 21 ++++++++++++------- gradle/testing/defaults-tests.gradle | 3 ++- gradle/testing/randomization.gradle | 8 ++++--- .../policies/replicator-tests.policy | 0 .../policies/solr-tests.policy | 0 .../{ => randomization}/policies/tests.policy | 0 gradle/validation/ecj-lint.gradle | 4 +++- gradle/validation/forbidden-apis.gradle | 8 ++++--- .../validation/owasp-dependency-check.gradle | 4 +++- 9 files changed, 31 insertions(+), 17 deletions(-) rename gradle/testing/{ => randomization}/policies/replicator-tests.policy (100%) rename gradle/testing/{ => randomization}/policies/solr-tests.policy (100%) rename gradle/testing/{ => randomization}/policies/tests.policy (100%) diff --git a/gradle/documentation/render-javadoc.gradle b/gradle/documentation/render-javadoc.gradle index 4d0ce2e4dcb..baae06665a5 100644 --- a/gradle/documentation/render-javadoc.gradle +++ b/gradle/documentation/render-javadoc.gradle @@ -20,6 +20,8 @@ import javax.annotation.Nullable // generate javadocs by calling javadoc tool // see https://docs.oracle.com/en/java/javase/11/tools/javadoc.html +def resources = scriptResources(buildscript) + allprojects { plugins.withType(JavaPlugin) { ext { @@ -39,17 +41,19 @@ allprojects { description "Generates Javadoc API documentation for the main source code. This directly invokes javadoc tool." group "documentation" + taskResources = resources dependsOn sourceSets.main.compileClasspath - classpath = sourceSets.main.compileClasspath; + classpath = sourceSets.main.compileClasspath srcDirSet = sourceSets.main.java; - outputDir = project.javadoc.destinationDir; + outputDir = project.javadoc.destinationDir } task renderSiteJavadoc(type: RenderJavadocTask) { description "Generates Javadoc API documentation for the site (relative links)." group "documentation" + taskResources = resources dependsOn sourceSets.main.compileClasspath classpath = sourceSets.main.compileClasspath; srcDirSet = sourceSets.main.java; @@ -65,9 +69,9 @@ allprojects { // Set up titles and link up some offline docs for all documentation // (they may be unused but this doesn't do any harm). -def taskResources = "${rootProject.projectDir}/gradle/documentation/render-javadoc" -def javaJavadocPackages = rootProject.file("${taskResources}/java11/") -def junitJavadocPackages = rootProject.file("${taskResources}/junit/") + +def javaJavadocPackages = rootProject.file("${resources}/java11/") +def junitJavadocPackages = rootProject.file("${resources}/junit/") allprojects { project.tasks.withType(RenderJavadocTask) { title = "${project.path.startsWith(':lucene') ? 'Lucene' : 'Solr'} ${project.version} ${project.name} API" @@ -158,7 +162,10 @@ class RenderJavadocTask extends DefaultTask { @Optional @Input def executable - + + @Input + def taskResources + /** Utility method to recursively collect all tasks with same name like this one that we depend on */ private Set findRenderTasksInDependencies() { Set found = [] @@ -311,8 +318,6 @@ class RenderJavadocTask extends DefaultTask { throw new GradleException("Javadoc generation failed for ${project.path},\n Options file at: ${optionsFile}\n Command output at: ${outputFile}", cause) } - def taskResources = "${project.rootDir}/gradle/documentation/render-javadoc" - // append some special table css, prettify css ant.concat(destfile: "${outputDir}/stylesheet.css", append: "true", fixlastline: "true", encoding: "UTF-8") { filelist(dir: taskResources, files: "table_padding.css") diff --git a/gradle/testing/defaults-tests.gradle b/gradle/testing/defaults-tests.gradle index 83d4735f0c1..2ceb436d76b 100644 --- a/gradle/testing/defaults-tests.gradle +++ b/gradle/testing/defaults-tests.gradle @@ -20,6 +20,7 @@ import org.apache.tools.ant.types.Commandline import org.gradle.api.tasks.testing.logging.* import org.apache.lucene.gradle.ErrorReportingTestListener +def resources = scriptResources(buildscript) def verboseModeHookInstalled = false allprojects { @@ -105,7 +106,7 @@ allprojects { jvmArgs Commandline.translateCommandline(resolvedTestOption("tests.jvmargs")) - systemProperty 'java.util.logging.config.file', rootProject.file("gradle/testing/defaults-tests/logging.properties") + systemProperty 'java.util.logging.config.file', file("${resources}/logging.properties") systemProperty 'java.awt.headless', 'true' systemProperty 'jdk.map.althashing.threshold', '0' diff --git a/gradle/testing/randomization.gradle b/gradle/testing/randomization.gradle index 570ff6aaa9f..298bfe13e0c 100644 --- a/gradle/testing/randomization.gradle +++ b/gradle/testing/randomization.gradle @@ -33,6 +33,8 @@ buildscript { } } +def resources = scriptResources(buildscript) + // Pick the "root" seed from which everything else is derived. configure(rootProject) { ext { @@ -182,14 +184,14 @@ allprojects { if (Boolean.parseBoolean(testOptionsResolved["tests.useSecurityManager"])) { if (project.path == ":lucene:replicator") { systemProperty 'java.security.manager', "org.apache.lucene.util.TestSecurityManager" - systemProperty 'java.security.policy', rootProject.file("gradle/testing/policies/replicator-tests.policy") + systemProperty 'java.security.policy', file("${resources}/policies/replicator-tests.policy") } else if (project.path.startsWith(":lucene")) { systemProperty 'java.security.manager', "org.apache.lucene.util.TestSecurityManager" - systemProperty 'java.security.policy', rootProject.file("gradle/testing/policies/tests.policy") + systemProperty 'java.security.policy', file("${resources}/policies/tests.policy") } else { systemProperty 'common-solr.dir', commonSolrDir systemProperty 'java.security.manager', "org.apache.lucene.util.TestSecurityManager" - systemProperty 'java.security.policy', rootProject.file("gradle/testing/policies/solr-tests.policy") + systemProperty 'java.security.policy', file("${resources}/policies/solr-tests.policy") } systemProperty 'common.dir', commonDir diff --git a/gradle/testing/policies/replicator-tests.policy b/gradle/testing/randomization/policies/replicator-tests.policy similarity index 100% rename from gradle/testing/policies/replicator-tests.policy rename to gradle/testing/randomization/policies/replicator-tests.policy diff --git a/gradle/testing/policies/solr-tests.policy b/gradle/testing/randomization/policies/solr-tests.policy similarity index 100% rename from gradle/testing/policies/solr-tests.policy rename to gradle/testing/randomization/policies/solr-tests.policy diff --git a/gradle/testing/policies/tests.policy b/gradle/testing/randomization/policies/tests.policy similarity index 100% rename from gradle/testing/policies/tests.policy rename to gradle/testing/randomization/policies/tests.policy diff --git a/gradle/validation/ecj-lint.gradle b/gradle/validation/ecj-lint.gradle index 56bbd8db1d1..3dcb2c00669 100644 --- a/gradle/validation/ecj-lint.gradle +++ b/gradle/validation/ecj-lint.gradle @@ -27,6 +27,8 @@ configure(rootProject) { } } +def resources = scriptResources(buildscript) + allprojects { plugins.withType(JavaPlugin) { // Create a [sourceSetName]EcjLint task for each source set @@ -69,7 +71,7 @@ allprojects { args += [ "-proc:none" ] args += [ "-nowarn" ] args += [ "-enableJavadoc" ] - args += [ "-properties", rootProject.file("gradle/validation/ecj-lint/ecj.javadocs.prefs").absolutePath ] + args += [ "-properties", file("${resources}/ecj.javadocs.prefs").absolutePath ] doFirst { tmpDst.mkdirs() diff --git a/gradle/validation/forbidden-apis.gradle b/gradle/validation/forbidden-apis.gradle index 5237570dfc9..4767d0fe3de 100644 --- a/gradle/validation/forbidden-apis.gradle +++ b/gradle/validation/forbidden-apis.gradle @@ -18,6 +18,8 @@ // This configures application of forbidden API rules // via https://github.com/policeman-tools/forbidden-apis +def resources = scriptResources(buildscript) + // Only apply forbidden-apis to java projects. allprojects { prj -> plugins.withId("java", { @@ -39,7 +41,7 @@ allprojects { prj -> deps += ["defaults.all.txt", "defaults.${suffix}.txt"] deps.each { sig -> - def signaturesFile = rootProject.file("gradle/validation/forbidden-apis/${sig}") + def signaturesFile = file("${resources}/${sig}") if (signaturesFile.exists()) { logger.info("Signature file applied: ${sig}") signaturesFiles += files(signaturesFile) @@ -79,7 +81,7 @@ allprojects { prj -> ] signaturesFiles = files( - rootProject.file("gradle/validation/forbidden-apis/defaults.tests.txt") + file("${resources}/defaults.tests.txt") ) suppressAnnotations += [ @@ -133,7 +135,7 @@ allprojects { prj -> // This is the simplest workaround possible: just point at all the rule files and indicate // them as inputs. This way if a rule is modified, checks will be reapplied. configure([forbiddenApisMain, forbiddenApisTest]) { task -> - task.inputs.dir(rootProject.file("gradle/validation/forbidden-apis")) + task.inputs.dir(file(resources)) } }) } \ No newline at end of file diff --git a/gradle/validation/owasp-dependency-check.gradle b/gradle/validation/owasp-dependency-check.gradle index 4d300b85c94..d58fd8bfd10 100644 --- a/gradle/validation/owasp-dependency-check.gradle +++ b/gradle/validation/owasp-dependency-check.gradle @@ -20,13 +20,15 @@ // If -Pvalidation.owasp=true is set the validation will also run as part of the check task. +def resources = scriptResources(buildscript) + configure(rootProject) { dependencyCheck { failBuildOnCVSS = propertyOrDefault("validation.owasp.threshold", 7) as Integer formats = ['HTML', 'JSON'] skipProjects = [':solr:solr-ref-guide'] skipConfigurations = ['unifiedClasspath'] - suppressionFile = rootProject.file('gradle/validation/owasp-dependency-check/exclusions.xml') + suppressionFile = file("${resources}/exclusions.xml") } task owasp() {