use of io.jenkins.tools.warpackager.lib.config.Config in project custom-war-packager by jenkinsci.
the class Main method main.
public static void main(String[] args) throws IOException, InterruptedException {
CliOptions options = new CliOptions();
CmdLineParser p = new CmdLineParser(options);
if (args.length == 0) {
System.out.println("Usage: java -jar war-packager-cli.jar -configPath=mywar.yml [-version=1.0-SNAPSHOT] [-tmpDir=tmp]\n");
p.printUsage(System.out);
return;
}
try {
p.parseArgument(args);
} catch (CmdLineException ex) {
p.printUsage(System.out);
throw new IOException("Failed to read command-line arguments", ex);
}
final Config cfg;
if (options.isDemo()) {
System.out.println("Running build in the demo mode");
cfg = Config.loadDemoConfig();
} else {
final File configPath = options.getConfigPath();
if (configPath == null) {
throw new IOException("-configPath or -demo must be defined");
}
cfg = Config.loadConfig(configPath);
}
// Override Build Settings by CLI arguments
cfg.buildSettings.setTmpDir(options.getTmpDir());
cfg.buildSettings.setVersion(options.getVersion());
final Builder bldr = new Builder(cfg);
bldr.build();
}
use of io.jenkins.tools.warpackager.lib.config.Config in project custom-war-packager by jenkinsci.
the class PackageMojo method execute.
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (configFilePath == null) {
throw new MojoExecutionException("Config file is not defined");
}
final Config cfg;
try {
cfg = Config.loadConfig(new File(configFilePath));
} catch (IOException ex) {
throw new MojoExecutionException("Cannot load configuration from " + configFilePath, ex);
}
cfg.buildSettings.setVersion(warVersion);
if (tmpDir != null) {
cfg.buildSettings.setTmpDir(new File(tmpDir));
} else {
// Use a Maven temporary dir
// TODO: use step ID
cfg.buildSettings.setTmpDir(new File(project.getBuild().getDirectory(), "custom-war-packager-maven-plugin"));
}
final Builder bldr = new Builder(cfg);
try {
bldr.build();
} catch (Exception ex) {
throw new MojoExecutionException("Failed to build the custom WAR", ex);
}
projectHelper.attachArtifact(project, "war", cfg.getOutputWar());
}
Aggregations