-
Notifications
You must be signed in to change notification settings - Fork 107
/
JDTCompilerAdapter.java
585 lines (543 loc) · 22.1 KB
/
JDTCompilerAdapter.java
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
/*******************************************************************************
* Copyright (c) 2000, 2013 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.core;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.Javac;
import org.apache.tools.ant.taskdefs.compilers.DefaultCompilerAdapter;
import org.apache.tools.ant.types.Commandline;
import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.Commandline.Argument;
import org.apache.tools.ant.util.JavaEnvUtils;
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.antadapter.AntAdapterMessages;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.util.SuffixConstants;
import org.eclipse.jdt.internal.compiler.util.Util;
/**
* Ant 1.5 compiler adapter for the Eclipse Java compiler. This adapter permits the
* Eclipse Java compiler to be used with the <code>javac</code> task in Ant scripts. In order
* to use it, just set the property <code>build.compiler</code> as follows:
* <p>
* <code><property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/></code>
* </p>
* <p>
* For more information on Ant check out the website at http://jakarta.apache.org/ant/ .
* </p>
*
* @since 2.0
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public class JDTCompilerAdapter extends DefaultCompilerAdapter {
private static final char[] SEPARATOR_CHARS = new char[] { '/', '\\' };
private static final char[] ADAPTER_PREFIX = "#ADAPTER#".toCharArray(); //$NON-NLS-1$
private static final char[] ADAPTER_ENCODING = "ENCODING#".toCharArray(); //$NON-NLS-1$
private static final char[] ADAPTER_ACCESS = "ACCESS#".toCharArray(); //$NON-NLS-1$
private static String compilerClass = "org.eclipse.jdt.internal.compiler.batch.Main"; //$NON-NLS-1$
String logFileName;
Map customDefaultOptions;
private Map fileEncodings = null;
private Map dirEncodings = null;
private List accessRules = null;
/**
* Performs a compile using the JDT batch compiler
* @throws BuildException if anything wrong happen during the compilation
* @return boolean true if the compilation is ok, false otherwise
*/
@Override
public boolean execute() throws BuildException {
this.attributes.log(AntAdapterMessages.getString("ant.jdtadapter.info.usingJDTCompiler"), Project.MSG_VERBOSE); //$NON-NLS-1$
Commandline cmd = setupJavacCommand();
try {
Class c = Class.forName(compilerClass);
Constructor batchCompilerConstructor = c.getConstructor(new Class[] { PrintWriter.class, PrintWriter.class, Boolean.TYPE, Map.class});
Object batchCompilerInstance = batchCompilerConstructor.newInstance(new Object[] {new PrintWriter(System.out), new PrintWriter(System.err), Boolean.TRUE, this.customDefaultOptions});
Method compile = c.getMethod("compile", new Class[] {String[].class}); //$NON-NLS-1$
Object result = compile.invoke(batchCompilerInstance, new Object[] { cmd.getArguments()});
final boolean resultValue = ((Boolean) result).booleanValue();
if (!resultValue && this.logFileName != null) {
this.attributes.log(AntAdapterMessages.getString("ant.jdtadapter.error.compilationFailed", this.logFileName)); //$NON-NLS-1$
}
return resultValue;
} catch (ClassNotFoundException cnfe) {
throw new BuildException(AntAdapterMessages.getString("ant.jdtadapter.error.cannotFindJDTCompiler"), cnfe); //$NON-NLS-1$
} catch (Exception ex) {
throw new BuildException(ex);
}
}
@Override
protected Commandline setupJavacCommand() throws BuildException {
Commandline cmd = new Commandline();
this.customDefaultOptions = new CompilerOptions().getMap();
Class javacClass = Javac.class;
/*
* Read in the compiler arguments first since we might need to modify
* the classpath if any access rules were specified
*/
String [] compilerArgs = processCompilerArguments(javacClass);
/*
* This option is used to never exit at the end of the ant task.
*/
cmd.createArgument().setValue("-noExit"); //$NON-NLS-1$
if (this.bootclasspath != null) {
cmd.createArgument().setValue("-bootclasspath"); //$NON-NLS-1$
if (this.bootclasspath.size() != 0) {
/*
* Set the bootclasspath for the Eclipse compiler.
*/
cmd.createArgument().setPath(this.bootclasspath);
} else {
cmd.createArgument().setValue(Util.EMPTY_STRING);
}
}
/*
* Eclipse compiler doesn't support -extdirs.
* It is emulated using the classpath. We add extdirs entries after the
* bootclasspath.
*/
if (this.extdirs != null) {
cmd.createArgument().setValue("-extdirs"); //$NON-NLS-1$
cmd.createArgument().setPath(this.extdirs);
}
Path classpath = new Path(this.project);
/*
* The java runtime is already handled, so we simply want to retrieve the
* ant runtime and the compile classpath.
*/
classpath.append(getCompileClasspath());
/*
* Set the classpath for the Eclipse compiler.
*/
cmd.createArgument().setValue("-classpath"); //$NON-NLS-1$
createClasspathArgument(cmd, classpath);
// For -sourcepath, use the "sourcepath" value if present.
// Otherwise default to the "srcdir" value.
Path sourcepath = null;
// retrieve the method getSourcepath() using reflect
// This is done to improve the compatibility to ant 1.5
Method getSourcepathMethod = null;
try {
getSourcepathMethod = javacClass.getMethod("getSourcepath", (Class[]) null); //$NON-NLS-1$
} catch(NoSuchMethodException e) {
// if not found, then we cannot use this method (ant 1.5)
}
Path compileSourcePath = null;
if (getSourcepathMethod != null) {
try {
compileSourcePath = (Path) getSourcepathMethod.invoke(this.attributes, (Object[]) null);
} catch (IllegalAccessException | InvocationTargetException e) {
// should never happen
}
}
if (compileSourcePath != null) {
sourcepath = compileSourcePath;
} else {
sourcepath = this.src;
}
cmd.createArgument().setValue("-sourcepath"); //$NON-NLS-1$
createClasspathArgument(cmd, sourcepath);
final String javaVersion = JavaEnvUtils.getJavaVersion();
String memoryParameterPrefix = javaVersion.equals(JavaEnvUtils.JAVA_1_1) ? "-J-" : "-J-X";//$NON-NLS-1$//$NON-NLS-2$
if (this.memoryInitialSize != null) {
if (!this.attributes.isForkedJavac()) {
this.attributes.log(AntAdapterMessages.getString("ant.jdtadapter.info.ignoringMemoryInitialSize"), Project.MSG_WARN); //$NON-NLS-1$
} else {
cmd.createArgument().setValue(memoryParameterPrefix
+ "ms" + this.memoryInitialSize); //$NON-NLS-1$
}
}
if (this.memoryMaximumSize != null) {
if (!this.attributes.isForkedJavac()) {
this.attributes.log(AntAdapterMessages.getString("ant.jdtadapter.info.ignoringMemoryMaximumSize"), Project.MSG_WARN); //$NON-NLS-1$
} else {
cmd.createArgument().setValue(memoryParameterPrefix
+ "mx" + this.memoryMaximumSize); //$NON-NLS-1$
}
}
if (this.debug) {
// retrieve the method getSourcepath() using reflect
// This is done to improve the compatibility to ant 1.5
Method getDebugLevelMethod = null;
try {
getDebugLevelMethod = javacClass.getMethod("getDebugLevel", (Class[]) null); //$NON-NLS-1$
} catch(NoSuchMethodException e) {
// if not found, then we cannot use this method (ant 1.5)
// debug level is only available with ant 1.5.x
}
String debugLevel = null;
if (getDebugLevelMethod != null) {
try {
debugLevel = (String) getDebugLevelMethod.invoke(this.attributes, (Object[]) null);
} catch (IllegalAccessException | InvocationTargetException e) {
// should never happen
}
}
if (debugLevel != null) {
this.customDefaultOptions.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.DO_NOT_GENERATE);
this.customDefaultOptions.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.DO_NOT_GENERATE);
this.customDefaultOptions.put(CompilerOptions.OPTION_SourceFileAttribute , CompilerOptions.DO_NOT_GENERATE);
if (debugLevel.length() != 0) {
if (debugLevel.indexOf("vars") != -1) {//$NON-NLS-1$
this.customDefaultOptions.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.GENERATE);
}
if (debugLevel.indexOf("lines") != -1) {//$NON-NLS-1$
this.customDefaultOptions.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.GENERATE);
}
if (debugLevel.indexOf("source") != -1) {//$NON-NLS-1$
this.customDefaultOptions.put(CompilerOptions.OPTION_SourceFileAttribute , CompilerOptions.GENERATE);
}
}
} else {
this.customDefaultOptions.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.GENERATE);
this.customDefaultOptions.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.GENERATE);
this.customDefaultOptions.put(CompilerOptions.OPTION_SourceFileAttribute , CompilerOptions.GENERATE);
}
} else {
this.customDefaultOptions.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.DO_NOT_GENERATE);
this.customDefaultOptions.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.DO_NOT_GENERATE);
this.customDefaultOptions.put(CompilerOptions.OPTION_SourceFileAttribute , CompilerOptions.DO_NOT_GENERATE);
}
/*
* Handle the nowarn option. If none, then we generate all warnings.
*/
if (this.attributes.getNowarn()) {
// disable all warnings
for (Object o : this.customDefaultOptions.entrySet()) {
Map.Entry entry = (Map.Entry) o;
if (!(entry.getKey() instanceof String))
continue;
if (!(entry.getValue() instanceof String))
continue;
if (((String) entry.getValue()).equals(CompilerOptions.WARNING)) {
this.customDefaultOptions.put(entry.getKey(), CompilerOptions.IGNORE);
}
}
this.customDefaultOptions.put(CompilerOptions.OPTION_TaskTags, Util.EMPTY_STRING);
if (this.deprecation) {
this.customDefaultOptions.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.WARNING);
this.customDefaultOptions.put(CompilerOptions.OPTION_ReportDeprecationInDeprecatedCode, CompilerOptions.ENABLED);
this.customDefaultOptions.put(CompilerOptions.OPTION_ReportDeprecationWhenOverridingDeprecatedMethod, CompilerOptions.ENABLED);
}
} else if (this.deprecation) {
this.customDefaultOptions.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.WARNING);
this.customDefaultOptions.put(CompilerOptions.OPTION_ReportDeprecationInDeprecatedCode, CompilerOptions.ENABLED);
this.customDefaultOptions.put(CompilerOptions.OPTION_ReportDeprecationWhenOverridingDeprecatedMethod, CompilerOptions.ENABLED);
} else {
this.customDefaultOptions.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.IGNORE);
this.customDefaultOptions.put(CompilerOptions.OPTION_ReportDeprecationInDeprecatedCode, CompilerOptions.DISABLED);
this.customDefaultOptions.put(CompilerOptions.OPTION_ReportDeprecationWhenOverridingDeprecatedMethod, CompilerOptions.DISABLED);
}
/*
* destDir option.
*/
if (this.destDir != null) {
cmd.createArgument().setValue("-d"); //$NON-NLS-1$
cmd.createArgument().setFile(this.destDir.getAbsoluteFile());
}
/*
* verbose option
*/
if (this.verbose) {
cmd.createArgument().setValue("-verbose"); //$NON-NLS-1$
}
/*
* failnoerror option
*/
if (!this.attributes.getFailonerror()) {
cmd.createArgument().setValue("-proceedOnError"); //$NON-NLS-1$
}
/*
* target option.
*/
if (this.target != null) {
this.customDefaultOptions.put(CompilerOptions.OPTION_TargetPlatform, this.target);
}
/*
* source option
*/
String source = this.attributes.getSource();
if (source != null) {
this.customDefaultOptions.put(CompilerOptions.OPTION_Source, source);
this.customDefaultOptions.put(CompilerOptions.OPTION_Compliance, source);
}
/*
* release option.
*/
if (this.release != null) {
this.customDefaultOptions.put(CompilerOptions.OPTION_Release, this.release);
}
if (compilerArgs != null) {
/*
* Add extra argument on the command line
*/
final int length = compilerArgs.length;
if (length != 0) {
for (int i = 0, max = length; i < max; i++) {
String arg = compilerArgs[i];
if (this.logFileName == null && "-log".equals(arg) && ((i + 1) < max)) { //$NON-NLS-1$
this.logFileName = compilerArgs[i + 1];
}
cmd.createArgument().setValue(arg);
}
}
}
/*
* encoding option. javac task encoding property must be the last encoding on the command
* line as compiler arg might also specify an encoding.
*/
if (this.encoding != null) {
cmd.createArgument().setValue("-encoding"); //$NON-NLS-1$
cmd.createArgument().setValue(this.encoding);
}
/*
* Eclipse compiler doesn't have a -sourcepath option. This is
* handled through the javac task that collects all source files in
* srcdir option.
*/
logAndAddFilesToCompile(cmd);
return cmd;
}
/**
* Get the compiler arguments
* @return String[] the array of arguments
*/
private String[] processCompilerArguments(Class javacClass) {
// retrieve the method getCurrentCompilerArgs() using reflect
// This is done to improve the compatibility to ant 1.5
Method getCurrentCompilerArgsMethod = null;
try {
getCurrentCompilerArgsMethod = javacClass.getMethod("getCurrentCompilerArgs", (Class[]) null); //$NON-NLS-1$
} catch (NoSuchMethodException e) {
// if not found, then we cannot use this method (ant 1.5)
// debug level is only available with ant 1.5.x
}
String[] compilerArgs = null;
if (getCurrentCompilerArgsMethod != null) {
try {
compilerArgs = (String[]) getCurrentCompilerArgsMethod.invoke(this.attributes, (Object[]) null);
} catch (IllegalAccessException | InvocationTargetException e) {
// should never happen
}
}
//check the compiler arguments for anything requiring extra processing
if (compilerArgs != null) checkCompilerArgs(compilerArgs);
return compilerArgs;
}
/**
* check the compiler arguments.
* Extract from files specified using @, lines marked with ADAPTER_PREFIX
* These lines specify information that needs to be interpreted by us.
* @param args compiler arguments to process
*/
private void checkCompilerArgs(String[] args) {
for (String arg : args) {
if (arg.charAt(0) == '@') {
try {
char[] content = Util.getFileCharContent(new File(arg.substring(1)), null);
int offset = 0;
int prefixLength = ADAPTER_PREFIX.length;
while ((offset = CharOperation.indexOf(ADAPTER_PREFIX, content, true, offset)) > -1) {
int start = offset + prefixLength;
int end = CharOperation.indexOf('\n', content, start);
if (end == -1)
end = content.length;
while (CharOperation.isWhitespace(content[end])) {
end--;
}
// end is inclusive, but in the API end is exclusive
if (CharOperation.equals(ADAPTER_ENCODING, content, start, start + ADAPTER_ENCODING.length)) {
CharOperation.replace(content, SEPARATOR_CHARS, File.separatorChar, start, end + 1);
// file or folder level custom encoding
start += ADAPTER_ENCODING.length;
int encodeStart = CharOperation.lastIndexOf('[', content, start, end);
if (start < encodeStart && encodeStart < end) {
boolean isFile = CharOperation.equals(SuffixConstants.SUFFIX_java, content, encodeStart - 5, encodeStart, false);
String str = String.valueOf(content, start, encodeStart - start);
String enc = String.valueOf(content, encodeStart, end - encodeStart + 1);
if (isFile) {
if (this.fileEncodings == null)
this.fileEncodings = new HashMap();
//use File to translate the string into a path with the correct File.seperator
this.fileEncodings.put(str, enc);
} else {
if (this.dirEncodings == null)
this.dirEncodings = new HashMap();
this.dirEncodings.put(str, enc);
}
}
} else if (CharOperation.equals(ADAPTER_ACCESS, content, start, start + ADAPTER_ACCESS.length)) {
// access rules for the classpath
start += ADAPTER_ACCESS.length;
int accessStart = CharOperation.indexOf('[', content, start, end);
CharOperation.replace(content, SEPARATOR_CHARS, File.separatorChar, start, accessStart);
if (start < accessStart && accessStart < end) {
String path = String.valueOf(content, start, accessStart - start);
String access = String.valueOf(content, accessStart, end - accessStart + 1);
if (this.accessRules == null)
this.accessRules = new ArrayList();
this.accessRules.add(path);
this.accessRules.add(access);
}
}
offset = end;
}
} catch (IOException e) {
//ignore
}
}
}
}
/**
* Copy the classpath to the command line with access rules included.
* @param cmd the given command line
* @param classpath the given classpath entry
*/
private void createClasspathArgument(Commandline cmd, Path classpath) {
Argument arg = cmd.createArgument();
final String[] pathElements = classpath.list();
// empty path return empty string
if (pathElements.length == 0) {
arg.setValue(Util.EMPTY_STRING);
return;
}
// no access rules, can set the path directly
if (this.accessRules == null) {
arg.setPath(classpath);
return;
}
int rulesLength = this.accessRules.size();
String[] rules = (String[]) this.accessRules.toArray(new String[rulesLength]);
int nextRule = 0;
final StringBuilder result = new StringBuilder();
//access rules are expected in the same order as the classpath, but there could
//be elements in the classpath not in the access rules or access rules not in the classpath
for (int i = 0, max = pathElements.length; i < max; i++) {
if (i > 0)
result.append(File.pathSeparatorChar);
String pathElement = pathElements[i];
result.append(pathElement);
//the rules list is [path, rule, path, rule, ...]
for (int j = nextRule; j < rulesLength; j += 2) {
String rule = rules[j];
if (pathElement.endsWith(rule)) {
result.append(rules[j + 1]);
nextRule = j + 2;
break;
}
// if the path doesn't match, it could be due to a trailing file separatorChar in the rule
if (rule.endsWith(File.separator)) {
// rule ends with the File.separator, but pathElement might not
// otherwise it would match on the first endsWith
int ruleLength = rule.length();
if (pathElement.regionMatches(false, pathElement.length() - ruleLength + 1, rule, 0, ruleLength - 1)) {
result.append(rules[j + 1]);
nextRule = j + 2;
break;
}
} else if (pathElement.endsWith(File.separator)) {
// rule doesn't end with the File.separator, but pathElement might
int ruleLength = rule.length();
if (pathElement.regionMatches(false, pathElement.length() - ruleLength - 1, rule, 0, ruleLength)) {
result.append(rules[j + 1]);
nextRule = j + 2;
break;
}
}
}
}
arg.setValue(result.toString());
}
/**
* Modified from base class, Logs the compilation parameters, adds the files
* to compile and logs the "niceSourceList"
* Appends encoding information at the end of arguments
*
* @param cmd the given command line
*/
@Override
protected void logAndAddFilesToCompile(Commandline cmd) {
this.attributes.log("Compilation " + cmd.describeArguments(), //$NON-NLS-1$
Project.MSG_VERBOSE);
StringBuilder niceSourceList = new StringBuilder("File"); //$NON-NLS-1$
if (this.compileList.length != 1) {
niceSourceList.append("s"); //$NON-NLS-1$
}
niceSourceList.append(" to be compiled:"); //$NON-NLS-1$
niceSourceList.append(System.lineSeparator());
String[] encodedFiles = null, encodedDirs = null;
int encodedFilesLength = 0, encodedDirsLength = 0;
if (this.fileEncodings != null) {
encodedFilesLength = this.fileEncodings.size();
encodedFiles = new String[encodedFilesLength];
this.fileEncodings.keySet().toArray(encodedFiles);
}
if (this.dirEncodings != null) {
encodedDirsLength = this.dirEncodings.size();
encodedDirs = new String[encodedDirsLength];
this.dirEncodings.keySet().toArray(encodedDirs);
//we need the directories sorted, longest first,since sub directories can
//override encodings for their parent directories
Comparator comparator = new Comparator() {
@Override
public int compare(Object o1, Object o2) {
return ((String) o2).length() - ((String) o1).length();
}
};
Arrays.sort(encodedDirs, comparator);
}
for (File file : this.compileList) {
String arg = file.getAbsolutePath();
boolean encoded = false;
if (encodedFiles != null) {
//check for file level custom encoding
for (int j = 0; j < encodedFilesLength; j++) {
if (arg.endsWith(encodedFiles[j])) {
//found encoding, remove it from the list to speed things up next time around
arg = arg + (String) this.fileEncodings.get(encodedFiles[j]);
if (j < encodedFilesLength - 1) {
System.arraycopy(encodedFiles, j + 1, encodedFiles, j, encodedFilesLength - j - 1);
}
encodedFiles[--encodedFilesLength] = null;
encoded = true;
break;
}
}
}
if (!encoded && encodedDirs != null) {
//check folder level custom encoding
for (int j = 0; j < encodedDirsLength; j++) {
if (arg.lastIndexOf(encodedDirs[j]) != -1) {
arg = arg + (String) this.dirEncodings.get(encodedDirs[j]);
break;
}
}
}
cmd.createArgument().setValue(arg);
niceSourceList.append(" " + arg + System.lineSeparator()); //$NON-NLS-1$
}
this.attributes.log(niceSourceList.toString(), Project.MSG_VERBOSE);
}
}