| 1 |
/** |
| 2 |
* Copyright 2015 Emmanuel Bourg |
| 3 |
* |
| 4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 |
* you may not use this file except in compliance with the License. |
| 6 |
* You may obtain a copy of the License at |
| 7 |
* |
| 8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
* |
| 10 |
* Unless required by applicable law or agreed to in writing, software |
| 11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
| 12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 |
* See the License for the specific language governing permissions and |
| 14 |
* limitations under the License. |
| 15 |
*/ |
| 16 |
|
| 17 |
package org.debian.gradle; |
| 18 |
|
| 19 |
import java.util.Timer; |
| 20 |
import java.util.TimerTask; |
| 21 |
|
| 22 |
import org.gradle.BuildAdapter; |
| 23 |
import org.gradle.api.invocation.Gradle; |
| 24 |
import org.slf4j.Logger; |
| 25 |
import org.slf4j.LoggerFactory; |
| 26 |
|
| 27 |
/** |
| 28 |
* Build listener displaying a message every 10 minutes. This prevents the auto builders |
| 29 |
* from killing Gradle on slow architectures. |
| 30 |
*/ |
| 31 |
class KeepAliveTimer extends BuildAdapter { |
| 32 |
|
| 33 |
private final Logger log = LoggerFactory.getLogger(KeepAliveTimer.class); |
| 34 |
|
| 35 |
private static final long PERIOD = 10 * 60 * 1000L; // 10 minutes |
| 36 |
|
| 37 |
@Override |
| 38 |
public void projectsLoaded(Gradle gradle) { |
| 39 |
Timer timer = new Timer("Gradle Keep-alive Timer", true); |
| 40 |
timer.schedule(new TimerTask() { |
| 41 |
@Override |
| 42 |
public void run() { |
| 43 |
log.info("\tGradle is still running, please be patient..."); |
| 44 |
} |
| 45 |
}, PERIOD, PERIOD); |
| 46 |
|
| 47 |
log.info("\tKeep-alive timer started"); |
| 48 |
} |
| 49 |
} |