diff --git a/org.jboss.tools.maven.apt.core/src/org/jboss/tools/maven/apt/internal/utils/ProjectUtils.java b/org.jboss.tools.maven.apt.core/src/org/jboss/tools/maven/apt/internal/utils/ProjectUtils.java index 4b15003..2981256 100644 --- a/org.jboss.tools.maven.apt.core/src/org/jboss/tools/maven/apt/internal/utils/ProjectUtils.java +++ b/org.jboss.tools.maven.apt.core/src/org/jboss/tools/maven/apt/internal/utils/ProjectUtils.java @@ -42,22 +42,19 @@ */ public class ProjectUtils { + private static final Pattern OPTION_PATTERN = Pattern.compile("-A([^ \\t\"']+)"); + /** * Parse a string to extract Annotation Processor options */ public static Map parseProcessorOptions(String compilerArgument) { - Pattern fullOptionPattern = Pattern.compile("-A([^ \\t\"']+)"); - return parseProcessorOptions(compilerArgument, fullOptionPattern); - } - - private static Map parseProcessorOptions(String compilerArgument, Pattern pattern) { if (compilerArgument == null || compilerArgument.trim().isEmpty()) { return Collections.emptyMap(); } Map ret = new HashMap(); - Matcher matcher = pattern.matcher(compilerArgument); + Matcher matcher = OPTION_PATTERN.matcher(compilerArgument); int start = 0; while(matcher.find(start)) { @@ -90,11 +87,9 @@ public static Map parseProcessorOptions(List compilerArg } Map options = new HashMap(); - Pattern pattern = Pattern.compile("A([^ \\t\"']+)"); - for (String arg : compilerArgs) { - if (arg.startsWith("A")) { - options.putAll(parseProcessorOptions(arg, pattern)); + if (arg.startsWith("-A")) { + options.putAll(parseProcessorOptions(arg)); } } return options; diff --git a/org.jboss.tools.maven.apt.tests/projects/compilerArgs/pom.xml b/org.jboss.tools.maven.apt.tests/projects/compilerArgs/pom.xml index 9962205..b0df337 100644 --- a/org.jboss.tools.maven.apt.tests/projects/compilerArgs/pom.xml +++ b/org.jboss.tools.maven.apt.tests/projects/compilerArgs/pom.xml @@ -18,8 +18,8 @@ true - AaddGeneratedAnnotation=true - AcompilerArg + -AaddGeneratedAnnotation=true + -AcompilerArg diff --git a/org.jboss.tools.maven.apt.tests/src/org/jboss/tools/maven/apt/tests/ProjectUtilsTest.java b/org.jboss.tools.maven.apt.tests/src/org/jboss/tools/maven/apt/tests/ProjectUtilsTest.java index 1d6704a..22fd478 100644 --- a/org.jboss.tools.maven.apt.tests/src/org/jboss/tools/maven/apt/tests/ProjectUtilsTest.java +++ b/org.jboss.tools.maven.apt.tests/src/org/jboss/tools/maven/apt/tests/ProjectUtilsTest.java @@ -30,7 +30,7 @@ public class ProjectUtilsTest { @Test public void testParseCompilerArgs() { - List compilerArgs = Arrays.asList("Afoo=bar","Abracadabra", "Xman"); + List compilerArgs = Arrays.asList("-Afoo=bar","-Abracadabra", "Xman"); Map result = ProjectUtils.parseProcessorOptions(compilerArgs); assertNotNull(result);