mirror of
https://github.com/ethauvin/bld.git
synced 2025-04-25 08:17:11 -07:00
Renamed fileOptions to cmdFiles
This commit is contained in:
parent
62a324068f
commit
a06ce8eaaa
4 changed files with 64 additions and 63 deletions
|
@ -15,14 +15,35 @@ import java.util.Map;
|
||||||
* @since 2.0.2
|
* @since 2.0.2
|
||||||
*/
|
*/
|
||||||
public class JlinkOperation extends AbstractToolProviderOperation<JlinkOperation> {
|
public class JlinkOperation extends AbstractToolProviderOperation<JlinkOperation> {
|
||||||
|
private final List<String> cmdFiles_ = new ArrayList<>();
|
||||||
private final List<String> disabledPlugins_ = new ArrayList<>();
|
private final List<String> disabledPlugins_ = new ArrayList<>();
|
||||||
private final JlinkOptions jlinkOptions_ = new JlinkOptions();
|
private final JlinkOptions jlinkOptions_ = new JlinkOptions();
|
||||||
private final List<String> fileOptions_ = new ArrayList<>();
|
|
||||||
|
|
||||||
public JlinkOperation() {
|
public JlinkOperation() {
|
||||||
super("jlink");
|
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.
|
* Disable the plugin mentioned.
|
||||||
*
|
*
|
||||||
|
@ -36,23 +57,12 @@ public class JlinkOperation extends AbstractToolProviderOperation<JlinkOperation
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() throws Exception {
|
public void execute() throws Exception {
|
||||||
toolArgsFromFile(fileOptions_);
|
toolArgsFromFile(cmdFiles_);
|
||||||
disabledPlugins_.forEach(plugin -> toolArgs("--disable-plugin", plugin));
|
disabledPlugins_.forEach(plugin -> toolArgs("--disable-plugin", plugin));
|
||||||
toolArgs(jlinkOptions_);
|
toolArgs(jlinkOptions_);
|
||||||
super.execute();
|
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.
|
* Provides a list of options to provide to the jlink tool.
|
||||||
* <p>
|
* <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 the map of jlink options
|
||||||
* @return this operation instance
|
|
||||||
*/
|
*/
|
||||||
public JlinkOperation fileOptions(String... file) {
|
public JlinkOptions jlinkOptions() {
|
||||||
fileOptions_.addAll(List.of(file));
|
return jlinkOptions_;
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the list of files containing options or mode.
|
|
||||||
*
|
|
||||||
* @return the list of files
|
|
||||||
*/
|
|
||||||
public List<String> fileOptions() {
|
|
||||||
return fileOptions_;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ import java.util.Map;
|
||||||
* @since 2.0.2
|
* @since 2.0.2
|
||||||
*/
|
*/
|
||||||
public class JmodOperation extends AbstractToolProviderOperation<JmodOperation> {
|
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 final JmodOptions jmodOptions_ = new JmodOptions();
|
||||||
private String jmodFile_;
|
private String jmodFile_;
|
||||||
private OperationMode operationMode_;
|
private OperationMode operationMode_;
|
||||||
|
@ -24,13 +24,33 @@ public class JmodOperation extends AbstractToolProviderOperation<JmodOperation>
|
||||||
super("jmod");
|
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
|
@Override
|
||||||
public void execute() throws Exception {
|
public void execute() throws Exception {
|
||||||
if (operationMode_ != null) {
|
if (operationMode_ != null) {
|
||||||
toolArgs(operationMode_.mode);
|
toolArgs(operationMode_.mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
toolArgsFromFile(fileOptions_);
|
toolArgsFromFile(cmdFiles);
|
||||||
toolArgs(jmodOptions_);
|
toolArgs(jmodOptions_);
|
||||||
|
|
||||||
if (jmodFile_ != null) {
|
if (jmodFile_ != null) {
|
||||||
|
@ -40,26 +60,6 @@ public class JmodOperation extends AbstractToolProviderOperation<JmodOperation>
|
||||||
super.execute();
|
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.
|
* Retrieves the name of the JMOD file to create or from which to retrieve information.
|
||||||
*
|
*
|
||||||
|
|
|
@ -116,7 +116,7 @@ public class TestJlinkOperation {
|
||||||
@Test
|
@Test
|
||||||
void testFileOptions() {
|
void testFileOptions() {
|
||||||
System.setOut(new PrintStream(outputStreamCaptor));
|
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");
|
"src/test/resources/jlink/options_version.txt");
|
||||||
assertDoesNotThrow(jlink::execute);
|
assertDoesNotThrow(jlink::execute);
|
||||||
var out = outputStreamCaptor.toString();
|
var out = outputStreamCaptor.toString();
|
||||||
|
@ -134,14 +134,14 @@ public class TestJlinkOperation {
|
||||||
void testNoArguments() {
|
void testNoArguments() {
|
||||||
var jlink = new JlinkOperation();
|
var jlink = new JlinkOperation();
|
||||||
assertTrue(jlink.jlinkOptions().isEmpty(), "jlink options not empty");
|
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);
|
assertThrows(ExitStatusException.class, jlink::execute);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testParseOptions() {
|
void testParseOptions() {
|
||||||
System.setOut(new PrintStream(outputStreamCaptor));
|
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);
|
assertDoesNotThrow(jlink::execute);
|
||||||
var out = outputStreamCaptor.toString();
|
var out = outputStreamCaptor.toString();
|
||||||
assertTrue(out.contains("List of available plugins:"), out);
|
assertTrue(out.contains("List of available plugins:"), out);
|
||||||
|
|
|
@ -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
|
@Test
|
||||||
void testHelp() {
|
void testHelp() {
|
||||||
var jmod = new JmodOperation().toolArgs("--help-extra");
|
var jmod = new JmodOperation().toolArgs("--help-extra");
|
||||||
|
@ -148,20 +157,11 @@ public class TestJmodOperation {
|
||||||
@Test
|
@Test
|
||||||
void testNoArguments() {
|
void testNoArguments() {
|
||||||
var jmod = new JmodOperation();
|
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");
|
assertTrue(jmod.jmodOptions().isEmpty(), "jmod options not empty");
|
||||||
assertThrows(ExitStatusException.class, jmod::execute);
|
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
|
@Test
|
||||||
void testVersion() {
|
void testVersion() {
|
||||||
System.setOut(new PrintStream(outputStreamCaptor));
|
System.setOut(new PrintStream(outputStreamCaptor));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue