lucene/gradle/globals.gradle

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

118 lines
4.1 KiB
Groovy
Raw Normal View History

/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
2019-12-02 09:34:57 -05:00
allprojects {
apply plugin: 'base'
group "org.apache"
// Repositories to fetch dependencies from.
repositories {
mavenCentral()
}
// Artifacts will have names after full gradle project path
// so :solr:core will have solr-core.jar, etc.
project.archivesBaseName = project.path.replaceAll("^:", "").replace(':', '-')
ext {
// Utility method to support passing overrides via -P or -D.
propertyOrDefault = { propName, defValue ->
def result
if (project.hasProperty(propName)) {
result = project.getProperty(propName)
} else if (System.properties.containsKey(propName)) {
result = System.properties.get(propName)
} else if (defValue instanceof Closure) {
result = defValue.call()
} else {
result = defValue
}
return result
}
// System environment variable or default.
envOrDefault = { envName, defValue ->
return Objects.requireNonNullElse(System.getenv(envName), defValue);
}
// Either a project, system property, environment variable or default value.
propertyOrEnvOrDefault = { propName, envName, defValue ->
return propertyOrDefault(propName, envOrDefault(envName, defValue));
}
// Locate script-relative resource folder. This is context-sensitive so pass
// the right buildscript (top-level).
scriptResources = { buildscript ->
return file(buildscript.sourceFile.absolutePath.replaceAll('.gradle$', ""))
}
// Utility function similar to project.exec but not emitting
// any output unless an error code is returned from the executed command.
quietExec = { closure ->
// Resolve any properties against the provided closure.
resolveStrategy = Closure.DELEGATE_ONLY
delegate = closure.delegate
File outputFile = File.createTempFile("exec-output-", ".txt", getTemporaryDir())
ExecResult result
boolean saveIgnoreExitValue
ExecSpec saveExecSpec
outputFile.withOutputStream { output ->
// we want to capture both stdout and stderr to the same
// stream but gradle attempts to close these separately
// (it has two independent pumping threads) and it can happen
// that one still tries to write something when the other closed
// the underlying output stream.
def wrapped = new java.io.FilterOutputStream(output) {
public void close() {
// no-op. we close this stream manually.
}
}
result = project.exec { ExecSpec execSpec ->
project.configure(execSpec, closure)
saveIgnoreExitValue = execSpec.ignoreExitValue
saveExecSpec = execSpec
standardOutput = wrapped
errorOutput = wrapped
ignoreExitValue true
}
}
if (result.getExitValue() != 0) {
// Pipe the output to console. Intentionally skips any encoding conversion
// and pumps raw bytes.
logger.error(new String(outputFile.bytes))
if (!saveIgnoreExitValue) {
result.rethrowFailure()
throw new GradleException("The executed process ${saveExecSpec.executable} " +
"returned an odd status " +
"code: ${result.exitValue}, " +
"output at: ${outputFile} (and logged above).")
}
}
return result
}
}
2019-12-02 09:34:57 -05:00
}