@@ -72,6 +72,24 @@ public class AntTask extends Task {
72
72
73
73
@ Override
74
74
public void execute () throws BuildException {
75
+ final Logger log = new Logger () {
76
+ @ Override
77
+ public void error (String msg ) {
78
+ log (msg , Project .MSG_ERR );
79
+ }
80
+
81
+ @ Override
82
+ public void warn (String msg ) {
83
+ // ANT has no real log levels printed, so prefix with "WARNING":
84
+ log ("WARNING: " + msg , Project .MSG_WARN );
85
+ }
86
+
87
+ @ Override
88
+ public void info (String msg ) {
89
+ log (msg , Project .MSG_INFO );
90
+ }
91
+ };
92
+
75
93
AntClassLoader antLoader = null ;
76
94
try {
77
95
final ClassLoader loader ;
@@ -90,23 +108,7 @@ public void execute() throws BuildException {
90
108
if (failOnMissingClasses ) options .add (FAIL_ON_MISSING_CLASSES );
91
109
if (failOnViolation ) options .add (FAIL_ON_VIOLATION );
92
110
if (failOnUnresolvableSignatures ) options .add (FAIL_ON_UNRESOLVABLE_SIGNATURES );
93
- final Checker checker = new Checker (new Logger () {
94
- @ Override
95
- public void error (String msg ) {
96
- log (msg , Project .MSG_ERR );
97
- }
98
-
99
- @ Override
100
- public void warn (String msg ) {
101
- // ANT has no real log levels printed, so prefix with "WARNING":
102
- log ("WARNING: " + msg , Project .MSG_WARN );
103
- }
104
-
105
- @ Override
106
- public void info (String msg ) {
107
- log (msg , Project .MSG_INFO );
108
- }
109
- }, loader , options );
111
+ final Checker checker = new Checker (log , loader , options );
110
112
111
113
if (!checker .isSupportedJDK ) {
112
114
final String msg = String .format (Locale .ENGLISH ,
@@ -115,7 +117,7 @@ public void info(String msg) {
115
117
if (failOnUnsupportedJava ) {
116
118
throw new BuildException (msg );
117
119
} else {
118
- log ( "WARNING: " + msg , Project . MSG_WARN );
120
+ log . warn ( msg );
119
121
return ;
120
122
}
121
123
}
@@ -156,7 +158,7 @@ public void info(String msg) {
156
158
throw new BuildException ("No API signatures found; use signaturesFile=, <signaturesFileSet/>, <bundledSignatures/> or inner text to define those!" );
157
159
}
158
160
159
- log ("Loading classes to check..." , Project . MSG_INFO );
161
+ log . info ("Loading classes to check..." );
160
162
try {
161
163
@ SuppressWarnings ("unchecked" )
162
164
final Iterator <Resource > iter = classFiles .iterator ();
@@ -172,8 +174,8 @@ public void info(String msg) {
172
174
}
173
175
if (!foundClass ) {
174
176
if (ignoreEmptyFileset ) {
175
- log ("There is no <fileset/> or other resource collection given, or the collection does not contain any class files to check." , Project . MSG_WARN );
176
- log ("Scanned 0 class files." , Project . MSG_INFO );
177
+ log . warn ("There is no <fileset/> or other resource collection given, or the collection does not contain any class files to check." );
178
+ log . info ("Scanned 0 class files." );
177
179
return ;
178
180
} else {
179
181
throw new BuildException ("There is no <fileset/> or other resource collection given, or the collection does not contain any class files to check." );
0 commit comments