mirror of
https://github.com/jlengrand/jreleaser.git
synced 2026-03-10 08:31:24 +00:00
[cli] Add i18n support. Resolves #392
This commit is contained in:
@@ -28,43 +28,41 @@ import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/**
|
||||
* @author Andres Almiray
|
||||
* @since 0.1.0
|
||||
*/
|
||||
@CommandLine.Command
|
||||
@CommandLine.Command(mixinStandardHelpOptions = true,
|
||||
resourceBundle = "org.jreleaser.cli.Messages")
|
||||
abstract class AbstractCommand implements Callable<Integer> {
|
||||
protected JReleaserLogger logger;
|
||||
|
||||
@CommandLine.Option(names = {"-d", "--debug"},
|
||||
description = "Set log level to debug.")
|
||||
@CommandLine.Option(names = {"-d", "--debug"})
|
||||
boolean debug;
|
||||
|
||||
@CommandLine.Option(names = {"-i", "--info"},
|
||||
description = "Set log level to info.")
|
||||
@CommandLine.Option(names = {"-i", "--info"})
|
||||
boolean info;
|
||||
|
||||
@CommandLine.Option(names = {"-w", "--warn"},
|
||||
description = "Set log level to warn.")
|
||||
@CommandLine.Option(names = {"-w", "--warn"})
|
||||
boolean warn;
|
||||
|
||||
@CommandLine.Option(names = {"-q", "--quiet"},
|
||||
description = "Log errors only.")
|
||||
@CommandLine.Option(names = {"-q", "--quiet"})
|
||||
boolean quiet;
|
||||
|
||||
@CommandLine.Option(names = {"-b", "--basedir"},
|
||||
description = "Base directory.")
|
||||
@CommandLine.Option(names = {"-b", "--basedir"})
|
||||
Path basedir;
|
||||
|
||||
@CommandLine.Option(names = {"-od", "--output-directory"},
|
||||
description = "Output directory.")
|
||||
@CommandLine.Option(names = {"-od", "--output-directory"})
|
||||
Path outputdir;
|
||||
|
||||
@CommandLine.Spec
|
||||
CommandLine.Model.CommandSpec spec;
|
||||
|
||||
ResourceBundle bundle = ResourceBundle.getBundle("org.jreleaser.cli.Messages");
|
||||
|
||||
protected abstract Main parent();
|
||||
|
||||
public Integer call() {
|
||||
@@ -116,7 +114,7 @@ abstract class AbstractCommand implements Callable<Integer> {
|
||||
return new PrintWriter(new FileOutputStream(
|
||||
getOutputDirectory().resolve("trace.log").toFile()));
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException("Could not initialize trace file", e);
|
||||
throw new IllegalStateException(bundle.getString("ERROR_trace_file_init"), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,17 +45,14 @@ import static org.jreleaser.util.FileUtils.resolveOutputDirectory;
|
||||
*/
|
||||
@CommandLine.Command
|
||||
public abstract class AbstractModelCommand extends AbstractCommand {
|
||||
@CommandLine.Option(names = {"-c", "--config-file"},
|
||||
description = "The config file")
|
||||
@CommandLine.Option(names = {"-c", "--config-file"})
|
||||
Path configFile;
|
||||
|
||||
@CommandLine.Option(names = {"-grs", "--git-root-search"},
|
||||
description = "Searches for the Git root.")
|
||||
@CommandLine.Option(names = {"-grs", "--git-root-search"})
|
||||
boolean gitRootSearch;
|
||||
|
||||
@CommandLine.Option(names = {"-p", "--set-property"},
|
||||
paramLabel = "<key=value>",
|
||||
description = "Sets the value of a property. Repeatable.")
|
||||
paramLabel = "<key=value>")
|
||||
String[] properties;
|
||||
|
||||
@CommandLine.ParentCommand
|
||||
@@ -75,9 +72,9 @@ public abstract class AbstractModelCommand extends AbstractCommand {
|
||||
initLogger();
|
||||
logger.info("JReleaser {}", JReleaserVersion.getPlainVersion());
|
||||
JReleaserVersion.banner(logger.getTracer(), false);
|
||||
logger.info("Configuring with {}", actualConfigFile);
|
||||
logger.info(bundle.getString("TEXT_config_file"), actualConfigFile);
|
||||
logger.increaseIndent();
|
||||
logger.info("- basedir set to {}", actualBasedir.toAbsolutePath());
|
||||
logger.info(bundle.getString("TEXT_basedir_set"), actualBasedir.toAbsolutePath());
|
||||
logger.decreaseIndent();
|
||||
doExecute(createContext());
|
||||
}
|
||||
@@ -98,9 +95,10 @@ public abstract class AbstractModelCommand extends AbstractCommand {
|
||||
spec.commandLine().getErr()
|
||||
.println(spec.commandLine()
|
||||
.getColorScheme()
|
||||
.errorText("Missing required option: '--config-file=<configFile>' " +
|
||||
"or local file named jreleaser[" +
|
||||
String.join("|", getSupportedConfigFormats()) + "]"));
|
||||
.errorText(String.format(
|
||||
bundle.getString("ERROR_missing_config_file"),
|
||||
String.join("|", getSupportedConfigFormats())
|
||||
)));
|
||||
spec.commandLine().usage(parent.out);
|
||||
throw new HaltExecutionException();
|
||||
}
|
||||
@@ -124,7 +122,9 @@ public abstract class AbstractModelCommand extends AbstractCommand {
|
||||
actualBasedir = null != basedir ? basedir : actualConfigFile.toAbsolutePath().getParent();
|
||||
if (!Files.exists(actualBasedir)) {
|
||||
spec.commandLine().getErr()
|
||||
.println(spec.commandLine().getColorScheme().errorText("Missing required option: '--basedir=<basedir>'"));
|
||||
.println(spec.commandLine().getColorScheme().errorText(String.format(
|
||||
bundle.getString("ERROR_missing_required_option"),
|
||||
"--basedir=<basedir>")));
|
||||
spec.commandLine().usage(parent.out);
|
||||
throw new HaltExecutionException();
|
||||
}
|
||||
@@ -160,7 +160,9 @@ public abstract class AbstractModelCommand extends AbstractCommand {
|
||||
return JReleaserContext.Configurer.CLI_JSON;
|
||||
}
|
||||
// should not happen!
|
||||
throw new IllegalArgumentException("Invalid configuration format: " + configFile.getFileName());
|
||||
throw new IllegalArgumentException(String.format(
|
||||
bundle.getString("ERROR_invalid_config_format"),
|
||||
configFile.getFileName()));
|
||||
}
|
||||
|
||||
protected Path getOutputDirectory() {
|
||||
@@ -200,7 +202,9 @@ public abstract class AbstractModelCommand extends AbstractCommand {
|
||||
if (property.contains("=")) {
|
||||
int d = property.indexOf('=');
|
||||
if (d == 0 || d == properties.length - 1) {
|
||||
throw new IllegalArgumentException("Invalid property '" + property + "'");
|
||||
throw new IllegalArgumentException(String.format(
|
||||
bundle.getString("ERROR_invalid_property"),
|
||||
property));
|
||||
}
|
||||
props.put(property.substring(0, d),
|
||||
property.substring(d + 1));
|
||||
|
||||
@@ -30,13 +30,11 @@ import java.util.List;
|
||||
*/
|
||||
@CommandLine.Command
|
||||
public abstract class AbstractPlatformAwareModelCommand extends AbstractModelCommand {
|
||||
@CommandLine.Option(names = {"-scp", "--select-current-platform"},
|
||||
description = "Activates paths matching the current platform.")
|
||||
@CommandLine.Option(names = {"-scp", "--select-current-platform"})
|
||||
boolean selectCurrentPlatform;
|
||||
|
||||
@CommandLine.Option(names = {"-sp", "--select-platform"},
|
||||
paramLabel = "<platform>",
|
||||
description = "Activates paths matching the given platform. Repeatable.")
|
||||
paramLabel = "<platform>")
|
||||
String[] selectPlatforms;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,16 +25,12 @@ import picocli.CommandLine;
|
||||
* @author Andres Almiray
|
||||
* @since 0.1.0
|
||||
*/
|
||||
@CommandLine.Command(name = "announce",
|
||||
mixinStandardHelpOptions = true,
|
||||
description = "Announce a release.")
|
||||
@CommandLine.Command(name = "announce")
|
||||
public class Announce extends AbstractPlatformAwareModelCommand {
|
||||
@CommandLine.Option(names = {"-y", "--dryrun"},
|
||||
description = "Skip remote operations.")
|
||||
@CommandLine.Option(names = {"-y", "--dryrun"})
|
||||
boolean dryrun;
|
||||
|
||||
@CommandLine.Option(names = {"-an", "--announcer-name"},
|
||||
description = "The name of the announcer.")
|
||||
@CommandLine.Option(names = {"-an", "--announcer-name"})
|
||||
String announcerName;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,16 +25,12 @@ import picocli.CommandLine;
|
||||
* @author Andres Almiray
|
||||
* @since 0.2.0
|
||||
*/
|
||||
@CommandLine.Command(name = "assemble",
|
||||
mixinStandardHelpOptions = true,
|
||||
description = "Assemble distributions.")
|
||||
@CommandLine.Command(name = "assemble")
|
||||
public class Assemble extends AbstractModelCommand {
|
||||
@CommandLine.Option(names = {"-an", "--assembler-name"},
|
||||
description = "The name of the assembler.")
|
||||
@CommandLine.Option(names = {"-an", "--assembler-name"})
|
||||
String assemblerName;
|
||||
|
||||
@CommandLine.Option(names = {"-dn", "--distribution-name"},
|
||||
description = "The name of the distribution.")
|
||||
@CommandLine.Option(names = {"-dn", "--distribution-name"})
|
||||
String distributionName;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,9 +25,7 @@ import picocli.CommandLine;
|
||||
* @author Andres Almiray
|
||||
* @since 0.1.0
|
||||
*/
|
||||
@CommandLine.Command(name = "changelog",
|
||||
mixinStandardHelpOptions = true,
|
||||
description = "Calculate the changelog.")
|
||||
@CommandLine.Command(name = "changelog")
|
||||
public class Changelog extends AbstractModelCommand {
|
||||
@Override
|
||||
protected void doExecute(JReleaserContext context) {
|
||||
|
||||
@@ -25,9 +25,7 @@ import picocli.CommandLine;
|
||||
* @author Andres Almiray
|
||||
* @since 0.1.0
|
||||
*/
|
||||
@CommandLine.Command(name = "checksum",
|
||||
mixinStandardHelpOptions = true,
|
||||
description = "Calculate checksums.")
|
||||
@CommandLine.Command(name = "checksum")
|
||||
public class Checksum extends AbstractPlatformAwareModelCommand {
|
||||
@Override
|
||||
protected void doExecute(JReleaserContext context) {
|
||||
|
||||
@@ -25,16 +25,12 @@ import picocli.CommandLine;
|
||||
* @author Andres Almiray
|
||||
* @since 0.1.0
|
||||
*/
|
||||
@CommandLine.Command(name = "config",
|
||||
mixinStandardHelpOptions = true,
|
||||
description = "Display current configuration.")
|
||||
@CommandLine.Command(name = "config")
|
||||
public class Config extends AbstractPlatformAwareModelCommand {
|
||||
@CommandLine.Option(names = {"-f", "--full"},
|
||||
description = "Display full configuration.")
|
||||
@CommandLine.Option(names = {"-f", "--full"})
|
||||
boolean full;
|
||||
|
||||
@CommandLine.Option(names = {"-a", "--assembly"},
|
||||
description = "Display assembly configuration.")
|
||||
@CommandLine.Option(names = {"-a", "--assembly"})
|
||||
boolean assembly;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,12 +25,9 @@ import picocli.CommandLine;
|
||||
* @author Andres Almiray
|
||||
* @since 0.1.0
|
||||
*/
|
||||
@CommandLine.Command(name = "full-release",
|
||||
mixinStandardHelpOptions = true,
|
||||
description = "Perform a full release.")
|
||||
@CommandLine.Command(name = "full-release")
|
||||
public class FullRelease extends AbstractPlatformAwareModelCommand {
|
||||
@CommandLine.Option(names = {"-y", "--dryrun"},
|
||||
description = "Skip remote operations.")
|
||||
@CommandLine.Option(names = {"-y", "--dryrun"})
|
||||
boolean dryrun;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -44,16 +44,12 @@ import static java.nio.file.StandardOpenOption.WRITE;
|
||||
* @author Andres Almiray
|
||||
* @since 0.1.0
|
||||
*/
|
||||
@CommandLine.Command(name = "init",
|
||||
mixinStandardHelpOptions = true,
|
||||
description = "Create a jreleaser config file.")
|
||||
@CommandLine.Command(name = "init")
|
||||
public class Init extends AbstractCommand {
|
||||
@CommandLine.Option(names = {"-o", "--overwrite"},
|
||||
description = "Overwrite existing files.")
|
||||
@CommandLine.Option(names = {"-o", "--overwrite"})
|
||||
boolean overwrite;
|
||||
|
||||
@CommandLine.Option(names = {"-f", "--format"},
|
||||
description = "Configuration file format.")
|
||||
@CommandLine.Option(names = {"-f", "--format"})
|
||||
String format;
|
||||
|
||||
@CommandLine.ParentCommand
|
||||
@@ -75,8 +71,10 @@ public class Init extends AbstractCommand {
|
||||
spec.commandLine().getErr()
|
||||
.println(spec.commandLine()
|
||||
.getColorScheme()
|
||||
.errorText("Unsupported file format. Must be one of [" +
|
||||
String.join("|", getSupportedConfigFormats()) + "]"));
|
||||
.errorText(String.format(
|
||||
bundle.getString("jreleaser.init.ERROR_invalid_format"),
|
||||
String.join("|", getSupportedConfigFormats())))
|
||||
);
|
||||
spec.commandLine().usage(parent.out);
|
||||
throw new HaltExecutionException();
|
||||
}
|
||||
@@ -97,20 +95,22 @@ public class Init extends AbstractCommand {
|
||||
LocalDate now = LocalDate.now();
|
||||
content = content.replaceAll("@year@", now.getYear() + "");
|
||||
|
||||
logger.info("Writing file " + outputFile.toAbsolutePath());
|
||||
logger.info(bundle.getString("jreleaser.init.TEXT_writing_file"), outputFile.toAbsolutePath());
|
||||
|
||||
try {
|
||||
Files.write(outputFile, content.getBytes(), (overwrite ? CREATE : CREATE_NEW), WRITE, TRUNCATE_EXISTING);
|
||||
} catch (FileAlreadyExistsException e) {
|
||||
logger.error("File {} already exists and overwrite was set to false.", outputFile.toAbsolutePath());
|
||||
logger.error(bundle.getString("jreleaser.init.ERROR_file_exists"), outputFile.toAbsolutePath());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!quiet) {
|
||||
logger.info("JReleaser initialized at " + outputDirectory.toAbsolutePath());
|
||||
logger.info(String.format(
|
||||
bundle.getString("jreleaser.init.TEXT_success"),
|
||||
outputDirectory.toAbsolutePath()));
|
||||
}
|
||||
} catch (IllegalStateException | IOException e) {
|
||||
throw new JReleaserException("Unexpected error", e);
|
||||
throw new JReleaserException(bundle.getString("ERROR_unexpected_error"), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import java.io.PrintWriter;
|
||||
* @since 0.1.0
|
||||
*/
|
||||
@CommandLine.Command(name = "jreleaser",
|
||||
description = "jreleaser",
|
||||
resourceBundle = "org.jreleaser.cli.Messages",
|
||||
mixinStandardHelpOptions = true,
|
||||
versionProvider = Versions.class,
|
||||
subcommands = {Init.class, Config.class, Template.class,
|
||||
|
||||
@@ -25,20 +25,15 @@ import picocli.CommandLine;
|
||||
* @author Andres Almiray
|
||||
* @since 0.1.0
|
||||
*/
|
||||
@CommandLine.Command(name = "package",
|
||||
mixinStandardHelpOptions = true,
|
||||
description = "Package all distributions.")
|
||||
@CommandLine.Command(name = "package")
|
||||
public class Package extends AbstractPlatformAwareModelCommand {
|
||||
@CommandLine.Option(names = {"-y", "--dryrun"},
|
||||
description = "Skip remote operations.")
|
||||
@CommandLine.Option(names = {"-y", "--dryrun"})
|
||||
boolean dryrun;
|
||||
|
||||
@CommandLine.Option(names = {"-dn", "--distribution-name"},
|
||||
description = "The name of the distribution.")
|
||||
@CommandLine.Option(names = {"-dn", "--distribution-name"})
|
||||
String distributionName;
|
||||
|
||||
@CommandLine.Option(names = {"-tn", "--tool-name"},
|
||||
description = "The name of the tool.")
|
||||
@CommandLine.Option(names = {"-tn", "--tool-name"})
|
||||
String toolName;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,16 +25,12 @@ import picocli.CommandLine;
|
||||
* @author Andres Almiray
|
||||
* @since 0.1.0
|
||||
*/
|
||||
@CommandLine.Command(name = "prepare",
|
||||
mixinStandardHelpOptions = true,
|
||||
description = "Prepare all distributions.")
|
||||
@CommandLine.Command(name = "prepare")
|
||||
public class Prepare extends AbstractPlatformAwareModelCommand {
|
||||
@CommandLine.Option(names = {"-dn", "--distribution-name"},
|
||||
description = "The name of the distribution.")
|
||||
@CommandLine.Option(names = {"-dn", "--distribution-name"})
|
||||
String distributionName;
|
||||
|
||||
@CommandLine.Option(names = {"-tn", "--tool-name"},
|
||||
description = "The name of the tool.")
|
||||
@CommandLine.Option(names = {"-tn", "--tool-name"})
|
||||
String toolName;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,20 +25,15 @@ import picocli.CommandLine;
|
||||
* @author Andres Almiray
|
||||
* @since 0.1.0
|
||||
*/
|
||||
@CommandLine.Command(name = "publish",
|
||||
mixinStandardHelpOptions = true,
|
||||
description = "Publish all distributions.")
|
||||
@CommandLine.Command(name = "publish")
|
||||
public class Publish extends AbstractPlatformAwareModelCommand {
|
||||
@CommandLine.Option(names = {"-y", "--dryrun"},
|
||||
description = "Skip remote operations.")
|
||||
@CommandLine.Option(names = {"-y", "--dryrun"})
|
||||
boolean dryrun;
|
||||
|
||||
@CommandLine.Option(names = {"-dn", "--distribution-name"},
|
||||
description = "The name of the distribution.")
|
||||
@CommandLine.Option(names = {"-dn", "--distribution-name"})
|
||||
String distributionName;
|
||||
|
||||
@CommandLine.Option(names = {"-tn", "--tool-name"},
|
||||
description = "The name of the tool.")
|
||||
@CommandLine.Option(names = {"-tn", "--tool-name"})
|
||||
String toolName;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -35,135 +35,109 @@ import java.util.Set;
|
||||
* @author Andres Almiray
|
||||
* @since 0.1.0
|
||||
*/
|
||||
@CommandLine.Command(name = "release",
|
||||
mixinStandardHelpOptions = true,
|
||||
description = "Create or update a release.")
|
||||
@CommandLine.Command(name = "release")
|
||||
public class Release extends AbstractPlatformAwareModelCommand {
|
||||
@CommandLine.Option(names = {"-y", "--dryrun"},
|
||||
description = "Skip remote operations.")
|
||||
@CommandLine.Option(names = {"-y", "--dryrun"})
|
||||
boolean dryrun;
|
||||
|
||||
@CommandLine.Option(names = {"--auto-config"},
|
||||
description = "Model auto configuration.")
|
||||
boolean autoConfig;
|
||||
@CommandLine.ArgGroup(exclusive = false, multiplicity = "1",
|
||||
headingKey = "auto-config.header")
|
||||
AutoConfigGroup autoConfigGroup;
|
||||
|
||||
@CommandLine.Option(names = {"--project-name"},
|
||||
description = "The project name.")
|
||||
String projectName;
|
||||
static class AutoConfigGroup {
|
||||
@CommandLine.Option(names = {"--auto-config"})
|
||||
boolean autoConfig;
|
||||
|
||||
@CommandLine.Option(names = {"--project-version"},
|
||||
description = "The project version.")
|
||||
String projectVersion;
|
||||
@CommandLine.Option(names = {"--project-name"})
|
||||
String projectName;
|
||||
|
||||
@CommandLine.Option(names = {"--project-version-pattern"},
|
||||
description = "The project version pattern.")
|
||||
String projectVersionPattern;
|
||||
@CommandLine.Option(names = {"--project-version"})
|
||||
String projectVersion;
|
||||
|
||||
@CommandLine.Option(names = {"--project-snapshot-pattern"},
|
||||
description = "The project snapshot pattern.")
|
||||
String projectSnapshotPattern;
|
||||
@CommandLine.Option(names = {"--project-version-pattern"})
|
||||
String projectVersionPattern;
|
||||
|
||||
@CommandLine.Option(names = {"--project-snapshot-label"},
|
||||
description = "The project snapshot label.")
|
||||
String projectSnapshotLabel;
|
||||
@CommandLine.Option(names = {"--project-snapshot-pattern"})
|
||||
String projectSnapshotPattern;
|
||||
|
||||
@CommandLine.Option(names = {"--project-snapshot-full-changelog"},
|
||||
description = "Calculate full changelog since last non-snapshot release.")
|
||||
boolean projectSnapshotFullChangelog;
|
||||
@CommandLine.Option(names = {"--project-snapshot-label"})
|
||||
String projectSnapshotLabel;
|
||||
|
||||
@CommandLine.Option(names = {"--tag-name"},
|
||||
description = "The release tag.")
|
||||
String tagName;
|
||||
@CommandLine.Option(names = {"--project-snapshot-full-changelog"})
|
||||
boolean projectSnapshotFullChangelog;
|
||||
|
||||
@CommandLine.Option(names = {"--previous-tag-name"},
|
||||
description = "The previous release tag.")
|
||||
String previousTagName;
|
||||
@CommandLine.Option(names = {"--tag-name"})
|
||||
String tagName;
|
||||
|
||||
@CommandLine.Option(names = {"--release-name"},
|
||||
description = "The release name.")
|
||||
String releaseName;
|
||||
@CommandLine.Option(names = {"--previous-tag-name"})
|
||||
String previousTagName;
|
||||
|
||||
@CommandLine.Option(names = {"--milestone-name"},
|
||||
description = "The milestone name.")
|
||||
String milestoneName;
|
||||
@CommandLine.Option(names = {"--release-name"})
|
||||
String releaseName;
|
||||
|
||||
@CommandLine.Option(names = {"--prerelease"},
|
||||
description = "If the release is a prerelease.")
|
||||
boolean prerelease;
|
||||
@CommandLine.Option(names = {"--milestone-name"})
|
||||
String milestoneName;
|
||||
|
||||
@CommandLine.Option(names = {"--prerelease-pattern"},
|
||||
description = "The prerelease pattern.")
|
||||
String prereleasePattern;
|
||||
@CommandLine.Option(names = {"--prerelease"})
|
||||
boolean prerelease;
|
||||
|
||||
@CommandLine.Option(names = {"--draft"},
|
||||
description = "If the release is a draft.")
|
||||
boolean draft;
|
||||
@CommandLine.Option(names = {"--prerelease-pattern"})
|
||||
String prereleasePattern;
|
||||
|
||||
@CommandLine.Option(names = {"--overwrite"},
|
||||
description = "Overwrite an existing release.")
|
||||
boolean overwrite;
|
||||
@CommandLine.Option(names = {"--draft"})
|
||||
boolean draft;
|
||||
|
||||
@CommandLine.Option(names = {"--update"},
|
||||
description = "Update an existing release.")
|
||||
boolean update;
|
||||
@CommandLine.Option(names = {"--overwrite"})
|
||||
boolean overwrite;
|
||||
|
||||
@CommandLine.Option(names = {"--update-section"},
|
||||
paramLabel = "<section>",
|
||||
description = "Release section to be updated. Repeatable.")
|
||||
String[] updateSections;
|
||||
@CommandLine.Option(names = {"--update"})
|
||||
boolean update;
|
||||
|
||||
@CommandLine.Option(names = {"--skip-tag"},
|
||||
description = "Skip tagging the release.")
|
||||
boolean skipTag;
|
||||
@CommandLine.Option(names = {"--update-section"},
|
||||
paramLabel = "<section>")
|
||||
String[] updateSections;
|
||||
|
||||
@CommandLine.Option(names = {"--skip-release"},
|
||||
description = "Skip creating a release.")
|
||||
boolean skipRelease;
|
||||
@CommandLine.Option(names = {"--skip-tag"})
|
||||
boolean skipTag;
|
||||
|
||||
@CommandLine.Option(names = {"--branch"},
|
||||
description = "The release branch.")
|
||||
String branch;
|
||||
@CommandLine.Option(names = {"--skip-release"})
|
||||
boolean skipRelease;
|
||||
|
||||
@CommandLine.Option(names = {"--changelog"},
|
||||
description = "Path to changelog file.")
|
||||
String changelog;
|
||||
@CommandLine.Option(names = {"--branch"})
|
||||
String branch;
|
||||
|
||||
@CommandLine.Option(names = {"--changelog-formatted"},
|
||||
description = "Format generated changelog.")
|
||||
boolean changelogFormatted;
|
||||
@CommandLine.Option(names = {"--changelog"})
|
||||
String changelog;
|
||||
|
||||
@CommandLine.Option(names = {"--username"},
|
||||
description = "Git username.")
|
||||
String username;
|
||||
@CommandLine.Option(names = {"--changelog-formatted"})
|
||||
boolean changelogFormatted;
|
||||
|
||||
@CommandLine.Option(names = {"--commit-author-name"},
|
||||
description = "Commit author name.")
|
||||
String commitAuthorName;
|
||||
@CommandLine.Option(names = {"--username"})
|
||||
String username;
|
||||
|
||||
@CommandLine.Option(names = {"--commit-author-email"},
|
||||
description = "Commit author e-mail.")
|
||||
String commitAuthorEmail;
|
||||
@CommandLine.Option(names = {"--commit-author-name"})
|
||||
String commitAuthorName;
|
||||
|
||||
@CommandLine.Option(names = {"--signing-enabled"},
|
||||
description = "Sign files.")
|
||||
boolean signing;
|
||||
@CommandLine.Option(names = {"--commit-author-email"})
|
||||
String commitAuthorEmail;
|
||||
|
||||
@CommandLine.Option(names = {"--signing-armored"},
|
||||
description = "Generate ascii armored signatures.")
|
||||
boolean armored;
|
||||
@CommandLine.Option(names = {"--signing-enabled"})
|
||||
boolean signing;
|
||||
|
||||
@CommandLine.Option(names = {"--file"},
|
||||
paramLabel = "<file>",
|
||||
description = "Input file to be uploaded. Repeatable.")
|
||||
String[] files;
|
||||
@CommandLine.Option(names = {"--signing-armored"})
|
||||
boolean armored;
|
||||
|
||||
@CommandLine.Option(names = {"--glob"},
|
||||
paramLabel = "<file>",
|
||||
description = "Input file to be uploaded (as glob). Repeatable.")
|
||||
String[] globs;
|
||||
@CommandLine.Option(names = {"--file"},
|
||||
paramLabel = "<file>")
|
||||
String[] files;
|
||||
|
||||
@CommandLine.Option(names = {"--glob"},
|
||||
paramLabel = "<glob>")
|
||||
String[] globs;
|
||||
}
|
||||
|
||||
protected void execute() {
|
||||
if (!autoConfig) {
|
||||
if (!autoConfigGroup.autoConfig) {
|
||||
super.execute();
|
||||
return;
|
||||
}
|
||||
@@ -177,32 +151,32 @@ public class Release extends AbstractPlatformAwareModelCommand {
|
||||
.outputDirectory(getOutputDirectory())
|
||||
.dryrun(dryrun())
|
||||
.gitRootSearch(gitRootSearch)
|
||||
.projectName(projectName)
|
||||
.projectVersion(projectVersion)
|
||||
.projectVersionPattern(projectVersionPattern)
|
||||
.projectSnapshotPattern(projectSnapshotPattern)
|
||||
.projectSnapshotLabel(projectSnapshotLabel)
|
||||
.projectSnapshotFullChangelog(projectSnapshotFullChangelog)
|
||||
.tagName(tagName)
|
||||
.previousTagName(previousTagName)
|
||||
.releaseName(releaseName)
|
||||
.milestoneName(milestoneName)
|
||||
.branch(branch)
|
||||
.prerelease(prerelease)
|
||||
.prereleasePattern(prereleasePattern)
|
||||
.draft(draft)
|
||||
.overwrite(overwrite)
|
||||
.update(update)
|
||||
.projectName(autoConfigGroup.projectName)
|
||||
.projectVersion(autoConfigGroup.projectVersion)
|
||||
.projectVersionPattern(autoConfigGroup.projectVersionPattern)
|
||||
.projectSnapshotPattern(autoConfigGroup.projectSnapshotPattern)
|
||||
.projectSnapshotLabel(autoConfigGroup.projectSnapshotLabel)
|
||||
.projectSnapshotFullChangelog(autoConfigGroup.projectSnapshotFullChangelog)
|
||||
.tagName(autoConfigGroup.tagName)
|
||||
.previousTagName(autoConfigGroup.previousTagName)
|
||||
.releaseName(autoConfigGroup.releaseName)
|
||||
.milestoneName(autoConfigGroup.milestoneName)
|
||||
.branch(autoConfigGroup.branch)
|
||||
.prerelease(autoConfigGroup.prerelease)
|
||||
.prereleasePattern(autoConfigGroup.prereleasePattern)
|
||||
.draft(autoConfigGroup.draft)
|
||||
.overwrite(autoConfigGroup.overwrite)
|
||||
.update(autoConfigGroup.update)
|
||||
.updateSections(collectUpdateSections())
|
||||
.skipTag(skipTag)
|
||||
.skipRelease(skipRelease)
|
||||
.changelog(changelog)
|
||||
.changelogFormatted(changelogFormatted)
|
||||
.username(username)
|
||||
.commitAuthorName(commitAuthorName)
|
||||
.commitAuthorEmail(commitAuthorEmail)
|
||||
.signing(signing)
|
||||
.armored(armored)
|
||||
.skipTag(autoConfigGroup.skipTag)
|
||||
.skipRelease(autoConfigGroup.skipRelease)
|
||||
.changelog(autoConfigGroup.changelog)
|
||||
.changelogFormatted(autoConfigGroup.changelogFormatted)
|
||||
.username(autoConfigGroup.username)
|
||||
.commitAuthorName(autoConfigGroup.commitAuthorName)
|
||||
.commitAuthorEmail(autoConfigGroup.commitAuthorEmail)
|
||||
.signing(autoConfigGroup.signing)
|
||||
.armored(autoConfigGroup.armored)
|
||||
.files(collectFiles())
|
||||
.globs(collectGlobs())
|
||||
.selectedPlatforms(collectSelectedPlatforms())
|
||||
@@ -213,24 +187,24 @@ public class Release extends AbstractPlatformAwareModelCommand {
|
||||
|
||||
private List<String> collectFiles() {
|
||||
List<String> list = new ArrayList<>();
|
||||
if (files != null && files.length > 0) {
|
||||
Collections.addAll(list, files);
|
||||
if (autoConfigGroup.files != null && autoConfigGroup.files.length > 0) {
|
||||
Collections.addAll(list, autoConfigGroup.files);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private List<String> collectGlobs() {
|
||||
List<String> list = new ArrayList<>();
|
||||
if (globs != null && globs.length > 0) {
|
||||
Collections.addAll(list, globs);
|
||||
if (autoConfigGroup.globs != null && autoConfigGroup.globs.length > 0) {
|
||||
Collections.addAll(list, autoConfigGroup.globs);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private Set<UpdateSection> collectUpdateSections() {
|
||||
Set<UpdateSection> set = new LinkedHashSet<>();
|
||||
if (updateSections != null && updateSections.length > 0) {
|
||||
for (String updateSection : updateSections) {
|
||||
if (autoConfigGroup.updateSections != null && autoConfigGroup.updateSections.length > 0) {
|
||||
for (String updateSection : autoConfigGroup.updateSections) {
|
||||
set.add(UpdateSection.of(updateSection.trim()));
|
||||
}
|
||||
}
|
||||
@@ -240,7 +214,9 @@ public class Release extends AbstractPlatformAwareModelCommand {
|
||||
private void basedir() {
|
||||
actualBasedir = null != basedir ? basedir : Paths.get(".").normalize();
|
||||
if (!Files.exists(actualBasedir)) {
|
||||
throw halt("Missing required option: '--basedir=<basedir>'");
|
||||
throw halt(String.format(
|
||||
bundle.getString("ERROR_missing_required_option"),
|
||||
"--basedir=<basedir>"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,9 +25,7 @@ import picocli.CommandLine;
|
||||
* @author Andres Almiray
|
||||
* @since 0.1.0
|
||||
*/
|
||||
@CommandLine.Command(name = "sign",
|
||||
mixinStandardHelpOptions = true,
|
||||
description = "Sign release artifacts.")
|
||||
@CommandLine.Command(name = "sign")
|
||||
public class Sign extends AbstractPlatformAwareModelCommand {
|
||||
@Override
|
||||
protected void doExecute(JReleaserContext context) {
|
||||
|
||||
@@ -30,20 +30,18 @@ import java.nio.file.Paths;
|
||||
* @author Andres Almiray
|
||||
* @since 0.1.0
|
||||
*/
|
||||
@CommandLine.Command(name = "template",
|
||||
mixinStandardHelpOptions = true,
|
||||
description = "Generate a tool/announcer template.")
|
||||
@CommandLine.Command(name = "template")
|
||||
public class Template extends AbstractCommand {
|
||||
@CommandLine.ArgGroup(exclusive = true, multiplicity = "1")
|
||||
Composite composite;
|
||||
|
||||
static class Composite {
|
||||
@CommandLine.ArgGroup(exclusive = false, multiplicity = "0..1", order = 1,
|
||||
heading = "Announcer templates%n")
|
||||
headingKey = "announcer.header")
|
||||
Announcers announcers;
|
||||
|
||||
@CommandLine.ArgGroup(exclusive = false, multiplicity = "0..1", order = 2,
|
||||
heading = "Tool templates%n")
|
||||
headingKey = "tool.header")
|
||||
Tools tools;
|
||||
|
||||
String announcerName() {
|
||||
@@ -65,35 +63,30 @@ public class Template extends AbstractCommand {
|
||||
|
||||
static class Announcers {
|
||||
@CommandLine.Option(names = {"-an", "--announcer-name"},
|
||||
description = "The name of the announcer.",
|
||||
descriptionKey = "announcer.name",
|
||||
required = true)
|
||||
String announcerName;
|
||||
}
|
||||
|
||||
static class Tools {
|
||||
@CommandLine.Option(names = {"-dn", "--distribution-name"},
|
||||
description = "The name of the distribution.",
|
||||
required = true)
|
||||
String distributionName;
|
||||
|
||||
@CommandLine.Option(names = {"-tn", "--tool-name"},
|
||||
description = "The name of the tool.",
|
||||
required = true)
|
||||
String toolName;
|
||||
|
||||
@CommandLine.Option(names = {"-dt", "--distribution-type"},
|
||||
description = "The type of the distribution.\nDefaults to JAVA_BINARY.",
|
||||
required = true,
|
||||
defaultValue = "JAVA_BINARY")
|
||||
Distribution.DistributionType distributionType;
|
||||
}
|
||||
|
||||
@CommandLine.Option(names = {"-o", "--overwrite"},
|
||||
description = "Overwrite existing files.")
|
||||
@CommandLine.Option(names = {"-o", "--overwrite"})
|
||||
boolean overwrite;
|
||||
|
||||
@CommandLine.Option(names = {"-s", "--snapshot"},
|
||||
description = "Use snapshot templates.")
|
||||
@CommandLine.Option(names = {"-s", "--snapshot"})
|
||||
boolean snapshot;
|
||||
|
||||
@CommandLine.ParentCommand
|
||||
@@ -127,10 +120,10 @@ public class Template extends AbstractCommand {
|
||||
.generate();
|
||||
|
||||
if (null != output && !quiet) {
|
||||
logger.info("Template generated at {}", output.toAbsolutePath());
|
||||
logger.info(bundle.getString("jreleaser.template.TEXT_success"), output.toAbsolutePath());
|
||||
}
|
||||
} catch (TemplateGenerationException e) {
|
||||
throw new JReleaserException("Unexpected error", e);
|
||||
throw new JReleaserException(bundle.getString("ERROR_unexpected_error"), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,20 +25,15 @@ import picocli.CommandLine;
|
||||
* @author Andres Almiray
|
||||
* @since 0.3.0
|
||||
*/
|
||||
@CommandLine.Command(name = "upload",
|
||||
mixinStandardHelpOptions = true,
|
||||
description = "Upload all artifacts.")
|
||||
@CommandLine.Command(name = "upload")
|
||||
public class Upload extends AbstractPlatformAwareModelCommand {
|
||||
@CommandLine.Option(names = {"-y", "--dryrun"},
|
||||
description = "Skip remote operations.")
|
||||
@CommandLine.Option(names = {"-y", "--dryrun"})
|
||||
boolean dryrun;
|
||||
|
||||
@CommandLine.Option(names = {"-ut", "--uploader-type"},
|
||||
description = "The type of the uploader.")
|
||||
@CommandLine.Option(names = {"-ut", "--uploader-type"})
|
||||
String uploaderType;
|
||||
|
||||
@CommandLine.Option(names = {"-un", "--uploader-name"},
|
||||
description = "The name of the uploader.")
|
||||
@CommandLine.Option(names = {"-un", "--uploader-name"})
|
||||
String uploaderName;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,221 @@
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
# Copyright 2020-2021 The JReleaser authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
###############################################################################
|
||||
# Shared
|
||||
###############################################################################
|
||||
# header
|
||||
usage.headerHeading = JReleaser is a release automation tool for Java projects.%n
|
||||
usage.header.0 = Its goal is to simplify creating releases and publishing
|
||||
usage.header.1 = artifacts to multiple package managers while providing
|
||||
usage.header.2 = customizable options.
|
||||
usage.synopsisHeading = %nUsage:\u0020
|
||||
usage.optionListHeading = %nOptions:%n
|
||||
usage.commandListHeading = %nCommands:%n
|
||||
usage.footerHeading = %nDocumentation found at https://jreleaser.org%n
|
||||
help = Show this help message and exit.
|
||||
version = Print version information and exit.
|
||||
# options
|
||||
debug = Set log level to debug.
|
||||
info = Set log level to info.
|
||||
warn = Set log level to warn.
|
||||
quiet = Log errors only.
|
||||
basedir = Base directory.
|
||||
output-directory = Output directory.
|
||||
overwrite = Overwrite existing files.
|
||||
dryrun = Skip remote operations.
|
||||
announcer-name = The name of the announcer.
|
||||
distribution-name = The name of the distribution.
|
||||
tool-name = The name of the tool.
|
||||
# errors
|
||||
ERROR_trace_file_init = Could not initialize trace file
|
||||
ERROR_unexpected_error = Unexpected error
|
||||
|
||||
###############################################################################
|
||||
# Shared - AbstractModelCommand
|
||||
###############################################################################
|
||||
# options
|
||||
config-file = The config file.
|
||||
git-root-search = Searches for the Git root.
|
||||
set-property = Sets the value of a property. Repeatable.
|
||||
# text
|
||||
TEXT_config_file = Configuring with {}
|
||||
TEXT_basedir_set = - basedir set to {}
|
||||
# errors
|
||||
ERROR_missing_config_file = Missing required option: '--config-file=<configFile>' or local file named jreleaser[{}]
|
||||
ERROR_missing_required_option = Missing required option: '{}'
|
||||
ERROR_invalid_config_format = Invalid configuration format: {}
|
||||
ERROR_invalid_property = Invalid property '{}'
|
||||
|
||||
###############################################################################
|
||||
# Shared - AbstractPlatformAwareModelCommand
|
||||
###############################################################################
|
||||
# options
|
||||
select-current-platform = Activates paths matching the current platform.
|
||||
select-platform = Activates paths matching the given platform. Repeatable.
|
||||
|
||||
###############################################################################
|
||||
# Announce
|
||||
###############################################################################
|
||||
# header
|
||||
jreleaser.announce.usage.headerHeading =
|
||||
jreleaser.announce.usage.header = Announce a release.
|
||||
|
||||
###############################################################################
|
||||
# Assemble
|
||||
###############################################################################
|
||||
# header
|
||||
jreleaser.assemble.usage.headerHeading =
|
||||
jreleaser.assemble.usage.header = Assemble distributions.
|
||||
jreleaser.assemble.assembler-name = The name of the assembler.
|
||||
|
||||
###############################################################################
|
||||
# Changelog
|
||||
###############################################################################
|
||||
# header
|
||||
jreleaser.changelog.usage.headerHeading =
|
||||
jreleaser.changelog.usage.header = Calculate the changelog.
|
||||
|
||||
###############################################################################
|
||||
# Checksum
|
||||
###############################################################################
|
||||
# header
|
||||
jreleaser.checksum.usage.headerHeading =
|
||||
jreleaser.checksum.usage.header = Calculate checksums.
|
||||
|
||||
###############################################################################
|
||||
# Config
|
||||
###############################################################################
|
||||
# header
|
||||
jreleaser.config.usage.headerHeading =
|
||||
jreleaser.config.usage.header = Display current configuration.
|
||||
# options
|
||||
jreleaser.config.full = Display full configuration.
|
||||
jreleaser.config.assembly = Display assembly configuration.
|
||||
|
||||
###############################################################################
|
||||
# FullRelease
|
||||
###############################################################################
|
||||
# header
|
||||
jreleaser.full-release.usage.headerHeading =
|
||||
jreleaser.full-release.usage.header = Perform a full release.
|
||||
|
||||
###############################################################################
|
||||
# Init
|
||||
###############################################################################
|
||||
# header
|
||||
jreleaser.init.usage.headerHeading =
|
||||
jreleaser.init.usage.header = Create a jreleaser config file.
|
||||
# options
|
||||
jreleaser.init.format = Configuration file format.
|
||||
# text
|
||||
jreleaser.init.TEXT_writing_file = Writing file {}
|
||||
jreleaser.init.TEXT_success = JReleaser initialized at {}
|
||||
# errors
|
||||
jreleaser.init.ERROR_invalid_format = Unsupported file format. Must be one of [{}]
|
||||
jreleaser.init.ERROR_file_exists = File {} already exists and overwrite was set to false.
|
||||
|
||||
###############################################################################
|
||||
# Package
|
||||
###############################################################################
|
||||
# header
|
||||
jreleaser.package.usage.headerHeading =
|
||||
jreleaser.package.usage.header = Package all distributions.
|
||||
|
||||
###############################################################################
|
||||
# Prepare
|
||||
###############################################################################
|
||||
# header
|
||||
jreleaser.prepare.usage.headerHeading =
|
||||
jreleaser.prepare.usage.header = Prepare all distributions.
|
||||
|
||||
###############################################################################
|
||||
# Publish
|
||||
###############################################################################
|
||||
# header
|
||||
jreleaser.publish.usage.headerHeading =
|
||||
jreleaser.publish.usage.header = Publish all distributions.
|
||||
|
||||
###############################################################################
|
||||
# Release
|
||||
###############################################################################
|
||||
# header
|
||||
jreleaser.release.usage.headerHeading =
|
||||
jreleaser.release.usage.header = Create or update a release.
|
||||
jreleaser.release.auto-config.header = %nAuto Config Options:%n
|
||||
# options
|
||||
jreleaser.release.auto-config = Activate auto configuration.
|
||||
jreleaser.release.project-name = The project name.
|
||||
jreleaser.release.project-version = The project version.
|
||||
jreleaser.release.project-version-pattern = The project version pattern.
|
||||
jreleaser.release.project-snapshot-pattern = The project snapshot pattern.
|
||||
jreleaser.release.project-snapshot-label = The project snapshot label.
|
||||
jreleaser.release.project-snapshot-full-changelog = Calculate full changelog since last non-snapshot release.
|
||||
jreleaser.release.tag-name = The release tag.
|
||||
jreleaser.release.previous-tag-name = The previous release tag.
|
||||
jreleaser.release.release-name = The release name.
|
||||
jreleaser.release.milestone-name = The milestone name.
|
||||
jreleaser.release.prerelease = If the release is a prerelease.
|
||||
jreleaser.release.prerelease-pattern = The prerelease pattern.
|
||||
jreleaser.release.draft = If the release is a draft.
|
||||
jreleaser.release.overwrite = Overwrite an existing release.
|
||||
jreleaser.release.update = Update an existing release.
|
||||
jreleaser.release.update-section = Release section to be updated. Repeatable.
|
||||
jreleaser.release.skip-tag = Skip tagging the release.
|
||||
jreleaser.release.skip-release = Skip creating a release.
|
||||
jreleaser.release.branch = The release branch.
|
||||
jreleaser.release.changelog = Path to changelog file.
|
||||
jreleaser.release.changelog-formatted = Format generated changelog.
|
||||
jreleaser.release.username = Git username.
|
||||
jreleaser.release.commit-author-name = Commit author name.
|
||||
jreleaser.release.commit-author-email = Commit author e-mail.
|
||||
jreleaser.release.signing-enabled = Sign files.
|
||||
jreleaser.release.signing-armored = Generate ascii armored signatures.
|
||||
jreleaser.release.file = Input file to be uploaded. Repeatable.
|
||||
jreleaser.release.glob = Input file to be uploaded (as glob). Repeatable.
|
||||
|
||||
###############################################################################
|
||||
# Sign
|
||||
###############################################################################
|
||||
# header
|
||||
jreleaser.sign.usage.headerHeading =
|
||||
jreleaser.sign.usage.header = Sign release artifacts.
|
||||
|
||||
###############################################################################
|
||||
# Template
|
||||
###############################################################################
|
||||
# header
|
||||
jreleaser.template.usage.headerHeading =
|
||||
jreleaser.template.usage.header = Generate a tool/announcer template.
|
||||
jreleaser.template.announcer.header = Announcer templates%n
|
||||
jreleaser.template.tool.header = Tool templates%n
|
||||
# options
|
||||
jreleaser.template.distribution-type = The type of the distribution.%nDefaults to JAVA_BINARY.
|
||||
jreleaser.template.snapshot = Use snapshot templates.
|
||||
# text
|
||||
jreleaser.template.TEXT_success = Template generated at {}
|
||||
|
||||
###############################################################################
|
||||
# Upload
|
||||
###############################################################################
|
||||
# header
|
||||
jreleaser.upload.usage.headerHeading =
|
||||
jreleaser.upload.usage.header = Upload all artifacts.
|
||||
# options
|
||||
jreleaser.upload.uploader-type = The type of the uploader.
|
||||
jreleaser.upload.uploader-name = The name of the uploader.
|
||||
Reference in New Issue
Block a user