File tree 1 file changed +20
-0
lines changed
1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 14
14
* See the License for the specific language governing permissions and
15
15
* limitations under the License.
16
16
*/
17
+ import java.nio.file.Files
18
+ import java.time.temporal.ChronoUnit
19
+ import java.time.Instant
20
+
17
21
18
22
// See LUCENE-9471. We redirect temporary location for gradle
19
23
// so that it doesn't pollute user's tmp. Wipe it during a clean though.
20
24
21
25
configure(rootProject) {
22
26
gradle. buildFinished {
27
+ // we clean up the java.io.tmpdir we've redirected gradle to use (LUCENE-9471).
28
+ // these are still used and populated with junk.
23
29
rootProject. delete fileTree(" .gradle/tmp" ). matching {
24
30
include " gradle-worker-classpath*"
25
31
}
32
+
33
+ // clean up any files older than 3 hours from the user's gradle temp. the time
34
+ // limit is added so that we don't interfere with any concurrent builds... just in case.
35
+ def gradleTmp = rootProject. gradle. gradleUserHomeDir. toPath(). resolve(" .tmp" )
36
+ if (Files . exists(gradleTmp)) {
37
+ Instant deadline = Instant . now(). minus(3 , ChronoUnit . HOURS );
38
+ try (var stream = Files . list(gradleTmp)) {
39
+ stream. forEach(path -> {
40
+ if (Files . getLastModifiedTime(path). toInstant(). isBefore(deadline)) {
41
+ Files . deleteIfExists(path);
42
+ }
43
+ });
44
+ }
45
+ }
26
46
}
27
47
}
28
48
You can’t perform that action at this time.
0 commit comments