mirror of
https://github.com/ethauvin/bld.git
synced 2025-04-25 16:27:11 -07:00
Merge pull request #4 from ethauvin/main
Added support for run arguments
This commit is contained in:
commit
5f619ce188
4 changed files with 550 additions and 480 deletions
|
@ -5,7 +5,7 @@
|
||||||
package rife.bld.help;
|
package rife.bld.help;
|
||||||
|
|
||||||
import rife.bld.CommandHelp;
|
import rife.bld.CommandHelp;
|
||||||
import rife.tools.StringUtils;
|
import rife.bld.operations.RunOperation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides help for the run command.
|
* Provides help for the run command.
|
||||||
|
@ -15,13 +15,13 @@ import rife.tools.StringUtils;
|
||||||
*/
|
*/
|
||||||
public class RunHelp implements CommandHelp {
|
public class RunHelp implements CommandHelp {
|
||||||
public String getSummary() {
|
public String getSummary() {
|
||||||
return "Runs the project";
|
return "Runs the project (take option)";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription(String topic) {
|
public String getDescription(String topic) {
|
||||||
return StringUtils.replace("""
|
return String.format("""
|
||||||
Runs the project.
|
Runs the project.
|
||||||
|
|
||||||
Usage : ${topic}""", "${topic}", topic);
|
Usage : %s [%sARG...]""", topic, RunOperation.ARGS_OPTION);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -8,6 +8,7 @@ import rife.bld.BaseProject;
|
||||||
import rife.tools.FileUtils;
|
import rife.tools.FileUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,6 +18,7 @@ import java.util.List;
|
||||||
* @since 1.5
|
* @since 1.5
|
||||||
*/
|
*/
|
||||||
public class RunOperation extends AbstractProcessOperation<RunOperation> {
|
public class RunOperation extends AbstractProcessOperation<RunOperation> {
|
||||||
|
public static final String ARGS_OPTION = "--args=";
|
||||||
protected final List<String> runOptions_ = new ArrayList<>();
|
protected final List<String> runOptions_ = new ArrayList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -52,6 +54,22 @@ public class RunOperation extends AbstractProcessOperation<RunOperation> {
|
||||||
if (project.usesRife2Agent()) {
|
if (project.usesRife2Agent()) {
|
||||||
operation.javaOptions().javaAgent(project.getRife2AgentFile());
|
operation.javaOptions().javaAgent(project.getRife2AgentFile());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// parse the run arguments if any
|
||||||
|
var args = project.arguments();
|
||||||
|
while (!args.isEmpty()) {
|
||||||
|
var arg = args.get(0);
|
||||||
|
if (arg.startsWith("-")) {
|
||||||
|
args.remove(0);
|
||||||
|
if (arg.startsWith(ARGS_OPTION)) {
|
||||||
|
var runArgs = arg.substring(ARGS_OPTION.length());
|
||||||
|
if (!runArgs.isBlank()) {
|
||||||
|
runOptions_.addAll(0, Arrays.asList(runArgs.split(" ")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,11 @@ package rife.bld.publish;
|
||||||
import rife.bld.dependencies.*;
|
import rife.bld.dependencies.*;
|
||||||
import rife.template.Template;
|
import rife.template.Template;
|
||||||
import rife.template.TemplateFactory;
|
import rife.template.TemplateFactory;
|
||||||
|
import rife.tools.FileUtils;
|
||||||
import rife.tools.StringUtils;
|
import rife.tools.StringUtils;
|
||||||
|
import rife.tools.exceptions.FileUtilsErrorException;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -121,6 +124,17 @@ public class PomBuilder {
|
||||||
return StringUtils.stripBlankLines(t.getContent());
|
return StringUtils.stripBlankLines(t.getContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates a POM into the given file.
|
||||||
|
*
|
||||||
|
* @since 1.7.1
|
||||||
|
*/
|
||||||
|
public static void generateInto(PublishInfo info, DependencyScopes dependencies, File file)
|
||||||
|
throws FileUtilsErrorException {
|
||||||
|
var pomBuilder = new PomBuilder().info(info).dependencies(dependencies);
|
||||||
|
FileUtils.writeString(pomBuilder.build(), file);
|
||||||
|
}
|
||||||
|
|
||||||
private void addDependencies(Template t, Scope scope) {
|
private void addDependencies(Template t, Scope scope) {
|
||||||
var scoped_dependencies = dependencies().scope(scope);
|
var scoped_dependencies = dependencies().scope(scope);
|
||||||
if (!scoped_dependencies.isEmpty()) {
|
if (!scoped_dependencies.isEmpty()) {
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue