From e850778d8ec38c3374f9d6fcb7fc70a9cebfe0ba Mon Sep 17 00:00:00 2001 From: Bernardo Date: Sun, 19 Jul 2020 14:31:58 +0200 Subject: [PATCH 01/13] Snapshot --- pom.xml | 2 +- src/changes/changes.xml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 32fe84c..a015069 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ com.bernardomg.tabletop dice-cli - 1.1.0 + 1.2.0-SNAPSHOT jar Dice Notation Tools CLI diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 4867fb8..acb7953 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -18,5 +18,7 @@ Extended and improved CLI. + + \ No newline at end of file From 82c98421ef420260674b583923fec90c7de5036e Mon Sep 17 00:00:00 2001 From: Bernardo Date: Sun, 19 Jul 2020 14:36:10 +0200 Subject: [PATCH 02/13] Corrected license --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index a015069..fee3a24 100644 --- a/pom.xml +++ b/pom.xml @@ -30,8 +30,8 @@ - MIT License - http://www.opensource.org/licenses/mit-license.php + Apache v2 License + http://www.apache.org/licenses/LICENSE-2.0.html repo From 564e71734c1ad55c05a133df50eacd65c19e6b16 Mon Sep 17 00:00:00 2001 From: Bernardo Date: Thu, 8 Oct 2020 13:11:02 +0200 Subject: [PATCH 03/13] Cleaned up configuration --- pom.xml | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/pom.xml b/pom.xml index fee3a24..7973d9b 100644 --- a/pom.xml +++ b/pom.xml @@ -403,8 +403,6 @@ ${project.basedir}/src/config/checkstyle/checkstyle-rules.xml - - **/generated/**/* @@ -417,18 +415,6 @@ ${project.basedir}/src/config/findbugs/findbugs-exclude.xml - - - - org.apache.maven.plugins - maven-javadoc-plugin - - - - **/generated/**/* - - - @@ -439,10 +425,6 @@ ${project.basedir}/src/config/pmd/pmd-rules.xml - - - **/generated/**/* - From 18af2a039fd7b495d0b48b4130a354c14a26323a Mon Sep 17 00:00:00 2001 From: Bernardo Date: Thu, 8 Oct 2020 15:30:39 +0200 Subject: [PATCH 04/13] Updated CI scripts --- .github/workflows/deploy_docs.yml | 15 ++++++++++----- .github/workflows/testing.yml | 7 ++++--- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.github/workflows/deploy_docs.yml b/.github/workflows/deploy_docs.yml index 7256463..b27c8e7 100644 --- a/.github/workflows/deploy_docs.yml +++ b/.github/workflows/deploy_docs.yml @@ -21,13 +21,14 @@ jobs: shell: bash run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" id: extract_branch - - uses: actions/checkout@v2 - - name: Set up JDK 1.8 + - name: Check-out + uses: actions/checkout@v2 + - name: Set up JDK uses: actions/setup-java@v1 with: java-version: 1.8 - name: Set up Maven settings - uses: Bernardo-MG/deployment-maven-settings-action@master + uses: bernardo-mg/deployment-maven-settings-action@v1.1.2 with: version-type: ${{ steps.extract_branch.outputs.branch }} env: @@ -37,5 +38,9 @@ jobs: DEPLOY_DOCS_DEVELOP_PASSWORD: ${{ secrets.DEPLOY_DOCS_DEVELOP_PASSWORD }} DEPLOY_DOCS_SITE: ${{ secrets.DEPLOY_DOCS_SITE }} DEPLOY_DOCS_DEVELOP_SITE: ${{ secrets.DEPLOY_DOCS_DEVELOP_SITE }} - - name: Deploy docs - run: mvn site site:deploy -B -P deployment --settings settings.xml + - name: Deploy development docs + if: steps.extract_branch.outputs.branch == 'develop' + run: mvn verify site site:deploy -B -P deployment,deployment-development --settings settings.xml + - name: Deploy release docs + if: steps.extract_branch.outputs.branch == 'master' + run: mvn verify site site:deploy -B -P deployment,deployment-release --settings settings.xml diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 64aed0d..dc3e150 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -11,10 +11,11 @@ jobs: jdk: [ 8, 11, 14 ] steps: - - uses: actions/checkout@v2 - - name: Set up JDK 1.8 + - name: Check-out + uses: actions/checkout@v2 + - name: Set up JDK ${{ matrix.jdk }} uses: actions/setup-java@v1 with: java-version: ${{ matrix.jdk }} - - name: Runs tests + - name: Run all tests run: mvn clean verify From 9d4286e4f23b55b9880c42960bbd53d350c6021d Mon Sep 17 00:00:00 2001 From: Bernardo Date: Thu, 8 Oct 2020 15:49:34 +0200 Subject: [PATCH 05/13] Sorted code --- .../bernardomg/tabletop/dice/cli/Main.java | 2 +- .../dice/cli/command/package-info.java | 20 +++++++++++++++++++ .../dice/cli/{command => menu}/DiceMenu.java | 4 +++- .../tabletop/dice/cli/menu/package-info.java | 20 +++++++++++++++++++ .../dice/cli/version/package-info.java | 20 +++++++++++++++++++ 5 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/bernardomg/tabletop/dice/cli/command/package-info.java rename src/main/java/com/bernardomg/tabletop/dice/cli/{command => menu}/DiceMenu.java (86%) create mode 100644 src/main/java/com/bernardomg/tabletop/dice/cli/menu/package-info.java create mode 100644 src/main/java/com/bernardomg/tabletop/dice/cli/version/package-info.java diff --git a/src/main/java/com/bernardomg/tabletop/dice/cli/Main.java b/src/main/java/com/bernardomg/tabletop/dice/cli/Main.java index 5ef304c..531a36d 100644 --- a/src/main/java/com/bernardomg/tabletop/dice/cli/Main.java +++ b/src/main/java/com/bernardomg/tabletop/dice/cli/Main.java @@ -19,7 +19,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.bernardomg.tabletop.dice.cli.command.DiceMenu; +import com.bernardomg.tabletop.dice.cli.menu.DiceMenu; import picocli.CommandLine; diff --git a/src/main/java/com/bernardomg/tabletop/dice/cli/command/package-info.java b/src/main/java/com/bernardomg/tabletop/dice/cli/command/package-info.java new file mode 100644 index 0000000..ddc60bc --- /dev/null +++ b/src/main/java/com/bernardomg/tabletop/dice/cli/command/package-info.java @@ -0,0 +1,20 @@ +/** + * Copyright 2020 the original author or 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 + *

+ * http://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. + */ +/** + * CLI commands. + */ + +package com.bernardomg.tabletop.dice.cli.command; diff --git a/src/main/java/com/bernardomg/tabletop/dice/cli/command/DiceMenu.java b/src/main/java/com/bernardomg/tabletop/dice/cli/menu/DiceMenu.java similarity index 86% rename from src/main/java/com/bernardomg/tabletop/dice/cli/command/DiceMenu.java rename to src/main/java/com/bernardomg/tabletop/dice/cli/menu/DiceMenu.java index b4a68cc..07d9256 100644 --- a/src/main/java/com/bernardomg/tabletop/dice/cli/command/DiceMenu.java +++ b/src/main/java/com/bernardomg/tabletop/dice/cli/menu/DiceMenu.java @@ -14,8 +14,10 @@ * the License. */ -package com.bernardomg.tabletop.dice.cli.command; +package com.bernardomg.tabletop.dice.cli.menu; +import com.bernardomg.tabletop.dice.cli.command.DiceGathererCommand; +import com.bernardomg.tabletop.dice.cli.command.DiceRollCommand; import com.bernardomg.tabletop.dice.cli.version.ManifestVersionProvider; import picocli.CommandLine.Command; diff --git a/src/main/java/com/bernardomg/tabletop/dice/cli/menu/package-info.java b/src/main/java/com/bernardomg/tabletop/dice/cli/menu/package-info.java new file mode 100644 index 0000000..8d5b85e --- /dev/null +++ b/src/main/java/com/bernardomg/tabletop/dice/cli/menu/package-info.java @@ -0,0 +1,20 @@ +/** + * Copyright 2020 the original author or 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 + *

+ * http://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. + */ +/** + * CLI menu. + */ + +package com.bernardomg.tabletop.dice.cli.menu; diff --git a/src/main/java/com/bernardomg/tabletop/dice/cli/version/package-info.java b/src/main/java/com/bernardomg/tabletop/dice/cli/version/package-info.java new file mode 100644 index 0000000..1659e3b --- /dev/null +++ b/src/main/java/com/bernardomg/tabletop/dice/cli/version/package-info.java @@ -0,0 +1,20 @@ +/** + * Copyright 2020 the original author or 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 + *

+ * http://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. + */ +/** + * Components for acquiring the version. + */ + +package com.bernardomg.tabletop.dice.cli.version; From dbce8670ad5859de67585745ae2cb3f1de1f737d Mon Sep 17 00:00:00 2001 From: Bernardo Date: Thu, 8 Oct 2020 16:03:14 +0200 Subject: [PATCH 06/13] Cleaned up code --- .../cli/version/ManifestVersionProvider.java | 102 ++++++++++++++---- 1 file changed, 81 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/bernardomg/tabletop/dice/cli/version/ManifestVersionProvider.java b/src/main/java/com/bernardomg/tabletop/dice/cli/version/ManifestVersionProvider.java index e9f1ccb..dc55087 100644 --- a/src/main/java/com/bernardomg/tabletop/dice/cli/version/ManifestVersionProvider.java +++ b/src/main/java/com/bernardomg/tabletop/dice/cli/version/ManifestVersionProvider.java @@ -22,45 +22,105 @@ import java.util.jar.Attributes; import java.util.jar.Manifest; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import picocli.CommandLine; import picocli.CommandLine.IVersionProvider; -public class ManifestVersionProvider implements IVersionProvider { +/** + * Version provider based on the JAR manifest. + * + * @author Bernardo Martínez Garrido + * + */ +public final class ManifestVersionProvider implements IVersionProvider { - private static Object get(final Attributes attributes, final String key) { - return attributes.get(new Attributes.Name(key)); - } + /** + * Logger. + */ + private static final Logger LOGGER = LoggerFactory + .getLogger(ManifestVersionProvider.class); + + /** + * Project title. Used to identify the correct manifest. + */ + private static final String project = "Dice Notation Tools CLI"; public ManifestVersionProvider() { super(); } @Override - public String[] getVersion() throws Exception { + public final String[] getVersion() throws Exception { final Enumeration resources = CommandLine.class.getClassLoader() .getResources("META-INF/MANIFEST.MF"); - while (resources.hasMoreElements()) { - final URL url = resources.nextElement(); + String[] result; + Boolean found; + + result = new String[0]; + found = false; + while ((!found) && (resources.hasMoreElements())) { + final URL url; + final Manifest manifest; + final Attributes attr; + final String version; + final String finalVersion; + + url = resources.nextElement(); + try { - final Manifest manifest = new Manifest(url.openStream()); - if (isApplicableManifest(manifest)) { - final Attributes attr = manifest.getMainAttributes(); - return new String[] { get(attr, "Implementation-Title") - + " version \"" - + get(attr, "Implementation-Version") + "\"" }; - } + manifest = new Manifest(url.openStream()); } catch (final IOException ex) { - return new String[] { - "Unable to read from " + url + ": " + ex }; + LOGGER.error("Unable to read from {}", url); + // TODO: Use detailed error + throw new RuntimeException(); + } + + if (isValid(manifest)) { + attr = manifest.getMainAttributes(); + + version = "%s version %s"; + finalVersion = String.format(version, + get(attr, "Implementation-Title"), + get(attr, "Implementation-Version")); + result = new String[] { finalVersion }; + found = true; } } - return new String[0]; + + return result; } - private boolean isApplicableManifest(final Manifest manifest) { - final Attributes attributes = manifest.getMainAttributes(); - return "Dice Notation Tools CLI" - .equals(get(attributes, "Implementation-Title")); + /** + * Returns the value for the received key. + * + * @param attributes + * source to get the value + * @param key + * key to search for + * @return value for the key + */ + private final Object get(final Attributes attributes, final String key) { + return attributes.get(new Attributes.Name(key)); + } + + /** + * Checks if the manifest is the correct one. + * + * @param manifest + * manifest to check + * @return {@code true} if it is the expected manifest, {@code false} in + * other case + */ + private final Boolean isValid(final Manifest manifest) { + final Attributes attributes; + final Object title; + + attributes = manifest.getMainAttributes(); + title = get(attributes, "Implementation-Title"); + + return project.equals(title); } } From 7cf116796539ee9596980e4b79eaca7bbc0161a2 Mon Sep 17 00:00:00 2001 From: Bernardo Date: Thu, 8 Oct 2020 16:05:53 +0200 Subject: [PATCH 07/13] Added test log config --- src/test/resources/log4j2-test.xml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/test/resources/log4j2-test.xml diff --git a/src/test/resources/log4j2-test.xml b/src/test/resources/log4j2-test.xml new file mode 100644 index 0000000..cd6d5fb --- /dev/null +++ b/src/test/resources/log4j2-test.xml @@ -0,0 +1,30 @@ + + + + + + testing.log + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 26c8be1bdd8961c90f8ff0fcf5d19555ca854473 Mon Sep 17 00:00:00 2001 From: Bernardo Date: Thu, 8 Oct 2020 16:10:16 +0200 Subject: [PATCH 08/13] Corrected links --- readme.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/readme.md b/readme.md index 8a8d8cb..266f9fb 100644 --- a/readme.md +++ b/readme.md @@ -72,11 +72,11 @@ If you wish to fork or modify the code, visit the [GitHub project page][scm], wh The project has been released under the [MIT License][license]. [issues]: https://github.com/bernardo-mg/dice-notation-java-cli/issues -[javadoc-develop]: http://docs.bernardomg.com/development/maven/dice-notation-java-cli/apidocs -[javadoc-release]: http://docs.bernardomg.com/maven/dice-notation-java-cli/apidocs +[javadoc-develop]: https://docs.bernardomg.com/development/maven/dice-notation-java-cli/apidocs +[javadoc-release]: https://docs.bernardomg.com/maven/dice-notation-java-cli/apidocs [license]: https://www.opensource.org/licenses/mit-license.php [scm]: https://github.com/bernardo-mg/dice-notation-java-cli -[site-develop]: http://docs.bernardomg.com/development/maven/dice-notation-java-cli -[site-release]: http://docs.bernardomg.com/maven/dice-notation-java-cli +[site-develop]: https://docs.bernardomg.com/development/maven/dice-notation-java-cli +[site-release]: https://docs.bernardomg.com/maven/dice-notation-java-cli [dice-notation-tools]: https://github.com/Bernardo-MG/dice-notation-java From eca7b7c32c4c1542ab133975fa40c12333864821 Mon Sep 17 00:00:00 2001 From: Bernardo Date: Thu, 8 Oct 2020 16:13:26 +0200 Subject: [PATCH 09/13] Added javadocs --- .../dice/cli/command/DiceGathererCommand.java | 9 +++++++ .../dice/cli/command/DiceRollCommand.java | 25 +++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/src/main/java/com/bernardomg/tabletop/dice/cli/command/DiceGathererCommand.java b/src/main/java/com/bernardomg/tabletop/dice/cli/command/DiceGathererCommand.java index e81d603..a61b7a5 100644 --- a/src/main/java/com/bernardomg/tabletop/dice/cli/command/DiceGathererCommand.java +++ b/src/main/java/com/bernardomg/tabletop/dice/cli/command/DiceGathererCommand.java @@ -54,13 +54,22 @@ public final class DiceGathererCommand implements Runnable { private static final Logger LOGGER = LoggerFactory .getLogger(DiceGathererCommand.class); + /** + * Expression to roll. + */ @Parameters(index = "0", description = "The expression to roll", paramLabel = "EXP") private String expression; + /** + * Command specification. Used to get the line output. + */ @Spec private CommandSpec spec; + /** + * Default constructor. + */ public DiceGathererCommand() { super(); } diff --git a/src/main/java/com/bernardomg/tabletop/dice/cli/command/DiceRollCommand.java b/src/main/java/com/bernardomg/tabletop/dice/cli/command/DiceRollCommand.java index 334ed77..f134fe1 100644 --- a/src/main/java/com/bernardomg/tabletop/dice/cli/command/DiceRollCommand.java +++ b/src/main/java/com/bernardomg/tabletop/dice/cli/command/DiceRollCommand.java @@ -55,30 +55,55 @@ public final class DiceRollCommand implements Runnable { private static final Logger LOGGER = LoggerFactory .getLogger(DiceRollCommand.class); + /** + * Expression to roll. + */ @Parameters(index = "0", description = "The expression to roll", paramLabel = "EXP") private String expression; + /** + * Roll history flag. + */ @Option(names = "-history", description = "Prints the roll history", defaultValue = "false") private Boolean history; + /** + * Full history flag. + */ @Option(names = "-fullHistory", description = "Prints a detailed roll history", defaultValue = "false") private Boolean historyDetailed; + /** + * Command specification. Used to get the line output. + */ @Spec private CommandSpec spec; + /** + * Default constructor. + */ public DiceRollCommand() { super(); } + /** + * Returns the history flag. + * + * @return the history flag + */ public Boolean getHistory() { return history; } + /** + * Returns the detailed history flag. + * + * @return the detailed history flag + */ public Boolean getHistoryDetailed() { return historyDetailed; } From 3a736e6c6204087dfc1b9a70ad4b7b10e3459756 Mon Sep 17 00:00:00 2001 From: Bernardo Date: Thu, 8 Oct 2020 16:16:01 +0200 Subject: [PATCH 10/13] Removed unused config --- pom.xml | 4 ---- src/config/findbugs/findbugs-exclude.xml | 9 --------- 2 files changed, 13 deletions(-) delete mode 100644 src/config/findbugs/findbugs-exclude.xml diff --git a/pom.xml b/pom.xml index 7973d9b..802b74d 100644 --- a/pom.xml +++ b/pom.xml @@ -410,10 +410,6 @@ org.codehaus.mojo findbugs-maven-plugin - - - ${project.basedir}/src/config/findbugs/findbugs-exclude.xml - diff --git a/src/config/findbugs/findbugs-exclude.xml b/src/config/findbugs/findbugs-exclude.xml deleted file mode 100644 index d4da3ac..0000000 --- a/src/config/findbugs/findbugs-exclude.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file From a3024d0ffc6df41d2fdf65d7108a89b3a6729505 Mon Sep 17 00:00:00 2001 From: Bernardo Date: Thu, 8 Oct 2020 16:21:30 +0200 Subject: [PATCH 11/13] Added default constructor --- .../com/bernardomg/tabletop/dice/cli/menu/DiceMenu.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/com/bernardomg/tabletop/dice/cli/menu/DiceMenu.java b/src/main/java/com/bernardomg/tabletop/dice/cli/menu/DiceMenu.java index 07d9256..bfa696e 100644 --- a/src/main/java/com/bernardomg/tabletop/dice/cli/menu/DiceMenu.java +++ b/src/main/java/com/bernardomg/tabletop/dice/cli/menu/DiceMenu.java @@ -35,4 +35,11 @@ versionProvider = ManifestVersionProvider.class) public class DiceMenu { + /** + * Default constructor. + */ + public DiceMenu() { + super(); + } + } From 717da4919489c959e7d9701b9a6d0e15795f01d4 Mon Sep 17 00:00:00 2001 From: Bernardo Date: Thu, 8 Oct 2020 16:23:42 +0200 Subject: [PATCH 12/13] Updated dependencies --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 802b74d..4a8b44e 100644 --- a/pom.xml +++ b/pom.xml @@ -174,11 +174,11 @@ - 2.0.2 + 2.0.4 29.0-jre 5.6.2 - 3.3.3 - 4.4.0 + 3.5.13 + 4.5.1 2.13.3 1.7.30 2.3.1.RELEASE From b712f9189a9838bc0f1bed69a02ed54cffdf7053 Mon Sep 17 00:00:00 2001 From: Bernardo Date: Thu, 8 Oct 2020 16:29:45 +0200 Subject: [PATCH 13/13] Raised version --- pom.xml | 2 +- src/changes/changes.xml | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 4a8b44e..2f092f7 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ com.bernardomg.tabletop dice-cli - 1.2.0-SNAPSHOT + 1.1.1 jar Dice Notation Tools CLI diff --git a/src/changes/changes.xml b/src/changes/changes.xml index acb7953..a75d745 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -18,7 +18,10 @@ Extended and improved CLI. - + + + Several small corrections. + \ No newline at end of file