LUCENE-9471: clean up task and global temporary junk files (workaround). (#1767)

This commit is contained in:
Dawid Weiss 2020-08-20 13:49:24 +02:00 committed by GitHub
parent 2f37f40171
commit 581e836569
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 66 additions and 0 deletions

View File

@ -153,3 +153,4 @@ apply from: file('gradle/documentation/markdown.gradle')
apply from: file('gradle/documentation/render-javadoc.gradle')
apply from: file('gradle/hacks/findbugs.gradle')
apply from: file('gradle/hacks/gradle.gradle')

View File

@ -0,0 +1,51 @@
/*
* 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.
*/
// See LUCENE-9471. We redirect temporary location for gradle
// so that it doesn't pollute user's tmp. Wipe it during a clean though.
configure(rootProject) {
task cleanGradleTmp(type: Delete) {
delete fileTree(".gradle/tmp").matching {
include "gradle-worker-classpath*"
}
}
clean.dependsOn cleanGradleTmp
}
// Make sure we clean up after running tests.
allprojects {
plugins.withType(JavaPlugin) {
def temps = []
task cleanTaskTmp() {
doLast {
temps.each { temp ->
project.delete fileTree(temp).matching {
include "jar_extract*"
}
}
}
}
tasks.withType(Test) {
finalizedBy rootProject.cleanGradleTmp, cleanTaskTmp
temps += temporaryDir
}
}
}

9
gradlew vendored
View File

@ -102,12 +102,21 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# LUCENE-9471: workaround for gradle leaving junk temp. files behind.
GRADLE_TEMPDIR=$APP_HOME/.gradle/tmp
mkdir -p $GRADLE_TEMPDIR
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
GRADLE_TEMPDIR=`cygpath --path --mixed "$GRADLE_TEMPDIR"`
fi
DEFAULT_JVM_OPTS="$DEFAULT_JVM_OPTS \"-Djava.io.tmpdir=$GRADLE_TEMPDIR\""
# LUCENE-9266: verify and download the gradle wrapper jar if we don't have one.
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
fi
GRADLE_WRAPPER_JAR=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
if ! $JAVACMD --source 11 $APP_HOME/buildSrc/src/main/java/org/apache/lucene/gradle/WrapperDownloader.java $GRADLE_WRAPPER_JAR ; then
echo "\nSomething went wrong. Make sure you're using Java 11 or later."
exit $?
fi

5
gradlew.bat vendored
View File

@ -32,6 +32,11 @@ set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem LUCENE-9471: workaround for gradle leaving junk temp. files behind.
SET GRADLE_TEMPDIR=%DIRNAME%\.gradle\tmp
IF NOT EXIST "%GRADLE_TEMPDIR%" MKDIR %GRADLE_TEMPDIR%
SET DEFAULT_JVM_OPTS=%DEFAULT_JVM_OPTS% -Djava.io.tmpdir=%GRADLE_TEMPDIR%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome