Skip to content

Commit 4d538e2

Browse files
mmazasmmazas
authored andcommitted
Fixed ConcurrentModificationException on a map and tweeked some options.
Signed-off-by: mmazas <[email protected]>
1 parent c0b88ba commit 4d538e2

File tree

1 file changed

+37
-15
lines changed
  • plexus-compilers/plexus-compiler-csharp/src/main/java/org/codehaus/plexus/compiler/csharp

1 file changed

+37
-15
lines changed

plexus-compilers/plexus-compiler-csharp/src/main/java/org/codehaus/plexus/compiler/csharp/CSharpCompiler.java

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import java.nio.file.Paths;
3030
import java.util.ArrayList;
3131
import java.util.Arrays;
32+
import java.util.HashMap;
3233
import java.util.HashSet;
3334
import java.util.Iterator;
3435
import java.util.List;
@@ -140,6 +141,7 @@ private Map<String, String> getCompilerArguments(CompilerConfiguration config) {
140141
}
141142

142143
compilerArguments = config.getCustomCompilerArgumentsAsMap();
144+
Map<String, String> ca2 = new HashMap<String, String>();
143145

144146
Iterator<String> i = compilerArguments.keySet().iterator();
145147

@@ -151,12 +153,15 @@ private Map<String, String> getCompilerArguments(CompilerConfiguration config) {
151153
i.remove();
152154
String k = arr[0];
153155
v = arr[1];
154-
compilerArguments.put(k, v);
156+
// compilerArguments.put(k, v);
157+
ca2.put(k, v);
155158
if (config.isDebug()) {
156-
System.out.println("transforming argument from " + orig + " to " + k + " = [" + v + "]");
159+
System.out.println(
160+
"internal splitting of argument '" + orig + "' to key '" + k + "', value '" + v + "'");
157161
}
158162
}
159163
}
164+
compilerArguments.putAll(ca2);
160165

161166
config.setCustomCompilerArgumentsAsMap(compilerArguments);
162167

@@ -389,11 +394,12 @@ private String[] buildCompilerArguments(CompilerConfiguration config, String[] s
389394
throws CompilerException {
390395
List<String> args = new ArrayList<>();
391396

392-
if (config.isDebug()) {
393-
args.add("/debug+");
394-
} else {
395-
args.add("/debug-");
396-
}
397+
// plugin parameter is no the same as the compiler option! so replaced
398+
// if (config.isDebug()) {
399+
// args.add("/debug+");
400+
// } else {
401+
// args.add("/debug-");
402+
// }
397403

398404
// config.isShowWarnings()
399405
// config.getSourceVersion()
@@ -433,12 +439,14 @@ private String[] buildCompilerArguments(CompilerConfiguration config, String[] s
433439
}
434440
}
435441

442+
// TODO: include all user compiler arguments and not only some!
443+
444+
Map<String, String> compilerArguments = getCompilerArguments(config);
445+
436446
// ----------------------------------------------------------------------
437447
// Main class
438448
// ----------------------------------------------------------------------
439449

440-
Map<String, String> compilerArguments = getCompilerArguments(config);
441-
442450
String mainClass = compilerArguments.get("-main");
443451

444452
if (!StringUtils.isEmpty(mainClass)) {
@@ -457,7 +465,17 @@ private String[] buildCompilerArguments(CompilerConfiguration config, String[] s
457465
}
458466

459467
// ----------------------------------------------------------------------
460-
// Nowarn option
468+
// Debug option (full, pdbonly...)
469+
// ----------------------------------------------------------------------
470+
471+
String debug = compilerArguments.get("-debug");
472+
473+
if (!StringUtils.isEmpty(debug)) {
474+
args.add("/debug:" + debug);
475+
}
476+
477+
// ----------------------------------------------------------------------
478+
// Nowarn option (w#1,w#2...)
461479
// ----------------------------------------------------------------------
462480

463481
String nowarn = compilerArguments.get("-nowarn");
@@ -489,7 +507,7 @@ private String[] buildCompilerArguments(CompilerConfiguration config, String[] s
489507
}
490508

491509
// ----------------------------------------------------------------------
492-
// Target - type of assembly to produce, lib,exe,winexe etc...
510+
// Target - type of assembly to produce: library,exe,winexe...
493511
// ----------------------------------------------------------------------
494512

495513
String target = compilerArguments.get("-target");
@@ -505,7 +523,7 @@ private String[] buildCompilerArguments(CompilerConfiguration config, String[] s
505523
// ----------------------------------------------------------------------
506524
String nologo = compilerArguments.get("-nologo");
507525

508-
if (!StringUtils.isEmpty(nologo)) {
526+
if (!StringUtils.isEmpty(nologo) && !"false".equals(nologo.toLowerCase())) {
509527
args.add("/nologo");
510528
}
511529

@@ -514,7 +532,7 @@ private String[] buildCompilerArguments(CompilerConfiguration config, String[] s
514532
// ----------------------------------------------------------------------
515533
String unsafe = compilerArguments.get("-unsafe");
516534

517-
if (!StringUtils.isEmpty(unsafe) && unsafe.equals("true")) {
535+
if (!StringUtils.isEmpty(unsafe) && "true".equals(unsafe.toLowerCase())) {
518536
args.add("/unsafe");
519537
}
520538

@@ -532,8 +550,8 @@ private String[] buildCompilerArguments(CompilerConfiguration config, String[] s
532550
// ----------------------------------------------------------------------
533551
String utf8output = compilerArguments.get("-utf8output");
534552

535-
if (!StringUtils.isEmpty(utf8output)) {
536-
args.add("/utf8output:");
553+
if (!StringUtils.isEmpty(utf8output) && !"false".equals(utf8output)) {
554+
args.add("/utf8output");
537555
}
538556

539557
// ----------------------------------------------------------------------
@@ -548,6 +566,10 @@ private String[] buildCompilerArguments(CompilerConfiguration config, String[] s
548566
args.add(sourceFile);
549567
}
550568

569+
if (config.isDebug()) {
570+
System.out.println("built compiler arguments:" + args);
571+
}
572+
551573
return args.toArray(new String[args.size()]);
552574
}
553575

0 commit comments

Comments
 (0)