Skip to content

Commit

Permalink
Inline one line utility
Browse files Browse the repository at this point in the history
  • Loading branch information
elharo committed Dec 3, 2024
1 parent 7caf7bf commit 7dcb435
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,4 @@ protected String getPlatformDependSeparateList(Collection<String> modulePaths) {
return String.join(Character.toString(File.pathSeparatorChar), modulePaths);
}

/**
* Convert a list into a
* @param modules The list of modules.
* @return The string with the module list which is separated by {@code ,}.
*/
protected String getCommaSeparatedList(Collection<String> modules) {
return String.join(",", modules);
}
}
8 changes: 4 additions & 4 deletions src/main/java/org/apache/maven/plugins/jlink/JLinkMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -706,23 +706,23 @@ protected List<String> createJlinkArgs(Collection<String> pathsOfModules, Collec

if (hasLimitModules()) {
jlinkArgs.add("--limit-modules");
String sb = getCommaSeparatedList(limitModules);
String sb = String.join(",", limitModules);
jlinkArgs.add(sb);
}

if (!modulesToAdd.isEmpty()) {
jlinkArgs.add("--add-modules");
// This must be name of the module and *NOT* the name of the
// file! Can we somehow pre check this information to fail early?
String sb = getCommaSeparatedList(modulesToAdd);
String sb = String.join(",", modulesToAdd);
jlinkArgs.add(sb.replace("\\", "\\\\"));
}

if (hasIncludeLocales()) {
jlinkArgs.add("--add-modules");
jlinkArgs.add("jdk.localedata");
jlinkArgs.add("--include-locales");
String sb = getCommaSeparatedList(includeLocales);
String sb = String.join(",", includeLocales);
jlinkArgs.add(sb);
}

Expand All @@ -744,7 +744,7 @@ protected List<String> createJlinkArgs(Collection<String> pathsOfModules, Collec
// NOTE: suggestProviders is a terminal JlinkTask, so must be at the end!
if (hasSuggestProviders()) {
jlinkArgs.add("--suggest-providers");
String sb = getCommaSeparatedList(suggestProviders);
String sb = String.join(",", suggestProviders);
jlinkArgs.add(sb);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,14 @@ public void getPlatformDependSeparateListShouldReturnThreeCharactersSeparated()
@Test
@DisplayName("getCommaSeparatedList() should return a single character")
public void getCommaSeparatedListShouldReturnASingleCharacter() {
String result = mojoMock.getCommaSeparatedList(Collections.singletonList("A"));
String result = String.join( ",", Collections.singletonList( "A" ) );
assertThat(result).isEqualTo("A");
}

@Test
@DisplayName("getCommaSeparatedList() should return two characters separated by comma")
public void getCommaSeparatedListShouldReturnTwoCharactersSeparatedByComma() {
String result = mojoMock.getCommaSeparatedList(Arrays.asList("A", "B"));
String result = String.join( ",", Arrays.asList( "A", "B" ) );
assertThat(result).isEqualTo("A,B");
}
}

0 comments on commit 7dcb435

Please sign in to comment.