2
0
Fork 0
mirror of https://github.com/ethauvin/bld.git synced 2025-04-25 00:07:12 -07:00

Renamed fileOptions to cmdFiles

This commit is contained in:
Erik C. Thauvin 2024-08-04 20:16:55 -07:00
parent 62a324068f
commit a06ce8eaaa
Signed by: erik
GPG key ID: 776702A6A2DA330E
4 changed files with 64 additions and 63 deletions

View file

@ -15,14 +15,35 @@ import java.util.Map;
* @since 2.0.2
*/
public class JlinkOperation extends AbstractToolProviderOperation<JlinkOperation> {
private final List<String> cmdFiles_ = new ArrayList<>();
private final List<String> disabledPlugins_ = new ArrayList<>();
private final JlinkOptions jlinkOptions_ = new JlinkOptions();
private final List<String> fileOptions_ = new ArrayList<>();
public JlinkOperation() {
super("jlink");
}
/**
* Read options and/or mode from file(s).
*
* @param file one or more file
* @return this operation instance
*/
public JlinkOperation cmdFiles(String... file) {
cmdFiles_.addAll(List.of(file));
return this;
}
/**
* Retrieves the list of files containing options or mode.
*
* @return the list of files
*/
public List<String> cmdFiles() {
return cmdFiles_;
}
/**
* Disable the plugin mentioned.
*
@ -36,23 +57,12 @@ public class JlinkOperation extends AbstractToolProviderOperation<JlinkOperation
@Override
public void execute() throws Exception {
toolArgsFromFile(fileOptions_);
toolArgsFromFile(cmdFiles_);
disabledPlugins_.forEach(plugin -> toolArgs("--disable-plugin", plugin));
toolArgs(jlinkOptions_);
super.execute();
}
/**
* Retrieves the list of options for the jlink tool.
* <p>
* This is a modifiable list that can be retrieved and changed.
*
* @return the map of jlink options
*/
public JlinkOptions jlinkOptions() {
return jlinkOptions_;
}
/**
* Provides a list of options to provide to the jlink tool.
* <p>
@ -67,22 +77,13 @@ public class JlinkOperation extends AbstractToolProviderOperation<JlinkOperation
}
/**
* Read options and/or mode from a file.
* Retrieves the list of options for the jlink tool.
* <p>
* This is a modifiable list that can be retrieved and changed.
*
* @param file one or more file
* @return this operation instance
* @return the map of jlink options
*/
public JlinkOperation fileOptions(String... file) {
fileOptions_.addAll(List.of(file));
return this;
}
/**
* Retrieves the list of files containing options or mode.
*
* @return the list of files
*/
public List<String> fileOptions() {
return fileOptions_;
public JlinkOptions jlinkOptions() {
return jlinkOptions_;
}
}

View file

@ -15,7 +15,7 @@ import java.util.Map;
* @since 2.0.2
*/
public class JmodOperation extends AbstractToolProviderOperation<JmodOperation> {
private final List<String> fileOptions_ = new ArrayList<>();
private final List<String> cmdFiles = new ArrayList<>();
private final JmodOptions jmodOptions_ = new JmodOptions();
private String jmodFile_;
private OperationMode operationMode_;
@ -24,13 +24,33 @@ public class JmodOperation extends AbstractToolProviderOperation<JmodOperation>
super("jmod");
}
/**
* Retrieves the list of files containing options or mode.
*
* @return the list of files
*/
public List<String> cmdFiles() {
return cmdFiles;
}
/**
* Read options and/or mode from file(s).
*
* @param file one or more file
* @return this operation instance
*/
public JmodOperation cmdFiles(String... file) {
cmdFiles.addAll(List.of(file));
return this;
}
@Override
public void execute() throws Exception {
if (operationMode_ != null) {
toolArgs(operationMode_.mode);
}
toolArgsFromFile(fileOptions_);
toolArgsFromFile(cmdFiles);
toolArgs(jmodOptions_);
if (jmodFile_ != null) {
@ -40,26 +60,6 @@ public class JmodOperation extends AbstractToolProviderOperation<JmodOperation>
super.execute();
}
/**
* Retrieves the list of files containing options or mode.
*
* @return the list of files
*/
public List<String> fileOptions() {
return fileOptions_;
}
/**
* Read options and/or mode from a file.
*
* @param file one or more file
* @return this operation instance
*/
public JmodOperation fileOptions(String... file) {
fileOptions_.addAll(List.of(file));
return this;
}
/**
* Retrieves the name of the JMOD file to create or from which to retrieve information.
*

View file

@ -116,7 +116,7 @@ public class TestJlinkOperation {
@Test
void testFileOptions() {
System.setOut(new PrintStream(outputStreamCaptor));
var jlink = new JlinkOperation().fileOptions("src/test/resources/jlink/options_verbose.txt",
var jlink = new JlinkOperation().cmdFiles("src/test/resources/jlink/options_verbose.txt",
"src/test/resources/jlink/options_version.txt");
assertDoesNotThrow(jlink::execute);
var out = outputStreamCaptor.toString();
@ -134,14 +134,14 @@ public class TestJlinkOperation {
void testNoArguments() {
var jlink = new JlinkOperation();
assertTrue(jlink.jlinkOptions().isEmpty(), "jlink options not empty");
assertTrue(jlink.fileOptions().isEmpty(), "file options not empty");
assertTrue(jlink.cmdFiles().isEmpty(), "file options not empty");
assertThrows(ExitStatusException.class, jlink::execute);
}
@Test
void testParseOptions() {
System.setOut(new PrintStream(outputStreamCaptor));
var jlink = new JlinkOperation().fileOptions("src/test/resources/jlink/options_jlink.txt");
var jlink = new JlinkOperation().cmdFiles("src/test/resources/jlink/options_jlink.txt");
assertDoesNotThrow(jlink::execute);
var out = outputStreamCaptor.toString();
assertTrue(out.contains("List of available plugins:"), out);

View file

@ -138,6 +138,15 @@ public class TestJmodOperation {
}
}
@Test
void testFileOptions() {
System.setOut(new PrintStream(outputStreamCaptor));
var jmod = new JmodOperation().cmdFiles("src/test/resources/jlink/options_version.txt");
assertDoesNotThrow(jmod::execute);
var out = outputStreamCaptor.toString();
assertTrue(out.matches("[\\d.]+[\\r\\n]+"), out);
}
@Test
void testHelp() {
var jmod = new JmodOperation().toolArgs("--help-extra");
@ -148,20 +157,11 @@ public class TestJmodOperation {
@Test
void testNoArguments() {
var jmod = new JmodOperation();
assertTrue(jmod.fileOptions().isEmpty(), "file options not empty");
assertTrue(jmod.cmdFiles().isEmpty(), "file options not empty");
assertTrue(jmod.jmodOptions().isEmpty(), "jmod options not empty");
assertThrows(ExitStatusException.class, jmod::execute);
}
@Test
void testFileOptions() {
System.setOut(new PrintStream(outputStreamCaptor));
var jmod = new JmodOperation().fileOptions("src/test/resources/jlink/options_version.txt");
assertDoesNotThrow(jmod::execute);
var out = outputStreamCaptor.toString();
assertTrue(out.matches("[\\d.]+[\\r\\n]+"), out);
}
@Test
void testVersion() {
System.setOut(new PrintStream(outputStreamCaptor));