From 7846aa5bab517105a12dd63e9f6c50d25ad39fca Mon Sep 17 00:00:00 2001 From: Greg Gibeling Date: Tue, 17 Mar 2026 16:05:06 -0700 Subject: [PATCH] G2-1892 Create & publish fat jar for project (pj-cli) --- pj-cli/.gitignore | 8 +++ pj-cli/pom.xml | 62 +++++++++++++++++++ .../java/com/g2forge/project/cli/Project.java | 12 ++++ .../g2forge/project/core/IProjectCommand.java | 5 ++ .../g2forge/project/plan/create/Create.java | 5 +- .../java/com/g2forge/project/plan/Plan.java | 23 ++++++- .../com/g2forge/project/report/Billing.java | 8 ++- pom.xml | 1 + 8 files changed, 118 insertions(+), 6 deletions(-) create mode 100644 pj-cli/.gitignore create mode 100644 pj-cli/pom.xml create mode 100644 pj-cli/src/main/java/com/g2forge/project/cli/Project.java create mode 100644 pj-core/src/main/java/com/g2forge/project/core/IProjectCommand.java diff --git a/pj-cli/.gitignore b/pj-cli/.gitignore new file mode 100644 index 0000000..cf5d013 --- /dev/null +++ b/pj-cli/.gitignore @@ -0,0 +1,8 @@ +/.project +/.classpath +/.settings/ +/target/ +/bulldozer-temp.json +/bulldozer-state.json +/.factorypath +/dependency-reduced-pom.xml diff --git a/pj-cli/pom.xml b/pj-cli/pom.xml new file mode 100644 index 0000000..a92c806 --- /dev/null +++ b/pj-cli/pom.xml @@ -0,0 +1,62 @@ + + + 4.0.0 + + pj-cli + + + com.g2forge.project + pj-project + 0.0.2-SNAPSHOT + ../pj-project/pom.xml + + + Project CLI + Command line interface for Project. + + + + com.g2forge.project + pj-plan + ${project.version} + + + com.g2forge.project + pj-create + ${project.version} + + + com.g2forge.project + pj-report + ${project.version} + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.5.3 + + + package + + shade + + + + + + com.g2forge.project.cli.Project + + + + + + + + + diff --git a/pj-cli/src/main/java/com/g2forge/project/cli/Project.java b/pj-cli/src/main/java/com/g2forge/project/cli/Project.java new file mode 100644 index 0000000..ac103ed --- /dev/null +++ b/pj-cli/src/main/java/com/g2forge/project/cli/Project.java @@ -0,0 +1,12 @@ +package com.g2forge.project.cli; + +import com.g2forge.alexandria.command.command.DispatchCommand; +import com.g2forge.alexandria.command.command.IStandardCommand; +import com.g2forge.alexandria.command.command.IStructuredCommand; +import com.g2forge.project.core.IProjectCommand; + +public class Project implements IStructuredCommand { + public static void main(String[] args) throws Throwable { + IStandardCommand.main(args, DispatchCommand.createAnnotation(IProjectCommand.class)); + } +} diff --git a/pj-core/src/main/java/com/g2forge/project/core/IProjectCommand.java b/pj-core/src/main/java/com/g2forge/project/core/IProjectCommand.java new file mode 100644 index 0000000..41b5a71 --- /dev/null +++ b/pj-core/src/main/java/com/g2forge/project/core/IProjectCommand.java @@ -0,0 +1,5 @@ +package com.g2forge.project.core; + +import com.g2forge.alexandria.command.command.IStandardCommand; + +public interface IProjectCommand extends IStandardCommand {} diff --git a/pj-create/src/main/java/com/g2forge/project/plan/create/Create.java b/pj-create/src/main/java/com/g2forge/project/plan/create/Create.java index 52780a8..a3a2576 100644 --- a/pj-create/src/main/java/com/g2forge/project/plan/create/Create.java +++ b/pj-create/src/main/java/com/g2forge/project/plan/create/Create.java @@ -33,6 +33,7 @@ import com.atlassian.jira.rest.client.api.domain.input.TransitionInput; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.JsonMappingException; +import com.g2forge.alexandria.annotations.service.Service; import com.g2forge.alexandria.command.command.IStandardCommand; import com.g2forge.alexandria.command.exit.IExit; import com.g2forge.alexandria.command.invocation.CommandInvocation; @@ -44,6 +45,7 @@ import com.g2forge.gearbox.jira.JiraAPI; import com.g2forge.gearbox.jira.fields.KnownField; import com.g2forge.project.core.HConfig; +import com.g2forge.project.core.IProjectCommand; import com.g2forge.project.core.Server; import com.g2forge.project.plan.create.CreateIssue.CreateIssueBuilder; import com.google.common.base.Objects; @@ -151,7 +153,8 @@ * * */ -public class Create implements IStandardCommand { +@Service(IProjectCommand.class) +public class Create implements IProjectCommand { @Data @Builder @AllArgsConstructor diff --git a/pj-plan/src/main/java/com/g2forge/project/plan/Plan.java b/pj-plan/src/main/java/com/g2forge/project/plan/Plan.java index ea14cc8..6d1335a 100644 --- a/pj-plan/src/main/java/com/g2forge/project/plan/Plan.java +++ b/pj-plan/src/main/java/com/g2forge/project/plan/Plan.java @@ -1,13 +1,30 @@ package com.g2forge.project.plan; +import java.io.InputStream; +import java.io.PrintStream; + +import com.g2forge.alexandria.annotations.service.Service; import com.g2forge.alexandria.command.command.DispatchCommand; import com.g2forge.alexandria.command.command.IStructuredCommand; +import com.g2forge.alexandria.command.exit.IExit; +import com.g2forge.alexandria.command.invocation.CommandInvocation; +import com.g2forge.project.core.IProjectCommand; -public class Plan implements IStructuredCommand { - public static void main(String[] args) throws Throwable { +@Service(IProjectCommand.class) +public class Plan implements IProjectCommand, IStructuredCommand { + protected static DispatchCommand.ManualBuilder build() { final DispatchCommand.ManualBuilder builder = new DispatchCommand.ManualBuilder(); builder.command(new Download(), "download"); builder.command(new Sprints(), "sprints"); - builder.main(args); + return builder; + } + + public static void main(String[] args) throws Throwable { + build().main(args); + } + + @Override + public IExit invoke(CommandInvocation invocation) throws Throwable { + return build().invoke(invocation); } } diff --git a/pj-report/src/main/java/com/g2forge/project/report/Billing.java b/pj-report/src/main/java/com/g2forge/project/report/Billing.java index cc5e0ef..66bee82 100644 --- a/pj-report/src/main/java/com/g2forge/project/report/Billing.java +++ b/pj-report/src/main/java/com/g2forge/project/report/Billing.java @@ -34,6 +34,7 @@ import com.atlassian.jira.rest.client.api.domain.User; import com.g2forge.alexandria.adt.associative.cache.Cache; import com.g2forge.alexandria.adt.associative.cache.NeverCacheEvictionPolicy; +import com.g2forge.alexandria.annotations.service.Service; import com.g2forge.alexandria.command.command.IStandardCommand; import com.g2forge.alexandria.command.exit.IExit; import com.g2forge.alexandria.command.invocation.CommandInvocation; @@ -44,6 +45,7 @@ import com.g2forge.alexandria.java.function.IFunction1; import com.g2forge.alexandria.java.function.IPredicate1; import com.g2forge.alexandria.java.function.builder.IBuilder; +import com.g2forge.alexandria.java.io.dataaccess.PathDataSink; import com.g2forge.alexandria.java.io.dataaccess.PathDataSource; import com.g2forge.alexandria.log.HLog; import com.g2forge.alexandria.match.HMatch; @@ -53,6 +55,7 @@ import com.g2forge.gearbox.jira.JiraAPI; import com.g2forge.gearbox.jira.fields.KnownField; import com.g2forge.project.core.HConfig; +import com.g2forge.project.core.IProjectCommand; import com.g2forge.project.core.Server; import lombok.AllArgsConstructor; @@ -63,7 +66,8 @@ import lombok.extern.slf4j.Slf4j; @Slf4j -public class Billing implements IStandardCommand { +@Service(IProjectCommand.class) +public class Billing implements IProjectCommand { @Data @Builder(toBuilder = true) @AllArgsConstructor @@ -317,7 +321,7 @@ public IExit invoke(CommandInvocation invocation) t } final Path outputFile = Filename.replaceExtension(arguments.getRequest(), "csv"); log.info("Writing bill to {}", outputFile); - BillLine.getMapper().write(billLines, outputFile); + BillLine.getMapper().write(billLines, new PathDataSink(outputFile)); log.info("Bill by user"); for (String user : bill.getUsers()) { diff --git a/pom.xml b/pom.xml index 1ffc36e..6047163 100644 --- a/pom.xml +++ b/pom.xml @@ -21,5 +21,6 @@ pj-create pj-plan pj-report + pj-cli