Skip to content

Commit

Permalink
Allow to backslash spaces in Custom xcodebuild arguments. Derived fro…
Browse files Browse the repository at this point in the history
…m pull jenkinsci#7 from tkirby:escape_custom_build_args
  • Loading branch information
lacostej committed Nov 27, 2012
1 parent ba8b687 commit 4a12a66
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main/java/au/com/rayh/XCodeBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,12 @@ else if (StringUtils.isEmpty(cfBundleVersion))
}

static List<String> splitXcodeBuildArguments(String xcodebuildArguments) {
return Arrays.asList(xcodebuildArguments.split("[ ]"));
String[] parts = xcodebuildArguments.split("(?<!\\\\)\\s+");
List<String> result = new ArrayList<String>(parts.length);
for(String arg : parts) {
result.add(arg.replaceAll("\\\\ ", " "));
}
return result;
}

@Override
Expand Down
8 changes: 8 additions & 0 deletions src/test/java/au/com/rayh/XCodeBuilderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,12 @@ public void shouldSplitXcodeBuildArgumentsWithoutEscapedSpaces() throws Exceptio
assertEquals(asList("GCC_SYMBOLS_PRIVATE_EXTERN=NO", "COPY_PHASE_STRIP=NO"),
XCodeBuilder.splitXcodeBuildArguments("GCC_SYMBOLS_PRIVATE_EXTERN=NO COPY_PHASE_STRIP=NO"));
}

@Test
public void shouldSplitXcodeBuildArgumentsWithEscapedSpaces() throws Exception {
assertEquals(asList("CODE_SIGN_IDENTITY=iPhone Developer: Todd Kirby"),
XCodeBuilder.splitXcodeBuildArguments("CODE_SIGN_IDENTITY=iPhone\\ Developer:\\ Todd\\ Kirby"));
assertEquals(asList("A=B", "CODE_SIGN_IDENTITY=iPhone Developer: Todd Kirby"),
XCodeBuilder.splitXcodeBuildArguments("A=B CODE_SIGN_IDENTITY=iPhone\\ Developer:\\ Todd\\ Kirby"));
}
}

0 comments on commit 4a12a66

Please sign in to comment.