2
0
Fork 0
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:
Geert Bevin 2023-08-16 20:54:15 -04:00 committed by GitHub
commit 5f619ce188
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 550 additions and 480 deletions

View file

@ -5,7 +5,7 @@
package rife.bld.help;
import rife.bld.CommandHelp;
import rife.tools.StringUtils;
import rife.bld.operations.RunOperation;
/**
* Provides help for the run command.
@ -15,13 +15,13 @@ import rife.tools.StringUtils;
*/
public class RunHelp implements CommandHelp {
public String getSummary() {
return "Runs the project";
return "Runs the project (take option)";
}
public String getDescription(String topic) {
return StringUtils.replace("""
Runs the project.
return String.format("""
Runs the project.
Usage : ${topic}""", "${topic}", topic);
Usage : %s [%sARG...]""", topic, RunOperation.ARGS_OPTION);
}
}

View file

@ -8,6 +8,7 @@ import rife.bld.BaseProject;
import rife.tools.FileUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
@ -17,6 +18,7 @@ import java.util.List;
* @since 1.5
*/
public class RunOperation extends AbstractProcessOperation<RunOperation> {
public static final String ARGS_OPTION = "--args=";
protected final List<String> runOptions_ = new ArrayList<>();
/**
@ -52,6 +54,22 @@ public class RunOperation extends AbstractProcessOperation<RunOperation> {
if (project.usesRife2Agent()) {
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;
}

View file

@ -7,8 +7,11 @@ package rife.bld.publish;
import rife.bld.dependencies.*;
import rife.template.Template;
import rife.template.TemplateFactory;
import rife.tools.FileUtils;
import rife.tools.StringUtils;
import rife.tools.exceptions.FileUtilsErrorException;
import java.io.File;
import java.util.Objects;
/**
@ -121,6 +124,17 @@ public class PomBuilder {
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) {
var scoped_dependencies = dependencies().scope(scope);
if (!scoped_dependencies.isEmpty()) {

File diff suppressed because it is too large Load diff