Cleanup remaining scripts to use script-relative resource location.

This commit is contained in:
Dawid Weiss 2020-08-31 15:35:14 +02:00
parent 66eb9f7f3d
commit 3e47bfb7b4
9 changed files with 31 additions and 17 deletions

View File

@ -20,6 +20,8 @@ import javax.annotation.Nullable
// generate javadocs by calling javadoc tool // generate javadocs by calling javadoc tool
// see https://docs.oracle.com/en/java/javase/11/tools/javadoc.html // see https://docs.oracle.com/en/java/javase/11/tools/javadoc.html
def resources = scriptResources(buildscript)
allprojects { allprojects {
plugins.withType(JavaPlugin) { plugins.withType(JavaPlugin) {
ext { ext {
@ -39,17 +41,19 @@ allprojects {
description "Generates Javadoc API documentation for the main source code. This directly invokes javadoc tool." description "Generates Javadoc API documentation for the main source code. This directly invokes javadoc tool."
group "documentation" group "documentation"
taskResources = resources
dependsOn sourceSets.main.compileClasspath dependsOn sourceSets.main.compileClasspath
classpath = sourceSets.main.compileClasspath; classpath = sourceSets.main.compileClasspath
srcDirSet = sourceSets.main.java; srcDirSet = sourceSets.main.java;
outputDir = project.javadoc.destinationDir; outputDir = project.javadoc.destinationDir
} }
task renderSiteJavadoc(type: RenderJavadocTask) { task renderSiteJavadoc(type: RenderJavadocTask) {
description "Generates Javadoc API documentation for the site (relative links)." description "Generates Javadoc API documentation for the site (relative links)."
group "documentation" group "documentation"
taskResources = resources
dependsOn sourceSets.main.compileClasspath dependsOn sourceSets.main.compileClasspath
classpath = sourceSets.main.compileClasspath; classpath = sourceSets.main.compileClasspath;
srcDirSet = sourceSets.main.java; srcDirSet = sourceSets.main.java;
@ -65,9 +69,9 @@ allprojects {
// Set up titles and link up some offline docs for all documentation // Set up titles and link up some offline docs for all documentation
// (they may be unused but this doesn't do any harm). // (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 javaJavadocPackages = rootProject.file("${resources}/java11/")
def junitJavadocPackages = rootProject.file("${taskResources}/junit/") def junitJavadocPackages = rootProject.file("${resources}/junit/")
allprojects { allprojects {
project.tasks.withType(RenderJavadocTask) { project.tasks.withType(RenderJavadocTask) {
title = "${project.path.startsWith(':lucene') ? 'Lucene' : 'Solr'} ${project.version} ${project.name} API" title = "${project.path.startsWith(':lucene') ? 'Lucene' : 'Solr'} ${project.version} ${project.name} API"
@ -159,6 +163,9 @@ class RenderJavadocTask extends DefaultTask {
@Input @Input
def executable def executable
@Input
def taskResources
/** Utility method to recursively collect all tasks with same name like this one that we depend on */ /** Utility method to recursively collect all tasks with same name like this one that we depend on */
private Set findRenderTasksInDependencies() { private Set findRenderTasksInDependencies() {
Set found = [] 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) 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 // append some special table css, prettify css
ant.concat(destfile: "${outputDir}/stylesheet.css", append: "true", fixlastline: "true", encoding: "UTF-8") { ant.concat(destfile: "${outputDir}/stylesheet.css", append: "true", fixlastline: "true", encoding: "UTF-8") {
filelist(dir: taskResources, files: "table_padding.css") filelist(dir: taskResources, files: "table_padding.css")

View File

@ -20,6 +20,7 @@ import org.apache.tools.ant.types.Commandline
import org.gradle.api.tasks.testing.logging.* import org.gradle.api.tasks.testing.logging.*
import org.apache.lucene.gradle.ErrorReportingTestListener import org.apache.lucene.gradle.ErrorReportingTestListener
def resources = scriptResources(buildscript)
def verboseModeHookInstalled = false def verboseModeHookInstalled = false
allprojects { allprojects {
@ -105,7 +106,7 @@ allprojects {
jvmArgs Commandline.translateCommandline(resolvedTestOption("tests.jvmargs")) 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 'java.awt.headless', 'true'
systemProperty 'jdk.map.althashing.threshold', '0' systemProperty 'jdk.map.althashing.threshold', '0'

View File

@ -33,6 +33,8 @@ buildscript {
} }
} }
def resources = scriptResources(buildscript)
// Pick the "root" seed from which everything else is derived. // Pick the "root" seed from which everything else is derived.
configure(rootProject) { configure(rootProject) {
ext { ext {
@ -182,14 +184,14 @@ allprojects {
if (Boolean.parseBoolean(testOptionsResolved["tests.useSecurityManager"])) { if (Boolean.parseBoolean(testOptionsResolved["tests.useSecurityManager"])) {
if (project.path == ":lucene:replicator") { if (project.path == ":lucene:replicator") {
systemProperty 'java.security.manager', "org.apache.lucene.util.TestSecurityManager" 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")) { } else if (project.path.startsWith(":lucene")) {
systemProperty 'java.security.manager', "org.apache.lucene.util.TestSecurityManager" 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 { } else {
systemProperty 'common-solr.dir', commonSolrDir systemProperty 'common-solr.dir', commonSolrDir
systemProperty 'java.security.manager', "org.apache.lucene.util.TestSecurityManager" 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 systemProperty 'common.dir', commonDir

View File

@ -27,6 +27,8 @@ configure(rootProject) {
} }
} }
def resources = scriptResources(buildscript)
allprojects { allprojects {
plugins.withType(JavaPlugin) { plugins.withType(JavaPlugin) {
// Create a [sourceSetName]EcjLint task for each source set // Create a [sourceSetName]EcjLint task for each source set
@ -69,7 +71,7 @@ allprojects {
args += [ "-proc:none" ] args += [ "-proc:none" ]
args += [ "-nowarn" ] args += [ "-nowarn" ]
args += [ "-enableJavadoc" ] args += [ "-enableJavadoc" ]
args += [ "-properties", rootProject.file("gradle/validation/ecj-lint/ecj.javadocs.prefs").absolutePath ] args += [ "-properties", file("${resources}/ecj.javadocs.prefs").absolutePath ]
doFirst { doFirst {
tmpDst.mkdirs() tmpDst.mkdirs()

View File

@ -18,6 +18,8 @@
// This configures application of forbidden API rules // This configures application of forbidden API rules
// via https://github.com/policeman-tools/forbidden-apis // via https://github.com/policeman-tools/forbidden-apis
def resources = scriptResources(buildscript)
// Only apply forbidden-apis to java projects. // Only apply forbidden-apis to java projects.
allprojects { prj -> allprojects { prj ->
plugins.withId("java", { plugins.withId("java", {
@ -39,7 +41,7 @@ allprojects { prj ->
deps += ["defaults.all.txt", "defaults.${suffix}.txt"] deps += ["defaults.all.txt", "defaults.${suffix}.txt"]
deps.each { sig -> deps.each { sig ->
def signaturesFile = rootProject.file("gradle/validation/forbidden-apis/${sig}") def signaturesFile = file("${resources}/${sig}")
if (signaturesFile.exists()) { if (signaturesFile.exists()) {
logger.info("Signature file applied: ${sig}") logger.info("Signature file applied: ${sig}")
signaturesFiles += files(signaturesFile) signaturesFiles += files(signaturesFile)
@ -79,7 +81,7 @@ allprojects { prj ->
] ]
signaturesFiles = files( signaturesFiles = files(
rootProject.file("gradle/validation/forbidden-apis/defaults.tests.txt") file("${resources}/defaults.tests.txt")
) )
suppressAnnotations += [ suppressAnnotations += [
@ -133,7 +135,7 @@ allprojects { prj ->
// This is the simplest workaround possible: just point at all the rule files and indicate // 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. // them as inputs. This way if a rule is modified, checks will be reapplied.
configure([forbiddenApisMain, forbiddenApisTest]) { task -> configure([forbiddenApisMain, forbiddenApisTest]) { task ->
task.inputs.dir(rootProject.file("gradle/validation/forbidden-apis")) task.inputs.dir(file(resources))
} }
}) })
} }

View File

@ -20,13 +20,15 @@
// If -Pvalidation.owasp=true is set the validation will also run as part of the check task. // If -Pvalidation.owasp=true is set the validation will also run as part of the check task.
def resources = scriptResources(buildscript)
configure(rootProject) { configure(rootProject) {
dependencyCheck { dependencyCheck {
failBuildOnCVSS = propertyOrDefault("validation.owasp.threshold", 7) as Integer failBuildOnCVSS = propertyOrDefault("validation.owasp.threshold", 7) as Integer
formats = ['HTML', 'JSON'] formats = ['HTML', 'JSON']
skipProjects = [':solr:solr-ref-guide'] skipProjects = [':solr:solr-ref-guide']
skipConfigurations = ['unifiedClasspath'] skipConfigurations = ['unifiedClasspath']
suppressionFile = rootProject.file('gradle/validation/owasp-dependency-check/exclusions.xml') suppressionFile = file("${resources}/exclusions.xml")
} }
task owasp() { task owasp() {