From b06d754456ece8c8c04292ad3899f626023ad040 Mon Sep 17 00:00:00 2001 From: Jim Zucker Date: Fri, 4 Aug 2023 22:49:57 -0400 Subject: [PATCH 01/12] Fix poms to use revision --- module1/pom.xml | 3 +-- module2/pom.xml | 5 ++--- pom.xml | 5 ++++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/module1/pom.xml b/module1/pom.xml index c6fbc4f..0379a20 100644 --- a/module1/pom.xml +++ b/module1/pom.xml @@ -5,11 +5,10 @@ io.jitpack example-root - 2.0-SNAPSHOT + ${revision} io.jitpack module1 - 2.0-SNAPSHOT module1 http://maven.apache.org diff --git a/module2/pom.xml b/module2/pom.xml index 770ece9..f475199 100644 --- a/module2/pom.xml +++ b/module2/pom.xml @@ -5,12 +5,11 @@ io.jitpack example-root - 2.0-SNAPSHOT + ${revision} io.jitpack module2 - 2.0-SNAPSHOT module2 http://maven.apache.org @@ -23,7 +22,7 @@ io.jitpack module1 - 2.0-SNAPSHOT + ${project.version} junit diff --git a/pom.xml b/pom.xml index f09a7b4..d530f60 100644 --- a/pom.xml +++ b/pom.xml @@ -4,10 +4,13 @@ io.jitpack example-root - 2.0-SNAPSHOT + ${revision} pom example-root + + 2.0-SNAPSHOT + module1 module2 From 91f56446c2ea70c59403a1f003f5b7cf28bacbed Mon Sep 17 00:00:00 2001 From: Jim Zucker Date: Sun, 6 Aug 2023 18:43:48 -0400 Subject: [PATCH 02/12] UPdate to be release friendly build --- README.md | 494 +++++++++++++++++++++++++++++++++++++++++++++++++---- pom.xml | 7 +- release.sh | 84 +++++++++ 3 files changed, 547 insertions(+), 38 deletions(-) create mode 100644 release.sh diff --git a/README.md b/README.md index 97156d2..274e374 100644 --- a/README.md +++ b/README.md @@ -1,37 +1,459 @@ -Example Maven multi-module project -=== - -This project has two maven modules: -- module1 -- module2 - -With multi-module projects the groupId becomes: com.github.User.Repo -And artifactId remains the same as in the module's pom file. - -Module 1: -```xml - - com.github.jitpack.maven-modular - module1 - 1.1 - -``` - -Module 2: -```xml - - com.github.jitpack.maven-modular - module2 - 1.1 - -``` - -To get both of them together use the usual repository syntax: - -```xml - - com.github.jitpack - maven-modular - 1.1 - + +# ci friendly process +Bottom line is we dont want to use maven release plugin it is heavy and timee consuming and not intenced to use wtih ci friendly + +## references: +https://stackoverflow.com/questions/59641739/maven-release-plugin-together-with-cifriendly-versions +https://medium.com/outbrain-engineering/faster-release-with-maven-ci-friendly-versions-and-a-customised-flatten-plugin-fe53f0fcc0df +https://stackoverflow.com/questions/8988405/automatically-incrementing-a-build-number-in-a-java-project +https://maven.apache.org/maven-ci-friendly.html + +# Below are 5 tests output + Test 1: show re-runnign a release due to tag existing (this protect releases) + Test 2: show we fail if there are snapshot depednencies on a release + Test 3: show a proper release, not the version is 1.0.sha1 + Test 4: Show a brnahc relase - note the version is 1.0.sha.branch-SNAPSHOT + Test 5: Show a local build version is 1.0.sha.local-SNAPSHOT + +## Test 1: show re-runnign a release due to tag existing (this protect releases) +``` +(base) ➜ maven-modular git:(master) ✗ sh ./release.sh RELEASE_CHECK +MVN_VERSION=1.0.0-local-SNAPSHOT +GIT_BRANCH=master +HEAD_SHA=11a078e +RELEASE_VERSION=1.0.11a078e +BRANCH_VERSION=1.0.11a078e.master-SNAPSHOT +TEST_OPTION=RELEASE_CHECK +Step 1 Check if releaes exit if it does fail +ERROR: Tag 1.0.11a078e exists, to rebuild version delete tag the re-run +``` + +### cleanup tag +``` +(base) ➜ maven-modular git:(master) ✗ git tag --delete 1.0.11a078e +Deleted tag '1.0.11a078e' (was 11a078e) +``` + +## Test 2: show we fail if there are snapshot depednencies on a release + +``` +(base) ➜ maven-modular git:(master) ✗ sh ./release.sh RELEASE_CHECK +MVN_VERSION=1.0.0-local-SNAPSHOT +GIT_BRANCH=master +HEAD_SHA=11a078e +RELEASE_VERSION=1.0.11a078e +BRANCH_VERSION=1.0.11a078e.master-SNAPSHOT +TEST_OPTION=RELEASE_CHECK +Step 1 Check if releaes exit if it does fail +Step 2 check if we have any snapshots, fail build if we do +ERROR: cannot release with SNAPSHOT dependencies +------------------------------------------------ +./module1/pom.xml: 5.11.0-SNAPSHOT +------------------------------------------------ +Updated 1 path from the index +``` + +## Test 3: show a proper release, not the version is 1.0.sha1 + +``` +(base) ➜ maven-modular git:(master) ✗ sh ./release.sh RELEASE_NO_CHECK +MVN_VERSION=1.0.0-local-SNAPSHOT +GIT_BRANCH=master +HEAD_SHA=11a078e +RELEASE_VERSION=1.0.11a078e +BRANCH_VERSION=1.0.11a078e.master-SNAPSHOT +TEST_OPTION=RELEASE_NO_CHECK +Step 1 Check if releaes exit if it does fail +INFO: Skipping step 2 - checking SNAPSHOT_DEPENDENCIES +Step 3 build branch - fail if build fails for compile or tests we save pushing artifacts +[INFO] Scanning for projects... +[INFO] ------------------------------------------------------------------------ +[INFO] Reactor Build Order: +[INFO] +[INFO] example-root [pom] +[INFO] module1 [jar] +[INFO] module2 [jar] +[INFO] +[INFO] ----------------------< io.jitpack:example-root >----------------------- +[INFO] Building example-root 1.0.11a078e [1/3] +[INFO] --------------------------------[ pom ]--------------------------------- +[INFO] +[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ example-root --- +[INFO] +[INFO] --- maven-install-plugin:2.4:install (default-install) @ example-root --- +[INFO] Installing /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/pom.xml to /Users/jim/.m2/repository/io/jitpack/example-root/1.0.11a078e/example-root-1.0.11a078e.pom +[INFO] +[INFO] -------------------------< io.jitpack:module1 >------------------------- +[INFO] Building module1 1.0.11a078e [2/3] +[INFO] --------------------------------[ jar ]--------------------------------- +[INFO] +[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ module1 --- +[INFO] Deleting /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module1/target +[INFO] +[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ module1 --- +[INFO] Using 'UTF-8' encoding to copy filtered resources. +[INFO] skip non existing resourceDirectory /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module1/src/main/resources +[INFO] +[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ module1 --- +[INFO] Changes detected - recompiling the module! +[INFO] Compiling 1 source file to /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module1/target/classes +[INFO] +[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ module1 --- +[INFO] Using 'UTF-8' encoding to copy filtered resources. +[INFO] skip non existing resourceDirectory /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module1/src/test/resources +[INFO] +[INFO] --- maven-compiler-plugin:3.2:testCompile (default-testCompile) @ module1 --- +[INFO] Changes detected - recompiling the module! +[INFO] Compiling 1 source file to /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module1/target/test-classes +[INFO] +[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ module1 --- +[INFO] Surefire report directory: /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module1/target/surefire-reports + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running io.jitpack.AppTest +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.008 sec + +Results : + +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 + +[INFO] +[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ module1 --- +[INFO] Building jar: /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module1/target/module1-1.0.11a078e.jar +[INFO] +[INFO] --- maven-install-plugin:2.4:install (default-install) @ module1 --- +[INFO] Installing /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module1/target/module1-1.0.11a078e.jar to /Users/jim/.m2/repository/io/jitpack/module1/1.0.11a078e/module1-1.0.11a078e.jar +[INFO] Installing /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module1/pom.xml to /Users/jim/.m2/repository/io/jitpack/module1/1.0.11a078e/module1-1.0.11a078e.pom +[INFO] +[INFO] -------------------------< io.jitpack:module2 >------------------------- +[INFO] Building module2 1.0.11a078e [3/3] +[INFO] --------------------------------[ jar ]--------------------------------- +[INFO] +[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ module2 --- +[INFO] Deleting /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module2/target +[INFO] +[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ module2 --- +[INFO] Using 'UTF-8' encoding to copy filtered resources. +[INFO] skip non existing resourceDirectory /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module2/src/main/resources +[INFO] +[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ module2 --- +[INFO] Changes detected - recompiling the module! +[INFO] Compiling 1 source file to /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module2/target/classes +[INFO] +[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ module2 --- +[INFO] Using 'UTF-8' encoding to copy filtered resources. +[INFO] skip non existing resourceDirectory /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module2/src/test/resources +[INFO] +[INFO] --- maven-compiler-plugin:3.2:testCompile (default-testCompile) @ module2 --- +[INFO] Changes detected - recompiling the module! +[INFO] Compiling 1 source file to /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module2/target/test-classes +[INFO] +[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ module2 --- +[INFO] Surefire report directory: /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module2/target/surefire-reports + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running io.jitpack.AppTest +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.016 sec + +Results : + +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 + +[INFO] +[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ module2 --- +[INFO] Building jar: /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module2/target/module2-1.0.11a078e.jar +[INFO] +[INFO] --- maven-install-plugin:2.4:install (default-install) @ module2 --- +[INFO] Installing /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module2/target/module2-1.0.11a078e.jar to /Users/jim/.m2/repository/io/jitpack/module2/1.0.11a078e/module2-1.0.11a078e.jar +[INFO] Installing /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module2/pom.xml to /Users/jim/.m2/repository/io/jitpack/module2/1.0.11a078e/module2-1.0.11a078e.pom +[INFO] ------------------------------------------------------------------------ +[INFO] Reactor Summary for example-root 1.0.11a078e: +[INFO] +[INFO] example-root ....................................... SUCCESS [ 0.215 s] +[INFO] module1 ............................................ SUCCESS [ 1.462 s] +[INFO] module2 ............................................ SUCCESS [ 0.482 s] +[INFO] ------------------------------------------------------------------------ +[INFO] BUILD SUCCESS +[INFO] ------------------------------------------------------------------------ +[INFO] Total time: 2.234 s +[INFO] Finished at: 2023-08-06T17:50:42-04:00 +[INFO] ------------------------------------------------------------------------ +Step 4 if build passes push to nexus +[INFO] Scanning for projects... +[INFO] ------------------------------------------------------------------------ +[INFO] Reactor Build Order: +[INFO] +[INFO] example-root [pom] +[INFO] module1 [jar] +[INFO] module2 [jar] +[INFO] ------------------------------------------------------------------------ +[INFO] Reactor Summary for example-root 1.0.11a078e: +[INFO] +[INFO] example-root ....................................... SKIPPED +[INFO] module1 ............................................ SKIPPED +[INFO] module2 ............................................ SKIPPED +[INFO] ------------------------------------------------------------------------ +[INFO] BUILD FAILURE +[INFO] ------------------------------------------------------------------------ +[INFO] Total time: 0.072 s +[INFO] Finished at: 2023-08-06T17:50:43-04:00 +[INFO] ------------------------------------------------------------------------ +[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format : or :[:]:. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1] +[ERROR] +[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. +[ERROR] Re-run Maven using the -X switch to enable full debug logging. +[ERROR] +[ERROR] For more information about the errors and possible solutions, please read the following articles: +[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoGoalSpecifiedException +Step 5 - Tag the release and push to repo, tag: 1.0.11a078e +Username for 'https://github.com': ^C +``` + +## Test 4: Show a brnahc relase - note the version is 1.0.sha.branch-SNAPSHOT + +``` +(base) ➜ maven-modular git:(master) ✗ sh ./release.sh BRANCH +MVN_VERSION=1.0.0-local-SNAPSHOT +GIT_BRANCH=master +HEAD_SHA=11a078e +RELEASE_VERSION=1.0.11a078e +BRANCH_VERSION=1.0.11a078e.master-SNAPSHOT +TEST_OPTION=BRANCH +BRANCH release +Step 3 build branch - fail if build fails for compile or tests we save pushing artifacts +[INFO] Scanning for projects... +[INFO] ------------------------------------------------------------------------ +[INFO] Reactor Build Order: +[INFO] +[INFO] example-root [pom] +[INFO] module1 [jar] +[INFO] module2 [jar] +[INFO] +[INFO] ----------------------< io.jitpack:example-root >----------------------- +[INFO] Building example-root 1.0.11a078e.master-SNAPSHOT [1/3] +[INFO] --------------------------------[ pom ]--------------------------------- +[INFO] +[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ example-root --- +[INFO] +[INFO] --- maven-install-plugin:2.4:install (default-install) @ example-root --- +[INFO] Installing /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/pom.xml to /Users/jim/.m2/repository/io/jitpack/example-root/1.0.11a078e.master-SNAPSHOT/example-root-1.0.11a078e.master-SNAPSHOT.pom +[INFO] +[INFO] -------------------------< io.jitpack:module1 >------------------------- +[INFO] Building module1 1.0.11a078e.master-SNAPSHOT [2/3] +[INFO] --------------------------------[ jar ]--------------------------------- +[INFO] +[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ module1 --- +[INFO] Deleting /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module1/target +[INFO] +[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ module1 --- +[INFO] Using 'UTF-8' encoding to copy filtered resources. +[INFO] skip non existing resourceDirectory /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module1/src/main/resources +[INFO] +[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ module1 --- +[INFO] Changes detected - recompiling the module! +[INFO] Compiling 1 source file to /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module1/target/classes +[INFO] +[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ module1 --- +[INFO] Using 'UTF-8' encoding to copy filtered resources. +[INFO] skip non existing resourceDirectory /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module1/src/test/resources +[INFO] +[INFO] --- maven-compiler-plugin:3.2:testCompile (default-testCompile) @ module1 --- +[INFO] Changes detected - recompiling the module! +[INFO] Compiling 1 source file to /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module1/target/test-classes +[INFO] +[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ module1 --- +[INFO] Surefire report directory: /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module1/target/surefire-reports + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running io.jitpack.AppTest +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.006 sec + +Results : + +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 + +[INFO] +[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ module1 --- +[INFO] Building jar: /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module1/target/module1-1.0.11a078e.master-SNAPSHOT.jar +[INFO] +[INFO] --- maven-install-plugin:2.4:install (default-install) @ module1 --- +[INFO] Installing /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module1/target/module1-1.0.11a078e.master-SNAPSHOT.jar to /Users/jim/.m2/repository/io/jitpack/module1/1.0.11a078e.master-SNAPSHOT/module1-1.0.11a078e.master-SNAPSHOT.jar +[INFO] Installing /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module1/pom.xml to /Users/jim/.m2/repository/io/jitpack/module1/1.0.11a078e.master-SNAPSHOT/module1-1.0.11a078e.master-SNAPSHOT.pom +[INFO] +[INFO] -------------------------< io.jitpack:module2 >------------------------- +[INFO] Building module2 1.0.11a078e.master-SNAPSHOT [3/3] +[INFO] --------------------------------[ jar ]--------------------------------- +[INFO] +[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ module2 --- +[INFO] Deleting /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module2/target +[INFO] +[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ module2 --- +[INFO] Using 'UTF-8' encoding to copy filtered resources. +[INFO] skip non existing resourceDirectory /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module2/src/main/resources +[INFO] +[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ module2 --- +[INFO] Changes detected - recompiling the module! +[INFO] Compiling 1 source file to /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module2/target/classes +[INFO] +[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ module2 --- +[INFO] Using 'UTF-8' encoding to copy filtered resources. +[INFO] skip non existing resourceDirectory /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module2/src/test/resources +[INFO] +[INFO] --- maven-compiler-plugin:3.2:testCompile (default-testCompile) @ module2 --- +[INFO] Changes detected - recompiling the module! +[INFO] Compiling 1 source file to /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module2/target/test-classes +[INFO] +[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ module2 --- +[INFO] Surefire report directory: /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module2/target/surefire-reports + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running io.jitpack.AppTest +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.013 sec + +Results : + +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 + +[INFO] +[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ module2 --- +[INFO] Building jar: /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module2/target/module2-1.0.11a078e.master-SNAPSHOT.jar +[INFO] +[INFO] --- maven-install-plugin:2.4:install (default-install) @ module2 --- +[INFO] Installing /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module2/target/module2-1.0.11a078e.master-SNAPSHOT.jar to /Users/jim/.m2/repository/io/jitpack/module2/1.0.11a078e.master-SNAPSHOT/module2-1.0.11a078e.master-SNAPSHOT.jar +[INFO] Installing /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module2/pom.xml to /Users/jim/.m2/repository/io/jitpack/module2/1.0.11a078e.master-SNAPSHOT/module2-1.0.11a078e.master-SNAPSHOT.pom +[INFO] ------------------------------------------------------------------------ +[INFO] Reactor Summary for example-root 1.0.11a078e.master-SNAPSHOT: +[INFO] +[INFO] example-root ....................................... SUCCESS [ 0.208 s] +[INFO] module1 ............................................ SUCCESS [ 1.330 s] +[INFO] module2 ............................................ SUCCESS [ 0.395 s] +[INFO] ------------------------------------------------------------------------ +[INFO] BUILD SUCCESS +[INFO] ------------------------------------------------------------------------ +[INFO] Total time: 2.004 s +[INFO] Finished at: 2023-08-06T17:51:05-04:00 +[INFO] ------------------------------------------------------------------------ +``` + + +## Test 5: Show a local build version is 1.0.sha.local-SNAPSHOT + +``` +(base) ➜ maven-modular git:(master) ✗ mvn install +[INFO] Scanning for projects... +[INFO] ------------------------------------------------------------------------ +[INFO] Reactor Build Order: +[INFO] +[INFO] example-root [pom] +[INFO] module1 [jar] +[INFO] module2 [jar] +[INFO] +[INFO] ----------------------< io.jitpack:example-root >----------------------- +[INFO] Building example-root 1.0.0-local-SNAPSHOT [1/3] +[INFO] --------------------------------[ pom ]--------------------------------- +[INFO] +[INFO] --- maven-install-plugin:2.4:install (default-install) @ example-root --- +[INFO] Installing /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/pom.xml to /Users/jim/.m2/repository/io/jitpack/example-root/1.0.0-local-SNAPSHOT/example-root-1.0.0-local-SNAPSHOT.pom +[INFO] +[INFO] -------------------------< io.jitpack:module1 >------------------------- +[INFO] Building module1 1.0.0-local-SNAPSHOT [2/3] +[INFO] --------------------------------[ jar ]--------------------------------- +[INFO] +[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ module1 --- +[INFO] Using 'UTF-8' encoding to copy filtered resources. +[INFO] skip non existing resourceDirectory /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module1/src/main/resources +[INFO] +[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ module1 --- +[INFO] Changes detected - recompiling the module! +[INFO] Compiling 1 source file to /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module1/target/classes +[INFO] +[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ module1 --- +[INFO] Using 'UTF-8' encoding to copy filtered resources. +[INFO] skip non existing resourceDirectory /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module1/src/test/resources +[INFO] +[INFO] --- maven-compiler-plugin:3.2:testCompile (default-testCompile) @ module1 --- +[INFO] Changes detected - recompiling the module! +[INFO] Compiling 1 source file to /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module1/target/test-classes +[INFO] +[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ module1 --- +[INFO] Surefire report directory: /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module1/target/surefire-reports + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running io.jitpack.AppTest +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.006 sec + +Results : + +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 + +[INFO] +[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ module1 --- +[INFO] Building jar: /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module1/target/module1-1.0.0-local-SNAPSHOT.jar +[INFO] +[INFO] --- maven-install-plugin:2.4:install (default-install) @ module1 --- +[INFO] Installing /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module1/target/module1-1.0.0-local-SNAPSHOT.jar to /Users/jim/.m2/repository/io/jitpack/module1/1.0.0-local-SNAPSHOT/module1-1.0.0-local-SNAPSHOT.jar +[INFO] Installing /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module1/pom.xml to /Users/jim/.m2/repository/io/jitpack/module1/1.0.0-local-SNAPSHOT/module1-1.0.0-local-SNAPSHOT.pom +[INFO] +[INFO] -------------------------< io.jitpack:module2 >------------------------- +[INFO] Building module2 1.0.0-local-SNAPSHOT [3/3] +[INFO] --------------------------------[ jar ]--------------------------------- +[INFO] +[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ module2 --- +[INFO] Using 'UTF-8' encoding to copy filtered resources. +[INFO] skip non existing resourceDirectory /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module2/src/main/resources +[INFO] +[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ module2 --- +[INFO] Changes detected - recompiling the module! +[INFO] Compiling 1 source file to /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module2/target/classes +[INFO] +[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ module2 --- +[INFO] Using 'UTF-8' encoding to copy filtered resources. +[INFO] skip non existing resourceDirectory /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module2/src/test/resources +[INFO] +[INFO] --- maven-compiler-plugin:3.2:testCompile (default-testCompile) @ module2 --- +[INFO] Changes detected - recompiling the module! +[INFO] Compiling 1 source file to /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module2/target/test-classes +[INFO] +[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ module2 --- +[INFO] Surefire report directory: /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module2/target/surefire-reports + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running io.jitpack.AppTest +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.017 sec + +Results : + +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 + +[INFO] +[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ module2 --- +[INFO] Building jar: /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module2/target/module2-1.0.0-local-SNAPSHOT.jar +[INFO] +[INFO] --- maven-install-plugin:2.4:install (default-install) @ module2 --- +[INFO] Installing /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module2/target/module2-1.0.0-local-SNAPSHOT.jar to /Users/jim/.m2/repository/io/jitpack/module2/1.0.0-local-SNAPSHOT/module2-1.0.0-local-SNAPSHOT.jar +[INFO] Installing /Users/jim/Library/CloudStorage/OneDrive-NessDigitalEngineering/rf-dev/maven-modular/module2/pom.xml to /Users/jim/.m2/repository/io/jitpack/module2/1.0.0-local-SNAPSHOT/module2-1.0.0-local-SNAPSHOT.pom +[INFO] ------------------------------------------------------------------------ +[INFO] Reactor Summary for example-root 1.0.0-local-SNAPSHOT: +[INFO] +[INFO] example-root ....................................... SUCCESS [ 0.196 s] +[INFO] module1 ............................................ SUCCESS [ 1.528 s] +[INFO] module2 ............................................ SUCCESS [ 0.534 s] +[INFO] ------------------------------------------------------------------------ +[INFO] BUILD SUCCESS +[INFO] ------------------------------------------------------------------------ +[INFO] Total time: 2.334 s +[INFO] Finished at: 2023-08-06T17:55:44-04:00 +[INFO] ------------------------------------------------------------------------ ``` diff --git a/pom.xml b/pom.xml index d530f60..260d56c 100644 --- a/pom.xml +++ b/pom.xml @@ -7,17 +7,20 @@ ${revision} pom example-root - + - 2.0-SNAPSHOT + 1.0.0-local-SNAPSHOT + module1 module2 + + org.apache.maven.plugins maven-compiler-plugin diff --git a/release.sh b/release.sh new file mode 100644 index 0000000..53101ff --- /dev/null +++ b/release.sh @@ -0,0 +1,84 @@ +#!/bin/sh + +TEST_OPTION=$1 +if [ "TEST_OPTION" = "help" ] +then + echo " test options + BRANCH - Release Branch Snapshopt like jenkins branch build" + RELEASE_CHECK - do full release process, check for snapshots + RELEASE_NO_CHECK - bypass snapshot check on build +fi + +#get the current pom version and store it into a variable +MVN_VERSION=`mvn help:evaluate -Dexpression=project.properties -q -DforceStdout|egrep revision|cut -f2 -d\>|cut -f1 -d\<` +echo "MVN_VERSION=$MVN_VERSION" + +GIT_BRANCH=`git rev-parse --abbrev-ref HEAD` +echo "GIT_BRANCH=$GIT_BRANCH" +HEAD_SHA=`git rev-parse --short HEAD` +echo "HEAD_SHA=$HEAD_SHA" + +#increment the second digit of the version and overwrite the variable +RELEASE_VERSION=$(echo ${MVN_VERSION} | awk -F'.' '{print $1"."$2}' | sed s/[.]$//)".$HEAD_SHA" +echo "RELEASE_VERSION=$RELEASE_VERSION" + +BRANCH_VERSION="${RELEASE_VERSION}.${GIT_BRANCH}-SNAPSHOT" +echo "BRANCH_VERSION=$BRANCH_VERSION" + +echo "TEST_OPTION=$TEST_OPTION" +case "$TEST_OPTION" in + + + "RELEASE_CHECK" | "RELEASE_NO_CHECK") + echo "Step 1 Check if releaes exit if it does fail" + EXISTING_TAG=`git tag --list | egrep "$RELEASE_VERSION"` + if [ "$EXISTING_TAG" != "" ] + then + echo "ERROR: Tag $RELEASE_VERSION exists, to rebuild version delete tag the re-run" + exit 1 + fi + + if [ "$TEST_OPTION" = "RELEASE_CHECK" ] + then + #for demoo purposes + cp module1/pom.xml module1/pom.xml.bak + sed 's/3.8.1/5.11.0-SNAPSHOT/g' module1/pom.xml.bak >module1/pom.xml + + echo "Step 2 check if we have any snapshots, fail build if we do" + SNAPSHOT_DEPENDENCIES=`find . -name pom.xml -exec egrep -H SNAPSHOT {} \;|egrep -v '.*\..*\..*-SNAPSHOT'` + #echo "SNAPSHOT_DEPENDENCIES=$SNAPSHOT_DEPENDENCIES" + if [ "$SNAPSHOT_DEPENDENCIES" != "" ] + then + echo "ERROR: cannot release with SNAPSHOT dependencies" + echo "------------------------------------------------" + echo $SNAPSHOT_DEPENDENCIES + echo "------------------------------------------------" + + #for demo cleanup + git co module1/pom.xml + + exit 1 + fi + else + echo "INFO: Skipping step 2 - checking SNAPSHOT_DEPENDENCIES" + fi + + echo "Step 3 build branch - fail if build fails for compile or tests we save pushing artifacts" + mvn -Drevision="$RELEASE_VERSION" clean install + + echo "Step 4 if build passes push to nexus" + mvn -Drevision="$RELEASE_VERSION" -DskipTests + #mvn -Drevision=$RELEASE_VERSION -DskipTests deploy + + echo "Step 5 - Tag the release and push to repo, tag: $RELEASE_VERSION" + git tag $RELEASE_VERSION + git push origin $RELEASE_VERSION + ;; + + *) echo "BRANCH release" + echo "Step 3 build branch - fail if build fails for compile or tests we save pushing artifacts" + #mvn -Drevision=$BRANCH_VERSION clean install deploy + mvn -Drevision=$BRANCH_VERSION clean install + ;; +esac + From 363ab513b07d5d48806bf39764654087a6afe8e3 Mon Sep 17 00:00:00 2001 From: Jim Zucker Date: Sun, 6 Aug 2023 21:18:43 -0400 Subject: [PATCH 03/12] Add tests for build --- README.md | 1 + pom.xml | 27 ++++++++++++++++++++++----- release.sh | 6 +++++- testRelease/pom.xml | 29 +++++++++++++++++++++++++++++ 4 files changed, 57 insertions(+), 6 deletions(-) create mode 100644 testRelease/pom.xml diff --git a/README.md b/README.md index 274e374..e6a3449 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ https://maven.apache.org/maven-ci-friendly.html Test 2: show we fail if there are snapshot depednencies on a release Test 3: show a proper release, not the version is 1.0.sha1 Test 4: Show a brnahc relase - note the version is 1.0.sha.branch-SNAPSHOT + Step 4a Validate maven artifacts Test 5: Show a local build version is 1.0.sha.local-SNAPSHOT ## Test 1: show re-runnign a release due to tag existing (this protect releases) diff --git a/pom.xml b/pom.xml index 260d56c..7c539f7 100644 --- a/pom.xml +++ b/pom.xml @@ -12,12 +12,29 @@ 1.0.0-local-SNAPSHOT - - module1 - module2 - + + + default + + true + + default + !disabled + + + + module1 + module2 + + + + testRelease + + testRelease + + + - diff --git a/release.sh b/release.sh index 53101ff..734ff97 100644 --- a/release.sh +++ b/release.sh @@ -63,13 +63,17 @@ case "$TEST_OPTION" in echo "INFO: Skipping step 2 - checking SNAPSHOT_DEPENDENCIES" fi + set -e echo "Step 3 build branch - fail if build fails for compile or tests we save pushing artifacts" mvn -Drevision="$RELEASE_VERSION" clean install echo "Step 4 if build passes push to nexus" - mvn -Drevision="$RELEASE_VERSION" -DskipTests + mvn -Drevision="$RELEASE_VERSION" -DskipTests validate #mvn -Drevision=$RELEASE_VERSION -DskipTests deploy + echo "Step 4a Validate maven artifacts" + mvn -Drevision="$RELEASE_VERSION" -DskipTests -P testRelease install + echo "Step 5 - Tag the release and push to repo, tag: $RELEASE_VERSION" git tag $RELEASE_VERSION git push origin $RELEASE_VERSION diff --git a/testRelease/pom.xml b/testRelease/pom.xml new file mode 100644 index 0000000..a2daf57 --- /dev/null +++ b/testRelease/pom.xml @@ -0,0 +1,29 @@ + + + 4.0.0 + + io.jitpack + example-root + ${revision} + + + io.jitpack + testrelease + module2 + pom + + + + + io.jitpack + module1 + ${project.version} + + + io.jitpack + module2 + ${project.version} + + + From 7ecf2181a58ec66ed7b2cd614e082652de22e79b Mon Sep 17 00:00:00 2001 From: Jim Zucker Date: Mon, 7 Aug 2023 06:01:05 -0400 Subject: [PATCH 04/12] Update README.md --- README.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e6a3449..10bb1a3 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,13 @@ Bottom line is we dont want to use maven release plugin it is heavy and timee consuming and not intenced to use wtih ci friendly ## references: -https://stackoverflow.com/questions/59641739/maven-release-plugin-together-with-cifriendly-versions -https://medium.com/outbrain-engineering/faster-release-with-maven-ci-friendly-versions-and-a-customised-flatten-plugin-fe53f0fcc0df -https://stackoverflow.com/questions/8988405/automatically-incrementing-a-build-number-in-a-java-project -https://maven.apache.org/maven-ci-friendly.html +1. https://stackoverflow.com/questions/59641739/maven-release-plugin-together-with-cifriendly-versions + +2. https://medium.com/outbrain-engineering/faster-release-with-maven-ci-friendly-versions-and-a-customised-flatten-plugin-fe53f0fcc0df + +3. https://stackoverflow.com/questions/8988405/automatically-incrementing-a-build-number-in-a-java-project + +4. https://maven.apache.org/maven-ci-friendly.html # Below are 5 tests output Test 1: show re-runnign a release due to tag existing (this protect releases) From 2b35ba25b04d0233619f07f0384fa68e033b845e Mon Sep 17 00:00:00 2001 From: Jim Zucker Date: Mon, 7 Aug 2023 06:02:28 -0400 Subject: [PATCH 05/12] Update README.md Give credit to forked from jitpack/maven-modular --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 10bb1a3..42907c1 100644 --- a/README.md +++ b/README.md @@ -4,12 +4,10 @@ Bottom line is we dont want to use maven release plugin it is heavy and timee co ## references: 1. https://stackoverflow.com/questions/59641739/maven-release-plugin-together-with-cifriendly-versions - 2. https://medium.com/outbrain-engineering/faster-release-with-maven-ci-friendly-versions-and-a-customised-flatten-plugin-fe53f0fcc0df - 3. https://stackoverflow.com/questions/8988405/automatically-incrementing-a-build-number-in-a-java-project - 4. https://maven.apache.org/maven-ci-friendly.html +5. Project forked from jitpack/maven-modular # Below are 5 tests output Test 1: show re-runnign a release due to tag existing (this protect releases) From 58619673c0f78feddcca753d0b8d0cc8d645fa39 Mon Sep 17 00:00:00 2001 From: Jim Zucker Date: Sun, 13 Aug 2023 10:31:30 -0400 Subject: [PATCH 06/12] Update README.md --- README.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 42907c1..049d8d8 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # ci friendly process -Bottom line is we dont want to use maven release plugin it is heavy and timee consuming and not intenced to use wtih ci friendly +The bottom line is we do not want to use Maven release plugin. It is heavy and time consuming and not intended to use with ci friendly ## references: 1. https://stackoverflow.com/questions/59641739/maven-release-plugin-together-with-cifriendly-versions @@ -9,15 +9,15 @@ Bottom line is we dont want to use maven release plugin it is heavy and timee co 4. https://maven.apache.org/maven-ci-friendly.html 5. Project forked from jitpack/maven-modular -# Below are 5 tests output - Test 1: show re-runnign a release due to tag existing (this protect releases) - Test 2: show we fail if there are snapshot depednencies on a release - Test 3: show a proper release, not the version is 1.0.sha1 - Test 4: Show a brnahc relase - note the version is 1.0.sha.branch-SNAPSHOT +# Below are five tests output + Test 1: show re-running a release due to the tag existing (this protects releases) + Test 2: show we fail if there are snapshot dependencies on a release + Test 3: show a proper release, not version is 1.0.sha1 + Test 4: Show a branch release - note the version is 1.0.sha.branch-SNAPSHOT Step 4a Validate maven artifacts Test 5: Show a local build version is 1.0.sha.local-SNAPSHOT -## Test 1: show re-runnign a release due to tag existing (this protect releases) +## Test 1: show re-running a release due to the tag existing (this protects releases) ``` (base) ➜ maven-modular git:(master) ✗ sh ./release.sh RELEASE_CHECK MVN_VERSION=1.0.0-local-SNAPSHOT @@ -26,7 +26,7 @@ HEAD_SHA=11a078e RELEASE_VERSION=1.0.11a078e BRANCH_VERSION=1.0.11a078e.master-SNAPSHOT TEST_OPTION=RELEASE_CHECK -Step 1 Check if releaes exit if it does fail +Step 1 Check if release exit if it does fail ERROR: Tag 1.0.11a078e exists, to rebuild version delete tag the re-run ``` @@ -36,7 +36,7 @@ ERROR: Tag 1.0.11a078e exists, to rebuild version delete tag the re-run Deleted tag '1.0.11a078e' (was 11a078e) ``` -## Test 2: show we fail if there are snapshot depednencies on a release +## Test 2: show we fail if there are snapshot dependencies on a release ``` (base) ➜ maven-modular git:(master) ✗ sh ./release.sh RELEASE_CHECK @@ -46,8 +46,8 @@ HEAD_SHA=11a078e RELEASE_VERSION=1.0.11a078e BRANCH_VERSION=1.0.11a078e.master-SNAPSHOT TEST_OPTION=RELEASE_CHECK -Step 1 Check if releaes exit if it does fail -Step 2 check if we have any snapshots, fail build if we do +Step 1 Check if release exit if it does fail +Step 2 check if we have any snapshots, fail to build if we do ERROR: cannot release with SNAPSHOT dependencies ------------------------------------------------ ./module1/pom.xml: 5.11.0-SNAPSHOT @@ -55,7 +55,7 @@ ERROR: cannot release with SNAPSHOT dependencies Updated 1 path from the index ``` -## Test 3: show a proper release, not the version is 1.0.sha1 +## Test 3: show a proper release, note version is 1.0.sha1 ``` (base) ➜ maven-modular git:(master) ✗ sh ./release.sh RELEASE_NO_CHECK @@ -65,9 +65,9 @@ HEAD_SHA=11a078e RELEASE_VERSION=1.0.11a078e BRANCH_VERSION=1.0.11a078e.master-SNAPSHOT TEST_OPTION=RELEASE_NO_CHECK -Step 1 Check if releaes exit if it does fail +Step 1 Check if releases exit if it does fail INFO: Skipping step 2 - checking SNAPSHOT_DEPENDENCIES -Step 3 build branch - fail if build fails for compile or tests we save pushing artifacts +Step 3 build branch - fail if the build fails for compile or tests, we save pushing artifacts [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Reactor Build Order: From 90330f77c404de10ac1bae1e9d6dd86ba68d67d4 Mon Sep 17 00:00:00 2001 From: Jim Zucker Date: Sun, 13 Aug 2023 10:32:44 -0400 Subject: [PATCH 07/12] Update release.sh --- release.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/release.sh b/release.sh index 734ff97..384b9b0 100644 --- a/release.sh +++ b/release.sh @@ -30,7 +30,7 @@ case "$TEST_OPTION" in "RELEASE_CHECK" | "RELEASE_NO_CHECK") - echo "Step 1 Check if releaes exit if it does fail" + echo "Step 1 Check if releases exit if it does fail." EXISTING_TAG=`git tag --list | egrep "$RELEASE_VERSION"` if [ "$EXISTING_TAG" != "" ] then @@ -40,16 +40,16 @@ case "$TEST_OPTION" in if [ "$TEST_OPTION" = "RELEASE_CHECK" ] then - #for demoo purposes + #for demo purposes cp module1/pom.xml module1/pom.xml.bak sed 's/3.8.1/5.11.0-SNAPSHOT/g' module1/pom.xml.bak >module1/pom.xml - echo "Step 2 check if we have any snapshots, fail build if we do" + echo "Step 2 check if we have any snapshots, fail build if we do." SNAPSHOT_DEPENDENCIES=`find . -name pom.xml -exec egrep -H SNAPSHOT {} \;|egrep -v '.*\..*\..*-SNAPSHOT'` #echo "SNAPSHOT_DEPENDENCIES=$SNAPSHOT_DEPENDENCIES" if [ "$SNAPSHOT_DEPENDENCIES" != "" ] then - echo "ERROR: cannot release with SNAPSHOT dependencies" + echo "ERROR: cannot release with SNAPSHOT dependencies." echo "------------------------------------------------" echo $SNAPSHOT_DEPENDENCIES echo "------------------------------------------------" @@ -64,14 +64,14 @@ case "$TEST_OPTION" in fi set -e - echo "Step 3 build branch - fail if build fails for compile or tests we save pushing artifacts" + echo "Step 3 build branch - fail if the build fails for compile or tests we save pushing artifacts." mvn -Drevision="$RELEASE_VERSION" clean install - echo "Step 4 if build passes push to nexus" + echo "Step 4 if the build passes push to nexus." mvn -Drevision="$RELEASE_VERSION" -DskipTests validate #mvn -Drevision=$RELEASE_VERSION -DskipTests deploy - echo "Step 4a Validate maven artifacts" + echo "Step 4a Validate maven artifacts." mvn -Drevision="$RELEASE_VERSION" -DskipTests -P testRelease install echo "Step 5 - Tag the release and push to repo, tag: $RELEASE_VERSION" @@ -79,8 +79,8 @@ case "$TEST_OPTION" in git push origin $RELEASE_VERSION ;; - *) echo "BRANCH release" - echo "Step 3 build branch - fail if build fails for compile or tests we save pushing artifacts" + *) echo "BRANCH release." + echo "Step 3 build branch - fail if the build fails for compile or tests we save pushing artifacts." #mvn -Drevision=$BRANCH_VERSION clean install deploy mvn -Drevision=$BRANCH_VERSION clean install ;; From efe9881118c89f61da916be860b4b7cbc13a40db Mon Sep 17 00:00:00 2001 From: Jim Zucker Date: Sun, 13 Aug 2023 10:34:21 -0400 Subject: [PATCH 08/12] Mark Test Code --- release.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/release.sh b/release.sh index 384b9b0..d77e9e0 100644 --- a/release.sh +++ b/release.sh @@ -40,10 +40,11 @@ case "$TEST_OPTION" in if [ "$TEST_OPTION" = "RELEASE_CHECK" ] then - #for demo purposes + #for demo purposes to make the build fail cp module1/pom.xml module1/pom.xml.bak sed 's/3.8.1/5.11.0-SNAPSHOT/g' module1/pom.xml.bak >module1/pom.xml - + ##### test code end + echo "Step 2 check if we have any snapshots, fail build if we do." SNAPSHOT_DEPENDENCIES=`find . -name pom.xml -exec egrep -H SNAPSHOT {} \;|egrep -v '.*\..*\..*-SNAPSHOT'` #echo "SNAPSHOT_DEPENDENCIES=$SNAPSHOT_DEPENDENCIES" From 37df4f1a5fd3e03bf1a92b0ed0fbe309bfbcd4bd Mon Sep 17 00:00:00 2001 From: Jim Zucker Date: Sun, 13 Aug 2023 10:44:27 -0400 Subject: [PATCH 09/12] Update README.md --- README.md | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 049d8d8..b1b691a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,24 @@ # ci friendly process -The bottom line is we do not want to use Maven release plugin. It is heavy and time consuming and not intended to use with ci friendly +The bottom line is we do not want to use the Maven release plugin. It is heavy, time-consuming, and not intended to use with ci-friendly '' property. + +## General Approach +The build should read the version from the '' tag in the parent pom and then build the repo passing -Drevision=xxx to build the appropriate versions. We will use the x.y from this property but ignore the .z- and construct the version as follows: + +### Feature branches +1. Set version to x.y..-SNAPSHOT +2. Do not tag anything + +### Protected branch +1. Validations: Check if the release tag exists and check for snapshot dependencies; both of these will fail the build +3. Set version to x.y. as a projected branch is always a release +4. Tag the protected branch with the release id + +## Benefits +1. Faster +2. Faster +3. Every merge commit creates a release and tag +4. There are no commits to the projected branch by CI, so we don't create additional builds in the pipeline. ## references: 1. https://stackoverflow.com/questions/59641739/maven-release-plugin-together-with-cifriendly-versions @@ -9,7 +27,7 @@ The bottom line is we do not want to use Maven release plugin. It is heavy and t 4. https://maven.apache.org/maven-ci-friendly.html 5. Project forked from jitpack/maven-modular -# Below are five tests output +## Below are five tests output Test 1: show re-running a release due to the tag existing (this protects releases) Test 2: show we fail if there are snapshot dependencies on a release Test 3: show a proper release, not version is 1.0.sha1 From bd8e364aef6134c2df0c98e3e9aade64e3b3caf8 Mon Sep 17 00:00:00 2001 From: Jim Zucker Date: Sun, 13 Aug 2023 10:47:30 -0400 Subject: [PATCH 10/12] Update README.md --- README.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index b1b691a..dd65e85 100644 --- a/README.md +++ b/README.md @@ -11,14 +11,15 @@ The build should read the version from the '' tag in the parent pom an ### Protected branch 1. Validations: Check if the release tag exists and check for snapshot dependencies; both of these will fail the build -3. Set version to x.y. as a projected branch is always a release -4. Tag the protected branch with the release id +2. Set version to x.y. as a projected branch is always a release +3. Run clean install package # Note: deploy run as a separate step so we don't push artifacts or create tags if build/tests fail. +4. Run deploy +5. Tag the protected branch with the release id ## Benefits -1. Faster -2. Faster -3. Every merge commit creates a release and tag -4. There are no commits to the projected branch by CI, so we don't create additional builds in the pipeline. +1. Your builds are measurably faster than using the release plugin +2. Every merge commit creates a release and tag +3. There are no commits to the projected branch by CI, so we don't create additional builds in the pipeline. ## references: 1. https://stackoverflow.com/questions/59641739/maven-release-plugin-together-with-cifriendly-versions From 444ac786dfa43480be3b13b77a1a87dcbed3d807 Mon Sep 17 00:00:00 2001 From: Jim Zucker Date: Thu, 2 May 2024 05:07:16 -0400 Subject: [PATCH 11/12] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dd65e85..b4c56e4 100644 --- a/README.md +++ b/README.md @@ -234,7 +234,7 @@ Step 5 - Tag the release and push to repo, tag: 1.0.11a078e Username for 'https://github.com': ^C ``` -## Test 4: Show a brnahc relase - note the version is 1.0.sha.branch-SNAPSHOT +## Test 4: Show a branch release - note the version is 1.0.sha.branch-SNAPSHOT ``` (base) ➜ maven-modular git:(master) ✗ sh ./release.sh BRANCH From 212fcc0069c6fbaf72af2d3e262be14863f47793 Mon Sep 17 00:00:00 2001 From: Jim Zucker Date: Thu, 2 May 2024 05:08:47 -0400 Subject: [PATCH 12/12] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b4c56e4..829fa55 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ The build should read the version from the '' tag in the parent pom an ## Benefits 1. Your builds are measurably faster than using the release plugin 2. Every merge commit creates a release and tag -3. There are no commits to the projected branch by CI, so we don't create additional builds in the pipeline. +3. There are no commits to the protected branch by CI, so we don't create additional builds in the pipeline. ## references: 1. https://stackoverflow.com/questions/59641739/maven-release-plugin-together-with-cifriendly-versions