From 3e48e10b2d088db0f45746efbcd075d6dfd1f314 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 26 Aug 2017 23:19:52 +0100 Subject: [PATCH 01/78] version: set to 0.4.0-SNAPSHOT --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c45fd52..0169c89 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ conditional - 0.3.0 + 0.4.0-SNAPSHOT From 69cb93ca1e5563c63f9c6ee99e941a0c5892319b Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 22 Feb 2018 22:37:51 +0000 Subject: [PATCH 02/78] Add Jenkinsfile --- Jenkinsfile | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..2d06154 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,20 @@ +pipeline { + agent any + stages { + stage('Build') { + steps { + checkout([ + $class: 'GitSCM', + branches: [[name: '**']], + doGenerateSubmoduleConfigurations: false, + extensions: [[$class: 'CleanBeforeCheckout']], + submoduleCfg: [], + userRemoteConfigs: [[credentialsId: 'github-kemitix', url: 'git@github.com:kemitix/conditional.git']] + ]) + sh './mvnw clean install' + junit '**/target/surefire-reports/*.xml' + archiveArtifacts '**/target/*.jar' + } + } + } +} From 9703dddbbcb657bb0bf99629df3c32335ef1f586 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 23 Feb 2018 17:01:20 +0000 Subject: [PATCH 03/78] Simplify Jenkins checkout --- Jenkinsfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2d06154..f8c4590 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,9 +6,7 @@ pipeline { checkout([ $class: 'GitSCM', branches: [[name: '**']], - doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CleanBeforeCheckout']], - submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'github-kemitix', url: 'git@github.com:kemitix/conditional.git']] ]) sh './mvnw clean install' From dec715a5cba532fc4e56529c7c8b22d4746d64f8 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 23 Feb 2018 18:36:28 +0000 Subject: [PATCH 04/78] Upgrade kemitix-parent to 5.0.3 --- CHANGELOG | 6 ++++++ pom.xml | 43 ++++++++++++++++++++++--------------------- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index accb642..bdec8c3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,12 @@ CHANGELOG ========= +0.4.0 +----- + +* Building with Jenkins +* Upgrade `kemitix-parent` to 5.0.3 + 0.3.0 ----- diff --git a/pom.xml b/pom.xml index 6ab918b..27cd5b1 100644 --- a/pom.xml +++ b/pom.xml @@ -4,8 +4,9 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - 3.2.0 - 5-complexity + 1.8 + 4.0.1 + 5-complexity 1 1 0 @@ -14,18 +15,27 @@ 4.12 3.8.0 4.3.0 + 2.10 + 0.4.1 + 1.16.20 - net.kemitix + net.kemitix kemitix-parent - 3.2.0 + 5.0.3 conditional 0.3.0-SNAPSHOT + + org.projectlombok + lombok + ${lombok.version} + true + junit junit @@ -43,25 +53,16 @@ - net.kemitix - kemitix-checkstyle-ruleset-maven-plugin - ${kemitix-checkstyle-ruleset.version} + io.repaint.maven + tiles-maven-plugin + ${tiles-maven-plugin.version} + true - ${kemitix-checkstyle-ruleset.level} + + net.kemitix.tiles:all:${kemitix-tiles.version} + net.kemitix.checkstyle:tile:${kemitix-checkstyle.version} + - - - validate - - check - - - - - - org.eluder.coveralls - coveralls-maven-plugin - ${coveralls-maven-plugin.version} From 78e7cff5f5be5aa170d76ad54fa37e8d68e2aeaf Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 23 Feb 2018 18:50:56 +0000 Subject: [PATCH 05/78] Add jenkins stages for coverage and deployment --- Jenkinsfile | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index f8c4590..5dc041d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -14,5 +14,16 @@ pipeline { archiveArtifacts '**/target/*.jar' } } + stage('Publish Coverage') { + steps { + sh './mvnw test jacoco:report coveralls:report' + sh 'bash <(curl -s https://codecov.io/bash)' + } + } + stage('Deploy') { + steps { + sh './mvnw -Dskip-Tests=true -P release -B deploy' + } + } } } From ff3ab06d9089b59b0d8c3e3b9bb43ac20b66f304 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 23 Feb 2018 19:14:40 +0000 Subject: [PATCH 06/78] Publish Codecov first to check if that works okay --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5dc041d..ddc41ab 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,8 +16,8 @@ pipeline { } stage('Publish Coverage') { steps { - sh './mvnw test jacoco:report coveralls:report' sh 'bash <(curl -s https://codecov.io/bash)' + sh './mvnw test jacoco:report coveralls:report' } } stage('Deploy') { From 7d9f3aebae15a8f3a388cd310dac09f7f5dc9ed8 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 23 Feb 2018 19:20:49 +0000 Subject: [PATCH 07/78] Use jenkins version for codecov --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index ddc41ab..06a19f5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,7 +16,7 @@ pipeline { } stage('Publish Coverage') { steps { - sh 'bash <(curl -s https://codecov.io/bash)' + sh 'curl -s https://codecov.io/bash | bash -s' sh './mvnw test jacoco:report coveralls:report' } } From c6e19005ff3cbc622f1f83db9a074b62a7824f0e Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 23 Feb 2018 19:25:45 +0000 Subject: [PATCH 08/78] Prevent Codecov from breaking the build --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 06a19f5..7444576 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,7 +16,7 @@ pipeline { } stage('Publish Coverage') { steps { - sh 'curl -s https://codecov.io/bash | bash -s' + sh 'curl -s https://codecov.io/bash | bash -s || echo "Codecov did not collect coverage reports"' sh './mvnw test jacoco:report coveralls:report' } } From 9cccc396bea99392d81907a91db15431dfc8c593 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 23 Feb 2018 19:44:55 +0000 Subject: [PATCH 09/78] Add CODECOV_REPO_TOKEN --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7444576..29c1f92 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,7 +16,7 @@ pipeline { } stage('Publish Coverage') { steps { - sh 'curl -s https://codecov.io/bash | bash -s || echo "Codecov did not collect coverage reports"' + sh 'curl -s https://codecov.io/bash | bash -s - -t ${CODECOV_REPO_TOKEN} || echo "Codecov did not collect coverage reports"' sh './mvnw test jacoco:report coveralls:report' } } From ec7ef90268504cf3e60497c8f413a48c68f3980f Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 23 Feb 2018 20:02:17 +0000 Subject: [PATCH 10/78] Remove public coverage services --- Jenkinsfile | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 29c1f92..2bdcaa8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -14,12 +14,6 @@ pipeline { archiveArtifacts '**/target/*.jar' } } - stage('Publish Coverage') { - steps { - sh 'curl -s https://codecov.io/bash | bash -s - -t ${CODECOV_REPO_TOKEN} || echo "Codecov did not collect coverage reports"' - sh './mvnw test jacoco:report coveralls:report' - } - } stage('Deploy') { steps { sh './mvnw -Dskip-Tests=true -P release -B deploy' From 9e42c6dd4f4f3cf4bd9dbf942f5485a5b80cd247 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 23 Feb 2018 20:09:49 +0000 Subject: [PATCH 11/78] Fix Inappropriate ioctl error --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2bdcaa8..0426d2d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,7 +16,7 @@ pipeline { } stage('Deploy') { steps { - sh './mvnw -Dskip-Tests=true -P release -B deploy' + sh 'export GPG_TTY=$(tty) ./mvnw -Dskip-Tests=true -P release -B deploy' } } } From 5e13e71a6838fdd032f8f526985edb05db76f9ee Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 23 Feb 2018 20:11:23 +0000 Subject: [PATCH 12/78] Fix space in 'not a tty' error --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0426d2d..849cb09 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,7 +16,7 @@ pipeline { } stage('Deploy') { steps { - sh 'export GPG_TTY=$(tty) ./mvnw -Dskip-Tests=true -P release -B deploy' + sh 'export GPG_TTY="$(tty)" ./mvnw -Dskip-Tests=true -P release -B deploy' } } } From 5c809216b8acb70e770b1a1207be519c7a7d8cbe Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 23 Feb 2018 20:12:44 +0000 Subject: [PATCH 13/78] Remove export --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 849cb09..ecdda66 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,7 +16,7 @@ pipeline { } stage('Deploy') { steps { - sh 'export GPG_TTY="$(tty)" ./mvnw -Dskip-Tests=true -P release -B deploy' + sh 'GPG_TTY="$(tty)" ./mvnw -Dskip-Tests=true -P release -B deploy' } } } From bb0ea1ed8518b1f8fa3265aa78c37b1e5ffecd5f Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 23 Feb 2018 20:30:43 +0000 Subject: [PATCH 14/78] Experimentally disable gpg pinentry --- pom.xml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pom.xml b/pom.xml index 27cd5b1..1881fa1 100644 --- a/pom.xml +++ b/pom.xml @@ -64,6 +64,16 @@ + + org.apache.maven.plugins + maven-gpg-plugin + + + --pinentry-mode + loopback + + + From 8e5b936934caf97bee54659c0549ecd2900618d6 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 23 Feb 2018 20:33:57 +0000 Subject: [PATCH 15/78] Revert GPG_TTY --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index ecdda66..2bdcaa8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,7 +16,7 @@ pipeline { } stage('Deploy') { steps { - sh 'GPG_TTY="$(tty)" ./mvnw -Dskip-Tests=true -P release -B deploy' + sh './mvnw -Dskip-Tests=true -P release -B deploy' } } } From 541c53099a8d1cb6e35ca998a648525157bec640 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 23 Feb 2018 21:10:48 +0000 Subject: [PATCH 16/78] try using pgp-maven-plugin to sign --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2bdcaa8..6ef3368 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,7 +16,7 @@ pipeline { } stage('Deploy') { steps { - sh './mvnw -Dskip-Tests=true -P release -B deploy' + sh './mvnw -Dskip-Tests=true -P release -B org.kohsuke:pgp-maven-plugin:sign' } } } From c8a128a1dd39c0327596b90d3a096556d30d3883 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 24 Feb 2018 07:15:17 +0000 Subject: [PATCH 17/78] Specify signing key --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6ef3368..6888927 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,7 +16,7 @@ pipeline { } stage('Deploy') { steps { - sh './mvnw -Dskip-Tests=true -P release -B org.kohsuke:pgp-maven-plugin:sign' + sh './mvnw -Dskip-Tests=true -P release -B org.kohsuke:pgp-maven-plugin:sign -Dpgp.secretkey=6F626C45D8B32894' } } } From 90d250fbf8346795d50ac23b3218f1b9a38ab545 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 24 Feb 2018 07:21:21 +0000 Subject: [PATCH 18/78] Specify signing key with scheme prefix --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6888927..90e0d4a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,7 +16,7 @@ pipeline { } stage('Deploy') { steps { - sh './mvnw -Dskip-Tests=true -P release -B org.kohsuke:pgp-maven-plugin:sign -Dpgp.secretkey=6F626C45D8B32894' + sh './mvnw -Dskip-Tests=true -P release -B org.kohsuke:pgp-maven-plugin:sign -Dpgp.secretkey=keyring:id=6F626C45D8B32894' } } } From 5d8979f834781713f9fd2907453e8a68ac6aeeb6 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 24 Feb 2018 07:35:45 +0000 Subject: [PATCH 19/78] Remove key id --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 90e0d4a..6ef3368 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,7 +16,7 @@ pipeline { } stage('Deploy') { steps { - sh './mvnw -Dskip-Tests=true -P release -B org.kohsuke:pgp-maven-plugin:sign -Dpgp.secretkey=keyring:id=6F626C45D8B32894' + sh './mvnw -Dskip-Tests=true -P release -B org.kohsuke:pgp-maven-plugin:sign' } } } From ca0731ee75572ac1963572ecf49b66bfc77c6830 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 24 Feb 2018 09:28:15 +0000 Subject: [PATCH 20/78] Revert to using deploy --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6ef3368..2bdcaa8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,7 +16,7 @@ pipeline { } stage('Deploy') { steps { - sh './mvnw -Dskip-Tests=true -P release -B org.kohsuke:pgp-maven-plugin:sign' + sh './mvnw -Dskip-Tests=true -P release -B deploy' } } } From 0ef291ca6a3df6ca0349f546f323c109b9ab3294 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 24 Feb 2018 18:59:13 +0000 Subject: [PATCH 21/78] Remove custom maven-gpg-plugin --- pom.xml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/pom.xml b/pom.xml index 1881fa1..27cd5b1 100644 --- a/pom.xml +++ b/pom.xml @@ -64,16 +64,6 @@ - - org.apache.maven.plugins - maven-gpg-plugin - - - --pinentry-mode - loopback - - - From 67185acc6651fec9a0b067b684265529178cc7c9 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 24 Feb 2018 20:00:34 +0000 Subject: [PATCH 22/78] Upgrade kemitix-maven-tiles to 0.5.0-SNAPSHOT --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 27cd5b1..049dd64 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,7 @@ 3.8.0 4.3.0 2.10 - 0.4.1 + 0.5.0-SNAPSHOT 1.16.20 From 41fa2bcbe5a9e7de469f5071a625a2fa0727dcca Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 24 Feb 2018 20:38:46 +0000 Subject: [PATCH 23/78] Upgrade kemitix-maven-tiles to 0.5.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 049dd64..4ffee2b 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,7 @@ 3.8.0 4.3.0 2.10 - 0.5.0-SNAPSHOT + 0.5.0 1.16.20 From ffdc554c602405f91458d9f2dc29218b43b84153 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 24 Feb 2018 20:39:51 +0000 Subject: [PATCH 24/78] jenkins: ensure batch mode and always update snapshots --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2bdcaa8..5a3b95a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -9,14 +9,14 @@ pipeline { extensions: [[$class: 'CleanBeforeCheckout']], userRemoteConfigs: [[credentialsId: 'github-kemitix', url: 'git@github.com:kemitix/conditional.git']] ]) - sh './mvnw clean install' + sh './mvnw -B -U clean install' junit '**/target/surefire-reports/*.xml' archiveArtifacts '**/target/*.jar' } } stage('Deploy') { steps { - sh './mvnw -Dskip-Tests=true -P release -B deploy' + sh './mvnw -B -Dskip-Tests=true -P release deploy' } } } From 96782dc30383dbea26c47a6004717a6df70332f5 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 24 Feb 2018 20:45:38 +0000 Subject: [PATCH 25/78] Only deploy when on master branch --- Jenkinsfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 5a3b95a..ca52d98 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -15,6 +15,11 @@ pipeline { } } stage('Deploy') { + when { + expression { + env.GIT_BRANCH === 'master' + } + } steps { sh './mvnw -B -Dskip-Tests=true -P release deploy' } From e85657f8b42d3b30e94a830032c63a1f98a530da Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 24 Feb 2018 20:47:10 +0000 Subject: [PATCH 26/78] Only deploy when on master branch (fix syntax) --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index ca52d98..b0f4760 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -17,7 +17,7 @@ pipeline { stage('Deploy') { when { expression { - env.GIT_BRANCH === 'master' + env.GIT_BRANCH == 'master' } } steps { From 3cf89ab11cdb8481c2bc0843c733624aed65d2af Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 24 Feb 2018 20:50:21 +0000 Subject: [PATCH 27/78] Split Build stage up --- Jenkinsfile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index b0f4760..880b2ed 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,7 +1,7 @@ pipeline { agent any stages { - stage('Build') { + stage('Prepare') { steps { checkout([ $class: 'GitSCM', @@ -9,7 +9,15 @@ pipeline { extensions: [[$class: 'CleanBeforeCheckout']], userRemoteConfigs: [[credentialsId: 'github-kemitix', url: 'git@github.com:kemitix/conditional.git']] ]) + } + } + stage('Build') { + steps { sh './mvnw -B -U clean install' + } + } + stage('Reporting') { + steps { junit '**/target/surefire-reports/*.xml' archiveArtifacts '**/target/*.jar' } From 03d6860775ea3bf32e40be8ac4f3d92b2df742ea Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 24 Feb 2018 21:32:47 +0000 Subject: [PATCH 28/78] Upgrade kemitix-maven-tiles to 0.5.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4ffee2b..aa6a6f5 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,7 @@ 3.8.0 4.3.0 2.10 - 0.5.0 + 0.5.1 1.16.20 From 065c366c6893cd2d5b7f40b10fa98cd03ef86d0f Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 24 Feb 2018 22:02:13 +0000 Subject: [PATCH 29/78] travis: batch mode and update snapshots --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0d1d54a..ea42614 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ cache: directories: - "$HOME/.m2" install: true -script: "./mvnw clean install" +script: "./mvnw -B -U clean install" after_success: - sh .travis-support/coveralls.sh - bash <(curl -s https://codecov.io/bash) From ecfc3d94cf2e288f0d8995c82df9344bc2b9a24f Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 26 Feb 2018 21:06:12 +0000 Subject: [PATCH 30/78] Rewrite Jenkinsfile --- Jenkinsfile | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 880b2ed..d43fdd7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,35 +1,32 @@ +def maven(goals, modules, profiles) { + withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { + sh "mvn -U $profiles $modules $goals" + } +} + +def isBranch(branch) { + return env.GIT_BRANCH == branch +} + pipeline { agent any stages { stage('Prepare') { steps { - checkout([ - $class: 'GitSCM', - branches: [[name: '**']], - extensions: [[$class: 'CleanBeforeCheckout']], - userRemoteConfigs: [[credentialsId: 'github-kemitix', url: 'git@github.com:kemitix/conditional.git']] - ]) + git url: 'git@github.com:kemitix/condition.git', + branch: '**', + credentialsId: 'github-kemitix' } } stage('Build') { steps { - sh './mvnw -B -U clean install' - } - } - stage('Reporting') { - steps { - junit '**/target/surefire-reports/*.xml' - archiveArtifacts '**/target/*.jar' + maven("clean install", ".", "") } } stage('Deploy') { - when { - expression { - env.GIT_BRANCH == 'master' - } - } + when { expression { isBranch 'master' } } steps { - sh './mvnw -B -Dskip-Tests=true -P release deploy' + maven("deploy", allModules, "-P release") } } } From 288fbf02f459a47467cf24d29646e3b6ec94cfa6 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 26 Feb 2018 21:07:02 +0000 Subject: [PATCH 31/78] pom: upgrade kemitix-maven-tiles to 0.5.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 00dd62e..6040f8c 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,7 @@ 3.8.0 4.3.0 2.10 - 0.5.1 + 0.5.2 1.16.20 From 4f633f7e72038fe33e09ecd999114742d056b5e0 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 27 Feb 2018 06:55:23 +0000 Subject: [PATCH 32/78] jenkins: inline methods --- Jenkinsfile | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d43fdd7..65449e8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,13 +1,3 @@ -def maven(goals, modules, profiles) { - withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { - sh "mvn -U $profiles $modules $goals" - } -} - -def isBranch(branch) { - return env.GIT_BRANCH == branch -} - pipeline { agent any stages { @@ -20,13 +10,17 @@ pipeline { } stage('Build') { steps { - maven("clean install", ".", "") + withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { + sh "mvn -B -U clean install" + } } } stage('Deploy') { - when { expression { isBranch 'master' } } + when { expression { (env.GIT_BRANCH == 'master') } } steps { - maven("deploy", allModules, "-P release") + withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { + sh "mvn -B -U -P release deploy" + } } } } From 463c9586028bfed71d7673aaa66d25f91d569fe7 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 27 Feb 2018 06:56:22 +0000 Subject: [PATCH 33/78] jenkins: fix typo --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 65449e8..3efa81b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,7 +3,7 @@ pipeline { stages { stage('Prepare') { steps { - git url: 'git@github.com:kemitix/condition.git', + git url: 'git@github.com:kemitix/conditional.git', branch: '**', credentialsId: 'github-kemitix' } From 75fe1a336b89b550f0dbd53870fcd365d0ff5cee Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 4 Mar 2018 16:28:12 +0000 Subject: [PATCH 34/78] jenkins: update to latest template --- Jenkinsfile | 27 ------------------- Jenkinsfile.groovy | 67 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 27 deletions(-) delete mode 100644 Jenkinsfile create mode 100644 Jenkinsfile.groovy diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index 3efa81b..0000000 --- a/Jenkinsfile +++ /dev/null @@ -1,27 +0,0 @@ -pipeline { - agent any - stages { - stage('Prepare') { - steps { - git url: 'git@github.com:kemitix/conditional.git', - branch: '**', - credentialsId: 'github-kemitix' - } - } - stage('Build') { - steps { - withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { - sh "mvn -B -U clean install" - } - } - } - stage('Deploy') { - when { expression { (env.GIT_BRANCH == 'master') } } - steps { - withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { - sh "mvn -B -U -P release deploy" - } - } - } - } -} diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy new file mode 100644 index 0000000..8664fb9 --- /dev/null +++ b/Jenkinsfile.groovy @@ -0,0 +1,67 @@ +final String repoName = "mon" +final String repoUrl = "git@github.com:kemitix/${repoName}.git" +final String mvn = "mvn --batch-mode --update-snapshots" + +pipeline { + agent any + stages { + stage('Prepare') { + steps { + git url: repoUrl, branch: '**', credentialsId: 'github-kemitix' + } + } + stage('no SNAPSHOT in master') { + // checks that the pom version is not a snapshot when the current branch is master + // TODO: also check for SNAPSHOT when is a pull request with master as the target branch + when { + expression { + (env.GIT_BRANCH == 'master') && + (readMavenPom(file: 'pom.xml').version).contains("SNAPSHOT") } + } + steps { + error("Build failed because SNAPSHOT version") + } + } + stage('Build') { + parallel { + stage('Java 8') { + steps { + withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { + sh "${mvn} clean install" + } + } + } + stage('Java 9') { + steps { + withMaven(maven: 'maven 3.5.2', jdk: 'JDK 9') { + sh 'mvn clean install' + } + } + } + } + } + stage('Test Results') { + steps { + junit '**/target/surefire-reports/*.xml' + } + } + stage('Archiving') { + steps { + archiveArtifacts '**/target/*.jar' + } + } + stage('Coverage') { + steps { + jacoco(execPattern: '**/target/jacoco.exec') + } + } + stage('Deploy') { + when { expression { (env.GIT_BRANCH == 'master') } } + steps { + withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { + sh "${mvn} deploy --activate-profiles release -DskipTests=true" + } + } + } + } +} From 9df27f80655703c1444f8b67d5502a963daa3afb Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 4 Mar 2018 18:18:00 +0000 Subject: [PATCH 35/78] lombok.config: added to prevent generated annotation --- lombok.config | 1 + 1 file changed, 1 insertion(+) create mode 100644 lombok.config diff --git a/lombok.config b/lombok.config new file mode 100644 index 0000000..00ebb3e --- /dev/null +++ b/lombok.config @@ -0,0 +1 @@ +lombok.addGeneratedAnnotation=false From 61ceec90fccde3f8fc868c5666770863df820dd7 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 4 Mar 2018 18:18:16 +0000 Subject: [PATCH 36/78] jenkins: fix repo name --- Jenkinsfile.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy index 8664fb9..871e9a5 100644 --- a/Jenkinsfile.groovy +++ b/Jenkinsfile.groovy @@ -1,4 +1,4 @@ -final String repoName = "mon" +final String repoName = "conditional" final String repoUrl = "git@github.com:kemitix/${repoName}.git" final String mvn = "mvn --batch-mode --update-snapshots" From 6a4cd3cd2f7b2b7b77524d8ed86aebd8000b576a Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 4 Mar 2018 18:18:49 +0000 Subject: [PATCH 37/78] jenkins: deploy using Java 9 --- Jenkinsfile.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy index 871e9a5..a62f310 100644 --- a/Jenkinsfile.groovy +++ b/Jenkinsfile.groovy @@ -58,7 +58,7 @@ pipeline { stage('Deploy') { when { expression { (env.GIT_BRANCH == 'master') } } steps { - withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { + withMaven(maven: 'maven 3.5.2', jdk: 'JDK 9') { sh "${mvn} deploy --activate-profiles release -DskipTests=true" } } From 3d0a51a7387de006f89c7609aca133e9db06e791 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 5 Mar 2018 07:03:40 +0000 Subject: [PATCH 38/78] Upgrade assertj to 3.9.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6040f8c..c28838f 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ 100 100 4.12 - 3.8.0 + 3.9.1 4.3.0 2.10 0.5.2 From 975acaa7177aa60d651463e46b924fe696d028c0 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 5 Mar 2018 07:04:36 +0000 Subject: [PATCH 39/78] Upgrade kemitix-parent to 5.1.0 * Add javadoc, source and nexus-staging plugins --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c28838f..eec70ef 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ net.kemitix kemitix-parent - 5.0.3 + 5.1.0 conditional From afb01c773f5652a3278aee8a86dec5987986e20d Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 5 Mar 2018 07:08:30 +0000 Subject: [PATCH 40/78] Upgrade kemitix-maven-tiles to 0.6.1 * testing: downgrade surefire and failsafe --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index eec70ef..f206829 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,7 @@ 3.9.1 4.3.0 2.10 - 0.5.2 + 0.6.1 1.16.20 From b702387bca2b86b06b64d31f88e7561a2af463e5 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 5 Mar 2018 07:21:13 +0000 Subject: [PATCH 41/78] maven-failsafe-plugin: override version to 2.20.1 Required for java 9 compatibility --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index f206829..976408e 100644 --- a/pom.xml +++ b/pom.xml @@ -17,6 +17,7 @@ 4.3.0 2.10 0.6.1 + 2.20.1 1.16.20 From e98cd2e29619a46d6176ca10420e5569733d3fbd Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 5 Mar 2018 19:53:49 +0000 Subject: [PATCH 42/78] Remove explicit git checkout stage --- Jenkinsfile.groovy | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy index a62f310..84286e7 100644 --- a/Jenkinsfile.groovy +++ b/Jenkinsfile.groovy @@ -1,15 +1,8 @@ -final String repoName = "conditional" -final String repoUrl = "git@github.com:kemitix/${repoName}.git" final String mvn = "mvn --batch-mode --update-snapshots" pipeline { agent any stages { - stage('Prepare') { - steps { - git url: repoUrl, branch: '**', credentialsId: 'github-kemitix' - } - } stage('no SNAPSHOT in master') { // checks that the pom version is not a snapshot when the current branch is master // TODO: also check for SNAPSHOT when is a pull request with master as the target branch From f16155d1d4c1c0194e73cceca7118a64effdc93d Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 5 Mar 2018 19:31:51 +0000 Subject: [PATCH 43/78] Publish Javadocs HTML --- Jenkinsfile.groovy | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy index 84286e7..9bf3d0f 100644 --- a/Jenkinsfile.groovy +++ b/Jenkinsfile.groovy @@ -43,9 +43,25 @@ pipeline { archiveArtifacts '**/target/*.jar' } } - stage('Coverage') { + stage('Javadoc') { steps { - jacoco(execPattern: '**/target/jacoco.exec') + withMaven(maven: 'maven 3.5.2', jdk: 'JDK 9') { + sh "${mvn} -P release javadoc:javadoc" + } + publishHTML([ + allowMissing: false, + alwaysLinkToLastBuild: false, + keepAll: false, + reportDir: 'target/site/apidocs/', + reportFiles: 'index.html', + reportName: 'Javadocs', + reportTitles: '' + ]) + } + } + stage('Quality') { + steps { + jacoco exclusionPattern: '**/*{Test|IT|Main|Application|Immutable}.class' } } stage('Deploy') { From d8cc0011ff06e4a276673a534bde2dfee4d8723d Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 5 Mar 2018 19:59:52 +0000 Subject: [PATCH 44/78] Upgrade maven-surefire-plugin to 2.20.1 --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index 976408e..d71e264 100644 --- a/pom.xml +++ b/pom.xml @@ -17,6 +17,7 @@ 4.3.0 2.10 0.6.1 + 2.20.1 2.20.1 1.16.20 From 7ac00c9b31e16c1630812889445d9b7913282614 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 6 Mar 2018 07:15:02 +0000 Subject: [PATCH 45/78] jenkins: javadoc: better page for nesting iframe --- Jenkinsfile.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy index 9bf3d0f..d9f6dea 100644 --- a/Jenkinsfile.groovy +++ b/Jenkinsfile.groovy @@ -53,7 +53,7 @@ pipeline { alwaysLinkToLastBuild: false, keepAll: false, reportDir: 'target/site/apidocs/', - reportFiles: 'index.html', + reportFiles: 'allclasses-noframe.html', reportName: 'Javadocs', reportTitles: '' ]) From 1ca92fde1a82d7d681a16619eb941a178266eb5e Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 6 Mar 2018 18:52:57 +0000 Subject: [PATCH 46/78] jenkins: use index.html for javadocs --- Jenkinsfile.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy index d9f6dea..9bf3d0f 100644 --- a/Jenkinsfile.groovy +++ b/Jenkinsfile.groovy @@ -53,7 +53,7 @@ pipeline { alwaysLinkToLastBuild: false, keepAll: false, reportDir: 'target/site/apidocs/', - reportFiles: 'allclasses-noframe.html', + reportFiles: 'index.html', reportName: 'Javadocs', reportTitles: '' ]) From 1cc338b737dc00365c3ec16435fbfb2e5364413c Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 6 Mar 2018 19:44:37 +0000 Subject: [PATCH 47/78] jenkins: remove javadoc --- Jenkinsfile.groovy | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy index 9bf3d0f..997d8a1 100644 --- a/Jenkinsfile.groovy +++ b/Jenkinsfile.groovy @@ -43,22 +43,6 @@ pipeline { archiveArtifacts '**/target/*.jar' } } - stage('Javadoc') { - steps { - withMaven(maven: 'maven 3.5.2', jdk: 'JDK 9') { - sh "${mvn} -P release javadoc:javadoc" - } - publishHTML([ - allowMissing: false, - alwaysLinkToLastBuild: false, - keepAll: false, - reportDir: 'target/site/apidocs/', - reportFiles: 'index.html', - reportName: 'Javadocs', - reportTitles: '' - ]) - } - } stage('Quality') { steps { jacoco exclusionPattern: '**/*{Test|IT|Main|Application|Immutable}.class' From c37dd12eb2b0366f19f92dcf2e99a1ef90d34163 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 5 Mar 2018 20:29:12 +0000 Subject: [PATCH 48/78] Add pmd reporting Merge jacoco into testing --- Jenkinsfile.groovy | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy index 997d8a1..2d9f47d 100644 --- a/Jenkinsfile.groovy +++ b/Jenkinsfile.groovy @@ -36,6 +36,7 @@ pipeline { stage('Test Results') { steps { junit '**/target/surefire-reports/*.xml' + jacoco exclusionPattern: '**/*{Test|IT|Main|Application|Immutable}.class' } } stage('Archiving') { @@ -45,7 +46,7 @@ pipeline { } stage('Quality') { steps { - jacoco exclusionPattern: '**/*{Test|IT|Main|Application|Immutable}.class' + pmd canComputeNew: false, defaultEncoding: '', healthy: '', pattern: '', unHealthy: '' } } stage('Deploy') { From 140f758609e0abadbcbda768d726359ec5a508da Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 6 Mar 2018 21:38:54 +0000 Subject: [PATCH 49/78] jenkins: run java 9 with maven options --- Jenkinsfile.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy index 2d9f47d..5b711b4 100644 --- a/Jenkinsfile.groovy +++ b/Jenkinsfile.groovy @@ -27,7 +27,7 @@ pipeline { stage('Java 9') { steps { withMaven(maven: 'maven 3.5.2', jdk: 'JDK 9') { - sh 'mvn clean install' + sh "${mvn} clean install" } } } From 836f2c550489b5c31e5107f9bb1356da5459eb49 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 6 Mar 2018 22:21:24 +0000 Subject: [PATCH 50/78] jenkins: codacy: add coverage-reporter --- Jenkinsfile.groovy | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy index 5b711b4..ef372a4 100644 --- a/Jenkinsfile.groovy +++ b/Jenkinsfile.groovy @@ -37,6 +37,13 @@ pipeline { steps { junit '**/target/surefire-reports/*.xml' jacoco exclusionPattern: '**/*{Test|IT|Main|Application|Immutable}.class' + withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { + sh "${mvn} com.gavinmogan:codacy-maven-plugin:coverage " + + "-DcoverageReportFile=target/site/jacoco/jacoco.xml " + + "-DprojectToken=`$JENKINS_HOME/codacy/token` " + + "-DapiToken=`$JENKINS_HOME/codacy/apitoken` " + + "-Dcommit=`git rev-parse HEAD`" + } } } stage('Archiving') { From 5101768f576d0e0b98e86d7559a3f9ebc3a1ee86 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Wed, 7 Mar 2018 23:13:37 +0000 Subject: [PATCH 51/78] Upgrade kemitix-maven-tiles to 0.7.1 * kemitix-pmd-ruleset 0.2.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d71e264..e4e2b9c 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,7 @@ 3.9.1 4.3.0 2.10 - 0.6.1 + 0.7.1 2.20.1 2.20.1 1.16.20 From b6801cf89e30fe4a873e149961815193c3e92322 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Wed, 7 Mar 2018 07:49:01 +0000 Subject: [PATCH 52/78] Replace Runnable with new Action interface --- .../java/net/kemitix/conditional/Action.java | 36 +++++++++++++++++++ .../net/kemitix/conditional/Condition.java | 4 +-- .../kemitix/conditional/FalseCondition.java | 6 ++-- .../kemitix/conditional/TrueCondition.java | 6 ++-- .../kemitix/conditional/ConditionalTest.java | 4 +-- 5 files changed, 46 insertions(+), 10 deletions(-) create mode 100644 src/main/java/net/kemitix/conditional/Action.java diff --git a/src/main/java/net/kemitix/conditional/Action.java b/src/main/java/net/kemitix/conditional/Action.java new file mode 100644 index 0000000..67508e5 --- /dev/null +++ b/src/main/java/net/kemitix/conditional/Action.java @@ -0,0 +1,36 @@ +/** + * The MIT License (MIT) + * + * Copyright (c) 2017 Paul Campbell + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies + * or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE + * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package net.kemitix.conditional; + +/** + * An action to perform in a clause when a {@link Condition} is met. + * + * @author Paul Campbell (pcampbell@kemitix.net) + */ +@FunctionalInterface +public interface Action { + + /** + * The action to perform. + */ + void perform(); +} diff --git a/src/main/java/net/kemitix/conditional/Condition.java b/src/main/java/net/kemitix/conditional/Condition.java index 7129574..f0523bf 100644 --- a/src/main/java/net/kemitix/conditional/Condition.java +++ b/src/main/java/net/kemitix/conditional/Condition.java @@ -98,14 +98,14 @@ public interface Condition { * * @return the Condition */ - Condition then(Runnable response); + Condition then(Action response); /** * Perform this response if the {@code Condition} is {@code false}. * * @param response the response to perform */ - void otherwise(Runnable response); + void otherwise(Action response); /** * Create a new {@code Condition} for the clause as a continuation to an existing {@code Condition}. diff --git a/src/main/java/net/kemitix/conditional/FalseCondition.java b/src/main/java/net/kemitix/conditional/FalseCondition.java index 165a649..0d8837c 100644 --- a/src/main/java/net/kemitix/conditional/FalseCondition.java +++ b/src/main/java/net/kemitix/conditional/FalseCondition.java @@ -41,13 +41,13 @@ final class FalseCondition implements Condition { } @Override - public Condition then(final Runnable response) { + public Condition then(final Action response) { return FALSE; } @Override - public void otherwise(final Runnable response) { - response.run(); + public void otherwise(final Action response) { + response.perform(); } } diff --git a/src/main/java/net/kemitix/conditional/TrueCondition.java b/src/main/java/net/kemitix/conditional/TrueCondition.java index d2132d1..ce2fbac 100644 --- a/src/main/java/net/kemitix/conditional/TrueCondition.java +++ b/src/main/java/net/kemitix/conditional/TrueCondition.java @@ -41,13 +41,13 @@ final class TrueCondition implements Condition { } @Override - public Condition then(final Runnable response) { - response.run(); + public Condition then(final Action response) { + response.perform(); return TRUE; } @Override - public void otherwise(final Runnable response) { + public void otherwise(final Action response) { // do nothing } diff --git a/src/test/java/net/kemitix/conditional/ConditionalTest.java b/src/test/java/net/kemitix/conditional/ConditionalTest.java index 0093cd4..525c534 100644 --- a/src/test/java/net/kemitix/conditional/ConditionalTest.java +++ b/src/test/java/net/kemitix/conditional/ConditionalTest.java @@ -10,9 +10,9 @@ import static org.assertj.core.api.Assertions.assertThat; */ public class ConditionalTest { - private Runnable thenResponse; + private Action thenResponse; - private Runnable otherwiseResponse; + private Action otherwiseResponse; private boolean thenFlag; From b5a225af6989fa788cde280bf3054a9dc4419ebc Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Wed, 7 Mar 2018 18:11:28 +0000 Subject: [PATCH 53/78] pmd: suppress short method name warning --- src/main/java/net/kemitix/conditional/Condition.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/net/kemitix/conditional/Condition.java b/src/main/java/net/kemitix/conditional/Condition.java index f0523bf..000268c 100644 --- a/src/main/java/net/kemitix/conditional/Condition.java +++ b/src/main/java/net/kemitix/conditional/Condition.java @@ -78,6 +78,7 @@ public interface Condition { * * @return the Condition */ + @SuppressWarnings("PMD.ShortMethodName") Condition or(boolean clause); /** From b48c9b9ee99b5941eeee7bd3064823d0179009e9 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Wed, 7 Mar 2018 18:22:37 +0000 Subject: [PATCH 54/78] jenkins: run static code analysis before compiling --- Jenkinsfile.groovy | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy index ef372a4..76a7ac8 100644 --- a/Jenkinsfile.groovy +++ b/Jenkinsfile.groovy @@ -15,6 +15,14 @@ pipeline { error("Build failed because SNAPSHOT version") } } + stage('Static Code Analysis') { + steps { + withMaven(maven: 'maven-3.5.2', jdk: 'JDK 1.8') { + sh "${mvn} checkstyle:checkstyle pmd:pmd" + } + pmd canComputeNew: false, defaultEncoding: '', healthy: '', pattern: '', unHealthy: '' + } + } stage('Build') { parallel { stage('Java 8') { @@ -51,15 +59,10 @@ pipeline { archiveArtifacts '**/target/*.jar' } } - stage('Quality') { - steps { - pmd canComputeNew: false, defaultEncoding: '', healthy: '', pattern: '', unHealthy: '' - } - } stage('Deploy') { when { expression { (env.GIT_BRANCH == 'master') } } steps { - withMaven(maven: 'maven 3.5.2', jdk: 'JDK 9') { + withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { sh "${mvn} deploy --activate-profiles release -DskipTests=true" } } From 74cdaa851f828af695c10063346adfa364bbdcbf Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Wed, 7 Mar 2018 18:25:56 +0000 Subject: [PATCH 55/78] jenkins: compile code before static code analysis --- Jenkinsfile.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy index 76a7ac8..e799493 100644 --- a/Jenkinsfile.groovy +++ b/Jenkinsfile.groovy @@ -17,8 +17,8 @@ pipeline { } stage('Static Code Analysis') { steps { - withMaven(maven: 'maven-3.5.2', jdk: 'JDK 1.8') { - sh "${mvn} checkstyle:checkstyle pmd:pmd" + withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { + sh "${mvn} compile checkstyle:checkstyle pmd:pmd" } pmd canComputeNew: false, defaultEncoding: '', healthy: '', pattern: '', unHealthy: '' } From f596984fa59648fe6c4d83d33dc97a2b2649bc56 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Wed, 7 Mar 2018 18:38:08 +0000 Subject: [PATCH 56/78] Fix PMD warnings --- src/main/java/net/kemitix/conditional/FalseCondition.java | 3 ++- src/main/java/net/kemitix/conditional/FalseValueClause.java | 1 + src/main/java/net/kemitix/conditional/TrueCondition.java | 3 ++- src/main/java/net/kemitix/conditional/TrueValueClause.java | 3 ++- src/main/java/net/kemitix/conditional/Value.java | 2 ++ 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/kemitix/conditional/FalseCondition.java b/src/main/java/net/kemitix/conditional/FalseCondition.java index 0d8837c..07881c7 100644 --- a/src/main/java/net/kemitix/conditional/FalseCondition.java +++ b/src/main/java/net/kemitix/conditional/FalseCondition.java @@ -28,7 +28,7 @@ package net.kemitix.conditional; */ final class FalseCondition implements Condition { - protected static final Condition FALSE = new net.kemitix.conditional.FalseCondition(); + public static final Condition FALSE = new net.kemitix.conditional.FalseCondition(); @Override public Condition and(final boolean clause) { @@ -36,6 +36,7 @@ final class FalseCondition implements Condition { } @Override + @SuppressWarnings("PMD.ShortMethodName") public Condition or(final boolean secondClause) { return Condition.where(secondClause); } diff --git a/src/main/java/net/kemitix/conditional/FalseValueClause.java b/src/main/java/net/kemitix/conditional/FalseValueClause.java index e0143e0..672d285 100644 --- a/src/main/java/net/kemitix/conditional/FalseValueClause.java +++ b/src/main/java/net/kemitix/conditional/FalseValueClause.java @@ -45,6 +45,7 @@ class FalseValueClause implements Value.ValueClause { } @Override + @SuppressWarnings("PMD.ShortMethodName") public Value.ValueClause or(final boolean clause) { return Value.where(clause); } diff --git a/src/main/java/net/kemitix/conditional/TrueCondition.java b/src/main/java/net/kemitix/conditional/TrueCondition.java index ce2fbac..06f041b 100644 --- a/src/main/java/net/kemitix/conditional/TrueCondition.java +++ b/src/main/java/net/kemitix/conditional/TrueCondition.java @@ -28,7 +28,7 @@ package net.kemitix.conditional; */ final class TrueCondition implements Condition { - protected static final Condition TRUE = new net.kemitix.conditional.TrueCondition(); + public static final Condition TRUE = new net.kemitix.conditional.TrueCondition(); @Override public Condition and(final boolean clause) { @@ -36,6 +36,7 @@ final class TrueCondition implements Condition { } @Override + @SuppressWarnings("PMD.ShortMethodName") public Condition or(final boolean secondClause) { return TRUE; } diff --git a/src/main/java/net/kemitix/conditional/TrueValueClause.java b/src/main/java/net/kemitix/conditional/TrueValueClause.java index c98f2be..9d3fbcc 100644 --- a/src/main/java/net/kemitix/conditional/TrueValueClause.java +++ b/src/main/java/net/kemitix/conditional/TrueValueClause.java @@ -47,6 +47,7 @@ class TrueValueClause implements Value.ValueClause { } @Override + @SuppressWarnings("PMD.ShortMethodName") public Value.ValueClause or(final boolean clause) { return this; } @@ -57,7 +58,7 @@ class TrueValueClause implements Value.ValueClause { @RequiredArgsConstructor private class TrueValueSupplier implements ValueSupplier { - private final Supplier valueSupplier; + private final transient Supplier valueSupplier; @Override public T otherwise(final Supplier falseSupplier) { diff --git a/src/main/java/net/kemitix/conditional/Value.java b/src/main/java/net/kemitix/conditional/Value.java index 6345564..9b1c3b6 100644 --- a/src/main/java/net/kemitix/conditional/Value.java +++ b/src/main/java/net/kemitix/conditional/Value.java @@ -41,6 +41,7 @@ public interface Value { * * @return the value from either the trueSupplier or the falseSupplier */ + @SuppressWarnings("PMD.LawOfDemeter") static T where( boolean clause, Supplier trueSupplier, @@ -123,6 +124,7 @@ public interface Value { * * @return a true or false value clause */ + @SuppressWarnings("PMD.ShortMethodName") ValueClause or(boolean clause); /** From d87008e3a567a901866759b7295c4b7878b8b930 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 27 Feb 2018 18:51:43 +0000 Subject: [PATCH 57/78] Add pmd-strict tile --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index e4e2b9c..18f42b7 100644 --- a/pom.xml +++ b/pom.xml @@ -62,6 +62,7 @@ net.kemitix.tiles:all:${kemitix-tiles.version} + net.kemitix.tiles:pmd-strict:${kemitix-tiles.version} net.kemitix.checkstyle:tile:${kemitix-checkstyle.version} From fd78eeece6fcea23c6a09fd3225e64c7aabde67e Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 8 Mar 2018 22:25:39 +0000 Subject: [PATCH 58/78] jenkins: report environment, no snapshots in PRs to master and only deploy from https repos --- Jenkinsfile.groovy | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy index e799493..02c109f 100644 --- a/Jenkinsfile.groovy +++ b/Jenkinsfile.groovy @@ -3,12 +3,16 @@ final String mvn = "mvn --batch-mode --update-snapshots" pipeline { agent any stages { + stage('Environment') { + steps { + sh 'set' + } + } stage('no SNAPSHOT in master') { - // checks that the pom version is not a snapshot when the current branch is master - // TODO: also check for SNAPSHOT when is a pull request with master as the target branch + // checks that the pom version is not a snapshot when the current or target branch is master when { expression { - (env.GIT_BRANCH == 'master') && + (env.GIT_BRANCH == 'master' || env.CHANGE_TARGET == 'master') && (readMavenPom(file: 'pom.xml').version).contains("SNAPSHOT") } } steps { @@ -60,7 +64,7 @@ pipeline { } } stage('Deploy') { - when { expression { (env.GIT_BRANCH == 'master') } } + when { expression { (env.GIT_BRANCH == 'master' && env.GIT_URL.startsWith('https://')) } } steps { withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { sh "${mvn} deploy --activate-profiles release -DskipTests=true" From 02ab4eaada6f8fb8935d88d94b20115c704c5d0c Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 10 Mar 2018 08:09:27 +0000 Subject: [PATCH 59/78] jenkins: Don't build java in parallel and only enter stages when suitable files found --- Jenkinsfile.groovy | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy index 02c109f..268e49c 100644 --- a/Jenkinsfile.groovy +++ b/Jenkinsfile.groovy @@ -13,13 +13,15 @@ pipeline { when { expression { (env.GIT_BRANCH == 'master' || env.CHANGE_TARGET == 'master') && - (readMavenPom(file: 'pom.xml').version).contains("SNAPSHOT") } + (readMavenPom(file: 'pom.xml').version).contains("SNAPSHOT") + } } steps { error("Build failed because SNAPSHOT version") } } stage('Static Code Analysis') { + when { expression { findFiles(glob: '**/src/main/java/*.java').length > 0 } } steps { withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { sh "${mvn} compile checkstyle:checkstyle pmd:pmd" @@ -27,25 +29,22 @@ pipeline { pmd canComputeNew: false, defaultEncoding: '', healthy: '', pattern: '', unHealthy: '' } } - stage('Build') { - parallel { - stage('Java 8') { - steps { - withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { - sh "${mvn} clean install" - } - } + stage('Build Java 9') { + steps { + withMaven(maven: 'maven 3.5.2', jdk: 'JDK 9') { + sh "${mvn} clean install" } - stage('Java 9') { - steps { - withMaven(maven: 'maven 3.5.2', jdk: 'JDK 9') { - sh "${mvn} clean install" - } - } + } + } + stage('Build Java 8') { + steps { + withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { + sh "${mvn} clean install" } } } stage('Test Results') { + when { expression { findFiles(glob: '**/target/surefire-reports/*.xml').length > 0 } } steps { junit '**/target/surefire-reports/*.xml' jacoco exclusionPattern: '**/*{Test|IT|Main|Application|Immutable}.class' @@ -59,6 +58,7 @@ pipeline { } } stage('Archiving') { + when { expression { findFiles(glob: '**/target/*.jar').length > 0 } } steps { archiveArtifacts '**/target/*.jar' } From 1439dcdb5e566d8f3dfaa89448d7732c87aeb323 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 10 Mar 2018 17:02:25 +0000 Subject: [PATCH 60/78] jenkins: check code with sonarqube --- Jenkinsfile.groovy | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy index 268e49c..298e7de 100644 --- a/Jenkinsfile.groovy +++ b/Jenkinsfile.groovy @@ -24,7 +24,9 @@ pipeline { when { expression { findFiles(glob: '**/src/main/java/*.java').length > 0 } } steps { withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { - sh "${mvn} compile checkstyle:checkstyle pmd:pmd" + withSonarQubeEnv('sonarqube') { + sh "${mvn} compile checkstyle:checkstyle pmd:pmd org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.0.905:sonar" + } } pmd canComputeNew: false, defaultEncoding: '', healthy: '', pattern: '', unHealthy: '' } From 8619824c41546c1fa4343d58ffe20ea41bc2281c Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 10 Mar 2018 17:04:56 +0000 Subject: [PATCH 61/78] jenkins: try to log java files --- Jenkinsfile.groovy | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy index 298e7de..fcc9346 100644 --- a/Jenkinsfile.groovy +++ b/Jenkinsfile.groovy @@ -21,14 +21,17 @@ pipeline { } } stage('Static Code Analysis') { - when { expression { findFiles(glob: '**/src/main/java/*.java').length > 0 } } + when { expression { findFiles(glob: '**/src/main/java/**/*.java').length > 0 } } steps { withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { + sh "${mvn} compile" + sh "${mvn} checkstyle:checkstyle" + sh "${mvn} pmd:pmd" + pmd canComputeNew: false, defaultEncoding: '', healthy: '', pattern: '', unHealthy: '' withSonarQubeEnv('sonarqube') { - sh "${mvn} compile checkstyle:checkstyle pmd:pmd org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.0.905:sonar" + sh "${mvn} org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.0.905:sonar" } } - pmd canComputeNew: false, defaultEncoding: '', healthy: '', pattern: '', unHealthy: '' } } stage('Build Java 9') { From 12f314396dc40d9a409f97b6487d6bf8dc2028ff Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 10 Mar 2018 18:09:03 +0000 Subject: [PATCH 62/78] jenkins: Use jeneric maven and jdk names --- Jenkinsfile.groovy | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy index fcc9346..7198d71 100644 --- a/Jenkinsfile.groovy +++ b/Jenkinsfile.groovy @@ -23,7 +23,7 @@ pipeline { stage('Static Code Analysis') { when { expression { findFiles(glob: '**/src/main/java/**/*.java').length > 0 } } steps { - withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { + withMaven(maven: 'maven', jdk: 'JDK LTS') { sh "${mvn} compile" sh "${mvn} checkstyle:checkstyle" sh "${mvn} pmd:pmd" @@ -34,16 +34,16 @@ pipeline { } } } - stage('Build Java 9') { + stage('Build Java Next') { steps { - withMaven(maven: 'maven 3.5.2', jdk: 'JDK 9') { + withMaven(maven: 'maven', jdk: 'JDK Next') { sh "${mvn} clean install" } } } - stage('Build Java 8') { + stage('Build Java LTS') { steps { - withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { + withMaven(maven: 'maven', jdk: 'JDK LTS') { sh "${mvn} clean install" } } @@ -53,7 +53,7 @@ pipeline { steps { junit '**/target/surefire-reports/*.xml' jacoco exclusionPattern: '**/*{Test|IT|Main|Application|Immutable}.class' - withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { + withMaven(maven: 'maven', jdk: 'JDK LTS') { sh "${mvn} com.gavinmogan:codacy-maven-plugin:coverage " + "-DcoverageReportFile=target/site/jacoco/jacoco.xml " + "-DprojectToken=`$JENKINS_HOME/codacy/token` " + @@ -71,7 +71,7 @@ pipeline { stage('Deploy') { when { expression { (env.GIT_BRANCH == 'master' && env.GIT_URL.startsWith('https://')) } } steps { - withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { + withMaven(maven: 'maven', jdk: 'JDK LTS') { sh "${mvn} deploy --activate-profiles release -DskipTests=true" } } From 0430d8a26e70f8a1497f345044bef1911b600985 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 10 Mar 2018 18:13:19 +0000 Subject: [PATCH 63/78] Remove circleci and werker config --- circle.yml | 3 --- wercker.yml | 6 ------ 2 files changed, 9 deletions(-) delete mode 100644 circle.yml delete mode 100644 wercker.yml diff --git a/circle.yml b/circle.yml deleted file mode 100644 index 280d970..0000000 --- a/circle.yml +++ /dev/null @@ -1,3 +0,0 @@ -test: - override: - - ./mvnw clean install diff --git a/wercker.yml b/wercker.yml deleted file mode 100644 index b152705..0000000 --- a/wercker.yml +++ /dev/null @@ -1,6 +0,0 @@ -box: maven:3.5.0-jdk-8 - -build: - steps: - - xenoterracide/maven: - goals: clean install From 1830db4476fbaede01e274e8154c008a44a40578 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 11 Mar 2018 19:25:50 +0000 Subject: [PATCH 64/78] jenkins: update to template --- Jenkinsfile.groovy | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy index 7198d71..9207dae 100644 --- a/Jenkinsfile.groovy +++ b/Jenkinsfile.groovy @@ -28,7 +28,14 @@ pipeline { sh "${mvn} checkstyle:checkstyle" sh "${mvn} pmd:pmd" pmd canComputeNew: false, defaultEncoding: '', healthy: '', pattern: '', unHealthy: '' - withSonarQubeEnv('sonarqube') { + } + } + } + stage('SonarQube (develop only)') { + when { expression { env.GIT_BRANCH == 'develop' && env.GIT_URL.startsWith('https://') } } + steps { + withSonarQubeEnv('sonarqube') { + withMaven(maven: 'maven', jdk: 'JDK LTS') { sh "${mvn} org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.0.905:sonar" } } @@ -37,7 +44,7 @@ pipeline { stage('Build Java Next') { steps { withMaven(maven: 'maven', jdk: 'JDK Next') { - sh "${mvn} clean install" + sh "${mvn} clean install -Djava.version=9" } } } From 7b0dc90d55ed54d3fe9ab104e6e90135bd963b7d Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 12 Mar 2018 20:08:04 +0000 Subject: [PATCH 65/78] Add missing generic types --- .../java/net/kemitix/conditional/TrueValueClause.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/kemitix/conditional/TrueValueClause.java b/src/main/java/net/kemitix/conditional/TrueValueClause.java index 9d3fbcc..c8e7143 100644 --- a/src/main/java/net/kemitix/conditional/TrueValueClause.java +++ b/src/main/java/net/kemitix/conditional/TrueValueClause.java @@ -34,11 +34,11 @@ import java.util.function.Supplier; */ class TrueValueClause implements Value.ValueClause { - protected static final Value.ValueClause TRUE = new TrueValueClause(); + protected static final Value.ValueClause TRUE = new TrueValueClause<>(); @Override public ValueSupplier then(final Supplier trueSupplier) { - return new TrueValueSupplier(trueSupplier); + return new TrueValueSupplier<>(trueSupplier); } @Override @@ -54,11 +54,13 @@ class TrueValueClause implements Value.ValueClause { /** * An intermediate result of the {@link Value} where the clause has evaluated to true. + * + * @param the type of the value */ @RequiredArgsConstructor - private class TrueValueSupplier implements ValueSupplier { + private static final class TrueValueSupplier implements ValueSupplier { - private final transient Supplier valueSupplier; + private final Supplier valueSupplier; @Override public T otherwise(final Supplier falseSupplier) { From e45246e2b727834fd3031d322493548ba0df6b71 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 12 Mar 2018 20:08:25 +0000 Subject: [PATCH 66/78] Suppress false-positive PMD error --- src/main/java/net/kemitix/conditional/TrueValueClause.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/net/kemitix/conditional/TrueValueClause.java b/src/main/java/net/kemitix/conditional/TrueValueClause.java index c8e7143..8179e27 100644 --- a/src/main/java/net/kemitix/conditional/TrueValueClause.java +++ b/src/main/java/net/kemitix/conditional/TrueValueClause.java @@ -60,6 +60,7 @@ class TrueValueClause implements Value.ValueClause { @RequiredArgsConstructor private static final class TrueValueSupplier implements ValueSupplier { + @SuppressWarnings("PMD.BeanMembersShouldSerialize") private final Supplier valueSupplier; @Override From f5f51cf347df17246879d9f498872ab723a2f8dd Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 12 Mar 2018 20:09:34 +0000 Subject: [PATCH 67/78] Add missing generic types --- src/main/java/net/kemitix/conditional/FalseValueClause.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/kemitix/conditional/FalseValueClause.java b/src/main/java/net/kemitix/conditional/FalseValueClause.java index 672d285..3f6be53 100644 --- a/src/main/java/net/kemitix/conditional/FalseValueClause.java +++ b/src/main/java/net/kemitix/conditional/FalseValueClause.java @@ -52,8 +52,10 @@ class FalseValueClause implements Value.ValueClause { /** * An intermediate result of the {@link Value} where the clause has evaluated to false. + * + * @param the type of the value */ - private class FalseValueSupplier implements ValueSupplier { + private static final class FalseValueSupplier implements ValueSupplier { @Override public T otherwise(final Supplier falseSupplier) { From 779a64427eb10798eca7312d89a7a51c8c2ac4f1 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 12 Mar 2018 20:08:04 +0000 Subject: [PATCH 68/78] Add missing generic types --- .../java/net/kemitix/conditional/TrueValueClause.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/kemitix/conditional/TrueValueClause.java b/src/main/java/net/kemitix/conditional/TrueValueClause.java index 9d3fbcc..c8e7143 100644 --- a/src/main/java/net/kemitix/conditional/TrueValueClause.java +++ b/src/main/java/net/kemitix/conditional/TrueValueClause.java @@ -34,11 +34,11 @@ import java.util.function.Supplier; */ class TrueValueClause implements Value.ValueClause { - protected static final Value.ValueClause TRUE = new TrueValueClause(); + protected static final Value.ValueClause TRUE = new TrueValueClause<>(); @Override public ValueSupplier then(final Supplier trueSupplier) { - return new TrueValueSupplier(trueSupplier); + return new TrueValueSupplier<>(trueSupplier); } @Override @@ -54,11 +54,13 @@ class TrueValueClause implements Value.ValueClause { /** * An intermediate result of the {@link Value} where the clause has evaluated to true. + * + * @param the type of the value */ @RequiredArgsConstructor - private class TrueValueSupplier implements ValueSupplier { + private static final class TrueValueSupplier implements ValueSupplier { - private final transient Supplier valueSupplier; + private final Supplier valueSupplier; @Override public T otherwise(final Supplier falseSupplier) { From ab47d4cad789e5984064fdc9c5d98e308779c324 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 12 Mar 2018 20:08:25 +0000 Subject: [PATCH 69/78] Suppress false-positive PMD error --- src/main/java/net/kemitix/conditional/TrueValueClause.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/net/kemitix/conditional/TrueValueClause.java b/src/main/java/net/kemitix/conditional/TrueValueClause.java index c8e7143..8179e27 100644 --- a/src/main/java/net/kemitix/conditional/TrueValueClause.java +++ b/src/main/java/net/kemitix/conditional/TrueValueClause.java @@ -60,6 +60,7 @@ class TrueValueClause implements Value.ValueClause { @RequiredArgsConstructor private static final class TrueValueSupplier implements ValueSupplier { + @SuppressWarnings("PMD.BeanMembersShouldSerialize") private final Supplier valueSupplier; @Override From d1ca0b039f3fd0d85a64ef17096ce1f40abe95fb Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 12 Mar 2018 20:09:34 +0000 Subject: [PATCH 70/78] Add missing generic types --- src/main/java/net/kemitix/conditional/FalseValueClause.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/kemitix/conditional/FalseValueClause.java b/src/main/java/net/kemitix/conditional/FalseValueClause.java index 672d285..3f6be53 100644 --- a/src/main/java/net/kemitix/conditional/FalseValueClause.java +++ b/src/main/java/net/kemitix/conditional/FalseValueClause.java @@ -52,8 +52,10 @@ class FalseValueClause implements Value.ValueClause { /** * An intermediate result of the {@link Value} where the clause has evaluated to false. + * + * @param the type of the value */ - private class FalseValueSupplier implements ValueSupplier { + private static final class FalseValueSupplier implements ValueSupplier { @Override public T otherwise(final Supplier falseSupplier) { From efc1705a6c1cf40825d3a255cbe02ac5bc49054a Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 13 Mar 2018 17:08:06 +0000 Subject: [PATCH 71/78] Condition: secondary clauses now use Supplier's to enable short circuiting --- .../net/kemitix/conditional/Condition.java | 20 ++-- .../kemitix/conditional/FalseCondition.java | 9 +- .../kemitix/conditional/TrueCondition.java | 9 +- .../kemitix/conditional/ConditionalTest.java | 108 +++++++++++------- 4 files changed, 88 insertions(+), 58 deletions(-) diff --git a/src/main/java/net/kemitix/conditional/Condition.java b/src/main/java/net/kemitix/conditional/Condition.java index 000268c..3f385eb 100644 --- a/src/main/java/net/kemitix/conditional/Condition.java +++ b/src/main/java/net/kemitix/conditional/Condition.java @@ -21,6 +21,8 @@ package net.kemitix.conditional; +import java.util.function.Supplier; + /** * If-then-else in a functional-style. * @@ -35,7 +37,6 @@ public interface Condition { * * @return the Condition */ - @SuppressWarnings("avoidinlineconditionals") static Condition where(final boolean clause) { return clause ? TrueCondition.TRUE : FalseCondition.FALSE; } @@ -58,7 +59,7 @@ public interface Condition { * * @return the Condition */ - Condition and(boolean clause); + Condition and(Supplier clause); /** * Logically AND combine the current {@code Condition} with boolean opposite of the clause. @@ -67,8 +68,8 @@ public interface Condition { * * @return the Condition */ - default Condition andNot(final boolean clause) { - return and(!clause); + default Condition andNot(final Supplier clause) { + return and(() -> !clause.get()); } /** @@ -78,8 +79,7 @@ public interface Condition { * * @return the Condition */ - @SuppressWarnings("PMD.ShortMethodName") - Condition or(boolean clause); + Condition or(Supplier clause); /** * Logically OR combine the current {@code Condition} with the boolean opposite of the clause. @@ -88,8 +88,8 @@ public interface Condition { * * @return the Condition */ - default Condition orNot(final boolean clause) { - return or(!clause); + default Condition orNot(final Supplier clause) { + return or(() -> !clause.get()); } /** @@ -115,8 +115,8 @@ public interface Condition { * * @return the Condition */ - default Condition otherwise(final boolean clause) { - return where(clause); + default Condition otherwise(final Supplier clause) { + return where(clause.get()); } } diff --git a/src/main/java/net/kemitix/conditional/FalseCondition.java b/src/main/java/net/kemitix/conditional/FalseCondition.java index 07881c7..cd382ca 100644 --- a/src/main/java/net/kemitix/conditional/FalseCondition.java +++ b/src/main/java/net/kemitix/conditional/FalseCondition.java @@ -21,6 +21,8 @@ package net.kemitix.conditional; +import java.util.function.Supplier; + /** * A {@code Condition} that has evaluated to {@code false}. * @@ -31,14 +33,13 @@ final class FalseCondition implements Condition { public static final Condition FALSE = new net.kemitix.conditional.FalseCondition(); @Override - public Condition and(final boolean clause) { + public Condition and(final Supplier clause) { return FALSE; } @Override - @SuppressWarnings("PMD.ShortMethodName") - public Condition or(final boolean secondClause) { - return Condition.where(secondClause); + public Condition or(final Supplier secondClause) { + return Condition.where(secondClause.get()); } @Override diff --git a/src/main/java/net/kemitix/conditional/TrueCondition.java b/src/main/java/net/kemitix/conditional/TrueCondition.java index 06f041b..987496c 100644 --- a/src/main/java/net/kemitix/conditional/TrueCondition.java +++ b/src/main/java/net/kemitix/conditional/TrueCondition.java @@ -21,6 +21,8 @@ package net.kemitix.conditional; +import java.util.function.Supplier; + /** * A {@code Condition} that has evaluated to {@code true}. * @@ -31,13 +33,12 @@ final class TrueCondition implements Condition { public static final Condition TRUE = new net.kemitix.conditional.TrueCondition(); @Override - public Condition and(final boolean clause) { - return Condition.where(clause); + public Condition and(final Supplier clause) { + return Condition.where(clause.get()); } @Override - @SuppressWarnings("PMD.ShortMethodName") - public Condition or(final boolean secondClause) { + public Condition or(final Supplier secondClause) { return TRUE; } diff --git a/src/test/java/net/kemitix/conditional/ConditionalTest.java b/src/test/java/net/kemitix/conditional/ConditionalTest.java index 525c534..5124b7f 100644 --- a/src/test/java/net/kemitix/conditional/ConditionalTest.java +++ b/src/test/java/net/kemitix/conditional/ConditionalTest.java @@ -3,6 +3,8 @@ package net.kemitix.conditional; import org.junit.Before; import org.junit.Test; +import java.util.concurrent.atomic.AtomicInteger; + import static org.assertj.core.api.Assertions.assertThat; /** @@ -76,9 +78,9 @@ public class ConditionalTest { public void whereTrueThenDoSomethingAndThenDoSomethingElse() { //when Condition.where(true) - .then(thenResponse) - .and(true) - .then(otherwiseResponse); + .then(thenResponse) + .and(() -> true) + .then(otherwiseResponse); //then assertThatBothResponsesRun(); } @@ -119,7 +121,7 @@ public class ConditionalTest { public void whereNotFalseThenRuns() { //when Condition.whereNot(false) - .then(thenResponse); + .then(thenResponse); //then assertThatTheThenResponseRuns(); } @@ -128,8 +130,8 @@ public class ConditionalTest { public void whereNotTrueThenOtherwiseRuns() { //when Condition.whereNot(true) - .then(thenResponse) - .otherwise(otherwiseResponse); + .then(thenResponse) + .otherwise(otherwiseResponse); //then assertThatTheOtherwiseResponseRuns(); } @@ -138,8 +140,8 @@ public class ConditionalTest { public void whereTrueAndNotFalseThenRuns() { //when Condition.where(true) - .andNot(false) - .then(thenResponse); + .andNot(() -> false) + .then(thenResponse); //then assertThatTheThenResponseRuns(); } @@ -148,9 +150,9 @@ public class ConditionalTest { public void whereTrueAndNotTrueThenOtherwiseRuns() { //when Condition.where(true) - .andNot(true) - .then(thenResponse) - .otherwise(otherwiseResponse); + .andNot(() -> true) + .then(thenResponse) + .otherwise(otherwiseResponse); //then assertThatTheOtherwiseResponseRuns(); } @@ -159,8 +161,8 @@ public class ConditionalTest { public void whereFalseOrNotFalseThenRuns() { //when Condition.where(false) - .orNot(false) - .then(thenResponse); + .orNot(() -> false) + .then(thenResponse); //then assertThatTheThenResponseRuns(); } @@ -169,9 +171,9 @@ public class ConditionalTest { public void whereFalseOrNotTrueThenOtherwiseRuns() { //when Condition.where(false) - .orNot(true) - .then(thenResponse) - .otherwise(otherwiseResponse); + .orNot(() -> true) + .then(thenResponse) + .otherwise(otherwiseResponse); //then assertThatTheOtherwiseResponseRuns(); } @@ -180,9 +182,9 @@ public class ConditionalTest { public void whereFalseElseTrueThenOtherwiseRuns() { //when Condition.where(false) - .then(thenResponse) - .otherwise(true) - .then(otherwiseResponse); + .then(thenResponse) + .otherwise(() -> true) + .then(otherwiseResponse); //then assertThatTheOtherwiseResponseRuns(); } @@ -191,9 +193,9 @@ public class ConditionalTest { public void whereFalseElseFalseThenNothingRuns() { //when Condition.where(false) - .then(thenResponse) - .otherwise(false) - .then(otherwiseResponse); + .then(thenResponse) + .otherwise(() -> false) + .then(otherwiseResponse); //then assertThatNoResponseRuns(); } @@ -202,8 +204,8 @@ public class ConditionalTest { public void whereTrueChainedThensBothRuns() { //when Condition.where(true) - .then(thenResponse) - .then(otherwiseResponse); + .then(thenResponse) + .then(otherwiseResponse); //then assertThatBothResponsesRun(); } @@ -212,8 +214,8 @@ public class ConditionalTest { public void whereFalseChainedThensNothingRuns() { //when Condition.where(false) - .then(thenResponse) - .then(otherwiseResponse); + .then(thenResponse) + .then(otherwiseResponse); //then assertThatNoResponseRuns(); } @@ -235,22 +237,22 @@ public class ConditionalTest { private void assertThatTheOtherwiseResponseRan() { assertThat(otherwiseFlag).as("otherwise response runs") - .isTrue(); + .isTrue(); } private void assertThatTheThenResponseRan() { assertThat(thenFlag).as("then response runs") - .isTrue(); + .isTrue(); } private void assertThatTheOtherwiseResponseDidNotRun() { assertThat(otherwiseFlag).as("otherwise response does not run") - .isFalse(); + .isFalse(); } private void assertThatTheThenResponseDidNotRun() { assertThat(thenFlag).as("then response does not run") - .isFalse(); + .isFalse(); } private void assertThatNoResponseRuns() { @@ -260,27 +262,53 @@ public class ConditionalTest { private void when(final boolean clause) { Condition.where(clause) - .then(thenResponse) - .otherwise(otherwiseResponse); + .then(thenResponse) + .otherwise(otherwiseResponse); } private void when( final boolean firstClause, final boolean secondClause - ) { + ) { Condition.where(firstClause) - .and(secondClause) - .then(thenResponse) - .otherwise(otherwiseResponse); + .and(() -> secondClause) + .then(thenResponse) + .otherwise(otherwiseResponse); } private void whenOr( final boolean firstClause, final boolean secondClause - ) { + ) { Condition.where(firstClause) - .or(secondClause) - .then(thenResponse) - .otherwise(otherwiseResponse); + .or(() -> secondClause) + .then(thenResponse) + .otherwise(otherwiseResponse); + } + + @Test + public void shortCurcuitOr() { + //given + final AtomicInteger atomicInteger = new AtomicInteger(); + //when + Condition.where(true) + .or(() -> atomicInteger.compareAndSet(0, 2)) + .then(thenResponse); + //then + assertThatTheThenResponseRan(); + assertThat(atomicInteger).hasValue(0); + } + + @Test + public void shortCurcuitAnd() { + //given + final AtomicInteger atomicInteger = new AtomicInteger(); + //when + Condition.where(false) + .and(() -> atomicInteger.compareAndSet(0, 2)) + .then(thenResponse); + //then + assertThatTheThenResponseDidNotRun(); + assertThat(atomicInteger).hasValue(0); } } From ac3e253bf2a0fe5fc878ff4abc79e3140e805d8e Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 13 Mar 2018 17:53:16 +0000 Subject: [PATCH 72/78] Value: secondary clauses now use Supplier's to enable short circuiting --- README.adoc | 69 +++++--- .../kemitix/conditional/FalseValueClause.java | 13 +- .../kemitix/conditional/TrueValueClause.java | 14 +- .../java/net/kemitix/conditional/Value.java | 33 ++-- .../net/kemitix/conditional/ValueTest.java | 149 ++++++++++++------ 5 files changed, 180 insertions(+), 98 deletions(-) diff --git a/README.adoc b/README.adoc index d4bebd6..5eadee4 100644 --- a/README.adoc +++ b/README.adoc @@ -59,7 +59,7 @@ if (isTrue() && isAlsoTrue()) { [[source,java]] ---- Condition.where(isTrue()) - .and(isAlsoTrue()) + .and(() -> isAlsoTrue()) .then(() -> doSomething()) .otherwise(() -> doSomethingElse()); ---- @@ -78,7 +78,7 @@ if (isTrue() || alternativeIsTrue()) { [[source,java]] ---- Condition.where(isTrue()) - .or(alternativeIsTrue()) + .or(() -> alternativeIsTrue()) .then(() -> doSomething()) .otherwise(() -> doSomethingElse()); ---- @@ -115,7 +115,7 @@ if (isTrue() || !isFalse()) { [[source,java]] ---- Condition.where(isTrue()) - .andNot(isFalse()) + .andNot(() -> isFalse()) .then(() -> doSomething()) .otherwise(() -> doSomethingElse()); ---- @@ -134,7 +134,7 @@ if (isFalse() || !isAlsoFalse()) { [[source,java]] ---- Condition.where(isFalse()) - .orNot(isAlsoFalse()) + .orNot(() -> isAlsoFalse()) .then(() -> doSomething()) .otherwise(() -> doSomethingElse()); ---- @@ -154,7 +154,7 @@ if (isFalse()) { ---- Condition.where(isFalse()) .then(() -> doSomething()) - .otherwise(isTrue()) + .otherwise(() -> isTrue()) .then(() -> doSomethingElse()); ---- @@ -174,7 +174,7 @@ if (isTrue()) { ---- Condition.where(isTrue()) .then(() -> doSomething()) - .and(isAlsoTrue()) + .and(() -> isAlsoTrue()) .then(() -> doSomethingElse()); ---- @@ -213,8 +213,9 @@ final Optional result = Value.where(isTrue(), () -> TRUE); [[source,java]] ---- -final String result = Value.where(isTrue()).then(() -> TRUE) - .otherwise(() -> FALSE); +final String result = Value.where(isTrue()) + .then(() -> TRUE) + .otherwise(() -> FALSE); ---- ### if-not-then-else @@ -231,8 +232,9 @@ if (!isTrue()) { [[source,java]] ---- -final String result = Value.whereNot(isTrue()).then(() -> TRUE) - .otherwise(() -> FALSE); +final String result = Value.whereNot(isTrue()) + .then(() -> TRUE) + .otherwise(() -> FALSE); ---- ### if-and-then-else @@ -249,9 +251,10 @@ if (isTrue() && alternativeIsTrue()) { [[source,java]] ---- -final String result = Value.where(isTrue()).and(alternativeIsTrue()) - .then(() -> TRUE) - .otherwise(() -> FALSE); +final String result = Value.where(isTrue()) + .and(() -> alternativeIsTrue()) + .then(() -> TRUE) + .otherwise(() -> FALSE); ---- ### if-and-not-then-else @@ -268,9 +271,10 @@ if (isTrue() && !alternativeIsFalse()) { [[source,java]] ---- -final String result = Value.where(isTrue()).andNot(alternativeIsFalse()) - .then(() -> TRUE) - .otherwise(() -> FALSE); +final String result = Value.where(isTrue()) + .andNot(() -> alternativeIsFalse()) + .then(() -> TRUE) + .otherwise(() -> FALSE); ---- ### if-or-then-else @@ -287,9 +291,10 @@ if (isTrue() || alternativeIsTrue()) { [[source,java]] ---- -final String result = Value.where(isTrue()).or(alternativeIsTrue()) - .then(() -> TRUE) - .otherwise(() -> FALSE); +final String result = Value.where(isTrue()) + .or(() -> alternativeIsTrue()) + .then(() -> TRUE) + .otherwise(() -> FALSE); ---- ### if-or-not-then-else @@ -306,7 +311,27 @@ if (isTrue() || !isFalse()) { [[source,java]] ---- -final String result = Value.where(isTrue()).orNot(isFalse()) - .then(() -> TRUE) - .otherwise(() -> FALSE); +final String result = Value.where(isTrue()) + .orNot(() -> isFalse()) + .then(() -> TRUE) + .otherwise(() -> FALSE); ---- + +### if-then + +[[source,java]] +----- +Optional result; +if (isTrue()) { + result = Optional.of(TRUE); +} else { + result = Optional.empty(); +} +----- + +[[source,java]] +----- +final Optional result = Value.where(isTrue()) + .then(() -> TRUE) + .optional(); +----- diff --git a/src/main/java/net/kemitix/conditional/FalseValueClause.java b/src/main/java/net/kemitix/conditional/FalseValueClause.java index 3f6be53..94775f2 100644 --- a/src/main/java/net/kemitix/conditional/FalseValueClause.java +++ b/src/main/java/net/kemitix/conditional/FalseValueClause.java @@ -21,6 +21,7 @@ package net.kemitix.conditional; +import java.util.Optional; import java.util.function.Supplier; /** @@ -40,14 +41,13 @@ class FalseValueClause implements Value.ValueClause { } @Override - public Value.ValueClause and(final boolean clause) { + public Value.ValueClause and(final Supplier clause) { return this; } @Override - @SuppressWarnings("PMD.ShortMethodName") - public Value.ValueClause or(final boolean clause) { - return Value.where(clause); + public Value.ValueClause or(final Supplier clause) { + return Value.where(clause.get()); } /** @@ -62,6 +62,11 @@ class FalseValueClause implements Value.ValueClause { return falseSupplier.get(); } + @Override + public Optional optional() { + return Optional.empty(); + } + } } diff --git a/src/main/java/net/kemitix/conditional/TrueValueClause.java b/src/main/java/net/kemitix/conditional/TrueValueClause.java index 8179e27..c5c04ad 100644 --- a/src/main/java/net/kemitix/conditional/TrueValueClause.java +++ b/src/main/java/net/kemitix/conditional/TrueValueClause.java @@ -23,6 +23,7 @@ package net.kemitix.conditional; import lombok.RequiredArgsConstructor; +import java.util.Optional; import java.util.function.Supplier; /** @@ -42,13 +43,12 @@ class TrueValueClause implements Value.ValueClause { } @Override - public Value.ValueClause and(final boolean clause) { - return Value.where(clause); + public Value.ValueClause and(final Supplier clause) { + return Value.where(clause.get()); } @Override - @SuppressWarnings("PMD.ShortMethodName") - public Value.ValueClause or(final boolean clause) { + public Value.ValueClause or(final Supplier clause) { return this; } @@ -60,7 +60,6 @@ class TrueValueClause implements Value.ValueClause { @RequiredArgsConstructor private static final class TrueValueSupplier implements ValueSupplier { - @SuppressWarnings("PMD.BeanMembersShouldSerialize") private final Supplier valueSupplier; @Override @@ -68,6 +67,11 @@ class TrueValueClause implements Value.ValueClause { return valueSupplier.get(); } + @Override + public Optional optional() { + return Optional.ofNullable(valueSupplier.get()); + } + } } diff --git a/src/main/java/net/kemitix/conditional/Value.java b/src/main/java/net/kemitix/conditional/Value.java index 9b1c3b6..55a0e68 100644 --- a/src/main/java/net/kemitix/conditional/Value.java +++ b/src/main/java/net/kemitix/conditional/Value.java @@ -41,11 +41,10 @@ public interface Value { * * @return the value from either the trueSupplier or the falseSupplier */ - @SuppressWarnings("PMD.LawOfDemeter") static T where( - boolean clause, - Supplier trueSupplier, - Supplier falseSupplier + final boolean clause, + final Supplier trueSupplier, + final Supplier falseSupplier ) { return Value.where(clause).then(trueSupplier) .otherwise(falseSupplier); @@ -61,8 +60,8 @@ public interface Value { * @return an Optional either containing the value from the trueSupplier or empty */ static Optional where( - boolean clause, - Supplier trueSupplier + final boolean clause, + final Supplier trueSupplier ) { return Optional.ofNullable(Value.where(clause, trueSupplier, () -> null)); } @@ -75,7 +74,6 @@ public interface Value { * * @return a true or false value clause */ - @SuppressWarnings({"unchecked", "avoidinlineconditionals"}) static ValueClause where(final boolean clause) { return (ValueClause) (clause ? TrueValueClause.TRUE : FalseValueClause.FALSE); } @@ -88,7 +86,7 @@ public interface Value { * * @return a true or false value clause */ - static ValueClause whereNot(boolean clause) { + static ValueClause whereNot(final boolean clause) { return where(!clause); } @@ -115,7 +113,7 @@ public interface Value { * * @return a true or false value clause */ - ValueClause and(boolean clause); + ValueClause and(Supplier clause); /** * Logically OR combine the current {@link ValueClause} with clause. @@ -124,8 +122,7 @@ public interface Value { * * @return a true or false value clause */ - @SuppressWarnings("PMD.ShortMethodName") - ValueClause or(boolean clause); + ValueClause or(Supplier clause); /** * Logically AND combine the current {@link ValueClause} with boolean opposite of the clause. @@ -134,8 +131,8 @@ public interface Value { * * @return a true or false value clause */ - default ValueClause andNot(final boolean clause) { - return and(!clause); + default ValueClause andNot(final Supplier clause) { + return and(() -> !clause.get()); } /** @@ -145,8 +142,8 @@ public interface Value { * * @return a true or false value clause */ - default ValueClause orNot(boolean clause) { - return or(!clause); + default ValueClause orNot(final Supplier clause) { + return or(() -> !clause.get()); } /** @@ -165,6 +162,12 @@ public interface Value { */ T otherwise(Supplier falseSupplier); + /** + * Returns the value in an Optional if the {@link ValueClause} is true, or an empty Optional if it is false. + * + * @return an Optional, possibly containing the value + */ + Optional optional(); } } diff --git a/src/test/java/net/kemitix/conditional/ValueTest.java b/src/test/java/net/kemitix/conditional/ValueTest.java index d76011b..3c72c6e 100644 --- a/src/test/java/net/kemitix/conditional/ValueTest.java +++ b/src/test/java/net/kemitix/conditional/ValueTest.java @@ -4,6 +4,7 @@ import lombok.val; import org.junit.Test; import java.util.Optional; +import java.util.concurrent.atomic.AtomicInteger; import static org.assertj.core.api.Assertions.assertThat; @@ -52,7 +53,7 @@ public class ValueTest { public void valueWhereClauseIsTrue() { //when val result = Value.where(true).then(() -> TRUE) - .otherwise(() -> FALSE); + .otherwise(() -> FALSE); //then assertThat(result).isEqualTo(TRUE); } @@ -61,7 +62,7 @@ public class ValueTest { public void valueWhereClauseIsFalse() { //when val result = Value.where(false).then(() -> TRUE) - .otherwise(() -> FALSE); + .otherwise(() -> FALSE); //then assertThat(result).isEqualTo(FALSE); } @@ -69,9 +70,9 @@ public class ValueTest { @Test public void valueWhereTrueAndTrueIsTrue() { //when - val result = Value.where(true).and(true) - .then(() -> TRUE) - .otherwise(() -> FALSE); + val result = Value.where(true).and(() -> true) + .then(() -> TRUE) + .otherwise(() -> FALSE); //then assertThat(result).isEqualTo(TRUE); } @@ -79,9 +80,9 @@ public class ValueTest { @Test public void valueWhereTrueAndFalseIsFalse() { //when - val result = Value.where(true).and(false) - .then(() -> TRUE) - .otherwise(() -> FALSE); + val result = Value.where(true).and(() -> false) + .then(() -> TRUE) + .otherwise(() -> FALSE); //then assertThat(result).isEqualTo(FALSE); } @@ -89,9 +90,9 @@ public class ValueTest { @Test public void valueWhereFalseAndTrueIsFalse() { //when - val result = Value.where(false).and(true) - .then(() -> TRUE) - .otherwise(() -> FALSE); + val result = Value.where(false).and(() -> true) + .then(() -> TRUE) + .otherwise(() -> FALSE); //then assertThat(result).isEqualTo(FALSE); } @@ -99,9 +100,9 @@ public class ValueTest { @Test public void valueWhereFalseAndFalseIsFalse() { //when - val result = Value.where(false).and(false) - .then(() -> TRUE) - .otherwise(() -> FALSE); + val result = Value.where(false).and(() -> false) + .then(() -> TRUE) + .otherwise(() -> FALSE); //then assertThat(result).isEqualTo(FALSE); } @@ -109,9 +110,9 @@ public class ValueTest { @Test public void valueWhereTrueOrTrueIsTrue() { //when - val result = Value.where(true).or(true) - .then(() -> TRUE) - .otherwise(() -> FALSE); + val result = Value.where(true).or(() -> true) + .then(() -> TRUE) + .otherwise(() -> FALSE); //then assertThat(result).isEqualTo(TRUE); } @@ -119,9 +120,9 @@ public class ValueTest { @Test public void valueWhereTrueOrFalseIsTrue() { //when - val result = Value.where(true).or(false) - .then(() -> TRUE) - .otherwise(() -> FALSE); + val result = Value.where(true).or(() -> false) + .then(() -> TRUE) + .otherwise(() -> FALSE); //then assertThat(result).isEqualTo(TRUE); } @@ -129,9 +130,9 @@ public class ValueTest { @Test public void valueWhereFalseOrTrueIsTrue() { //when - val result = Value.where(false).or(true) - .then(() -> TRUE) - .otherwise(() -> FALSE); + val result = Value.where(false).or(() -> true) + .then(() -> TRUE) + .otherwise(() -> FALSE); //then assertThat(result).isEqualTo(TRUE); } @@ -139,9 +140,9 @@ public class ValueTest { @Test public void valueWhereFalseOrFalseIsFalse() { //when - val result = Value.where(false).or(false) - .then(() -> TRUE) - .otherwise(() -> FALSE); + val result = Value.where(false).or(() -> false) + .then(() -> TRUE) + .otherwise(() -> FALSE); //then assertThat(result).isEqualTo(FALSE); } @@ -150,7 +151,7 @@ public class ValueTest { public void valueWhereNotTrueIsFalse() { //when val result = Value.whereNot(true).then(() -> TRUE) - .otherwise(() -> FALSE); + .otherwise(() -> FALSE); //then assertThat(result).isEqualTo(FALSE); } @@ -159,7 +160,7 @@ public class ValueTest { public void valueWhereNotFalseIsTrue() { //when val result = Value.whereNot(false).then(() -> TRUE) - .otherwise(() -> FALSE); + .otherwise(() -> FALSE); //then assertThat(result).isEqualTo(TRUE); } @@ -167,9 +168,9 @@ public class ValueTest { @Test public void valueWhereTrueAndNotTrueIsFalse() { //when - val result = Value.where(true).andNot(true) - .then(() -> TRUE) - .otherwise(() -> FALSE); + val result = Value.where(true).andNot(() -> true) + .then(() -> TRUE) + .otherwise(() -> FALSE); //then assertThat(result).isEqualTo(FALSE); } @@ -177,9 +178,9 @@ public class ValueTest { @Test public void valueWhereTrueAndNotFalseIsTrue() { //when - val result = Value.where(true).andNot(false) - .then(() -> TRUE) - .otherwise(() -> FALSE); + val result = Value.where(true).andNot(() -> false) + .then(() -> TRUE) + .otherwise(() -> FALSE); //then assertThat(result).isEqualTo(TRUE); } @@ -187,9 +188,9 @@ public class ValueTest { @Test public void valueWhereFalseAndNotTrueIsFalse() { //when - val result = Value.where(false).andNot(true) - .then(() -> TRUE) - .otherwise(() -> FALSE); + val result = Value.where(false).andNot(() -> true) + .then(() -> TRUE) + .otherwise(() -> FALSE); //then assertThat(result).isEqualTo(FALSE); } @@ -197,9 +198,9 @@ public class ValueTest { @Test public void valueWhereFalseAndNotFalseIsFalse() { //when - val result = Value.where(false).andNot(false) - .then(() -> TRUE) - .otherwise(() -> FALSE); + val result = Value.where(false).andNot(() -> false) + .then(() -> TRUE) + .otherwise(() -> FALSE); //then assertThat(result).isEqualTo(FALSE); } @@ -207,9 +208,9 @@ public class ValueTest { @Test public void valueWhereTrueOrNotTrueIsTrue() { //when - val result = Value.where(true).orNot(true) - .then(() -> TRUE) - .otherwise(() -> FALSE); + val result = Value.where(true).orNot(() -> true) + .then(() -> TRUE) + .otherwise(() -> FALSE); //then assertThat(result).isEqualTo(TRUE); } @@ -217,9 +218,9 @@ public class ValueTest { @Test public void valueWhereTrueOrNotFalseIsTrue() { //when - val result = Value.where(true).orNot(false) - .then(() -> TRUE) - .otherwise(() -> FALSE); + val result = Value.where(true).orNot(() -> false) + .then(() -> TRUE) + .otherwise(() -> FALSE); //then assertThat(result).isEqualTo(TRUE); } @@ -227,9 +228,9 @@ public class ValueTest { @Test public void valueWhereFalseOrNotTrueIsFalse() { //when - val result = Value.where(false).orNot(true) - .then(() -> TRUE) - .otherwise(() -> FALSE); + val result = Value.where(false).orNot(() -> true) + .then(() -> TRUE) + .otherwise(() -> FALSE); //then assertThat(result).isEqualTo(FALSE); } @@ -237,10 +238,54 @@ public class ValueTest { @Test public void valueWhereFalseOrNotFalseIsTrue() { //when - val result = Value.where(false).orNot(false) - .then(() -> TRUE) - .otherwise(() -> FALSE); + val result = Value.where(false).orNot(() -> false) + .then(() -> TRUE) + .otherwise(() -> FALSE); //then assertThat(result).isEqualTo(TRUE); } + + @Test + public void valueWhereTrueThenIsNotEmpty() { + //given + final Optional result = Value.where(true).then(() -> "value").optional(); + //then + assertThat(result).contains("value"); + } + + @Test + public void valueWhereFalseThenIsEmpty() { + //given + final Optional result = Value.where(false).then(() -> "value").optional(); + //when + assertThat(result).isEmpty(); + } + + @Test + public void shortCurcuitOr() { + //given + final AtomicInteger atomicInteger = new AtomicInteger(); + //when + final Optional result = Value.where(true) + .or(() -> atomicInteger.compareAndSet(0, 2)) + .then(() -> "Pass") + .optional(); + //then + assertThat(result).contains("Pass"); + assertThat(atomicInteger).hasValue(0); + } + + @Test + public void shortCurcuitAnd() { + //given + final AtomicInteger atomicInteger = new AtomicInteger(); + //when + final Optional result = Value.where(false) + .and(() -> atomicInteger.compareAndSet(0, 2)) + .then(() -> "Pass") + .optional(); + //then + assertThat(result).isEmpty(); + assertThat(atomicInteger).hasValue(0); + } } From 66a0222253c94b8addf319a467218d28cb9fb476 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 13 Mar 2018 18:00:59 +0000 Subject: [PATCH 73/78] Suppress PMD.ShortMethodName for or() methods --- src/main/java/net/kemitix/conditional/Condition.java | 1 + src/main/java/net/kemitix/conditional/Value.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/java/net/kemitix/conditional/Condition.java b/src/main/java/net/kemitix/conditional/Condition.java index 3f385eb..33c0a31 100644 --- a/src/main/java/net/kemitix/conditional/Condition.java +++ b/src/main/java/net/kemitix/conditional/Condition.java @@ -79,6 +79,7 @@ public interface Condition { * * @return the Condition */ + @SuppressWarnings("PMD.ShortMethodName") Condition or(Supplier clause); /** diff --git a/src/main/java/net/kemitix/conditional/Value.java b/src/main/java/net/kemitix/conditional/Value.java index 55a0e68..fe2b182 100644 --- a/src/main/java/net/kemitix/conditional/Value.java +++ b/src/main/java/net/kemitix/conditional/Value.java @@ -122,6 +122,7 @@ public interface Value { * * @return a true or false value clause */ + @SuppressWarnings("PMD.ShortMethodName") ValueClause or(Supplier clause); /** From e427f14b70ef9952974275571adbca41f4beb410 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 13 Mar 2018 18:18:38 +0000 Subject: [PATCH 74/78] Upgrade kemitix-maven-tiles to 0.8.1 --- pom.xml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 18f42b7..38800de 100644 --- a/pom.xml +++ b/pom.xml @@ -16,9 +16,7 @@ 3.9.1 4.3.0 2.10 - 0.7.1 - 2.20.1 - 2.20.1 + 0.8.1 1.16.20 From 3a1e51aa9f811359445b8a6e4ff021941a64289b Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 13 Mar 2018 18:29:41 +0000 Subject: [PATCH 75/78] Apply PMD and Checkstyle updates --- src/main/java/net/kemitix/conditional/Condition.java | 5 ++++- src/main/java/net/kemitix/conditional/FalseCondition.java | 1 + src/main/java/net/kemitix/conditional/FalseValueClause.java | 1 + src/main/java/net/kemitix/conditional/TrueCondition.java | 1 + src/main/java/net/kemitix/conditional/TrueValueClause.java | 2 ++ src/main/java/net/kemitix/conditional/Value.java | 6 +++++- 6 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/kemitix/conditional/Condition.java b/src/main/java/net/kemitix/conditional/Condition.java index 33c0a31..c87a74f 100644 --- a/src/main/java/net/kemitix/conditional/Condition.java +++ b/src/main/java/net/kemitix/conditional/Condition.java @@ -38,7 +38,10 @@ public interface Condition { * @return the Condition */ static Condition where(final boolean clause) { - return clause ? TrueCondition.TRUE : FalseCondition.FALSE; + if (clause) { + return TrueCondition.TRUE; + } + return FalseCondition.FALSE; } /** diff --git a/src/main/java/net/kemitix/conditional/FalseCondition.java b/src/main/java/net/kemitix/conditional/FalseCondition.java index cd382ca..3ffdbd2 100644 --- a/src/main/java/net/kemitix/conditional/FalseCondition.java +++ b/src/main/java/net/kemitix/conditional/FalseCondition.java @@ -38,6 +38,7 @@ final class FalseCondition implements Condition { } @Override + @SuppressWarnings("PMD.ShortMethodName") public Condition or(final Supplier secondClause) { return Condition.where(secondClause.get()); } diff --git a/src/main/java/net/kemitix/conditional/FalseValueClause.java b/src/main/java/net/kemitix/conditional/FalseValueClause.java index 94775f2..b609428 100644 --- a/src/main/java/net/kemitix/conditional/FalseValueClause.java +++ b/src/main/java/net/kemitix/conditional/FalseValueClause.java @@ -46,6 +46,7 @@ class FalseValueClause implements Value.ValueClause { } @Override + @SuppressWarnings("PMD.ShortMethodName") public Value.ValueClause or(final Supplier clause) { return Value.where(clause.get()); } diff --git a/src/main/java/net/kemitix/conditional/TrueCondition.java b/src/main/java/net/kemitix/conditional/TrueCondition.java index 987496c..0691433 100644 --- a/src/main/java/net/kemitix/conditional/TrueCondition.java +++ b/src/main/java/net/kemitix/conditional/TrueCondition.java @@ -38,6 +38,7 @@ final class TrueCondition implements Condition { } @Override + @SuppressWarnings("PMD.ShortMethodName") public Condition or(final Supplier secondClause) { return TRUE; } diff --git a/src/main/java/net/kemitix/conditional/TrueValueClause.java b/src/main/java/net/kemitix/conditional/TrueValueClause.java index c5c04ad..41707c3 100644 --- a/src/main/java/net/kemitix/conditional/TrueValueClause.java +++ b/src/main/java/net/kemitix/conditional/TrueValueClause.java @@ -48,6 +48,7 @@ class TrueValueClause implements Value.ValueClause { } @Override + @SuppressWarnings("PMD.ShortMethodName") public Value.ValueClause or(final Supplier clause) { return this; } @@ -60,6 +61,7 @@ class TrueValueClause implements Value.ValueClause { @RequiredArgsConstructor private static final class TrueValueSupplier implements ValueSupplier { + @SuppressWarnings("PMD.BeanMembersShouldSerialize") private final Supplier valueSupplier; @Override diff --git a/src/main/java/net/kemitix/conditional/Value.java b/src/main/java/net/kemitix/conditional/Value.java index fe2b182..d41b481 100644 --- a/src/main/java/net/kemitix/conditional/Value.java +++ b/src/main/java/net/kemitix/conditional/Value.java @@ -41,6 +41,7 @@ public interface Value { * * @return the value from either the trueSupplier or the falseSupplier */ + @SuppressWarnings("PMD.LawOfDemeter") static T where( final boolean clause, final Supplier trueSupplier, @@ -75,7 +76,10 @@ public interface Value { * @return a true or false value clause */ static ValueClause where(final boolean clause) { - return (ValueClause) (clause ? TrueValueClause.TRUE : FalseValueClause.FALSE); + if (clause) { + return TrueValueClause.TRUE; + } + return FalseValueClause.FALSE; } /** From ca83e1c24447be628f232887d541ce7a8e1a9c16 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 13 Mar 2018 18:34:15 +0000 Subject: [PATCH 76/78] jenkins: update template --- Jenkinsfile.groovy | 62 +++++++++++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 23 deletions(-) diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy index e799493..9207dae 100644 --- a/Jenkinsfile.groovy +++ b/Jenkinsfile.groovy @@ -3,49 +3,64 @@ final String mvn = "mvn --batch-mode --update-snapshots" pipeline { agent any stages { + stage('Environment') { + steps { + sh 'set' + } + } stage('no SNAPSHOT in master') { - // checks that the pom version is not a snapshot when the current branch is master - // TODO: also check for SNAPSHOT when is a pull request with master as the target branch + // checks that the pom version is not a snapshot when the current or target branch is master when { expression { - (env.GIT_BRANCH == 'master') && - (readMavenPom(file: 'pom.xml').version).contains("SNAPSHOT") } + (env.GIT_BRANCH == 'master' || env.CHANGE_TARGET == 'master') && + (readMavenPom(file: 'pom.xml').version).contains("SNAPSHOT") + } } steps { error("Build failed because SNAPSHOT version") } } stage('Static Code Analysis') { + when { expression { findFiles(glob: '**/src/main/java/**/*.java').length > 0 } } steps { - withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { - sh "${mvn} compile checkstyle:checkstyle pmd:pmd" + withMaven(maven: 'maven', jdk: 'JDK LTS') { + sh "${mvn} compile" + sh "${mvn} checkstyle:checkstyle" + sh "${mvn} pmd:pmd" + pmd canComputeNew: false, defaultEncoding: '', healthy: '', pattern: '', unHealthy: '' } - pmd canComputeNew: false, defaultEncoding: '', healthy: '', pattern: '', unHealthy: '' } } - stage('Build') { - parallel { - stage('Java 8') { - steps { - withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { - sh "${mvn} clean install" - } + stage('SonarQube (develop only)') { + when { expression { env.GIT_BRANCH == 'develop' && env.GIT_URL.startsWith('https://') } } + steps { + withSonarQubeEnv('sonarqube') { + withMaven(maven: 'maven', jdk: 'JDK LTS') { + sh "${mvn} org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.0.905:sonar" } } - stage('Java 9') { - steps { - withMaven(maven: 'maven 3.5.2', jdk: 'JDK 9') { - sh "${mvn} clean install" - } - } + } + } + stage('Build Java Next') { + steps { + withMaven(maven: 'maven', jdk: 'JDK Next') { + sh "${mvn} clean install -Djava.version=9" + } + } + } + stage('Build Java LTS') { + steps { + withMaven(maven: 'maven', jdk: 'JDK LTS') { + sh "${mvn} clean install" } } } stage('Test Results') { + when { expression { findFiles(glob: '**/target/surefire-reports/*.xml').length > 0 } } steps { junit '**/target/surefire-reports/*.xml' jacoco exclusionPattern: '**/*{Test|IT|Main|Application|Immutable}.class' - withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { + withMaven(maven: 'maven', jdk: 'JDK LTS') { sh "${mvn} com.gavinmogan:codacy-maven-plugin:coverage " + "-DcoverageReportFile=target/site/jacoco/jacoco.xml " + "-DprojectToken=`$JENKINS_HOME/codacy/token` " + @@ -55,14 +70,15 @@ pipeline { } } stage('Archiving') { + when { expression { findFiles(glob: '**/target/*.jar').length > 0 } } steps { archiveArtifacts '**/target/*.jar' } } stage('Deploy') { - when { expression { (env.GIT_BRANCH == 'master') } } + when { expression { (env.GIT_BRANCH == 'master' && env.GIT_URL.startsWith('https://')) } } steps { - withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { + withMaven(maven: 'maven', jdk: 'JDK LTS') { sh "${mvn} deploy --activate-profiles release -DskipTests=true" } } From 1992db49f12641b8658a277137634f579041e5d8 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 13 Mar 2018 18:46:44 +0000 Subject: [PATCH 77/78] Suppress unchecked cast --- src/main/java/net/kemitix/conditional/FalseValueClause.java | 4 ++-- src/main/java/net/kemitix/conditional/TrueValueClause.java | 2 +- src/main/java/net/kemitix/conditional/Value.java | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/kemitix/conditional/FalseValueClause.java b/src/main/java/net/kemitix/conditional/FalseValueClause.java index b609428..f4283c3 100644 --- a/src/main/java/net/kemitix/conditional/FalseValueClause.java +++ b/src/main/java/net/kemitix/conditional/FalseValueClause.java @@ -33,11 +33,11 @@ import java.util.function.Supplier; */ class FalseValueClause implements Value.ValueClause { - protected static final Value.ValueClause FALSE = new FalseValueClause(); + protected static final Value.ValueClause FALSE = new FalseValueClause<>(); @Override public ValueSupplier then(final Supplier trueSupplier) { - return new FalseValueSupplier(); + return new FalseValueSupplier<>(); } @Override diff --git a/src/main/java/net/kemitix/conditional/TrueValueClause.java b/src/main/java/net/kemitix/conditional/TrueValueClause.java index 41707c3..46903c5 100644 --- a/src/main/java/net/kemitix/conditional/TrueValueClause.java +++ b/src/main/java/net/kemitix/conditional/TrueValueClause.java @@ -35,7 +35,7 @@ import java.util.function.Supplier; */ class TrueValueClause implements Value.ValueClause { - protected static final Value.ValueClause TRUE = new TrueValueClause<>(); + protected static final Value.ValueClause TRUE = new TrueValueClause<>(); @Override public ValueSupplier then(final Supplier trueSupplier) { diff --git a/src/main/java/net/kemitix/conditional/Value.java b/src/main/java/net/kemitix/conditional/Value.java index d41b481..c07737a 100644 --- a/src/main/java/net/kemitix/conditional/Value.java +++ b/src/main/java/net/kemitix/conditional/Value.java @@ -75,11 +75,12 @@ public interface Value { * * @return a true or false value clause */ + @SuppressWarnings("unchecked") static ValueClause where(final boolean clause) { if (clause) { - return TrueValueClause.TRUE; + return (ValueClause) TrueValueClause.TRUE; } - return FalseValueClause.FALSE; + return (ValueClause) FalseValueClause.FALSE; } /** From a94fe48b9e66d585ccb9b7baa9ffb8ff6097da86 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 13 Mar 2018 22:15:54 +0000 Subject: [PATCH 78/78] version: set to 0.4.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 38800de..bdeef58 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ conditional - 0.4.0-SNAPSHOT + 0.4.0