forked from howardpang/androidNativeBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.gradle
69 lines (61 loc) · 3.1 KB
/
settings.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
include 'buildSrc'
import org.gradle.internal.operations.BuildOperationDescriptor
import org.gradle.internal.operations.BuildOperationListener
import org.gradle.internal.operations.BuildOperationListenerManager;
import org.gradle.internal.operations.OperationFinishEvent
import org.gradle.internal.operations.OperationIdentifier
import org.gradle.internal.operations.OperationProgressEvent
import org.gradle.internal.operations.OperationStartEvent
import org.gradle.api.logging.StandardOutputListener;
import java.lang.reflect.Field
settings.gradle.settingsEvaluated {
settings.gradle.rootProject { Project rootPrj->
BuildOperationListenerManager buildOperationListenerManager = rootPrj.getServices().get(BuildOperationListenerManager.class)
Field listenersF = buildOperationListenerManager.class.getDeclaredField("listeners")
listenersF.setAccessible(true)
List listeners = listenersF.get(buildOperationListenerManager)
BuildOperationListener buildOperationListener = new BuildOperationListener() {
@Override
void started(BuildOperationDescriptor buildOperation, OperationStartEvent startEvent) {
}
@Override
void progress(OperationIdentifier operationIdentifier, OperationProgressEvent progressEvent) {
}
@Override
void finished(BuildOperationDescriptor buildOperation, OperationFinishEvent finishEvent) {
if (buildOperation.displayName.startsWith("Download") || buildOperation.displayName.startsWith("Upload") ) {
rootPrj.logger.quiet(buildOperation.displayName)
}
}
}
StandardOutputListener standardOutputListener = new StandardOutputListener() {
boolean isProcessing = false // protect dead recursive
@Override
void onOutput(CharSequence output) {
if (!isProcessing) {
//Filter log
if ((output.toString().indexOf("Upload") != -1 || output.toString().indexOf("Download") != -1)) {
isProcessing = true
rootPrj.logger.quiet(output)
isProcessing = false
}
}
}
}
rootPrj.beforeEvaluate {
println(" beforeEvaluate BuildOperationListenerManager size " + listeners.size())
buildOperationListenerManager.addListener(buildOperationListener)
}
rootPrj.afterEvaluate {
//Some log will not output to 'Build' window, so we can add a listener to redirect it to 'Build'
//rootPrj.logging.start()
//rootPrj.logging.setLevelInternal(LogLevel.DEBUG)
//rootPrj.logging.addStandardOutputListener(standardOutputListener)
}
rootPrj.gradle.buildFinished {
buildOperationListenerManager.removeListener(buildOperationListener)
println(" build finish BuildOperationListenerManager size " + listeners.size())
//rootPrj.logging.removeStandardOutputListener(standardOutputListener)
}
}
}