Skip to content

Commit

Permalink
Use Jcommander 2.0 (#2552)
Browse files Browse the repository at this point in the history
  • Loading branch information
jianglai authored Sep 13, 2024
1 parent 0389b0d commit 352618b
Show file tree
Hide file tree
Showing 19 changed files with 166 additions and 159 deletions.
40 changes: 20 additions & 20 deletions core/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ com.google.http-client:google-http-client-apache-v2:1.45.0=compileClasspath,depl
com.google.http-client:google-http-client-appengine:1.43.3=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath
com.google.http-client:google-http-client-appengine:1.44.2=testCompileClasspath,testRuntimeClasspath
com.google.http-client:google-http-client-gson:1.45.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.http-client:google-http-client-jackson2:1.44.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath
com.google.http-client:google-http-client-jackson2:1.43.3=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath
com.google.http-client:google-http-client-jackson2:1.44.2=testCompileClasspath,testRuntimeClasspath
com.google.http-client:google-http-client-protobuf:1.44.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.http-client:google-http-client:1.45.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
Expand Down Expand Up @@ -378,24 +378,24 @@ org.apache.arrow:arrow-format:15.0.2=compileClasspath,deploy_jar,nonprodCompileC
org.apache.arrow:arrow-memory-core:15.0.2=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apache.arrow:arrow-vector:15.0.2=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apache.avro:avro:1.11.3=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apache.beam:beam-model-fn-execution:2.58.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apache.beam:beam-model-job-management:2.58.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apache.beam:beam-model-pipeline:2.58.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apache.beam:beam-model-fn-execution:2.59.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apache.beam:beam-model-job-management:2.59.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apache.beam:beam-model-pipeline:2.59.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apache.beam:beam-runners-core-construction-java:2.54.0=testCompileClasspath,testRuntimeClasspath
org.apache.beam:beam-runners-core-java:2.58.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apache.beam:beam-runners-direct-java:2.58.1=testCompileClasspath,testRuntimeClasspath
org.apache.beam:beam-runners-google-cloud-dataflow-java:2.58.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apache.beam:beam-runners-java-fn-execution:2.58.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apache.beam:beam-sdks-java-core:2.58.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apache.beam:beam-sdks-java-expansion-service:2.58.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apache.beam:beam-sdks-java-extensions-arrow:2.58.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apache.beam:beam-sdks-java-extensions-avro:2.58.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apache.beam:beam-sdks-java-extensions-google-cloud-platform-core:2.58.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apache.beam:beam-sdks-java-extensions-protobuf:2.58.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apache.beam:beam-runners-core-java:2.59.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apache.beam:beam-runners-direct-java:2.59.0=testCompileClasspath,testRuntimeClasspath
org.apache.beam:beam-runners-google-cloud-dataflow-java:2.59.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apache.beam:beam-runners-java-fn-execution:2.59.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apache.beam:beam-sdks-java-core:2.59.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apache.beam:beam-sdks-java-expansion-service:2.59.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apache.beam:beam-sdks-java-extensions-arrow:2.59.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apache.beam:beam-sdks-java-extensions-avro:2.59.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apache.beam:beam-sdks-java-extensions-google-cloud-platform-core:2.59.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apache.beam:beam-sdks-java-extensions-protobuf:2.59.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apache.beam:beam-sdks-java-fn-execution:2.54.0=testCompileClasspath,testRuntimeClasspath
org.apache.beam:beam-sdks-java-harness:2.58.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apache.beam:beam-sdks-java-io-google-cloud-platform:2.58.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apache.beam:beam-sdks-java-transform-service-launcher:2.58.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apache.beam:beam-sdks-java-harness:2.59.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apache.beam:beam-sdks-java-io-google-cloud-platform:2.59.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apache.beam:beam-sdks-java-transform-service-launcher:2.59.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apache.beam:beam-vendor-grpc-1_60_1:0.2=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apache.beam:beam-vendor-guava-32_1_2-jre:0.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apache.commons:commons-compress:1.26.2=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
Expand Down Expand Up @@ -442,8 +442,8 @@ org.eclipse.jetty:jetty-server:12.0.13=testCompileClasspath,testRuntimeClasspath
org.eclipse.jetty:jetty-session:12.0.13=testCompileClasspath,testRuntimeClasspath
org.eclipse.jetty:jetty-util:12.0.13=testCompileClasspath,testRuntimeClasspath
org.eclipse.jetty:jetty-xml:12.0.13=testCompileClasspath,testRuntimeClasspath
org.flywaydb:flyway-core:10.17.3=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.flywaydb:flyway-database-postgresql:10.17.3=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.flywaydb:flyway-core:10.18.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.flywaydb:flyway-database-postgresql:10.18.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.glassfish.jaxb:jaxb-core:4.0.2=deploy_jar,nonprodRuntimeClasspath,runtimeClasspath,testRuntimeClasspath
org.glassfish.jaxb:jaxb-runtime:4.0.2=deploy_jar,nonprodRuntimeClasspath,runtimeClasspath,testRuntimeClasspath
org.glassfish.jaxb:txw2:4.0.2=deploy_jar,nonprodRuntimeClasspath,runtimeClasspath,testRuntimeClasspath
Expand All @@ -464,7 +464,7 @@ org.jacoco:org.jacoco.core:0.8.12=jacocoAnt
org.jacoco:org.jacoco.report:0.8.12=jacocoAnt
org.javassist:javassist:3.28.0-GA=checkstyle
org.jboss.logging:jboss-logging:3.5.0.Final=deploy_jar,nonprodRuntimeClasspath,runtimeClasspath,testRuntimeClasspath
org.jcommander:jcommander:1.83=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.jcommander:jcommander:2.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-bom:1.4.0=deploy_jar,nonprodRuntimeClasspath,runtimeClasspath,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-reflect:1.6.10=annotationProcessor,testAnnotationProcessor
org.jetbrains.kotlin:kotlin-reflect:1.9.20=deploy_jar,nonprodRuntimeClasspath,runtimeClasspath,testRuntimeClasspath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ abstract class CreateOrUpdateBulkPricingPackageCommand extends MutatingCommand {
@Nullable
@Parameter(
names = "--next_billing_date",
converter = DateTimeParameter.class,
validateWith = DateTimeParameter.class,
description =
"The next date that the bulk pricing package should be billed for its annual fee")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ abstract class CreateOrUpdateDomainCommand extends MutatingEppToolCommand {
@Parameter(
names = {"-n", "--nameservers"},
description = "Comma-delimited list of nameservers, up to 13.",
converter = NameserversParameter.class,
listConverter = NameserversParameter.class,
validateWith = NameserversParameter.class)
Set<String> nameservers = new HashSet<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import google.registry.model.rde.RdeMode;
import google.registry.rde.RdeStagingAction;
import google.registry.request.Action.Service;
import google.registry.tools.params.DateTimeParameter;
import java.util.List;
import java.util.stream.Collectors;
import javax.inject.Inject;
Expand All @@ -54,8 +53,7 @@ final class GenerateEscrowDepositCommand implements Command {
@Parameter(
names = {"-w", "--watermark"},
description = "Point-in-time timestamp(s) for which time the deposit should be generated",
required = true,
converter = DateTimeParameter.class)
required = true)
private List<DateTime> watermarks;

@Parameter(
Expand Down Expand Up @@ -85,7 +83,12 @@ final class GenerateEscrowDepositCommand implements Command {

@Override
public void run() {
if (watermarks.isEmpty()) {
throw new ParameterException("At least one watermark must be specified");
}

// We need to test for cases where "--watermark=" is passed in as a parameter, because it would
// first be converted to an empty list, and as such the DateTime converter would not be called.
if (tlds.isEmpty()) {
throw new ParameterException("At least one TLD must be specified");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import google.registry.util.RegistryEnvironment;
import google.registry.util.StringGenerator;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import javax.inject.Inject;
Expand All @@ -52,7 +51,7 @@ final class SetupOteCommand extends ConfirmingCommand {
names = {"-a", "--ip_allow_list"},
description = "Comma-separated list of IP addresses or CIDR ranges.",
required = true)
private List<String> ipAllowList = new ArrayList<>();
private List<String> ipAllowList;

@Parameter(
names = {"--email"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ final class UniformRapidSuspensionCommand extends MutatingEppToolCommand {
description =
"Comma-delimited set of fully qualified host names to replace the current hosts"
+ " on the domain.",
converter = NameserversParameter.class,
listConverter = NameserversParameter.class,
validateWith = NameserversParameter.class)
private Set<String> newHosts = new HashSet<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ final class UpdateDomainCommand extends CreateOrUpdateDomainCommand {
description =
"Comma-delimited list of nameservers to add, up to 13. "
+ "Cannot be set if --nameservers is set.",
converter = NameserversParameter.class,
listConverter = NameserversParameter.class,
validateWith = NameserversParameter.class)
private Set<String> addNameservers = new HashSet<>();

Expand Down Expand Up @@ -95,7 +95,7 @@ final class UpdateDomainCommand extends CreateOrUpdateDomainCommand {
description =
"Comma-delimited list of nameservers to remove, up to 13. "
+ "Cannot be set if --nameservers is set.",
converter = NameserversParameter.class,
listConverter = NameserversParameter.class,
validateWith = NameserversParameter.class)
private Set<String> removeNameservers = new HashSet<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ void testCommand_missingTld() {

@Test
void testCommand_emptyTld() {
IllegalArgumentException thrown =
ParameterException thrown =
assertThrows(
IllegalArgumentException.class,
ParameterException.class,
() ->
runCommand(
"--tld=",
"--watermark=2017-01-01T00:00:00Z",
"--mode=thin",
"-r 42",
"-o test"));
assertThat(thrown).hasMessageThat().contains("Null or empty TLD specified");
assertThat(thrown).hasMessageThat().contains("At least one TLD must be specified");
}

@Test
Expand Down Expand Up @@ -94,11 +94,20 @@ void testCommand_missingWatermark() {

@Test
void testCommand_emptyWatermark() {
ParameterException thrown =
assertThrows(
ParameterException.class,
() -> runCommand("--tld=tld", "--watermark=", "--mode=full", "-r 42", "-o test"));
assertThat(thrown).hasMessageThat().contains("At least one watermark must be specified");
}

@Test
void testCommand_malformedWatermark() {
IllegalArgumentException thrown =
assertThrows(
IllegalArgumentException.class,
() -> runCommand("--tld=tld", "--watermark=", "--mode=full", "-r 42", "-o test"));
assertThat(thrown).hasMessageThat().contains("Invalid format: \"\"");
() -> runCommand("--tld=tld", "--watermark=blah", "--mode=full", "-r 42", "-o test"));
assertThat(thrown).hasMessageThat().contains("Invalid format: \"blah\"");
}

@Test
Expand Down
4 changes: 2 additions & 2 deletions db/buildscript-gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.15.2=classpath
com.fasterxml.jackson:jackson-bom:2.15.2=classpath
gradle.plugin.org.flywaydb:gradle-plugin-publishing:10.13.0=classpath
org.flywaydb.flyway:org.flywaydb.flyway.gradle.plugin:10.13.0=classpath
org.flywaydb:flyway-core:10.17.3=classpath
org.flywaydb:flyway-database-postgresql:10.17.3=classpath
org.flywaydb:flyway-core:10.18.0=classpath
org.flywaydb:flyway-database-postgresql:10.18.0=classpath
empty=
4 changes: 2 additions & 2 deletions db/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ org.checkerframework:checker-compat-qual:2.5.3=testCompileClasspath,testRuntimeC
org.checkerframework:checker-qual:3.12.0=checkstyle
org.checkerframework:checker-qual:3.33.0=annotationProcessor,errorprone,testAnnotationProcessor
org.checkerframework:checker-qual:3.42.0=deploy_jar,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.flywaydb:flyway-core:10.17.3=compileClasspath,deploy_jar,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.flywaydb:flyway-database-postgresql:10.17.3=compileClasspath,deploy_jar,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.flywaydb:flyway-core:10.18.0=compileClasspath,deploy_jar,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.flywaydb:flyway-database-postgresql:10.18.0=compileClasspath,deploy_jar,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.hamcrest:hamcrest-core:1.3=testCompileClasspath,testRuntimeClasspath
org.jacoco:org.jacoco.agent:0.8.12=jacocoAgent,jacocoAnt
org.jacoco:org.jacoco.ant:0.8.12=jacocoAnt
Expand Down
5 changes: 1 addition & 4 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ ext {

// CAPPED VERSIONS START HERE.

// 2.0+ versions of jcommander have breaking changes that impact how
// collections are parsed.
'org.jcommander:jcommander:[1.83, 2.0)!!',

// 6.6 is alpha.
'org.hibernate.orm:hibernate-core:[6.0,6.6)!!',
'org.hibernate.orm:hibernate-hikaricp:[6.0,6.6)!!',
Expand Down Expand Up @@ -202,6 +198,7 @@ ext {
'org.hamcrest:hamcrest-core:[2.2,)',
'org.hamcrest:hamcrest-library:[2.2,)',
'org.hamcrest:hamcrest:[2.2,)',
'org.jcommander:jcommander:[2.0,)',
'org.jline:jline:[3.0,)',
'org.joda:joda-money:[1.0.1,)',
'org.json:json:[20160810,)',
Expand Down
Loading

0 comments on commit 352618b

Please sign in to comment.