From 9d087355029512a464bc548ceed72a8daa63d949 Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Sat, 14 Sep 2024 18:22:33 -0700 Subject: [PATCH 01/59] Break ground on code for Winter 2025 by introducing SNAPSHOT versions of project artifacts. --- examples/pom.xml | 10 +++++----- family/pom.xml | 6 +++--- grader/pom.xml | 4 ++-- pom.xml | 4 ++-- .../archetypes-parent/airline-archetype/pom.xml | 4 ++-- .../src/main/resources/archetype-resources/pom.xml | 6 +++--- .../archetypes-parent/airline-web-archetype/pom.xml | 4 ++-- .../src/main/resources/archetype-resources/pom.xml | 8 ++++---- .../archetypes-parent/apptbook-archetype/pom.xml | 4 ++-- .../src/main/resources/archetype-resources/pom.xml | 6 +++--- .../archetypes-parent/apptbook-web-archetype/pom.xml | 4 ++-- .../src/main/resources/archetype-resources/pom.xml | 8 ++++---- .../archetypes-parent/java-koans-archetype/pom.xml | 4 ++-- .../src/main/resources/archetype-resources/pom.xml | 4 ++-- .../archetypes-parent/kata-archetype/pom.xml | 4 ++-- .../src/main/resources/archetype-resources/pom.xml | 4 ++-- .../archetypes-parent/phonebill-archetype/pom.xml | 4 ++-- .../src/main/resources/archetype-resources/pom.xml | 6 +++--- .../archetypes-parent/phonebill-web-archetype/pom.xml | 4 ++-- .../src/main/resources/archetype-resources/pom.xml | 8 ++++---- projects-parent/archetypes-parent/pom.xml | 4 ++-- .../archetypes-parent/student-archetype/pom.xml | 4 ++-- .../src/main/resources/archetype-resources/pom.xml | 6 +++--- projects-parent/originals-parent/airline-web/pom.xml | 8 ++++---- projects-parent/originals-parent/airline/pom.xml | 8 ++++---- projects-parent/originals-parent/apptbook-web/pom.xml | 8 ++++---- projects-parent/originals-parent/apptbook/pom.xml | 8 ++++---- projects-parent/originals-parent/kata/pom.xml | 6 +++--- projects-parent/originals-parent/phonebill-web/pom.xml | 8 ++++---- projects-parent/originals-parent/phonebill/pom.xml | 8 ++++---- projects-parent/originals-parent/pom.xml | 4 ++-- projects-parent/originals-parent/student/pom.xml | 6 +++--- projects-parent/pom.xml | 4 ++-- projects-parent/projects/pom.xml | 4 ++-- web/pom.xml | 7 +++---- 35 files changed, 99 insertions(+), 100 deletions(-) diff --git a/examples/pom.xml b/examples/pom.xml index b18ae4448..ef459325c 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -3,23 +3,23 @@ joy io.github.davidwhitlock.joy - 1.1.1 + 1.1.2-SNAPSHOT 4.0.0 examples examples - 1.2.1 + 1.2.2-SNAPSHOT https://www.cs.pdx.edu/~whitlock io.github.davidwhitlock.joy family - 1.1.1 + 1.1.2-SNAPSHOT io.github.davidwhitlock.joy projects - 2.1.1 + 2.1.1-SNAPSHOT com.sun.mail @@ -45,7 +45,7 @@ io.github.davidwhitlock.joy projects - 2.1.1 + 2.1.1-SNAPSHOT tests test diff --git a/family/pom.xml b/family/pom.xml index 1419b4be0..4c56ce99c 100644 --- a/family/pom.xml +++ b/family/pom.xml @@ -3,12 +3,12 @@ joy io.github.davidwhitlock.joy - 1.1.1 + 1.1.2-SNAPSHOT 4.0.0 family jar - 1.1.1 + 1.1.2-SNAPSHOT Family Tree Application An Family Tree application for The Joy of Coding https://www.cs.pdx.edu/~whitlock @@ -16,7 +16,7 @@ io.github.davidwhitlock.joy projects - 2.1.1 + 2.1.1-SNAPSHOT diff --git a/grader/pom.xml b/grader/pom.xml index eedc34d2b..847700b47 100644 --- a/grader/pom.xml +++ b/grader/pom.xml @@ -2,7 +2,7 @@ joy io.github.davidwhitlock.joy - 1.1.1 + 1.1.2-SNAPSHOT 4.0.0 grader @@ -19,7 +19,7 @@ io.github.davidwhitlock.joy projects - 2.1.1 + 2.1.1-SNAPSHOT com.opencsv diff --git a/pom.xml b/pom.xml index 11b04710d..ce731a6b4 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 io.github.davidwhitlock.joy - 1.1.1 + 1.1.2-SNAPSHOT joy pom Java Example Code @@ -92,7 +92,7 @@ 0.75 0 - 1.3.0 + 1.3.1-SNAPSHOT diff --git a/projects-parent/archetypes-parent/airline-archetype/pom.xml b/projects-parent/archetypes-parent/airline-archetype/pom.xml index cbb79b8d8..c698b8435 100644 --- a/projects-parent/archetypes-parent/airline-archetype/pom.xml +++ b/projects-parent/archetypes-parent/airline-archetype/pom.xml @@ -4,10 +4,10 @@ archetypes-parent io.github.davidwhitlock.joy - 2.1.1 + 2.1.1-SNAPSHOT airline-archetype - 2.1.1 + 2.1.1-SNAPSHOT maven-archetype airline-archetype diff --git a/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/pom.xml index 867ccbad7..145f69415 100644 --- a/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/pom.xml @@ -3,7 +3,7 @@ joy io.github.davidwhitlock.joy - 1.1.1 + 1.1.2-SNAPSHOT 4.0.0 ${groupId} @@ -32,12 +32,12 @@ io.github.davidwhitlock.joy projects - 2.1.1 + 2.1.1-SNAPSHOT io.github.davidwhitlock.joy projects - 2.1.1 + 2.1.1-SNAPSHOT tests test diff --git a/projects-parent/archetypes-parent/airline-web-archetype/pom.xml b/projects-parent/archetypes-parent/airline-web-archetype/pom.xml index c121430aa..3afd6ada8 100644 --- a/projects-parent/archetypes-parent/airline-web-archetype/pom.xml +++ b/projects-parent/archetypes-parent/airline-web-archetype/pom.xml @@ -4,10 +4,10 @@ archetypes-parent io.github.davidwhitlock.joy - 2.1.1 + 2.1.1-SNAPSHOT airline-web-archetype - 2.2.1 + 2.2.2-SNAPSHOT maven-archetype airline-web-archetype diff --git a/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/pom.xml index c67e1fa39..67f20de41 100644 --- a/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/pom.xml @@ -3,7 +3,7 @@ joy io.github.davidwhitlock.joy - 1.1.1 + 1.1.2-SNAPSHOT 4.0.0 ${groupId} @@ -21,17 +21,17 @@ io.github.davidwhitlock.joy projects - 2.1.1 + 2.1.1-SNAPSHOT io.github.davidwhitlock.joy examples - 1.2.1 + 1.2.2-SNAPSHOT io.github.davidwhitlock.joy projects - 2.1.1 + 2.1.1-SNAPSHOT tests test diff --git a/projects-parent/archetypes-parent/apptbook-archetype/pom.xml b/projects-parent/archetypes-parent/apptbook-archetype/pom.xml index 6cc388614..04ac31631 100644 --- a/projects-parent/archetypes-parent/apptbook-archetype/pom.xml +++ b/projects-parent/archetypes-parent/apptbook-archetype/pom.xml @@ -4,10 +4,10 @@ archetypes-parent io.github.davidwhitlock.joy - 2.1.1 + 2.1.1-SNAPSHOT apptbook-archetype - 2.1.1 + 2.1.1-SNAPSHOT maven-archetype apptbook-archetype diff --git a/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/pom.xml index 37dac08c9..491f6ceee 100644 --- a/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/pom.xml @@ -3,7 +3,7 @@ joy io.github.davidwhitlock.joy - 1.1.1 + 1.1.2-SNAPSHOT 4.0.0 ${groupId} @@ -32,12 +32,12 @@ io.github.davidwhitlock.joy projects - 2.1.1 + 2.1.1-SNAPSHOT io.github.davidwhitlock.joy projects - 2.1.1 + 2.1.1-SNAPSHOT tests test diff --git a/projects-parent/archetypes-parent/apptbook-web-archetype/pom.xml b/projects-parent/archetypes-parent/apptbook-web-archetype/pom.xml index 439e53e87..163626a0c 100644 --- a/projects-parent/archetypes-parent/apptbook-web-archetype/pom.xml +++ b/projects-parent/archetypes-parent/apptbook-web-archetype/pom.xml @@ -4,10 +4,10 @@ archetypes-parent io.github.davidwhitlock.joy - 2.1.1 + 2.1.1-SNAPSHOT apptbook-web-archetype - 2.2.1 + 2.2.2-SNAPSHOT maven-archetype apptbook-web-archetype diff --git a/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/pom.xml index 17e39ca93..8227459fd 100644 --- a/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/pom.xml @@ -3,7 +3,7 @@ joy io.github.davidwhitlock.joy - 1.1.1 + 1.1.2-SNAPSHOT 4.0.0 ${groupId} @@ -21,17 +21,17 @@ io.github.davidwhitlock.joy projects - 2.1.1 + 2.1.1-SNAPSHOT io.github.davidwhitlock.joy examples - 1.2.1 + 1.2.2-SNAPSHOT io.github.davidwhitlock.joy projects - 2.1.1 + 2.1.1-SNAPSHOT tests test diff --git a/projects-parent/archetypes-parent/java-koans-archetype/pom.xml b/projects-parent/archetypes-parent/java-koans-archetype/pom.xml index c80befced..1ee469011 100644 --- a/projects-parent/archetypes-parent/java-koans-archetype/pom.xml +++ b/projects-parent/archetypes-parent/java-koans-archetype/pom.xml @@ -3,13 +3,13 @@ archetypes-parent io.github.davidwhitlock.joy - 2.1.1 + 2.1.1-SNAPSHOT 4.0.0 java-koans-archetype - 2.1.1 + 2.1.1-SNAPSHOT maven-archetype java-koans-archetype diff --git a/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/pom.xml index 47ca39821..d4fba1175 100644 --- a/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/pom.xml @@ -4,7 +4,7 @@ joy io.github.davidwhitlock.joy - 1.1.1 + 1.1.2-SNAPSHOT ${groupId} ${artifactId} @@ -48,7 +48,7 @@ io.github.davidwhitlock.joy.com.sandwich koans-lib - 1.1.1 + 1.1.2-SNAPSHOT diff --git a/projects-parent/archetypes-parent/kata-archetype/pom.xml b/projects-parent/archetypes-parent/kata-archetype/pom.xml index 4e96b02bd..8f1dfddbb 100644 --- a/projects-parent/archetypes-parent/kata-archetype/pom.xml +++ b/projects-parent/archetypes-parent/kata-archetype/pom.xml @@ -5,10 +5,10 @@ archetypes-parent io.github.davidwhitlock.joy - 2.1.1 + 2.1.1-SNAPSHOT kata-archetype - 2.1.1 + 2.1.1-SNAPSHOT maven-archetype kata-archetype diff --git a/projects-parent/archetypes-parent/kata-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/kata-archetype/src/main/resources/archetype-resources/pom.xml index eb1558052..581befadd 100644 --- a/projects-parent/archetypes-parent/kata-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/kata-archetype/src/main/resources/archetype-resources/pom.xml @@ -4,7 +4,7 @@ joy io.github.davidwhitlock.joy - 1.1.1 + 1.1.2-SNAPSHOT ${groupId} ${artifactId} @@ -88,7 +88,7 @@ io.github.davidwhitlock.joy projects - 2.1.1 + 2.1.1-SNAPSHOT tests test diff --git a/projects-parent/archetypes-parent/phonebill-archetype/pom.xml b/projects-parent/archetypes-parent/phonebill-archetype/pom.xml index 259461263..3fdc7c076 100644 --- a/projects-parent/archetypes-parent/phonebill-archetype/pom.xml +++ b/projects-parent/archetypes-parent/phonebill-archetype/pom.xml @@ -3,11 +3,11 @@ archetypes-parent io.github.davidwhitlock.joy - 2.1.1 + 2.1.1-SNAPSHOT 4.0.0 phonebill-archetype - 2.1.1 + 2.1.1-SNAPSHOT maven-archetype phonebill-archetype diff --git a/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/pom.xml index 5a985c24f..14929cbc3 100644 --- a/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/pom.xml @@ -3,7 +3,7 @@ joy io.github.davidwhitlock.joy - 1.1.1 + 1.1.2-SNAPSHOT 4.0.0 ${groupId} @@ -38,12 +38,12 @@ io.github.davidwhitlock.joy projects - 2.1.1 + 2.1.1-SNAPSHOT io.github.davidwhitlock.joy projects - 2.1.1 + 2.1.1-SNAPSHOT tests test diff --git a/projects-parent/archetypes-parent/phonebill-web-archetype/pom.xml b/projects-parent/archetypes-parent/phonebill-web-archetype/pom.xml index 59b0572d6..18873423e 100644 --- a/projects-parent/archetypes-parent/phonebill-web-archetype/pom.xml +++ b/projects-parent/archetypes-parent/phonebill-web-archetype/pom.xml @@ -4,10 +4,10 @@ archetypes-parent io.github.davidwhitlock.joy - 2.1.1 + 2.1.1-SNAPSHOT phonebill-web-archetype - 2.2.1 + 2.2.2-SNAPSHOT maven-archetype phonebill-web-archetype diff --git a/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/pom.xml index 11d78d138..7ebf223b4 100644 --- a/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/pom.xml @@ -3,7 +3,7 @@ joy io.github.davidwhitlock.joy - 1.1.1 + 1.1.2-SNAPSHOT 4.0.0 ${groupId} @@ -22,17 +22,17 @@ io.github.davidwhitlock.joy projects - 2.1.1 + 2.1.1-SNAPSHOT io.github.davidwhitlock.joy examples - 1.2.1 + 1.2.2-SNAPSHOT io.github.davidwhitlock.joy projects - 2.1.1 + 2.1.1-SNAPSHOT tests test diff --git a/projects-parent/archetypes-parent/pom.xml b/projects-parent/archetypes-parent/pom.xml index cbea128be..82178221d 100644 --- a/projects-parent/archetypes-parent/pom.xml +++ b/projects-parent/archetypes-parent/pom.xml @@ -7,11 +7,11 @@ io.github.davidwhitlock.joy projects-parent - 2.1.1 + 2.1.1-SNAPSHOT archetypes-parent - 2.1.1 + 2.1.1-SNAPSHOT pom diff --git a/projects-parent/archetypes-parent/student-archetype/pom.xml b/projects-parent/archetypes-parent/student-archetype/pom.xml index 8ee340c7d..8784d8655 100644 --- a/projects-parent/archetypes-parent/student-archetype/pom.xml +++ b/projects-parent/archetypes-parent/student-archetype/pom.xml @@ -5,11 +5,11 @@ archetypes-parent io.github.davidwhitlock.joy - 2.1.1 + 2.1.1-SNAPSHOT student-archetype - 2.2.1 + 2.2.2-SNAPSHOT maven-archetype Archetype for Student project diff --git a/projects-parent/archetypes-parent/student-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/student-archetype/src/main/resources/archetype-resources/pom.xml index c7916ce0d..672911057 100644 --- a/projects-parent/archetypes-parent/student-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/student-archetype/src/main/resources/archetype-resources/pom.xml @@ -4,7 +4,7 @@ joy io.github.davidwhitlock.joy - 1.1.1 + 1.1.2-SNAPSHOT ${groupId} ${artifactId} @@ -102,12 +102,12 @@ io.github.davidwhitlock.joy examples - 1.2.1 + 1.2.2-SNAPSHOT io.github.davidwhitlock.joy projects - 2.1.1 + 2.1.1-SNAPSHOT tests test diff --git a/projects-parent/originals-parent/airline-web/pom.xml b/projects-parent/originals-parent/airline-web/pom.xml index 73bd235c1..ebeeb40a7 100644 --- a/projects-parent/originals-parent/airline-web/pom.xml +++ b/projects-parent/originals-parent/airline-web/pom.xml @@ -3,7 +3,7 @@ originals-parent io.github.davidwhitlock.joy - 2.1.1 + 2.1.1-SNAPSHOT 4.0.0 io.github.davidwhitlock.joy.original @@ -21,17 +21,17 @@ io.github.davidwhitlock.joy projects - 2.1.1 + 2.1.1-SNAPSHOT io.github.davidwhitlock.joy examples - 1.2.1 + 1.2.2-SNAPSHOT io.github.davidwhitlock.joy projects - 2.1.1 + 2.1.1-SNAPSHOT tests test diff --git a/projects-parent/originals-parent/airline/pom.xml b/projects-parent/originals-parent/airline/pom.xml index b9070d2df..8686297cb 100644 --- a/projects-parent/originals-parent/airline/pom.xml +++ b/projects-parent/originals-parent/airline/pom.xml @@ -3,13 +3,13 @@ originals-parent io.github.davidwhitlock.joy - 2.1.1 + 2.1.1-SNAPSHOT 4.0.0 io.github.davidwhitlock.joy.original airline jar - 2.1.1 + 2.1.1-SNAPSHOT Airline Project An Airline application for The Joy of Coding at Portland State University 2000 @@ -32,12 +32,12 @@ io.github.davidwhitlock.joy projects - 2.1.1 + 2.1.1-SNAPSHOT io.github.davidwhitlock.joy projects - 2.1.1 + 2.1.1-SNAPSHOT tests test diff --git a/projects-parent/originals-parent/apptbook-web/pom.xml b/projects-parent/originals-parent/apptbook-web/pom.xml index 9bc2f1f48..2e2a043a0 100644 --- a/projects-parent/originals-parent/apptbook-web/pom.xml +++ b/projects-parent/originals-parent/apptbook-web/pom.xml @@ -3,7 +3,7 @@ originals-parent io.github.davidwhitlock.joy - 2.1.1 + 2.1.1-SNAPSHOT 4.0.0 io.github.davidwhitlock.joy.original @@ -21,17 +21,17 @@ io.github.davidwhitlock.joy projects - 2.1.1 + 2.1.1-SNAPSHOT io.github.davidwhitlock.joy examples - 1.2.1 + 1.2.2-SNAPSHOT io.github.davidwhitlock.joy projects - 2.1.1 + 2.1.1-SNAPSHOT tests test diff --git a/projects-parent/originals-parent/apptbook/pom.xml b/projects-parent/originals-parent/apptbook/pom.xml index f45bfb3d0..62a6b4ebe 100644 --- a/projects-parent/originals-parent/apptbook/pom.xml +++ b/projects-parent/originals-parent/apptbook/pom.xml @@ -3,13 +3,13 @@ originals-parent io.github.davidwhitlock.joy - 2.1.1 + 2.1.1-SNAPSHOT 4.0.0 io.github.davidwhitlock.joy.original apptbook jar - 2.1.1 + 2.1.1-SNAPSHOT Appointment Book Project An Appointment Book application for The Joy of Coding at Portland State University 2000 @@ -32,12 +32,12 @@ io.github.davidwhitlock.joy projects - 2.1.1 + 2.1.1-SNAPSHOT io.github.davidwhitlock.joy projects - 2.1.1 + 2.1.1-SNAPSHOT tests test diff --git a/projects-parent/originals-parent/kata/pom.xml b/projects-parent/originals-parent/kata/pom.xml index a70314638..baed56708 100644 --- a/projects-parent/originals-parent/kata/pom.xml +++ b/projects-parent/originals-parent/kata/pom.xml @@ -4,11 +4,11 @@ originals-parent io.github.davidwhitlock.joy - 2.1.1 + 2.1.1-SNAPSHOT io.github.davidwhitlock.joy.original kata - 2.1.1 + 2.1.1-SNAPSHOT jar Kata Project @@ -88,7 +88,7 @@ io.github.davidwhitlock.joy projects - 2.1.1 + 2.1.1-SNAPSHOT tests test diff --git a/projects-parent/originals-parent/phonebill-web/pom.xml b/projects-parent/originals-parent/phonebill-web/pom.xml index 9c01d988f..97d1abd1b 100644 --- a/projects-parent/originals-parent/phonebill-web/pom.xml +++ b/projects-parent/originals-parent/phonebill-web/pom.xml @@ -3,7 +3,7 @@ originals-parent io.github.davidwhitlock.joy - 2.1.1 + 2.1.1-SNAPSHOT 4.0.0 io.github.davidwhitlock.joy.original @@ -22,17 +22,17 @@ io.github.davidwhitlock.joy projects - 2.1.1 + 2.1.1-SNAPSHOT io.github.davidwhitlock.joy examples - 1.2.1 + 1.2.2-SNAPSHOT io.github.davidwhitlock.joy projects - 2.1.1 + 2.1.1-SNAPSHOT tests test diff --git a/projects-parent/originals-parent/phonebill/pom.xml b/projects-parent/originals-parent/phonebill/pom.xml index 709843f0a..dc40bebe9 100644 --- a/projects-parent/originals-parent/phonebill/pom.xml +++ b/projects-parent/originals-parent/phonebill/pom.xml @@ -3,13 +3,13 @@ originals-parent io.github.davidwhitlock.joy - 2.1.1 + 2.1.1-SNAPSHOT 4.0.0 io.github.davidwhitlock.joy.original phonebill jar - 2.1.1 + 2.1.1-SNAPSHOT Phone Bill Project A Phone Bill application for The Joy of Coding at Portland State University 2000 @@ -38,12 +38,12 @@ io.github.davidwhitlock.joy projects - 2.1.1 + 2.1.1-SNAPSHOT io.github.davidwhitlock.joy projects - 2.1.1 + 2.1.1-SNAPSHOT tests test diff --git a/projects-parent/originals-parent/pom.xml b/projects-parent/originals-parent/pom.xml index 3e84d24b4..69684a41b 100644 --- a/projects-parent/originals-parent/pom.xml +++ b/projects-parent/originals-parent/pom.xml @@ -5,11 +5,11 @@ io.github.davidwhitlock.joy projects-parent - 2.1.1 + 2.1.1-SNAPSHOT originals-parent - 2.1.1 + 2.1.1-SNAPSHOT pom diff --git a/projects-parent/originals-parent/student/pom.xml b/projects-parent/originals-parent/student/pom.xml index 587987765..485104afe 100644 --- a/projects-parent/originals-parent/student/pom.xml +++ b/projects-parent/originals-parent/student/pom.xml @@ -4,7 +4,7 @@ originals-parent io.github.davidwhitlock.joy - 2.1.1 + 2.1.1-SNAPSHOT io.github.davidwhitlock.joy.original student @@ -88,12 +88,12 @@ io.github.davidwhitlock.joy examples - 1.2.1 + 1.2.2-SNAPSHOT io.github.davidwhitlock.joy projects - 2.1.1 + 2.1.1-SNAPSHOT tests test diff --git a/projects-parent/pom.xml b/projects-parent/pom.xml index e976640b0..a9b106e1d 100644 --- a/projects-parent/pom.xml +++ b/projects-parent/pom.xml @@ -7,11 +7,11 @@ io.github.davidwhitlock.joy joy - 1.1.1 + 1.1.2-SNAPSHOT projects-parent - 2.1.1 + 2.1.1-SNAPSHOT pom diff --git a/projects-parent/projects/pom.xml b/projects-parent/projects/pom.xml index 0a9d6cd6e..ba576135c 100644 --- a/projects-parent/projects/pom.xml +++ b/projects-parent/projects/pom.xml @@ -2,13 +2,13 @@ projects-parent io.github.davidwhitlock.joy - 2.1.1 + 2.1.1-SNAPSHOT 4.0.0 projects Project APIs Classes needed for the Projects in The Joy of Coding - 2.1.1 + 2.1.1-SNAPSHOT http://www.cs.pdx.edu/~whitlock diff --git a/web/pom.xml b/web/pom.xml index 5cf076050..eb65e01c5 100644 --- a/web/pom.xml +++ b/web/pom.xml @@ -3,14 +3,13 @@ joy io.github.davidwhitlock.joy - 1.1.1 + 1.1.2-SNAPSHOT 4.0.0 - io.github.davidwhitlock.joy web war Web Application examples - 1.2.1 + 1.2.2-SNAPSHOT http://www.cs.pdx.edu/~whitlock 6.2.8.Final @@ -118,7 +117,7 @@ io.github.davidwhitlock.joy examples - 1.2.1 + 1.2.2-SNAPSHOT jakarta.xml.bind From 19219d73ba7fdd1f0f3f84bd5721286ced360ecc Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Sat, 14 Sep 2024 19:18:44 -0700 Subject: [PATCH 02/59] Get the latest Koans library. --- .../src/main/resources/archetype-resources/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/pom.xml index d4fba1175..d0c44c5af 100644 --- a/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/pom.xml @@ -48,7 +48,7 @@ io.github.davidwhitlock.joy.com.sandwich koans-lib - 1.1.2-SNAPSHOT + 1.2.0-SNAPSHOT From 4a4d367c298fc08e496e53d24046bcae9edf5559 Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Sat, 14 Sep 2024 21:09:32 -0700 Subject: [PATCH 03/59] Address #474 by requiring Java language level 17. --- .github/workflows/maven.yml | 2 +- examples/pom.xml | 2 +- family/pom.xml | 2 +- grader/pom.xml | 2 +- pom.xml | 6 +++--- .../src/main/resources/archetype-resources/pom.xml | 2 +- .../src/main/resources/archetype-resources/pom.xml | 2 +- .../src/main/resources/archetype-resources/pom.xml | 2 +- .../src/main/resources/archetype-resources/pom.xml | 2 +- .../src/main/resources/archetype-resources/pom.xml | 2 +- .../src/main/resources/archetype-resources/pom.xml | 2 +- .../src/main/resources/archetype-resources/pom.xml | 2 +- .../src/main/resources/archetype-resources/pom.xml | 2 +- .../src/main/resources/archetype-resources/pom.xml | 2 +- projects-parent/pom.xml | 2 +- web/pom.xml | 2 +- 16 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 9bc75e33a..1367b61f1 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -20,7 +20,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - java: [ '11', '17', '22' ] + java: [ '17', '22' ] name: JDK ${{ matrix.Java }} steps: - uses: actions/checkout@v4 diff --git a/examples/pom.xml b/examples/pom.xml index ef459325c..4fce43aa8 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -3,7 +3,7 @@ joy io.github.davidwhitlock.joy - 1.1.2-SNAPSHOT + 1.2.0-SNAPSHOT 4.0.0 examples diff --git a/family/pom.xml b/family/pom.xml index 4c56ce99c..62289a5bc 100644 --- a/family/pom.xml +++ b/family/pom.xml @@ -3,7 +3,7 @@ joy io.github.davidwhitlock.joy - 1.1.2-SNAPSHOT + 1.2.0-SNAPSHOT 4.0.0 family diff --git a/grader/pom.xml b/grader/pom.xml index 847700b47..b16da7285 100644 --- a/grader/pom.xml +++ b/grader/pom.xml @@ -2,7 +2,7 @@ joy io.github.davidwhitlock.joy - 1.1.2-SNAPSHOT + 1.2.0-SNAPSHOT 4.0.0 grader diff --git a/pom.xml b/pom.xml index ce731a6b4..e60310478 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 io.github.davidwhitlock.joy - 1.1.2-SNAPSHOT + 1.2.0-SNAPSHOT joy pom Java Example Code @@ -54,8 +54,8 @@ true - 11 - 11 + 17 + 17 33.1.0-jre 5.1.0 diff --git a/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/pom.xml index 145f69415..08060f50e 100644 --- a/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/pom.xml @@ -3,7 +3,7 @@ joy io.github.davidwhitlock.joy - 1.1.2-SNAPSHOT + 1.2.0-SNAPSHOT 4.0.0 ${groupId} diff --git a/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/pom.xml index 67f20de41..492d96d31 100644 --- a/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/pom.xml @@ -3,7 +3,7 @@ joy io.github.davidwhitlock.joy - 1.1.2-SNAPSHOT + 1.2.0-SNAPSHOT 4.0.0 ${groupId} diff --git a/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/pom.xml index 491f6ceee..cc09b18c1 100644 --- a/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/pom.xml @@ -3,7 +3,7 @@ joy io.github.davidwhitlock.joy - 1.1.2-SNAPSHOT + 1.2.0-SNAPSHOT 4.0.0 ${groupId} diff --git a/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/pom.xml index 8227459fd..8f7410324 100644 --- a/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/pom.xml @@ -3,7 +3,7 @@ joy io.github.davidwhitlock.joy - 1.1.2-SNAPSHOT + 1.2.0-SNAPSHOT 4.0.0 ${groupId} diff --git a/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/pom.xml index d0c44c5af..0951f8c55 100644 --- a/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/pom.xml @@ -4,7 +4,7 @@ joy io.github.davidwhitlock.joy - 1.1.2-SNAPSHOT + 1.2.0-SNAPSHOT ${groupId} ${artifactId} diff --git a/projects-parent/archetypes-parent/kata-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/kata-archetype/src/main/resources/archetype-resources/pom.xml index 581befadd..bb23a5e79 100644 --- a/projects-parent/archetypes-parent/kata-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/kata-archetype/src/main/resources/archetype-resources/pom.xml @@ -4,7 +4,7 @@ joy io.github.davidwhitlock.joy - 1.1.2-SNAPSHOT + 1.2.0-SNAPSHOT ${groupId} ${artifactId} diff --git a/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/pom.xml index 14929cbc3..2cbd64a8a 100644 --- a/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/pom.xml @@ -3,7 +3,7 @@ joy io.github.davidwhitlock.joy - 1.1.2-SNAPSHOT + 1.2.0-SNAPSHOT 4.0.0 ${groupId} diff --git a/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/pom.xml index 7ebf223b4..2a89905d5 100644 --- a/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/pom.xml @@ -3,7 +3,7 @@ joy io.github.davidwhitlock.joy - 1.1.2-SNAPSHOT + 1.2.0-SNAPSHOT 4.0.0 ${groupId} diff --git a/projects-parent/archetypes-parent/student-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/student-archetype/src/main/resources/archetype-resources/pom.xml index 672911057..a80f10e30 100644 --- a/projects-parent/archetypes-parent/student-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/student-archetype/src/main/resources/archetype-resources/pom.xml @@ -4,7 +4,7 @@ joy io.github.davidwhitlock.joy - 1.1.2-SNAPSHOT + 1.2.0-SNAPSHOT ${groupId} ${artifactId} diff --git a/projects-parent/pom.xml b/projects-parent/pom.xml index a9b106e1d..6f6a8724d 100644 --- a/projects-parent/pom.xml +++ b/projects-parent/pom.xml @@ -7,7 +7,7 @@ io.github.davidwhitlock.joy joy - 1.1.2-SNAPSHOT + 1.2.0-SNAPSHOT projects-parent diff --git a/web/pom.xml b/web/pom.xml index eb65e01c5..a2c048439 100644 --- a/web/pom.xml +++ b/web/pom.xml @@ -3,7 +3,7 @@ joy io.github.davidwhitlock.joy - 1.1.2-SNAPSHOT + 1.2.0-SNAPSHOT 4.0.0 web From 01c5fa025d6321266549ead01cdf8d5f106f9ee9 Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Sat, 14 Sep 2024 21:37:15 -0700 Subject: [PATCH 04/59] Address #475 by logging a message when the top-level servlet methods are called. --- .../main/java/edu/pdx/cs/joy/airlineweb/AirlineServlet.java | 6 ++++++ .../edu/pdx/cs/joy/apptbookweb/AppointmentBookServlet.java | 6 ++++++ .../java/edu/pdx/cs/joy/phonebillweb/PhoneBillServlet.java | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/projects-parent/originals-parent/airline-web/src/main/java/edu/pdx/cs/joy/airlineweb/AirlineServlet.java b/projects-parent/originals-parent/airline-web/src/main/java/edu/pdx/cs/joy/airlineweb/AirlineServlet.java index 0b8ce291f..54bfc0993 100644 --- a/projects-parent/originals-parent/airline-web/src/main/java/edu/pdx/cs/joy/airlineweb/AirlineServlet.java +++ b/projects-parent/originals-parent/airline-web/src/main/java/edu/pdx/cs/joy/airlineweb/AirlineServlet.java @@ -35,9 +35,11 @@ protected void doGet( HttpServletRequest request, HttpServletResponse response ) String word = getParameter( WORD_PARAMETER, request ); if (word != null) { + log("GET " + word); writeDefinition(word, response); } else { + log("GET all dictionary entries"); writeAllDictionaryEntries(response); } } @@ -64,6 +66,8 @@ protected void doPost( HttpServletRequest request, HttpServletResponse response return; } + log("POST " + word + " -> " + definition); + this.dictionary.put(word, definition); PrintWriter pw = response.getWriter(); @@ -82,6 +86,8 @@ protected void doPost( HttpServletRequest request, HttpServletResponse response protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setContentType("text/plain"); + log("DELETE all dictionary entries"); + this.dictionary.clear(); PrintWriter pw = response.getWriter(); diff --git a/projects-parent/originals-parent/apptbook-web/src/main/java/edu/pdx/cs/joy/apptbookweb/AppointmentBookServlet.java b/projects-parent/originals-parent/apptbook-web/src/main/java/edu/pdx/cs/joy/apptbookweb/AppointmentBookServlet.java index 99ef07faa..b039d4cfd 100644 --- a/projects-parent/originals-parent/apptbook-web/src/main/java/edu/pdx/cs/joy/apptbookweb/AppointmentBookServlet.java +++ b/projects-parent/originals-parent/apptbook-web/src/main/java/edu/pdx/cs/joy/apptbookweb/AppointmentBookServlet.java @@ -36,9 +36,11 @@ protected void doGet( HttpServletRequest request, HttpServletResponse response ) String word = getParameter( WORD_PARAMETER, request ); if (word != null) { + log("GET " + word); writeDefinition(word, response); } else { + log("GET all dictionary entries"); writeAllDictionaryEntries(response); } } @@ -65,6 +67,8 @@ protected void doPost( HttpServletRequest request, HttpServletResponse response return; } + log("POST " + word + " -> " + definition); + this.dictionary.put(word, definition); PrintWriter pw = response.getWriter(); @@ -83,6 +87,8 @@ protected void doPost( HttpServletRequest request, HttpServletResponse response protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setContentType("text/plain"); + log("DELETE all dictionary entries"); + this.dictionary.clear(); PrintWriter pw = response.getWriter(); diff --git a/projects-parent/originals-parent/phonebill-web/src/main/java/edu/pdx/cs/joy/phonebillweb/PhoneBillServlet.java b/projects-parent/originals-parent/phonebill-web/src/main/java/edu/pdx/cs/joy/phonebillweb/PhoneBillServlet.java index d4858d33e..16cc6d8c3 100644 --- a/projects-parent/originals-parent/phonebill-web/src/main/java/edu/pdx/cs/joy/phonebillweb/PhoneBillServlet.java +++ b/projects-parent/originals-parent/phonebill-web/src/main/java/edu/pdx/cs/joy/phonebillweb/PhoneBillServlet.java @@ -36,9 +36,11 @@ protected void doGet( HttpServletRequest request, HttpServletResponse response ) String word = getParameter( WORD_PARAMETER, request ); if (word != null) { + log("GET " + word); writeDefinition(word, response); } else { + log("GET all dictionary entries"); writeAllDictionaryEntries(response); } } @@ -65,6 +67,8 @@ protected void doPost( HttpServletRequest request, HttpServletResponse response return; } + log("POST " + word + " -> " + definition); + this.dictionary.put(word, definition); PrintWriter pw = response.getWriter(); @@ -83,6 +87,8 @@ protected void doPost( HttpServletRequest request, HttpServletResponse response protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setContentType("text/plain"); + log("DELETE all dictionary entries"); + this.dictionary.clear(); PrintWriter pw = response.getWriter(); From c6a939041b14af8037c3b901b7837aa44d012a1b Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Sat, 14 Sep 2024 21:42:33 -0700 Subject: [PATCH 05/59] Move the servlet logging to the archetypes. --- .../archetype-resources/src/main/java/AirlineServlet.java | 6 ++++++ .../src/main/java/AppointmentBookServlet.java | 6 ++++++ .../archetype-resources/src/main/java/PhoneBillServlet.java | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/src/main/java/AirlineServlet.java b/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/src/main/java/AirlineServlet.java index 0c597fe73..52bfe3554 100644 --- a/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/src/main/java/AirlineServlet.java +++ b/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/src/main/java/AirlineServlet.java @@ -38,9 +38,11 @@ protected void doGet( HttpServletRequest request, HttpServletResponse response ) String word = getParameter( WORD_PARAMETER, request ); if (word != null) { + log("GET " + word); writeDefinition(word, response); } else { + log("GET all dictionary entries"); writeAllDictionaryEntries(response); } } @@ -67,6 +69,8 @@ protected void doPost( HttpServletRequest request, HttpServletResponse response return; } + log("POST " + word + " -> " + definition); + this.dictionary.put(word, definition); PrintWriter pw = response.getWriter(); @@ -85,6 +89,8 @@ protected void doPost( HttpServletRequest request, HttpServletResponse response protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setContentType("text/plain"); + log("DELETE all dictionary entries"); + this.dictionary.clear(); PrintWriter pw = response.getWriter(); diff --git a/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/src/main/java/AppointmentBookServlet.java b/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/src/main/java/AppointmentBookServlet.java index 3ef7360ce..7e4b43531 100644 --- a/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/src/main/java/AppointmentBookServlet.java +++ b/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/src/main/java/AppointmentBookServlet.java @@ -39,9 +39,11 @@ protected void doGet( HttpServletRequest request, HttpServletResponse response ) String word = getParameter( WORD_PARAMETER, request ); if (word != null) { + log("GET " + word); writeDefinition(word, response); } else { + log("GET all dictionary entries"); writeAllDictionaryEntries(response); } } @@ -68,6 +70,8 @@ protected void doPost( HttpServletRequest request, HttpServletResponse response return; } + log("POST " + word + " -> " + definition); + this.dictionary.put(word, definition); PrintWriter pw = response.getWriter(); @@ -86,6 +90,8 @@ protected void doPost( HttpServletRequest request, HttpServletResponse response protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setContentType("text/plain"); + log("DELETE all dictionary entries"); + this.dictionary.clear(); PrintWriter pw = response.getWriter(); diff --git a/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/src/main/java/PhoneBillServlet.java b/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/src/main/java/PhoneBillServlet.java index 70d50a9e0..233a77050 100644 --- a/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/src/main/java/PhoneBillServlet.java +++ b/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/src/main/java/PhoneBillServlet.java @@ -39,9 +39,11 @@ protected void doGet( HttpServletRequest request, HttpServletResponse response ) String word = getParameter( WORD_PARAMETER, request ); if (word != null) { + log("GET " + word); writeDefinition(word, response); } else { + log("GET all dictionary entries"); writeAllDictionaryEntries(response); } } @@ -68,6 +70,8 @@ protected void doPost( HttpServletRequest request, HttpServletResponse response return; } + log("POST " + word + " -> " + definition); + this.dictionary.put(word, definition); PrintWriter pw = response.getWriter(); @@ -86,6 +90,8 @@ protected void doPost( HttpServletRequest request, HttpServletResponse response protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setContentType("text/plain"); + log("DELETE all dictionary entries"); + this.dictionary.clear(); PrintWriter pw = response.getWriter(); From cceb74152a17a2f919c6fd93f60556b3e5644fe8 Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Sat, 14 Sep 2024 22:03:59 -0700 Subject: [PATCH 06/59] Address #476 by only displaying a assignment's score if it has been graded. --- .../edu/pdx/cs/joy/grader/SummaryReport.java | 10 +++--- .../pdx/cs/joy/grader/SummaryReportTest.java | 32 +++++++++++++++++++ 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/grader/src/main/java/edu/pdx/cs/joy/grader/SummaryReport.java b/grader/src/main/java/edu/pdx/cs/joy/grader/SummaryReport.java index 0066e6fce..2ae79cd94 100644 --- a/grader/src/main/java/edu/pdx/cs/joy/grader/SummaryReport.java +++ b/grader/src/main/java/edu/pdx/cs/joy/grader/SummaryReport.java @@ -82,9 +82,6 @@ static void dumpReportTo(GradeBook book, Student student, line.append(" (OPTIONAL)"); } line.append(": "); - line.append(format.format(score)); - line.append("/"); - line.append(format.format(assignment.getPoints())); // Skip incompletes and no grades @@ -100,7 +97,12 @@ static void dumpReportTo(GradeBook book, Student student, line.append(" (INCOMPLETE)"); } else if (grade.isNotGraded()) { - line.append( " (NOT GRADED)"); + line.append(" (NOT GRADED)"); + + } else { + line.append(format.format(score)); + line.append("/"); + line.append(format.format(assignment.getPoints())); } pw.println(line); diff --git a/grader/src/test/java/edu/pdx/cs/joy/grader/SummaryReportTest.java b/grader/src/test/java/edu/pdx/cs/joy/grader/SummaryReportTest.java index a270e0a36..311ba72ba 100644 --- a/grader/src/test/java/edu/pdx/cs/joy/grader/SummaryReportTest.java +++ b/grader/src/test/java/edu/pdx/cs/joy/grader/SummaryReportTest.java @@ -245,4 +245,36 @@ private static File getStudentReportFile(File directory, Student student) { return new File(sectionDirectory, SummaryReport.getReportFileName(student.getId())); } + @Test + void missingGradeIsClearInReport(@TempDir File tempDirectory) throws IOException { + GradeBook gradeBook = new GradeBook("test"); + + String assignmentName = "Assignment"; + Assignment assignment = gradeBook.addAssignment(new Assignment(assignmentName, 10.0)); + Assignment assignment2 = gradeBook.addAssignment(new Assignment("Assignment 2", 10.0)); + + Student studentWithMissingGrade = + gradeBook.addStudent(new Student("studentWithMissingGrade")) + .setLastName("studentWithMissingGrade") + .setEnrolledSection(Student.Section.UNDERGRADUATE) + .setGrade(assignment, Grade.NO_GRADE) + .setGrade(assignment2, 10.0); + + Student studentWithGrade = + gradeBook.addStudent(new Student("studentWithGrade")) + .setLastName("studentWithGrade") + .setEnrolledSection(Student.Section.UNDERGRADUATE) + .setGrade(assignment, 10.0) + .setGrade(assignment2, 10.0); + + SummaryReport.dumpReports(gradeBook.getStudentIds(), gradeBook, tempDirectory, false); + + File studentWithMissingGradeReportFile = getStudentReportFile(tempDirectory, studentWithMissingGrade); + assertThat(studentWithMissingGradeReportFile.exists(), equalTo(true)); + + String studentWithSomeNonZeroGradesReport = readTextFromFile(studentWithMissingGradeReportFile); + assertThat(studentWithSomeNonZeroGradesReport, not(containsString(String.valueOf(Grade.NO_GRADE)))); + assertThat(studentWithSomeNonZeroGradesReport, containsString("NOT GRADED")); + } + } From f889f909d60ed2a17c599677eb33771b9f3a1bdd Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Sat, 14 Sep 2024 22:11:33 -0700 Subject: [PATCH 07/59] Override the log method so that it can be invoked by a unit test (that doesn't initialize the ServletContext). --- .../archetype-resources/src/main/java/AirlineServlet.java | 5 +++++ .../src/main/java/AppointmentBookServlet.java | 5 +++++ .../archetype-resources/src/main/java/PhoneBillServlet.java | 4 ++++ .../main/java/edu/pdx/cs/joy/airlineweb/AirlineServlet.java | 5 +++++ .../edu/pdx/cs/joy/apptbookweb/AppointmentBookServlet.java | 5 +++++ .../java/edu/pdx/cs/joy/phonebillweb/PhoneBillServlet.java | 4 ++++ 6 files changed, 28 insertions(+) diff --git a/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/src/main/java/AirlineServlet.java b/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/src/main/java/AirlineServlet.java index 52bfe3554..dd6dc2fcd 100644 --- a/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/src/main/java/AirlineServlet.java +++ b/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/src/main/java/AirlineServlet.java @@ -169,4 +169,9 @@ private String getParameter(String name, HttpServletRequest request) { String getDefinition(String word) { return this.dictionary.get(word); } + + @Override + public void log(String msg) { + System.out.println(msg); + } } diff --git a/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/src/main/java/AppointmentBookServlet.java b/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/src/main/java/AppointmentBookServlet.java index 7e4b43531..0ebf4f781 100644 --- a/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/src/main/java/AppointmentBookServlet.java +++ b/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/src/main/java/AppointmentBookServlet.java @@ -170,4 +170,9 @@ private String getParameter(String name, HttpServletRequest request) { String getDefinition(String word) { return this.dictionary.get(word); } + + @Override + public void log(String msg) { + System.out.println(msg); + } } diff --git a/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/src/main/java/PhoneBillServlet.java b/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/src/main/java/PhoneBillServlet.java index 233a77050..336a3d555 100644 --- a/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/src/main/java/PhoneBillServlet.java +++ b/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/src/main/java/PhoneBillServlet.java @@ -171,4 +171,8 @@ String getDefinition(String word) { return this.dictionary.get(word); } + @Override + public void log(String msg) { + System.out.println(msg); + } } diff --git a/projects-parent/originals-parent/airline-web/src/main/java/edu/pdx/cs/joy/airlineweb/AirlineServlet.java b/projects-parent/originals-parent/airline-web/src/main/java/edu/pdx/cs/joy/airlineweb/AirlineServlet.java index 54bfc0993..01af61594 100644 --- a/projects-parent/originals-parent/airline-web/src/main/java/edu/pdx/cs/joy/airlineweb/AirlineServlet.java +++ b/projects-parent/originals-parent/airline-web/src/main/java/edu/pdx/cs/joy/airlineweb/AirlineServlet.java @@ -166,4 +166,9 @@ private String getParameter(String name, HttpServletRequest request) { String getDefinition(String word) { return this.dictionary.get(word); } + + @Override + public void log(String msg) { + System.out.println(msg); + } } diff --git a/projects-parent/originals-parent/apptbook-web/src/main/java/edu/pdx/cs/joy/apptbookweb/AppointmentBookServlet.java b/projects-parent/originals-parent/apptbook-web/src/main/java/edu/pdx/cs/joy/apptbookweb/AppointmentBookServlet.java index b039d4cfd..f7658255e 100644 --- a/projects-parent/originals-parent/apptbook-web/src/main/java/edu/pdx/cs/joy/apptbookweb/AppointmentBookServlet.java +++ b/projects-parent/originals-parent/apptbook-web/src/main/java/edu/pdx/cs/joy/apptbookweb/AppointmentBookServlet.java @@ -167,4 +167,9 @@ private String getParameter(String name, HttpServletRequest request) { String getDefinition(String word) { return this.dictionary.get(word); } + + @Override + public void log(String msg) { + System.out.println(msg); + } } diff --git a/projects-parent/originals-parent/phonebill-web/src/main/java/edu/pdx/cs/joy/phonebillweb/PhoneBillServlet.java b/projects-parent/originals-parent/phonebill-web/src/main/java/edu/pdx/cs/joy/phonebillweb/PhoneBillServlet.java index 16cc6d8c3..5d5e08d06 100644 --- a/projects-parent/originals-parent/phonebill-web/src/main/java/edu/pdx/cs/joy/phonebillweb/PhoneBillServlet.java +++ b/projects-parent/originals-parent/phonebill-web/src/main/java/edu/pdx/cs/joy/phonebillweb/PhoneBillServlet.java @@ -168,4 +168,8 @@ String getDefinition(String word) { return this.dictionary.get(word); } + @Override + public void log(String msg) { + System.out.println(msg); + } } From 51b53709cc17bb39a6334d83614ab3f29e1bab79 Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Sun, 13 Oct 2024 14:39:10 -0700 Subject: [PATCH 08/59] Use a SNAPSHOT version for the original project pom.xml files. --- projects-parent/originals-parent/airline-web/pom.xml | 2 +- projects-parent/originals-parent/apptbook-web/pom.xml | 2 +- projects-parent/originals-parent/phonebill-web/pom.xml | 2 +- projects-parent/originals-parent/student/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/projects-parent/originals-parent/airline-web/pom.xml b/projects-parent/originals-parent/airline-web/pom.xml index ebeeb40a7..99d97e3f3 100644 --- a/projects-parent/originals-parent/airline-web/pom.xml +++ b/projects-parent/originals-parent/airline-web/pom.xml @@ -8,7 +8,7 @@ 4.0.0 io.github.davidwhitlock.joy.original airline-web - 2.2.0 + 2.2.1-SNAPSHOT 8080 diff --git a/projects-parent/originals-parent/apptbook-web/pom.xml b/projects-parent/originals-parent/apptbook-web/pom.xml index 2e2a043a0..41b5cdec6 100644 --- a/projects-parent/originals-parent/apptbook-web/pom.xml +++ b/projects-parent/originals-parent/apptbook-web/pom.xml @@ -8,7 +8,7 @@ 4.0.0 io.github.davidwhitlock.joy.original apptbook-web - 2.2.0 + 2.2.1-SNAPSHOT 8080 diff --git a/projects-parent/originals-parent/phonebill-web/pom.xml b/projects-parent/originals-parent/phonebill-web/pom.xml index 97d1abd1b..bdbafc772 100644 --- a/projects-parent/originals-parent/phonebill-web/pom.xml +++ b/projects-parent/originals-parent/phonebill-web/pom.xml @@ -8,7 +8,7 @@ 4.0.0 io.github.davidwhitlock.joy.original phonebill-web - 2.2.0 + 2.2.1-SNAPSHOT 8080 diff --git a/projects-parent/originals-parent/student/pom.xml b/projects-parent/originals-parent/student/pom.xml index 485104afe..cb89391aa 100644 --- a/projects-parent/originals-parent/student/pom.xml +++ b/projects-parent/originals-parent/student/pom.xml @@ -8,7 +8,7 @@ io.github.davidwhitlock.joy.original student - 2.2.0 + 2.2.1-SNAPSHOT jar Student Project From 99ce06a0cefcc77eb5f19451061b722f9aa46735 Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Thu, 14 Nov 2024 18:35:34 -0800 Subject: [PATCH 09/59] Address #479 by validating that .gradle files are not submitted. --- .../cs/joy/grader/SubmitAndroidProjectIT.java | 40 ++++++++++++++++++- .../java/edu/pdx/cs/joy/grader/SubmitIT.java | 10 ++--- 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/grader/src/it/java/edu/pdx/cs/joy/grader/SubmitAndroidProjectIT.java b/grader/src/it/java/edu/pdx/cs/joy/grader/SubmitAndroidProjectIT.java index 1d8a0a96a..fb8fa702f 100644 --- a/grader/src/it/java/edu/pdx/cs/joy/grader/SubmitAndroidProjectIT.java +++ b/grader/src/it/java/edu/pdx/cs/joy/grader/SubmitAndroidProjectIT.java @@ -1,12 +1,23 @@ package edu.pdx.cs.joy.grader; +import edu.pdx.cs.joy.grader.gradebook.Assignment; +import edu.pdx.cs.joy.grader.gradebook.Grade; +import edu.pdx.cs.joy.grader.gradebook.GradeBook; +import edu.pdx.cs.joy.grader.gradebook.Student; +import jakarta.mail.MessagingException; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.File; import java.io.IOException; import java.util.Arrays; +import java.util.List; -public class SubmitAndroidProjectIT extends SubmitIT { +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.*; +import static org.hamcrest.Matchers.equalTo; + +public class SubmitAndroidProjectIT extends SubmitIT { @BeforeEach @Override @@ -32,6 +43,8 @@ public void createFilesToSubmit() throws IOException { this.filesToSubmit.add(createEmptyFile(wrapperDir, fileName)); } + File dotGradleDir = createDirectories(".gradle"); + this.filesToSubmit.add(createEmptyFile(dotGradleDir, "config.properties")); } @Override @@ -45,4 +58,29 @@ protected Submit getSubmitProgram() { return new SubmitAndroidProject(() -> submitTime); } } + + @Test + void dotGradleFilesAreNotSubmitted() throws MessagingException, IOException { + submitter().submitFiles(); + + GradeBook gradeBook = new GradeBook("SubmitIT"); + gradeBook.addStudent(new Student(studentLoginId)); + gradeBook.addAssignment(new Assignment(projectName, 3.5)); + + GraderEmailAccount account = new GraderEmailAccount(emailServerHost, imapsPort, graderEmail, imapPassword, true, m -> { }); + FetchAndProcessGraderEmail.fetchAndProcessGraderEmails("projects", account, this.tempDirectory, gradeBook); + + Grade grade = gradeBook.getStudent(studentLoginId).get().getGrade(projectName); + assertThat(grade, is(notNullValue())); + assertThat(grade.getScore(), equalTo(Grade.NO_GRADE)); + assertThat(grade.getSubmissionTimes().size(), equalTo(1)); + + File zipFile = findNewestZipFileInTempDirectory(); + assertThat(zipFile, is(notNullValue())); + List entryNames = getZipFileEntryNames(zipFile); + assertThat(entryNames, not(empty())); + + assertThat(entryNames, not(hasItem(".gradle"))); + assertThat(entryNames, not(hasItem(".gradle/config.properties"))); + } } diff --git a/grader/src/it/java/edu/pdx/cs/joy/grader/SubmitIT.java b/grader/src/it/java/edu/pdx/cs/joy/grader/SubmitIT.java index 821af8e8a..ffd941be7 100644 --- a/grader/src/it/java/edu/pdx/cs/joy/grader/SubmitIT.java +++ b/grader/src/it/java/edu/pdx/cs/joy/grader/SubmitIT.java @@ -42,8 +42,8 @@ public class SubmitIT extends EmailSenderIntegrationTestCase { private final String studentName = studentFirstName + " " + studentLastName; protected final Collection filesToSubmit = new ArrayList<>(); protected final String studentLoginId = "student"; - private final String projectName = "Project"; - private final String graderEmail = TA_EMAIL.getAddress(); + protected final String projectName = "Project"; + protected final String graderEmail = TA_EMAIL.getAddress(); @BeforeEach public void createFilesToSubmit() throws IOException { @@ -151,7 +151,7 @@ private void assertZipFileContainsFilesInProjectDirectories() throws IOException }); } - private List getZipFileEntryNames(File zipFile) throws IOException { + protected List getZipFileEntryNames(File zipFile) throws IOException { List entryNames = new ArrayList<>(); FileInputStream stream = new FileInputStream(zipFile); try ( @@ -166,7 +166,7 @@ private List getZipFileEntryNames(File zipFile) throws IOException { return entryNames; } - private File findNewestZipFileInTempDirectory() { + protected File findNewestZipFileInTempDirectory() { File[] zipFiles = this.tempDirectory.listFiles((dir, name) -> name.endsWith(".zip")); if (zipFiles == null) { return null; @@ -201,7 +201,7 @@ public ProjectSubmitter setSendReceipt(boolean sendReceipt) { return this; } - private void submitFiles() throws IOException, MessagingException { + protected void submitFiles() throws IOException, MessagingException { Student student = new Student(studentLoginId); student.setEmail(studentEmail); student.setFirstName(studentFirstName); From 2cdc6cd2689cd01bf08cb637b3b797b1b8a890fc Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Thu, 14 Nov 2024 18:54:44 -0800 Subject: [PATCH 10/59] Address #473 by requiring an @pdx.edu email address for the survey. --- .../java/edu/pdx/cs/joy/grader/Survey.java | 11 +++++++++- .../edu/pdx/cs/joy/grader/SurveyTest.java | 20 ++++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/grader/src/main/java/edu/pdx/cs/joy/grader/Survey.java b/grader/src/main/java/edu/pdx/cs/joy/grader/Survey.java index 31016f9de..c8630cbe6 100644 --- a/grader/src/main/java/edu/pdx/cs/joy/grader/Survey.java +++ b/grader/src/main/java/edu/pdx/cs/joy/grader/Survey.java @@ -40,6 +40,11 @@ public Survey(PrintStream out, PrintStream err, InputStream in, File xmlFileDir, this.gitCheckoutDir = gitCheckoutDir; } + public static boolean hasPdxDotEduEmail(Student student) { + String email = student.getEmail(); + return email != null && email.endsWith("@pdx.edu"); + } + /** * Returns a textual summary of a Student */ @@ -148,7 +153,11 @@ private Student gatherStudentInformation() { setValueIfNotEmpty(lastName, student::setLastName); setValueIfNotEmpty(nickName, student::setNickName); - askQuestionAndSetValue("What is your email address (doesn't have to be PSU)?", student::setEmail); + askQuestionAndSetValue("What is your email address (must be @pdx.edu)?", student::setEmail); + if (!hasPdxDotEduEmail(student)) { + printErrorMessageAndExit("** Your email address must be @pdx.edu"); + } + askQuestionAndSetValue("What is your major?", student::setMajor); askEnrolledSectionQuestion(student); diff --git a/grader/src/test/java/edu/pdx/cs/joy/grader/SurveyTest.java b/grader/src/test/java/edu/pdx/cs/joy/grader/SurveyTest.java index bbf0b6a14..5bab981ca 100644 --- a/grader/src/test/java/edu/pdx/cs/joy/grader/SurveyTest.java +++ b/grader/src/test/java/edu/pdx/cs/joy/grader/SurveyTest.java @@ -7,7 +7,6 @@ import org.junit.jupiter.api.io.TempDir; import java.io.*; -import java.nio.file.Files; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; @@ -58,7 +57,7 @@ void longMessageIsBrokenInto80CharacterLines() { @Test void validEmailAddressIsValid() { - String address = "whitlock@cs.pdx.edu"; + String address = "whitlocd@pdx.edu"; assertThat(Survey.isEmailAddress(address), equalTo(true)); } @@ -86,7 +85,7 @@ void successfulSurveyWritesStudentXmlFile(@TempDir File tempDir) throws IOExcept String lastName = "Last name"; String nickName = "Nick name"; String loginId = "LoginId"; - String email = "email@email.com"; + String email = "email@pdx.edu"; String major = "Major"; String section = "u"; String recordGitHubUserName = "y"; @@ -164,4 +163,19 @@ String getTextThatWasOutput() { return captured.toString(); } } + + @Test + void emailAddressIsPdxDotEdu() { + Student student = new Student("id"); + student.setEmail("student@pdx.edu"); + assertThat(Survey.hasPdxDotEduEmail(student), equalTo(true)); + } + + @Test + void emailAddressIsNotPdxDotEdu() { + Student student = new Student("id"); + student.setEmail("student@gmail.com"); + assertThat(Survey.hasPdxDotEduEmail(student), equalTo(false)); + } + } From 1cc0dcb85df0b76b07202d3c98e3ae9a167990ef Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Sat, 16 Nov 2024 13:07:43 -0800 Subject: [PATCH 11/59] Fix a test inherited in SubmitAndroidProjectIT from SubmitIT. --- .../edu/pdx/cs/joy/grader/SubmitAndroidProjectIT.java | 9 +++++++++ grader/src/it/java/edu/pdx/cs/joy/grader/SubmitIT.java | 6 +++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/grader/src/it/java/edu/pdx/cs/joy/grader/SubmitAndroidProjectIT.java b/grader/src/it/java/edu/pdx/cs/joy/grader/SubmitAndroidProjectIT.java index fb8fa702f..b3134a9bb 100644 --- a/grader/src/it/java/edu/pdx/cs/joy/grader/SubmitAndroidProjectIT.java +++ b/grader/src/it/java/edu/pdx/cs/joy/grader/SubmitAndroidProjectIT.java @@ -11,6 +11,7 @@ import java.io.File; import java.io.IOException; import java.util.Arrays; +import java.util.Collection; import java.util.List; import static org.hamcrest.MatcherAssert.assertThat; @@ -83,4 +84,12 @@ void dotGradleFilesAreNotSubmitted() throws MessagingException, IOException { assertThat(entryNames, not(hasItem(".gradle"))); assertThat(entryNames, not(hasItem(".gradle/config.properties"))); } + + @Override + protected Collection getExpectedFilesToSubmit() { + Collection allFiles = super.getExpectedFilesToSubmit(); + return allFiles.stream() + .filter(file -> !file.getPath().contains(".gradle")) + .toList(); + } } diff --git a/grader/src/it/java/edu/pdx/cs/joy/grader/SubmitIT.java b/grader/src/it/java/edu/pdx/cs/joy/grader/SubmitIT.java index ffd941be7..dcf22033c 100644 --- a/grader/src/it/java/edu/pdx/cs/joy/grader/SubmitIT.java +++ b/grader/src/it/java/edu/pdx/cs/joy/grader/SubmitIT.java @@ -145,12 +145,16 @@ private void assertZipFileContainsFilesInProjectDirectories() throws IOException List entryNames = getZipFileEntryNames(zipFile); assertThat(entryNames, not(empty())); - filesToSubmit.forEach(file -> { + getExpectedFilesToSubmit().forEach(file -> { String filePath = file.getPath().substring(this.tempDirectory.getPath().length() + 1); assertThat(entryNames, hasItem(filePath)); }); } + protected Collection getExpectedFilesToSubmit() { + return filesToSubmit; + } + protected List getZipFileEntryNames(File zipFile) throws IOException { List entryNames = new ArrayList<>(); FileInputStream stream = new FileInputStream(zipFile); From 97d2ed9e887937be62c1cd96ca96d3a514847c56 Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Sun, 17 Nov 2024 19:25:41 -0800 Subject: [PATCH 12/59] Remove the DTD URL from example XML files because the URL returns a 403 now. --- examples/pom.xml | 4 ++-- family/pom.xml | 2 +- grader/pom.xml | 2 +- .../main/resources/archetype-resources/pom.xml | 4 ++-- .../src/main/java/AirlineXmlHelper.java | 6 +----- .../invalid-airline.xml | 16 ++++++++-------- .../__packageInPathFormat__/valid-airline.xml | 18 +++++++++--------- .../main/resources/archetype-resources/pom.xml | 4 ++-- .../main/resources/archetype-resources/pom.xml | 4 ++-- .../main/resources/archetype-resources/pom.xml | 4 ++-- .../main/resources/archetype-resources/pom.xml | 2 +- .../main/resources/archetype-resources/pom.xml | 4 ++-- .../main/resources/archetype-resources/pom.xml | 4 ++-- .../main/resources/archetype-resources/pom.xml | 2 +- .../originals-parent/airline-web/pom.xml | 8 ++++---- .../originals-parent/airline/pom.xml | 8 ++++---- .../pdx/cs/joy/airline/AirlineXmlHelper.java | 6 +----- .../edu/pdx/cs/joy/airline/invalid-airline.xml | 16 ++++++++-------- .../edu/pdx/cs/joy/airline/valid-airline.xml | 18 +++++++++--------- .../originals-parent/apptbook-web/pom.xml | 8 ++++---- .../originals-parent/apptbook/pom.xml | 8 ++++---- .../joy/apptbook/AppointmentBookXmlHelper.java | 8 +------- projects-parent/originals-parent/kata/pom.xml | 6 +++--- .../originals-parent/phonebill-web/pom.xml | 8 ++++---- .../originals-parent/phonebill/pom.xml | 8 ++++---- projects-parent/originals-parent/pom.xml | 4 ++-- .../originals-parent/student/pom.xml | 6 +++--- projects-parent/pom.xml | 2 +- projects-parent/projects/pom.xml | 4 ++-- .../java/edu/pdx/cs/joy/ProjectXmlHelper.java | 16 +++------------- .../src/main/java/edu/pdx/cs/joy/airline.xml | 2 +- .../main/resources/edu/pdx/cs/joy/airline.dtd | 1 - 32 files changed, 94 insertions(+), 119 deletions(-) diff --git a/examples/pom.xml b/examples/pom.xml index 4fce43aa8..4be91ce1d 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -19,7 +19,7 @@ io.github.davidwhitlock.joy projects - 2.1.1-SNAPSHOT + 3.0.0-SNAPSHOT com.sun.mail @@ -45,7 +45,7 @@ io.github.davidwhitlock.joy projects - 2.1.1-SNAPSHOT + 3.0.0-SNAPSHOT tests test diff --git a/family/pom.xml b/family/pom.xml index 62289a5bc..8d7e15408 100644 --- a/family/pom.xml +++ b/family/pom.xml @@ -16,7 +16,7 @@ io.github.davidwhitlock.joy projects - 2.1.1-SNAPSHOT + 3.0.0-SNAPSHOT diff --git a/grader/pom.xml b/grader/pom.xml index b16da7285..82f2d3202 100644 --- a/grader/pom.xml +++ b/grader/pom.xml @@ -19,7 +19,7 @@ io.github.davidwhitlock.joy projects - 2.1.1-SNAPSHOT + 3.0.0-SNAPSHOT com.opencsv diff --git a/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/pom.xml index 08060f50e..12e908909 100644 --- a/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/pom.xml @@ -32,12 +32,12 @@ io.github.davidwhitlock.joy projects - 2.1.1-SNAPSHOT + 3.0.0-SNAPSHOT io.github.davidwhitlock.joy projects - 2.1.1-SNAPSHOT + 3.0.0-SNAPSHOT tests test diff --git a/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/src/main/java/AirlineXmlHelper.java b/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/src/main/java/AirlineXmlHelper.java index 48cc63b6b..2630971c5 100644 --- a/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/src/main/java/AirlineXmlHelper.java +++ b/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/src/main/java/AirlineXmlHelper.java @@ -11,16 +11,12 @@ */ public class AirlineXmlHelper extends ProjectXmlHelper { - /** The System ID for the Family Tree DTD */ - protected static final String SYSTEM_ID = - "http://www.cs.pdx.edu/~whitlock/dtds/airline.dtd"; - /** The Public ID for the Family Tree DTD */ protected static final String PUBLIC_ID = "-//Joy of Coding at PSU//DTD Airline//EN"; public AirlineXmlHelper() { - super(PUBLIC_ID, SYSTEM_ID, "airline.dtd"); + super(PUBLIC_ID, "airline.dtd"); } } diff --git a/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/src/test/resources/__packageInPathFormat__/invalid-airline.xml b/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/src/test/resources/__packageInPathFormat__/invalid-airline.xml index 8f2ddbcab..def406306 100644 --- a/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/src/test/resources/__packageInPathFormat__/invalid-airline.xml +++ b/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/src/test/resources/__packageInPathFormat__/invalid-airline.xml @@ -5,7 +5,7 @@ + PUBLIC "-//Joy of Coding at PSU//DTD Airline//EN" "airline.dtd"> Example Airlines @@ -13,26 +13,26 @@ 1437 BJX - + CMN - - 7865 JNB - - XIY - - diff --git a/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/src/test/resources/__packageInPathFormat__/valid-airline.xml b/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/src/test/resources/__packageInPathFormat__/valid-airline.xml index bdbefbc2d..342228230 100644 --- a/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/src/test/resources/__packageInPathFormat__/valid-airline.xml +++ b/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/src/test/resources/__packageInPathFormat__/valid-airline.xml @@ -4,7 +4,7 @@ + PUBLIC "-//Joy of Coding at PSU//DTD Airline//EN" "airline.dtd"> Valid Airlines @@ -12,26 +12,26 @@ 1437 BJX - - CMN - - 7865 JNB - - XIY - - diff --git a/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/pom.xml index 492d96d31..e23ab33e5 100644 --- a/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/pom.xml @@ -21,7 +21,7 @@ io.github.davidwhitlock.joy projects - 2.1.1-SNAPSHOT + 3.0.0-SNAPSHOT io.github.davidwhitlock.joy @@ -31,7 +31,7 @@ io.github.davidwhitlock.joy projects - 2.1.1-SNAPSHOT + 3.0.0-SNAPSHOT tests test diff --git a/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/pom.xml index cc09b18c1..a20fcbdfc 100644 --- a/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/pom.xml @@ -32,12 +32,12 @@ io.github.davidwhitlock.joy projects - 2.1.1-SNAPSHOT + 3.0.0-SNAPSHOT io.github.davidwhitlock.joy projects - 2.1.1-SNAPSHOT + 3.0.0-SNAPSHOT tests test diff --git a/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/pom.xml index 8f7410324..28dbf3f32 100644 --- a/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/pom.xml @@ -21,7 +21,7 @@ io.github.davidwhitlock.joy projects - 2.1.1-SNAPSHOT + 3.0.0-SNAPSHOT io.github.davidwhitlock.joy @@ -31,7 +31,7 @@ io.github.davidwhitlock.joy projects - 2.1.1-SNAPSHOT + 3.0.0-SNAPSHOT tests test diff --git a/projects-parent/archetypes-parent/kata-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/kata-archetype/src/main/resources/archetype-resources/pom.xml index bb23a5e79..eeba1df13 100644 --- a/projects-parent/archetypes-parent/kata-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/kata-archetype/src/main/resources/archetype-resources/pom.xml @@ -88,7 +88,7 @@ io.github.davidwhitlock.joy projects - 2.1.1-SNAPSHOT + 3.0.0-SNAPSHOT tests test diff --git a/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/pom.xml index 2cbd64a8a..dbaf8d3ba 100644 --- a/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/pom.xml @@ -38,12 +38,12 @@ io.github.davidwhitlock.joy projects - 2.1.1-SNAPSHOT + 3.0.0-SNAPSHOT io.github.davidwhitlock.joy projects - 2.1.1-SNAPSHOT + 3.0.0-SNAPSHOT tests test diff --git a/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/pom.xml index 2a89905d5..cc030aa95 100644 --- a/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/pom.xml @@ -22,7 +22,7 @@ io.github.davidwhitlock.joy projects - 2.1.1-SNAPSHOT + 3.0.0-SNAPSHOT io.github.davidwhitlock.joy @@ -32,7 +32,7 @@ io.github.davidwhitlock.joy projects - 2.1.1-SNAPSHOT + 3.0.0-SNAPSHOT tests test diff --git a/projects-parent/archetypes-parent/student-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/student-archetype/src/main/resources/archetype-resources/pom.xml index a80f10e30..3bc859005 100644 --- a/projects-parent/archetypes-parent/student-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/student-archetype/src/main/resources/archetype-resources/pom.xml @@ -107,7 +107,7 @@ io.github.davidwhitlock.joy projects - 2.1.1-SNAPSHOT + 3.0.0-SNAPSHOT tests test diff --git a/projects-parent/originals-parent/airline-web/pom.xml b/projects-parent/originals-parent/airline-web/pom.xml index 99d97e3f3..ab72e8f91 100644 --- a/projects-parent/originals-parent/airline-web/pom.xml +++ b/projects-parent/originals-parent/airline-web/pom.xml @@ -3,12 +3,12 @@ originals-parent io.github.davidwhitlock.joy - 2.1.1-SNAPSHOT + 2.2.0-SNAPSHOT 4.0.0 io.github.davidwhitlock.joy.original airline-web - 2.2.1-SNAPSHOT + 2.3.0-SNAPSHOT 8080 @@ -21,7 +21,7 @@ io.github.davidwhitlock.joy projects - 2.1.1-SNAPSHOT + 3.0.0-SNAPSHOT io.github.davidwhitlock.joy @@ -31,7 +31,7 @@ io.github.davidwhitlock.joy projects - 2.1.1-SNAPSHOT + 3.0.0-SNAPSHOT tests test diff --git a/projects-parent/originals-parent/airline/pom.xml b/projects-parent/originals-parent/airline/pom.xml index 8686297cb..d48f0b57b 100644 --- a/projects-parent/originals-parent/airline/pom.xml +++ b/projects-parent/originals-parent/airline/pom.xml @@ -3,13 +3,13 @@ originals-parent io.github.davidwhitlock.joy - 2.1.1-SNAPSHOT + 2.2.0-SNAPSHOT 4.0.0 io.github.davidwhitlock.joy.original airline jar - 2.1.1-SNAPSHOT + 2.2.0-SNAPSHOT Airline Project An Airline application for The Joy of Coding at Portland State University 2000 @@ -32,12 +32,12 @@ io.github.davidwhitlock.joy projects - 2.1.1-SNAPSHOT + 3.0.0-SNAPSHOT io.github.davidwhitlock.joy projects - 2.1.1-SNAPSHOT + 3.0.0-SNAPSHOT tests test diff --git a/projects-parent/originals-parent/airline/src/main/java/edu/pdx/cs/joy/airline/AirlineXmlHelper.java b/projects-parent/originals-parent/airline/src/main/java/edu/pdx/cs/joy/airline/AirlineXmlHelper.java index 816df1652..9977c3610 100644 --- a/projects-parent/originals-parent/airline/src/main/java/edu/pdx/cs/joy/airline/AirlineXmlHelper.java +++ b/projects-parent/originals-parent/airline/src/main/java/edu/pdx/cs/joy/airline/AirlineXmlHelper.java @@ -8,16 +8,12 @@ */ public class AirlineXmlHelper extends ProjectXmlHelper { - /** The System ID for the Family Tree DTD */ - protected static final String SYSTEM_ID = - "http://www.cs.pdx.edu/~whitlock/dtds/airline.dtd"; - /** The Public ID for the Family Tree DTD */ protected static final String PUBLIC_ID = "-//Joy of Coding at PSU//DTD Airline//EN"; public AirlineXmlHelper() { - super(PUBLIC_ID, SYSTEM_ID, "airline.dtd"); + super(PUBLIC_ID, "airline.dtd"); } } diff --git a/projects-parent/originals-parent/airline/src/test/resources/edu/pdx/cs/joy/airline/invalid-airline.xml b/projects-parent/originals-parent/airline/src/test/resources/edu/pdx/cs/joy/airline/invalid-airline.xml index 45dd8a4ae..db01d9c48 100644 --- a/projects-parent/originals-parent/airline/src/test/resources/edu/pdx/cs/joy/airline/invalid-airline.xml +++ b/projects-parent/originals-parent/airline/src/test/resources/edu/pdx/cs/joy/airline/invalid-airline.xml @@ -2,7 +2,7 @@ + PUBLIC "-//Joy of Coding at PSU//DTD Airline//EN" "airline.dtd"> Example Airlines @@ -10,26 +10,26 @@ 1437 BJX - + CMN - - 7865 JNB - - XIY - - diff --git a/projects-parent/originals-parent/airline/src/test/resources/edu/pdx/cs/joy/airline/valid-airline.xml b/projects-parent/originals-parent/airline/src/test/resources/edu/pdx/cs/joy/airline/valid-airline.xml index bc73b2a95..4cc9dd902 100644 --- a/projects-parent/originals-parent/airline/src/test/resources/edu/pdx/cs/joy/airline/valid-airline.xml +++ b/projects-parent/originals-parent/airline/src/test/resources/edu/pdx/cs/joy/airline/valid-airline.xml @@ -1,7 +1,7 @@ + PUBLIC "-//Joy of Coding at PSU//DTD Airline//EN" "airline.dtd"> Valid Airlines @@ -9,26 +9,26 @@ 1437 BJX - - CMN - - 7865 JNB - - XIY - - diff --git a/projects-parent/originals-parent/apptbook-web/pom.xml b/projects-parent/originals-parent/apptbook-web/pom.xml index 41b5cdec6..75c8c27fd 100644 --- a/projects-parent/originals-parent/apptbook-web/pom.xml +++ b/projects-parent/originals-parent/apptbook-web/pom.xml @@ -3,12 +3,12 @@ originals-parent io.github.davidwhitlock.joy - 2.1.1-SNAPSHOT + 2.2.0-SNAPSHOT 4.0.0 io.github.davidwhitlock.joy.original apptbook-web - 2.2.1-SNAPSHOT + 2.3.0-SNAPSHOT 8080 @@ -21,7 +21,7 @@ io.github.davidwhitlock.joy projects - 2.1.1-SNAPSHOT + 3.0.0-SNAPSHOT io.github.davidwhitlock.joy @@ -31,7 +31,7 @@ io.github.davidwhitlock.joy projects - 2.1.1-SNAPSHOT + 3.0.0-SNAPSHOT tests test diff --git a/projects-parent/originals-parent/apptbook/pom.xml b/projects-parent/originals-parent/apptbook/pom.xml index 62a6b4ebe..7344134a1 100644 --- a/projects-parent/originals-parent/apptbook/pom.xml +++ b/projects-parent/originals-parent/apptbook/pom.xml @@ -3,13 +3,13 @@ originals-parent io.github.davidwhitlock.joy - 2.1.1-SNAPSHOT + 2.2.0-SNAPSHOT 4.0.0 io.github.davidwhitlock.joy.original apptbook jar - 2.1.1-SNAPSHOT + 2.2.0-SNAPSHOT Appointment Book Project An Appointment Book application for The Joy of Coding at Portland State University 2000 @@ -32,12 +32,12 @@ io.github.davidwhitlock.joy projects - 2.1.1-SNAPSHOT + 3.0.0-SNAPSHOT io.github.davidwhitlock.joy projects - 2.1.1-SNAPSHOT + 3.0.0-SNAPSHOT tests test diff --git a/projects-parent/originals-parent/apptbook/src/main/java/edu/pdx/cs/joy/apptbook/AppointmentBookXmlHelper.java b/projects-parent/originals-parent/apptbook/src/main/java/edu/pdx/cs/joy/apptbook/AppointmentBookXmlHelper.java index 27fec8fc4..34cb67f4f 100644 --- a/projects-parent/originals-parent/apptbook/src/main/java/edu/pdx/cs/joy/apptbook/AppointmentBookXmlHelper.java +++ b/projects-parent/originals-parent/apptbook/src/main/java/edu/pdx/cs/joy/apptbook/AppointmentBookXmlHelper.java @@ -4,12 +4,6 @@ public class AppointmentBookXmlHelper extends ProjectXmlHelper { - /** - * The System ID for the Family Tree DTD - */ - protected static final String SYSTEM_ID = - "http://www.cs.pdx.edu/~whitlock/dtds/apptbook.dtd"; - /** * The Public ID for the Family Tree DTD */ @@ -17,6 +11,6 @@ public class AppointmentBookXmlHelper extends ProjectXmlHelper { "-//Joy of Coding at PSU//DTD Appointment Book//EN"; protected AppointmentBookXmlHelper() { - super(PUBLIC_ID, SYSTEM_ID, "apptbook.dtd"); + super(PUBLIC_ID, "apptbook.dtd"); } } diff --git a/projects-parent/originals-parent/kata/pom.xml b/projects-parent/originals-parent/kata/pom.xml index baed56708..5779e68e9 100644 --- a/projects-parent/originals-parent/kata/pom.xml +++ b/projects-parent/originals-parent/kata/pom.xml @@ -4,11 +4,11 @@ originals-parent io.github.davidwhitlock.joy - 2.1.1-SNAPSHOT + 2.2.0-SNAPSHOT io.github.davidwhitlock.joy.original kata - 2.1.1-SNAPSHOT + 2.2.0-SNAPSHOT jar Kata Project @@ -88,7 +88,7 @@ io.github.davidwhitlock.joy projects - 2.1.1-SNAPSHOT + 3.0.0-SNAPSHOT tests test diff --git a/projects-parent/originals-parent/phonebill-web/pom.xml b/projects-parent/originals-parent/phonebill-web/pom.xml index bdbafc772..b86ee6430 100644 --- a/projects-parent/originals-parent/phonebill-web/pom.xml +++ b/projects-parent/originals-parent/phonebill-web/pom.xml @@ -3,12 +3,12 @@ originals-parent io.github.davidwhitlock.joy - 2.1.1-SNAPSHOT + 2.2.0-SNAPSHOT 4.0.0 io.github.davidwhitlock.joy.original phonebill-web - 2.2.1-SNAPSHOT + 2.3.0-SNAPSHOT 8080 @@ -22,7 +22,7 @@ io.github.davidwhitlock.joy projects - 2.1.1-SNAPSHOT + 3.0.0-SNAPSHOT io.github.davidwhitlock.joy @@ -32,7 +32,7 @@ io.github.davidwhitlock.joy projects - 2.1.1-SNAPSHOT + 3.0.0-SNAPSHOT tests test diff --git a/projects-parent/originals-parent/phonebill/pom.xml b/projects-parent/originals-parent/phonebill/pom.xml index dc40bebe9..24f7e3c10 100644 --- a/projects-parent/originals-parent/phonebill/pom.xml +++ b/projects-parent/originals-parent/phonebill/pom.xml @@ -3,13 +3,13 @@ originals-parent io.github.davidwhitlock.joy - 2.1.1-SNAPSHOT + 2.2.0-SNAPSHOT 4.0.0 io.github.davidwhitlock.joy.original phonebill jar - 2.1.1-SNAPSHOT + 2.2.0-SNAPSHOT Phone Bill Project A Phone Bill application for The Joy of Coding at Portland State University 2000 @@ -38,12 +38,12 @@ io.github.davidwhitlock.joy projects - 2.1.1-SNAPSHOT + 3.0.0-SNAPSHOT io.github.davidwhitlock.joy projects - 2.1.1-SNAPSHOT + 3.0.0-SNAPSHOT tests test diff --git a/projects-parent/originals-parent/pom.xml b/projects-parent/originals-parent/pom.xml index 69684a41b..da9c4ec51 100644 --- a/projects-parent/originals-parent/pom.xml +++ b/projects-parent/originals-parent/pom.xml @@ -5,11 +5,11 @@ io.github.davidwhitlock.joy projects-parent - 2.1.1-SNAPSHOT + 2.2.0-SNAPSHOT originals-parent - 2.1.1-SNAPSHOT + 2.2.0-SNAPSHOT pom diff --git a/projects-parent/originals-parent/student/pom.xml b/projects-parent/originals-parent/student/pom.xml index cb89391aa..d9d843cf4 100644 --- a/projects-parent/originals-parent/student/pom.xml +++ b/projects-parent/originals-parent/student/pom.xml @@ -4,11 +4,11 @@ originals-parent io.github.davidwhitlock.joy - 2.1.1-SNAPSHOT + 2.2.0-SNAPSHOT io.github.davidwhitlock.joy.original student - 2.2.1-SNAPSHOT + 2.2.0-SNAPSHOT jar Student Project @@ -93,7 +93,7 @@ io.github.davidwhitlock.joy projects - 2.1.1-SNAPSHOT + 3.0.0-SNAPSHOT tests test diff --git a/projects-parent/pom.xml b/projects-parent/pom.xml index 6f6a8724d..8bbb85991 100644 --- a/projects-parent/pom.xml +++ b/projects-parent/pom.xml @@ -11,7 +11,7 @@ projects-parent - 2.1.1-SNAPSHOT + 2.2.0-SNAPSHOT pom diff --git a/projects-parent/projects/pom.xml b/projects-parent/projects/pom.xml index ba576135c..3952a041a 100644 --- a/projects-parent/projects/pom.xml +++ b/projects-parent/projects/pom.xml @@ -2,13 +2,13 @@ projects-parent io.github.davidwhitlock.joy - 2.1.1-SNAPSHOT + 2.2.0-SNAPSHOT 4.0.0 projects Project APIs Classes needed for the Projects in The Joy of Coding - 2.1.1-SNAPSHOT + 3.0.0-SNAPSHOT http://www.cs.pdx.edu/~whitlock diff --git a/projects-parent/projects/src/main/java/edu/pdx/cs/joy/ProjectXmlHelper.java b/projects-parent/projects/src/main/java/edu/pdx/cs/joy/ProjectXmlHelper.java index ddeb4d671..66a2419be 100644 --- a/projects-parent/projects/src/main/java/edu/pdx/cs/joy/ProjectXmlHelper.java +++ b/projects-parent/projects/src/main/java/edu/pdx/cs/joy/ProjectXmlHelper.java @@ -8,12 +8,10 @@ public abstract class ProjectXmlHelper implements ErrorHandler, EntityResolver { private final String publicId; - private final String systemId; private final String dtdFileName; - protected ProjectXmlHelper(String publicId, String systemId, String dtdFileName) { + protected ProjectXmlHelper(String publicId, String dtdFileName) { this.publicId = publicId; - this.systemId = systemId; this.dtdFileName = dtdFileName; } @@ -34,7 +32,7 @@ public void fatalError(SAXParseException exception) throws SAXException { @Override public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { - if (this.publicId.equals(publicId) || this.systemId.equals(systemId)) { + if (this.publicId.equals(publicId)) { // We're resolving the external entity for the DTD // Check to see if it's in the jar file. This way we don't // need to go all the way to the website to find the DTD. @@ -45,14 +43,6 @@ public InputSource resolveEntity(String publicId, String systemId) throws SAXExc } } - // Try to access the DTD using the URL - try { - URL url = new URL(systemId); - InputStream stream = url.openStream(); - return new InputSource(stream); - - } catch (Exception ex) { - return null; - } + return null; } } diff --git a/projects-parent/projects/src/main/java/edu/pdx/cs/joy/airline.xml b/projects-parent/projects/src/main/java/edu/pdx/cs/joy/airline.xml index 4260935c3..77c6a2707 100644 --- a/projects-parent/projects/src/main/java/edu/pdx/cs/joy/airline.xml +++ b/projects-parent/projects/src/main/java/edu/pdx/cs/joy/airline.xml @@ -2,7 +2,7 @@ + PUBLIC "-//Joy of Coding at PSU//DTD Airline//EN" "airline.dtd"> Example Airlines diff --git a/projects-parent/projects/src/main/resources/edu/pdx/cs/joy/airline.dtd b/projects-parent/projects/src/main/resources/edu/pdx/cs/joy/airline.dtd index ec33861de..430e20a00 100644 --- a/projects-parent/projects/src/main/resources/edu/pdx/cs/joy/airline.dtd +++ b/projects-parent/projects/src/main/resources/edu/pdx/cs/joy/airline.dtd @@ -40,5 +40,4 @@ From 37a928aa13f004d3ea078d4e4d31357a2a8c788f Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Sun, 17 Nov 2024 19:38:33 -0800 Subject: [PATCH 13/59] Update the airline archetype project to no longer reference the DTD URL. --- .../airline-archetype/pom.xml | 71 +++++++++++++------ .../META-INF/maven/archetype-metadata.xml | 4 +- .../src/main/java/TextDumper.java | 1 - .../src/main/java/TextParser.java | 1 - .../pdx/cs410J/__artifactId__/package.html | 6 ++ .../pdx/cs410J/__artifactId__/package.html | 6 ++ .../projects/basic/archetype.properties | 4 +- 7 files changed, 67 insertions(+), 26 deletions(-) create mode 100644 projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/src/main/javadoc/edu/pdx/cs410J/__artifactId__/package.html create mode 100644 projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/src/test/javadoc/edu/pdx/cs410J/__artifactId__/package.html diff --git a/projects-parent/archetypes-parent/airline-archetype/pom.xml b/projects-parent/archetypes-parent/airline-archetype/pom.xml index c698b8435..6d048038d 100644 --- a/projects-parent/archetypes-parent/airline-archetype/pom.xml +++ b/projects-parent/archetypes-parent/airline-archetype/pom.xml @@ -1,13 +1,10 @@ 4.0.0 - - archetypes-parent - io.github.davidwhitlock.joy - 2.1.1-SNAPSHOT - + + io.github.davidwhitlock.joy.original airline-archetype - 2.1.1-SNAPSHOT + 2.2.0-SNAPSHOT maven-archetype airline-archetype @@ -17,7 +14,7 @@ org.apache.maven.archetype archetype-packaging - ${maven-archetype-plugin.version} + 3.2.1 @@ -25,24 +22,58 @@ maven-archetype-plugin - ${maven-archetype-plugin.version} + 3.2.1 - + An Airline application for The Joy of Coding at Portland State University + + http://www.cs.pdx.edu/~whitlock + + + + YOU + Your name here + you@youremail.com + http://www.cs.pdx.edu/~YOU + PSU Department of Computer Science + http://www.cs.pdx.edu + + Student + + -7 + + + + + + Apache License, Version 2.0 + https://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + + scm:git:git@github.com:JoyOfCodingPDX/JoyOfCoding.git/projects-parent/originals-parent/airline + scm:git:git@github.com:JoyOfCodingPDX/JoyOfCoding.git/projects-parent/originals-parent/airline + https://github.com/JoyOfCodingPDX/JoyOfCoding/tree/main/projects-parent/originals-parent/airline + + + - maven-snapshots - https://s01.oss.sonatype.org/content/repositories/snapshots - default - - false - - - true - + ossrh + https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/ - - + + ossrh + https://s01.oss.sonatype.org/content/repositories/snapshots + + + gh-pages + GitHub Pages + scm:git:git@github.com:JoyOfCodingPDX/JoyOfCoding.git/projects-parent/originals-parent + + diff --git a/projects-parent/archetypes-parent/airline-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml b/projects-parent/archetypes-parent/airline-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml index dac75e55e..78c6f431d 100644 --- a/projects-parent/archetypes-parent/airline-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml +++ b/projects-parent/archetypes-parent/airline-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -1,6 +1,6 @@ - diff --git a/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/src/main/java/TextDumper.java b/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/src/main/java/TextDumper.java index fd9242301..22605a2b0 100644 --- a/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/src/main/java/TextDumper.java +++ b/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/src/main/java/TextDumper.java @@ -5,7 +5,6 @@ import edu.pdx.cs.joy.AirlineDumper; -import java.io.IOException; import java.io.PrintWriter; import java.io.Writer; diff --git a/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/src/main/java/TextParser.java b/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/src/main/java/TextParser.java index 2aeedeeb8..baab64120 100644 --- a/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/src/main/java/TextParser.java +++ b/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/src/main/java/TextParser.java @@ -8,7 +8,6 @@ import java.io.BufferedReader; import java.io.IOException; -import java.io.InputStreamReader; import java.io.Reader; /** diff --git a/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/src/main/javadoc/edu/pdx/cs410J/__artifactId__/package.html b/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/src/main/javadoc/edu/pdx/cs410J/__artifactId__/package.html new file mode 100644 index 000000000..4f17af6f2 --- /dev/null +++ b/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/src/main/javadoc/edu/pdx/cs410J/__artifactId__/package.html @@ -0,0 +1,6 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) + +

Contains the application classes for the Airline project.

+ \ No newline at end of file diff --git a/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/src/test/javadoc/edu/pdx/cs410J/__artifactId__/package.html b/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/src/test/javadoc/edu/pdx/cs410J/__artifactId__/package.html new file mode 100644 index 000000000..63197885a --- /dev/null +++ b/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/src/test/javadoc/edu/pdx/cs410J/__artifactId__/package.html @@ -0,0 +1,6 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) + +

Contains the test classes for the Airline project.

+ \ No newline at end of file diff --git a/projects-parent/archetypes-parent/airline-archetype/src/test/resources/projects/basic/archetype.properties b/projects-parent/archetypes-parent/airline-archetype/src/test/resources/projects/basic/archetype.properties index 98813a488..0a7b2a947 100644 --- a/projects-parent/archetypes-parent/airline-archetype/src/test/resources/projects/basic/archetype.properties +++ b/projects-parent/archetypes-parent/airline-archetype/src/test/resources/projects/basic/archetype.properties @@ -1,5 +1,5 @@ -#Fri Nov 27 14:58:27 PST 2015 +#Sun Nov 17 19:26:52 PST 2024 package=it.pkg -version=0.1-SNAPSHOT groupId=archetype.it artifactId=basic +version=0.1-SNAPSHOT From 98ced21578b84c52ac829afb09c430fe1872d0a9 Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Sun, 17 Nov 2024 19:46:13 -0800 Subject: [PATCH 14/59] Update the appointment book archetype project to no longer reference the DTD URL. --- .../resources/edu/pdx/cs/joy/apptbook/invalid-apptbook.xml | 4 ++-- .../resources/edu/pdx/cs/joy/apptbook/valid-apptbook.xml | 6 +++--- .../projects/src/main/resources/edu/pdx/cs/joy/apptbook.dtd | 1 - 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/projects-parent/originals-parent/apptbook/src/test/resources/edu/pdx/cs/joy/apptbook/invalid-apptbook.xml b/projects-parent/originals-parent/apptbook/src/test/resources/edu/pdx/cs/joy/apptbook/invalid-apptbook.xml index 48436f9f2..77f85c4a0 100644 --- a/projects-parent/originals-parent/apptbook/src/test/resources/edu/pdx/cs/joy/apptbook/invalid-apptbook.xml +++ b/projects-parent/originals-parent/apptbook/src/test/resources/edu/pdx/cs/joy/apptbook/invalid-apptbook.xml @@ -1,14 +1,14 @@ + PUBLIC "-//Joy of Coding at PSU//DTD Appointment Book//EN" "apptbook.dtd"> Example Appointment Book - diff --git a/projects-parent/originals-parent/apptbook/src/test/resources/edu/pdx/cs/joy/apptbook/valid-apptbook.xml b/projects-parent/originals-parent/apptbook/src/test/resources/edu/pdx/cs/joy/apptbook/valid-apptbook.xml index df2fffe5b..53800923b 100644 --- a/projects-parent/originals-parent/apptbook/src/test/resources/edu/pdx/cs/joy/apptbook/valid-apptbook.xml +++ b/projects-parent/originals-parent/apptbook/src/test/resources/edu/pdx/cs/joy/apptbook/valid-apptbook.xml @@ -1,18 +1,18 @@ + PUBLIC "-//Joy of Coding at PSU//DTD Appointment Book//EN" "apptbook.dtd"> Example Appointment Book - - Example Appointment diff --git a/projects-parent/projects/src/main/resources/edu/pdx/cs/joy/apptbook.dtd b/projects-parent/projects/src/main/resources/edu/pdx/cs/joy/apptbook.dtd index 4a3c75bae..40319c5ad 100644 --- a/projects-parent/projects/src/main/resources/edu/pdx/cs/joy/apptbook.dtd +++ b/projects-parent/projects/src/main/resources/edu/pdx/cs/joy/apptbook.dtd @@ -37,6 +37,5 @@ From c09bb538fcf954c2fe420d260dafd8f90a0cce7c Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Sun, 17 Nov 2024 20:04:24 -0800 Subject: [PATCH 15/59] Update the appointment book archetype project to no longer reference the DTD URL. --- .../archetypes-parent/apptbook-archetype/pom.xml | 6 +++--- .../src/main/java/AppointmentBookXmlHelper.java | 8 +------- .../archetype-resources/src/main/java/TextParser.java | 1 - .../javadoc/edu/pdx/cs410J/__artifactId__/package.html | 6 ++++++ .../javadoc/edu/pdx/cs410J/__artifactId__/package.html | 6 ++++++ .../__packageInPathFormat__/invalid-apptbook.xml | 4 ++-- .../resources/__packageInPathFormat__/valid-apptbook.xml | 6 +++--- .../test/resources/projects/basic/archetype.properties | 2 +- 8 files changed, 22 insertions(+), 17 deletions(-) create mode 100644 projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/src/main/javadoc/edu/pdx/cs410J/__artifactId__/package.html create mode 100644 projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/src/test/javadoc/edu/pdx/cs410J/__artifactId__/package.html diff --git a/projects-parent/archetypes-parent/apptbook-archetype/pom.xml b/projects-parent/archetypes-parent/apptbook-archetype/pom.xml index 04ac31631..9531b2f57 100644 --- a/projects-parent/archetypes-parent/apptbook-archetype/pom.xml +++ b/projects-parent/archetypes-parent/apptbook-archetype/pom.xml @@ -7,7 +7,7 @@ 2.1.1-SNAPSHOT apptbook-archetype - 2.1.1-SNAPSHOT + 2.2.0-SNAPSHOT maven-archetype apptbook-archetype @@ -17,7 +17,7 @@ org.apache.maven.archetype archetype-packaging - ${maven-archetype-plugin.version} + 3.2.1 @@ -25,7 +25,7 @@ maven-archetype-plugin - ${maven-archetype-plugin.version} + 3.2.1 diff --git a/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/src/main/java/AppointmentBookXmlHelper.java b/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/src/main/java/AppointmentBookXmlHelper.java index d1ed52f5d..3edff15a9 100644 --- a/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/src/main/java/AppointmentBookXmlHelper.java +++ b/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/src/main/java/AppointmentBookXmlHelper.java @@ -7,12 +7,6 @@ public class AppointmentBookXmlHelper extends ProjectXmlHelper { - /** - * The System ID for the Family Tree DTD - */ - protected static final String SYSTEM_ID = - "http://www.cs.pdx.edu/~whitlock/dtds/apptbook.dtd"; - /** * The Public ID for the Family Tree DTD */ @@ -20,6 +14,6 @@ public class AppointmentBookXmlHelper extends ProjectXmlHelper { "-//Joy of Coding at PSU//DTD Appointment Book//EN"; protected AppointmentBookXmlHelper() { - super(PUBLIC_ID, SYSTEM_ID, "apptbook.dtd"); + super(PUBLIC_ID, "apptbook.dtd"); } } diff --git a/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/src/main/java/TextParser.java b/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/src/main/java/TextParser.java index 8eed9a42d..0bc4d01d8 100644 --- a/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/src/main/java/TextParser.java +++ b/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/src/main/java/TextParser.java @@ -7,7 +7,6 @@ import edu.pdx.cs.joy.ParserException; import java.io.BufferedReader; -import java.io.FileReader; import java.io.IOException; import java.io.Reader; diff --git a/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/src/main/javadoc/edu/pdx/cs410J/__artifactId__/package.html b/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/src/main/javadoc/edu/pdx/cs410J/__artifactId__/package.html new file mode 100644 index 000000000..54dbc66f8 --- /dev/null +++ b/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/src/main/javadoc/edu/pdx/cs410J/__artifactId__/package.html @@ -0,0 +1,6 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) + +

Contains the application classes for the Appointment Book project.

+ \ No newline at end of file diff --git a/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/src/test/javadoc/edu/pdx/cs410J/__artifactId__/package.html b/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/src/test/javadoc/edu/pdx/cs410J/__artifactId__/package.html new file mode 100644 index 000000000..9777aff71 --- /dev/null +++ b/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/src/test/javadoc/edu/pdx/cs410J/__artifactId__/package.html @@ -0,0 +1,6 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) + +

Contains the test classes for the Appointment Book project.

+ \ No newline at end of file diff --git a/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/src/test/resources/__packageInPathFormat__/invalid-apptbook.xml b/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/src/test/resources/__packageInPathFormat__/invalid-apptbook.xml index 404d94022..5d6df1bce 100644 --- a/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/src/test/resources/__packageInPathFormat__/invalid-apptbook.xml +++ b/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/src/test/resources/__packageInPathFormat__/invalid-apptbook.xml @@ -4,14 +4,14 @@ + PUBLIC "-//Joy of Coding at PSU//DTD Appointment Book//EN" "apptbook.dtd"> Example Appointment Book - diff --git a/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/src/test/resources/__packageInPathFormat__/valid-apptbook.xml b/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/src/test/resources/__packageInPathFormat__/valid-apptbook.xml index d34023188..ba14419e4 100644 --- a/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/src/test/resources/__packageInPathFormat__/valid-apptbook.xml +++ b/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/src/test/resources/__packageInPathFormat__/valid-apptbook.xml @@ -4,18 +4,18 @@ + PUBLIC "-//Joy of Coding at PSU//DTD Appointment Book//EN" "apptbook.dtd"> Example Appointment Book - - Example Appointment diff --git a/projects-parent/archetypes-parent/apptbook-archetype/src/test/resources/projects/basic/archetype.properties b/projects-parent/archetypes-parent/apptbook-archetype/src/test/resources/projects/basic/archetype.properties index b9b6662a1..741afd93f 100644 --- a/projects-parent/archetypes-parent/apptbook-archetype/src/test/resources/projects/basic/archetype.properties +++ b/projects-parent/archetypes-parent/apptbook-archetype/src/test/resources/projects/basic/archetype.properties @@ -1,4 +1,4 @@ -#Sat Nov 11 08:26:12 PST 2023 +#Sun Nov 17 19:44:35 PST 2024 package=it.pkg groupId=archetype.it artifactId=basic From be1c157d1cff51768b3a9e3da643b0d8111e1fcb Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Wed, 20 Nov 2024 18:24:55 -0800 Subject: [PATCH 16/59] Incremented the versions of the archetype projects. --- projects-parent/archetypes-parent/airline-web-archetype/pom.xml | 2 +- .../archetypes-parent/apptbook-web-archetype/pom.xml | 2 +- projects-parent/archetypes-parent/java-koans-archetype/pom.xml | 2 +- projects-parent/archetypes-parent/kata-archetype/pom.xml | 2 +- projects-parent/archetypes-parent/phonebill-archetype/pom.xml | 2 +- .../archetypes-parent/phonebill-web-archetype/pom.xml | 2 +- projects-parent/archetypes-parent/student-archetype/pom.xml | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/projects-parent/archetypes-parent/airline-web-archetype/pom.xml b/projects-parent/archetypes-parent/airline-web-archetype/pom.xml index 3afd6ada8..a4bba4804 100644 --- a/projects-parent/archetypes-parent/airline-web-archetype/pom.xml +++ b/projects-parent/archetypes-parent/airline-web-archetype/pom.xml @@ -7,7 +7,7 @@ 2.1.1-SNAPSHOT airline-web-archetype - 2.2.2-SNAPSHOT + 2.3.0-SNAPSHOT maven-archetype airline-web-archetype diff --git a/projects-parent/archetypes-parent/apptbook-web-archetype/pom.xml b/projects-parent/archetypes-parent/apptbook-web-archetype/pom.xml index 163626a0c..a9af8d324 100644 --- a/projects-parent/archetypes-parent/apptbook-web-archetype/pom.xml +++ b/projects-parent/archetypes-parent/apptbook-web-archetype/pom.xml @@ -7,7 +7,7 @@ 2.1.1-SNAPSHOT apptbook-web-archetype - 2.2.2-SNAPSHOT + 2.3.0-SNAPSHOT maven-archetype apptbook-web-archetype diff --git a/projects-parent/archetypes-parent/java-koans-archetype/pom.xml b/projects-parent/archetypes-parent/java-koans-archetype/pom.xml index 1ee469011..9a4b8348e 100644 --- a/projects-parent/archetypes-parent/java-koans-archetype/pom.xml +++ b/projects-parent/archetypes-parent/java-koans-archetype/pom.xml @@ -9,7 +9,7 @@ 4.0.0 java-koans-archetype - 2.1.1-SNAPSHOT + 2.2.0-SNAPSHOT maven-archetype java-koans-archetype diff --git a/projects-parent/archetypes-parent/kata-archetype/pom.xml b/projects-parent/archetypes-parent/kata-archetype/pom.xml index 8f1dfddbb..5e0213c88 100644 --- a/projects-parent/archetypes-parent/kata-archetype/pom.xml +++ b/projects-parent/archetypes-parent/kata-archetype/pom.xml @@ -8,7 +8,7 @@ 2.1.1-SNAPSHOT kata-archetype - 2.1.1-SNAPSHOT + 2.2.0-SNAPSHOT maven-archetype kata-archetype diff --git a/projects-parent/archetypes-parent/phonebill-archetype/pom.xml b/projects-parent/archetypes-parent/phonebill-archetype/pom.xml index 3fdc7c076..ab8aceb11 100644 --- a/projects-parent/archetypes-parent/phonebill-archetype/pom.xml +++ b/projects-parent/archetypes-parent/phonebill-archetype/pom.xml @@ -7,7 +7,7 @@ 4.0.0 phonebill-archetype - 2.1.1-SNAPSHOT + 2.2.0-SNAPSHOT maven-archetype phonebill-archetype diff --git a/projects-parent/archetypes-parent/phonebill-web-archetype/pom.xml b/projects-parent/archetypes-parent/phonebill-web-archetype/pom.xml index 18873423e..8d41a6fac 100644 --- a/projects-parent/archetypes-parent/phonebill-web-archetype/pom.xml +++ b/projects-parent/archetypes-parent/phonebill-web-archetype/pom.xml @@ -7,7 +7,7 @@ 2.1.1-SNAPSHOT phonebill-web-archetype - 2.2.2-SNAPSHOT + 2.3.0-SNAPSHOT maven-archetype phonebill-web-archetype diff --git a/projects-parent/archetypes-parent/student-archetype/pom.xml b/projects-parent/archetypes-parent/student-archetype/pom.xml index 8784d8655..05360dc06 100644 --- a/projects-parent/archetypes-parent/student-archetype/pom.xml +++ b/projects-parent/archetypes-parent/student-archetype/pom.xml @@ -9,7 +9,7 @@ student-archetype - 2.2.2-SNAPSHOT + 2.3.0-SNAPSHOT maven-archetype Archetype for Student project From 4050d52b9673d476e3a56c218d430a6151b0749d Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Wed, 20 Nov 2024 18:34:07 -0800 Subject: [PATCH 17/59] Incremented the versions of the archetype parent project. --- .../archetypes-parent/airline-web-archetype/pom.xml | 2 +- projects-parent/archetypes-parent/apptbook-archetype/pom.xml | 2 +- .../archetypes-parent/apptbook-web-archetype/pom.xml | 2 +- .../archetypes-parent/java-koans-archetype/pom.xml | 2 +- projects-parent/archetypes-parent/kata-archetype/pom.xml | 2 +- projects-parent/archetypes-parent/phonebill-archetype/pom.xml | 2 +- .../archetypes-parent/phonebill-web-archetype/pom.xml | 2 +- projects-parent/archetypes-parent/pom.xml | 4 ++-- projects-parent/archetypes-parent/student-archetype/pom.xml | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/projects-parent/archetypes-parent/airline-web-archetype/pom.xml b/projects-parent/archetypes-parent/airline-web-archetype/pom.xml index a4bba4804..49ee431bd 100644 --- a/projects-parent/archetypes-parent/airline-web-archetype/pom.xml +++ b/projects-parent/archetypes-parent/airline-web-archetype/pom.xml @@ -4,7 +4,7 @@ archetypes-parent io.github.davidwhitlock.joy - 2.1.1-SNAPSHOT + 2.2.0-SNAPSHOT airline-web-archetype 2.3.0-SNAPSHOT diff --git a/projects-parent/archetypes-parent/apptbook-archetype/pom.xml b/projects-parent/archetypes-parent/apptbook-archetype/pom.xml index 9531b2f57..9fcc27032 100644 --- a/projects-parent/archetypes-parent/apptbook-archetype/pom.xml +++ b/projects-parent/archetypes-parent/apptbook-archetype/pom.xml @@ -4,7 +4,7 @@ archetypes-parent io.github.davidwhitlock.joy - 2.1.1-SNAPSHOT + 2.2.0-SNAPSHOT apptbook-archetype 2.2.0-SNAPSHOT diff --git a/projects-parent/archetypes-parent/apptbook-web-archetype/pom.xml b/projects-parent/archetypes-parent/apptbook-web-archetype/pom.xml index a9af8d324..e4d5143f2 100644 --- a/projects-parent/archetypes-parent/apptbook-web-archetype/pom.xml +++ b/projects-parent/archetypes-parent/apptbook-web-archetype/pom.xml @@ -4,7 +4,7 @@ archetypes-parent io.github.davidwhitlock.joy - 2.1.1-SNAPSHOT + 2.2.0-SNAPSHOT apptbook-web-archetype 2.3.0-SNAPSHOT diff --git a/projects-parent/archetypes-parent/java-koans-archetype/pom.xml b/projects-parent/archetypes-parent/java-koans-archetype/pom.xml index 9a4b8348e..9f8454688 100644 --- a/projects-parent/archetypes-parent/java-koans-archetype/pom.xml +++ b/projects-parent/archetypes-parent/java-koans-archetype/pom.xml @@ -3,7 +3,7 @@ archetypes-parent io.github.davidwhitlock.joy - 2.1.1-SNAPSHOT + 2.2.0-SNAPSHOT 4.0.0 diff --git a/projects-parent/archetypes-parent/kata-archetype/pom.xml b/projects-parent/archetypes-parent/kata-archetype/pom.xml index 5e0213c88..6fb09e6ff 100644 --- a/projects-parent/archetypes-parent/kata-archetype/pom.xml +++ b/projects-parent/archetypes-parent/kata-archetype/pom.xml @@ -5,7 +5,7 @@ archetypes-parent io.github.davidwhitlock.joy - 2.1.1-SNAPSHOT + 2.2.0-SNAPSHOT kata-archetype 2.2.0-SNAPSHOT diff --git a/projects-parent/archetypes-parent/phonebill-archetype/pom.xml b/projects-parent/archetypes-parent/phonebill-archetype/pom.xml index ab8aceb11..1c6df1fc5 100644 --- a/projects-parent/archetypes-parent/phonebill-archetype/pom.xml +++ b/projects-parent/archetypes-parent/phonebill-archetype/pom.xml @@ -3,7 +3,7 @@ archetypes-parent io.github.davidwhitlock.joy - 2.1.1-SNAPSHOT + 2.2.0-SNAPSHOT 4.0.0 phonebill-archetype diff --git a/projects-parent/archetypes-parent/phonebill-web-archetype/pom.xml b/projects-parent/archetypes-parent/phonebill-web-archetype/pom.xml index 8d41a6fac..4f9e6b005 100644 --- a/projects-parent/archetypes-parent/phonebill-web-archetype/pom.xml +++ b/projects-parent/archetypes-parent/phonebill-web-archetype/pom.xml @@ -4,7 +4,7 @@ archetypes-parent io.github.davidwhitlock.joy - 2.1.1-SNAPSHOT + 2.2.0-SNAPSHOT phonebill-web-archetype 2.3.0-SNAPSHOT diff --git a/projects-parent/archetypes-parent/pom.xml b/projects-parent/archetypes-parent/pom.xml index 82178221d..d0b112ded 100644 --- a/projects-parent/archetypes-parent/pom.xml +++ b/projects-parent/archetypes-parent/pom.xml @@ -7,11 +7,11 @@ io.github.davidwhitlock.joy projects-parent - 2.1.1-SNAPSHOT + 2.2.0-SNAPSHOT archetypes-parent - 2.1.1-SNAPSHOT + 2.2.0-SNAPSHOT pom diff --git a/projects-parent/archetypes-parent/student-archetype/pom.xml b/projects-parent/archetypes-parent/student-archetype/pom.xml index 05360dc06..8203266e5 100644 --- a/projects-parent/archetypes-parent/student-archetype/pom.xml +++ b/projects-parent/archetypes-parent/student-archetype/pom.xml @@ -5,7 +5,7 @@ archetypes-parent io.github.davidwhitlock.joy - 2.1.1-SNAPSHOT + 2.2.0-SNAPSHOT student-archetype From 87ab29f6148f6e287775c97064ab1b6092b44ce1 Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Wed, 20 Nov 2024 20:59:54 -0800 Subject: [PATCH 18/59] New version of examples project. --- examples/pom.xml | 2 +- .../src/main/resources/archetype-resources/pom.xml | 2 +- .../src/main/resources/archetype-resources/pom.xml | 2 +- .../src/main/resources/archetype-resources/pom.xml | 2 +- .../src/main/resources/archetype-resources/pom.xml | 2 +- projects-parent/originals-parent/airline-web/pom.xml | 2 +- projects-parent/originals-parent/apptbook-web/pom.xml | 2 +- projects-parent/originals-parent/phonebill-web/pom.xml | 2 +- projects-parent/originals-parent/student/pom.xml | 2 +- web/pom.xml | 4 ++-- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/examples/pom.xml b/examples/pom.xml index 4be91ce1d..9f399b2de 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -8,7 +8,7 @@ 4.0.0 examples examples - 1.2.2-SNAPSHOT + 1.3.0-SNAPSHOT https://www.cs.pdx.edu/~whitlock diff --git a/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/pom.xml index e23ab33e5..aedc40e7c 100644 --- a/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/pom.xml @@ -26,7 +26,7 @@ io.github.davidwhitlock.joy examples - 1.2.2-SNAPSHOT + 1.3.0-SNAPSHOT io.github.davidwhitlock.joy diff --git a/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/pom.xml index 28dbf3f32..3adeab2d2 100644 --- a/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/pom.xml @@ -26,7 +26,7 @@ io.github.davidwhitlock.joy examples - 1.2.2-SNAPSHOT + 1.3.0-SNAPSHOT io.github.davidwhitlock.joy diff --git a/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/pom.xml index cc030aa95..012c6916d 100644 --- a/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/pom.xml @@ -27,7 +27,7 @@ io.github.davidwhitlock.joy examples - 1.2.2-SNAPSHOT + 1.3.0-SNAPSHOT io.github.davidwhitlock.joy diff --git a/projects-parent/archetypes-parent/student-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/student-archetype/src/main/resources/archetype-resources/pom.xml index 3bc859005..4470f6bdf 100644 --- a/projects-parent/archetypes-parent/student-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/student-archetype/src/main/resources/archetype-resources/pom.xml @@ -102,7 +102,7 @@ io.github.davidwhitlock.joy examples - 1.2.2-SNAPSHOT + 1.3.0-SNAPSHOT io.github.davidwhitlock.joy diff --git a/projects-parent/originals-parent/airline-web/pom.xml b/projects-parent/originals-parent/airline-web/pom.xml index ab72e8f91..ed9bd0aeb 100644 --- a/projects-parent/originals-parent/airline-web/pom.xml +++ b/projects-parent/originals-parent/airline-web/pom.xml @@ -26,7 +26,7 @@ io.github.davidwhitlock.joy examples - 1.2.2-SNAPSHOT + 1.3.0-SNAPSHOT io.github.davidwhitlock.joy diff --git a/projects-parent/originals-parent/apptbook-web/pom.xml b/projects-parent/originals-parent/apptbook-web/pom.xml index 75c8c27fd..3db222a4e 100644 --- a/projects-parent/originals-parent/apptbook-web/pom.xml +++ b/projects-parent/originals-parent/apptbook-web/pom.xml @@ -26,7 +26,7 @@ io.github.davidwhitlock.joy examples - 1.2.2-SNAPSHOT + 1.3.0-SNAPSHOT io.github.davidwhitlock.joy diff --git a/projects-parent/originals-parent/phonebill-web/pom.xml b/projects-parent/originals-parent/phonebill-web/pom.xml index b86ee6430..abdafc5f7 100644 --- a/projects-parent/originals-parent/phonebill-web/pom.xml +++ b/projects-parent/originals-parent/phonebill-web/pom.xml @@ -27,7 +27,7 @@ io.github.davidwhitlock.joy examples - 1.2.2-SNAPSHOT + 1.3.0-SNAPSHOT io.github.davidwhitlock.joy diff --git a/projects-parent/originals-parent/student/pom.xml b/projects-parent/originals-parent/student/pom.xml index d9d843cf4..a3dd3c728 100644 --- a/projects-parent/originals-parent/student/pom.xml +++ b/projects-parent/originals-parent/student/pom.xml @@ -88,7 +88,7 @@ io.github.davidwhitlock.joy examples - 1.2.2-SNAPSHOT + 1.3.0-SNAPSHOT io.github.davidwhitlock.joy diff --git a/web/pom.xml b/web/pom.xml index a2c048439..debe4b91e 100644 --- a/web/pom.xml +++ b/web/pom.xml @@ -9,7 +9,7 @@ web war Web Application examples - 1.2.2-SNAPSHOT + 1.3.0-SNAPSHOT http://www.cs.pdx.edu/~whitlock 6.2.8.Final @@ -117,7 +117,7 @@ io.github.davidwhitlock.joy examples - 1.2.2-SNAPSHOT + 1.3.0-SNAPSHOT jakarta.xml.bind From 5ac3bbe4ea279e240a54c39054b0b762e9322b2b Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Thu, 21 Nov 2024 21:27:02 -0800 Subject: [PATCH 19/59] GitHub CI build is using an old version of the maven-site-plugin. Try explicitly setting it. --- .../src/main/resources/archetype-resources/pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/pom.xml index 12e908909..4562a06f4 100644 --- a/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/pom.xml @@ -109,6 +109,11 @@ + + org.apache.maven.plugins + maven-site-plugin + 4.0.0-M13 + org.apache.maven.plugins maven-surefire-report-plugin From ebc5b1c25cd3226cca69c1a00140b7d22c39d925 Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Thu, 21 Nov 2024 21:43:40 -0800 Subject: [PATCH 20/59] Restore some changes that I think broke things. --- .../airline-archetype/pom.xml | 68 ++++++------------- .../resources/archetype-resources/pom.xml | 5 -- 2 files changed, 19 insertions(+), 54 deletions(-) diff --git a/projects-parent/archetypes-parent/airline-archetype/pom.xml b/projects-parent/archetypes-parent/airline-archetype/pom.xml index 6d048038d..bb988ee31 100644 --- a/projects-parent/archetypes-parent/airline-archetype/pom.xml +++ b/projects-parent/archetypes-parent/airline-archetype/pom.xml @@ -2,7 +2,11 @@ 4.0.0 - io.github.davidwhitlock.joy.original + + archetypes-parent + io.github.davidwhitlock.joy + 2.2.0-SNAPSHOT + airline-archetype 2.2.0-SNAPSHOT maven-archetype @@ -14,7 +18,7 @@ org.apache.maven.archetype archetype-packaging - 3.2.1 + ${maven-archetype-plugin.version} @@ -22,58 +26,24 @@ maven-archetype-plugin - 3.2.1 + ${maven-archetype-plugin.version}
- An Airline application for The Joy of Coding at Portland State University - - http://www.cs.pdx.edu/~whitlock - - - - YOU - Your name here - you@youremail.com - http://www.cs.pdx.edu/~YOU - PSU Department of Computer Science - http://www.cs.pdx.edu - - Student - - -7 - - - - - - Apache License, Version 2.0 - https://www.apache.org/licenses/LICENSE-2.0.txt - repo - - - - - scm:git:git@github.com:JoyOfCodingPDX/JoyOfCoding.git/projects-parent/originals-parent/airline - scm:git:git@github.com:JoyOfCodingPDX/JoyOfCoding.git/projects-parent/originals-parent/airline - https://github.com/JoyOfCodingPDX/JoyOfCoding/tree/main/projects-parent/originals-parent/airline - - - + - ossrh - https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/ - - - ossrh + maven-snapshots https://s01.oss.sonatype.org/content/repositories/snapshots - - - gh-pages - GitHub Pages - scm:git:git@github.com:JoyOfCodingPDX/JoyOfCoding.git/projects-parent/originals-parent - - + default + + false + + + true + + + +
diff --git a/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/pom.xml index 4562a06f4..12e908909 100644 --- a/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/pom.xml @@ -109,11 +109,6 @@ - - org.apache.maven.plugins - maven-site-plugin - 4.0.0-M13 - org.apache.maven.plugins maven-surefire-report-plugin From 569cce4a12bb21705450d38dc4b21f0f02528a70 Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Thu, 21 Nov 2024 21:46:23 -0800 Subject: [PATCH 21/59] Restore some changes that I think broke things. --- projects-parent/archetypes-parent/apptbook-archetype/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects-parent/archetypes-parent/apptbook-archetype/pom.xml b/projects-parent/archetypes-parent/apptbook-archetype/pom.xml index 9fcc27032..8c4dffa53 100644 --- a/projects-parent/archetypes-parent/apptbook-archetype/pom.xml +++ b/projects-parent/archetypes-parent/apptbook-archetype/pom.xml @@ -17,7 +17,7 @@ org.apache.maven.archetype archetype-packaging - 3.2.1 + ${maven-archetype-plugin.version} @@ -25,7 +25,7 @@ maven-archetype-plugin - 3.2.1 + ${maven-archetype-plugin.version} From b786ffdca991135e7e52791082af97b955026549 Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Thu, 28 Nov 2024 08:31:09 -0800 Subject: [PATCH 22/59] Begin updating third-party dependencies. --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index e60310478..26d2a894f 100644 --- a/pom.xml +++ b/pom.xml @@ -57,7 +57,7 @@ 17 17 - 33.1.0-jre + 33.1.1-jre 5.1.0 UTF-8 @@ -67,9 +67,9 @@ 2.0.4 3.5.3 - 5.10.2 + 5.11.3 2.2 - 5.11.0 + 5.14.2 3.2.5 3.4.1 3.5.0 From 01af43fa645bba5ed75bc6c2e968677ed6de59bf Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Thu, 28 Nov 2024 08:33:52 -0800 Subject: [PATCH 23/59] Oops. Typo in version number. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 26d2a894f..0372a4a07 100644 --- a/pom.xml +++ b/pom.xml @@ -57,7 +57,7 @@ 17 17 - 33.1.1-jre + 33.3.1-jre 5.1.0 UTF-8 From fb3939e0cb666149cdf43009b8f174ca6a0e62bb Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Thu, 28 Nov 2024 08:38:33 -0800 Subject: [PATCH 24/59] More minor dependency updates. --- grader/pom.xml | 4 ++-- web/pom.xml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/grader/pom.xml b/grader/pom.xml index 82f2d3202..66b917fe1 100644 --- a/grader/pom.xml +++ b/grader/pom.xml @@ -29,7 +29,7 @@ ch.qos.logback logback-classic - 1.5.6 + 1.5.12 com.google.inject @@ -39,7 +39,7 @@ com.icegreen greenmail - 2.0.1 + 2.1.1 test diff --git a/web/pom.xml b/web/pom.xml index debe4b91e..5973a1062 100644 --- a/web/pom.xml +++ b/web/pom.xml @@ -112,7 +112,7 @@ commons-io commons-io - 2.16.1 + 2.18.0 io.github.davidwhitlock.joy From 4e7afcabff0f775ac79f9b22e30b00bc0b6ba23f Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Thu, 28 Nov 2024 09:50:56 -0800 Subject: [PATCH 25/59] Revert to greenmail 2.0.1. --- grader/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grader/pom.xml b/grader/pom.xml index 66b917fe1..a19a00e53 100644 --- a/grader/pom.xml +++ b/grader/pom.xml @@ -39,7 +39,7 @@ com.icegreen greenmail - 2.1.1 + 2.0.1 test From 0b01847f883c734435e09b2422df4029756f5432 Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Thu, 28 Nov 2024 10:18:19 -0800 Subject: [PATCH 26/59] Upgrade hamcrest. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0372a4a07..add6e532a 100644 --- a/pom.xml +++ b/pom.xml @@ -68,7 +68,7 @@ 3.5.3 5.11.3 - 2.2 + 3.0 5.14.2 3.2.5 3.4.1 From bbfede8f02d8f80cb91b7f30efa45b7aca03e287 Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Thu, 28 Nov 2024 10:26:51 -0800 Subject: [PATCH 27/59] Update some Maven plugins. --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index add6e532a..e354e7d8b 100644 --- a/pom.xml +++ b/pom.xml @@ -62,7 +62,7 @@ UTF-8 UTF-8 - 6.55.0 + 7.7.0 2.0.4 3.5.3 @@ -70,7 +70,7 @@ 5.11.3 3.0 5.14.2 - 3.2.5 + 3.5.2 3.4.1 3.5.0 3.13.0 @@ -82,7 +82,7 @@ 3.5.0 3.2.5 3.3.1 - 10.15.0 + 10.20.1 3.2.1 3.6.3 3.21.2 From 2fabf0ee68beafc2adba1c1fe27ca73b8a7e6cb1 Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Thu, 28 Nov 2024 10:42:21 -0800 Subject: [PATCH 28/59] Update more Maven plugins. --- pom.xml | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/pom.xml b/pom.xml index e354e7d8b..f1e5c77f6 100644 --- a/pom.xml +++ b/pom.xml @@ -71,23 +71,23 @@ 3.0 5.14.2 3.5.2 - 3.4.1 - 3.5.0 + 3.4.2 + 3.6.0 3.13.0 10.0.15 - 4.8.4.0 + 4.8.6.6 0.8.12 - 3.5.2 + 3.6.0 3.3.1 - 3.5.0 - 3.2.5 - 3.3.1 + 3.8.0 + 3.5.2 + 3.6.0 10.20.1 - 3.2.1 - 3.6.3 - 3.21.2 - 2.16.2 - 3.2.0 + 3.3.1 + 3.11.1 + 3.26.0 + 2.18.0 + 3.5.0 0.75 0 @@ -124,7 +124,7 @@ org.apache.maven.plugins maven-enforcer-plugin - 3.4.1 + 3.5.0 enforce-versions @@ -194,7 +194,7 @@ org.apache.maven.plugins maven-deploy-plugin - 3.1.1 + 3.1.3 org.apache.maven.plugins @@ -204,7 +204,7 @@ org.codehaus.mojo buildnumber-maven-plugin - 3.2.0 + 3.2.1 validate @@ -227,7 +227,7 @@ org.apache.maven.plugins maven-gpg-plugin - 3.2.4 + 3.2.7 sign-artifacts @@ -241,7 +241,7 @@ org.sonatype.plugins nexus-staging-maven-plugin - 1.6.13 + 1.7.0 true ossrh @@ -480,12 +480,12 @@ org.apache.maven.plugins maven-dependency-plugin - 3.6.1 + 3.8.1 org.apache.maven.plugins maven-release-plugin - 3.0.1 + 3.1.1 org.apache.maven.plugins @@ -553,7 +553,7 @@ org.apache.maven.plugins maven-site-plugin - 4.0.0-M13 + 4.0.0-M16 net.trajano.wagon @@ -582,7 +582,7 @@ org.apache.maven.plugins maven-scm-publish-plugin - 3.2.1 + 3.3.0 gh-pages true @@ -618,7 +618,7 @@ org.apache.maven.plugins maven-jxr-plugin - 3.3.2 + 3.6.0 true From ee2b6c2aa9cc70f74b868647064f99ba6825ebd8 Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Thu, 28 Nov 2024 13:40:43 -0800 Subject: [PATCH 29/59] Something about version 3.3.1 of the maven-archetype-plugin causes the archetype project integration tests to fail. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f1e5c77f6..0894dd9af 100644 --- a/pom.xml +++ b/pom.xml @@ -83,7 +83,7 @@ 3.5.2 3.6.0 10.20.1 - 3.3.1 + 3.3.0 3.11.1 3.26.0 2.18.0 From 139072096e58cb8aa9ea81a95f4cf770c8fb53db Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Thu, 28 Nov 2024 15:42:19 -0800 Subject: [PATCH 30/59] Upgrade jetty-maven-plugin to latest 10.X. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0894dd9af..3e34712bc 100644 --- a/pom.xml +++ b/pom.xml @@ -74,7 +74,7 @@ 3.4.2 3.6.0 3.13.0 - 10.0.15 + 10.0.24 4.8.6.6 0.8.12 3.6.0 From 23556bb33c71bad5bbdd2df9a2a2057a56fc9316 Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Fri, 29 Nov 2024 07:56:32 -0800 Subject: [PATCH 31/59] Begin migrating servlet code to Jetty 11. This includes replacing usages of javax.servlet APIs with jakarta.servlet. --- pom.xml | 4 +- .../src/main/java/AirlineServlet.java | 6 +-- .../src/test/java/AirlineServletTest.java | 4 +- .../src/main/java/AppointmentBookServlet.java | 6 +-- .../test/java/AppointmentBookServletTest.java | 6 +-- .../src/main/java/PhoneBillServlet.java | 6 +-- .../src/test/java/PhoneBillServletTest.java | 6 +-- .../pdx/cs/joy/airlineweb/AirlineServlet.java | 6 +-- .../cs/joy/airlineweb/AirlineServletTest.java | 4 +- .../apptbookweb/AppointmentBookServlet.java | 6 +-- .../AppointmentBookServletTest.java | 6 +-- .../cs/joy/phonebillweb/PhoneBillServlet.java | 6 +-- .../phonebillweb/PhoneBillServletTest.java | 6 +-- web/pom.xml | 29 +++++++++----- .../edu/pdx/cs/joy/di/RestLoggingFilter.java | 11 +++-- .../cs/joy/di/RestfulCreditCardService.java | 4 +- .../cs/joy/servlets/FamilyTreeServlet.java | 20 +++++----- .../cs/joy/servlets/FileUploadServlet.java | 40 +++++++++---------- .../pdx/cs/joy/servlets/LastVisitServlet.java | 8 ++-- .../cs/joy/servlets/MovieDatabaseServlet.java | 12 +++--- .../cs/joy/servlets/ServletInfoServlet.java | 4 +- .../pdx/cs/joy/servlets/SessionServlet.java | 4 +- web/src/main/webapp/WEB-INF/web.xml | 2 +- 23 files changed, 107 insertions(+), 99 deletions(-) diff --git a/pom.xml b/pom.xml index 3e34712bc..809a2e5e8 100644 --- a/pom.xml +++ b/pom.xml @@ -58,7 +58,7 @@ 17 33.3.1-jre - 5.1.0 + 7.0.0 UTF-8 UTF-8 @@ -74,7 +74,7 @@ 3.4.2 3.6.0 3.13.0 - 10.0.24 + 11.0.24 4.8.6.6 0.8.12 3.6.0 diff --git a/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/src/main/java/AirlineServlet.java b/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/src/main/java/AirlineServlet.java index dd6dc2fcd..4ea2bc0c4 100644 --- a/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/src/main/java/AirlineServlet.java +++ b/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/src/main/java/AirlineServlet.java @@ -5,9 +5,9 @@ import com.google.common.annotations.VisibleForTesting; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.PrintWriter; import java.util.HashMap; diff --git a/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/src/test/java/AirlineServletTest.java b/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/src/test/java/AirlineServletTest.java index 36f9ba7d9..e4de41f5a 100644 --- a/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/src/test/java/AirlineServletTest.java +++ b/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/src/test/java/AirlineServletTest.java @@ -6,8 +6,8 @@ import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; diff --git a/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/src/main/java/AppointmentBookServlet.java b/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/src/main/java/AppointmentBookServlet.java index 0ebf4f781..90105f604 100644 --- a/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/src/main/java/AppointmentBookServlet.java +++ b/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/src/main/java/AppointmentBookServlet.java @@ -5,9 +5,9 @@ import com.google.common.annotations.VisibleForTesting; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.PrintWriter; import java.util.HashMap; diff --git a/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/src/test/java/AppointmentBookServletTest.java b/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/src/test/java/AppointmentBookServletTest.java index 74717aff7..f55747474 100644 --- a/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/src/test/java/AppointmentBookServletTest.java +++ b/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/src/test/java/AppointmentBookServletTest.java @@ -6,9 +6,9 @@ import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; diff --git a/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/src/main/java/PhoneBillServlet.java b/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/src/main/java/PhoneBillServlet.java index 336a3d555..a7b099211 100644 --- a/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/src/main/java/PhoneBillServlet.java +++ b/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/src/main/java/PhoneBillServlet.java @@ -5,9 +5,9 @@ import com.google.common.annotations.VisibleForTesting; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.PrintWriter; import java.util.HashMap; diff --git a/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/src/test/java/PhoneBillServletTest.java b/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/src/test/java/PhoneBillServletTest.java index bcf32581d..f45363a92 100644 --- a/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/src/test/java/PhoneBillServletTest.java +++ b/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/src/test/java/PhoneBillServletTest.java @@ -6,9 +6,9 @@ import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; diff --git a/projects-parent/originals-parent/airline-web/src/main/java/edu/pdx/cs/joy/airlineweb/AirlineServlet.java b/projects-parent/originals-parent/airline-web/src/main/java/edu/pdx/cs/joy/airlineweb/AirlineServlet.java index 01af61594..1d7e0b666 100644 --- a/projects-parent/originals-parent/airline-web/src/main/java/edu/pdx/cs/joy/airlineweb/AirlineServlet.java +++ b/projects-parent/originals-parent/airline-web/src/main/java/edu/pdx/cs/joy/airlineweb/AirlineServlet.java @@ -2,9 +2,9 @@ import com.google.common.annotations.VisibleForTesting; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.PrintWriter; import java.util.HashMap; diff --git a/projects-parent/originals-parent/airline-web/src/test/java/edu/pdx/cs/joy/airlineweb/AirlineServletTest.java b/projects-parent/originals-parent/airline-web/src/test/java/edu/pdx/cs/joy/airlineweb/AirlineServletTest.java index a56728a51..4b42bcbe4 100644 --- a/projects-parent/originals-parent/airline-web/src/test/java/edu/pdx/cs/joy/airlineweb/AirlineServletTest.java +++ b/projects-parent/originals-parent/airline-web/src/test/java/edu/pdx/cs/joy/airlineweb/AirlineServletTest.java @@ -3,8 +3,8 @@ import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; diff --git a/projects-parent/originals-parent/apptbook-web/src/main/java/edu/pdx/cs/joy/apptbookweb/AppointmentBookServlet.java b/projects-parent/originals-parent/apptbook-web/src/main/java/edu/pdx/cs/joy/apptbookweb/AppointmentBookServlet.java index f7658255e..9bda465c8 100644 --- a/projects-parent/originals-parent/apptbook-web/src/main/java/edu/pdx/cs/joy/apptbookweb/AppointmentBookServlet.java +++ b/projects-parent/originals-parent/apptbook-web/src/main/java/edu/pdx/cs/joy/apptbookweb/AppointmentBookServlet.java @@ -2,9 +2,9 @@ import com.google.common.annotations.VisibleForTesting; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.PrintWriter; import java.util.HashMap; diff --git a/projects-parent/originals-parent/apptbook-web/src/test/java/edu/pdx/cs/joy/apptbookweb/AppointmentBookServletTest.java b/projects-parent/originals-parent/apptbook-web/src/test/java/edu/pdx/cs/joy/apptbookweb/AppointmentBookServletTest.java index cf6c28f0d..dbd49754e 100644 --- a/projects-parent/originals-parent/apptbook-web/src/test/java/edu/pdx/cs/joy/apptbookweb/AppointmentBookServletTest.java +++ b/projects-parent/originals-parent/apptbook-web/src/test/java/edu/pdx/cs/joy/apptbookweb/AppointmentBookServletTest.java @@ -3,9 +3,9 @@ import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; diff --git a/projects-parent/originals-parent/phonebill-web/src/main/java/edu/pdx/cs/joy/phonebillweb/PhoneBillServlet.java b/projects-parent/originals-parent/phonebill-web/src/main/java/edu/pdx/cs/joy/phonebillweb/PhoneBillServlet.java index 5d5e08d06..643a9d706 100644 --- a/projects-parent/originals-parent/phonebill-web/src/main/java/edu/pdx/cs/joy/phonebillweb/PhoneBillServlet.java +++ b/projects-parent/originals-parent/phonebill-web/src/main/java/edu/pdx/cs/joy/phonebillweb/PhoneBillServlet.java @@ -2,9 +2,9 @@ import com.google.common.annotations.VisibleForTesting; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.PrintWriter; import java.util.HashMap; diff --git a/projects-parent/originals-parent/phonebill-web/src/test/java/edu/pdx/cs/joy/phonebillweb/PhoneBillServletTest.java b/projects-parent/originals-parent/phonebill-web/src/test/java/edu/pdx/cs/joy/phonebillweb/PhoneBillServletTest.java index 9fe7b7c0e..a1e0af0df 100644 --- a/projects-parent/originals-parent/phonebill-web/src/test/java/edu/pdx/cs/joy/phonebillweb/PhoneBillServletTest.java +++ b/projects-parent/originals-parent/phonebill-web/src/test/java/edu/pdx/cs/joy/phonebillweb/PhoneBillServletTest.java @@ -3,9 +3,9 @@ import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; diff --git a/web/pom.xml b/web/pom.xml index 5973a1062..41480b3bf 100644 --- a/web/pom.xml +++ b/web/pom.xml @@ -12,7 +12,7 @@ 1.3.0-SNAPSHOT http://www.cs.pdx.edu/~whitlock - 6.2.8.Final + 6.2.11.Final 8080 @@ -100,14 +100,16 @@ - javax.servlet - javax.servlet-api - 4.0.1 + jakarta.platform + jakarta.jakartaee-bom + 10.0.0 + import + pom - commons-fileupload - commons-fileupload - 1.5 + org.apache.commons + commons-fileupload2-jakarta-servlet6 + 2.0.0-M2 commons-io @@ -126,13 +128,20 @@ org.jboss.resteasy - resteasy-jaxb-provider + resteasy-bom ${resteasy.version} + pom + import - org.jboss.resteasy + jakarta.ws.rs + jakarta.ws.rs-api + 4.0.0 + + + dev.resteasy.guice resteasy-guice - 4.7.9.Final + 1.0.0.Alpha1 com.google.inject diff --git a/web/src/main/java/edu/pdx/cs/joy/di/RestLoggingFilter.java b/web/src/main/java/edu/pdx/cs/joy/di/RestLoggingFilter.java index 8db6c0836..3645ceb9c 100644 --- a/web/src/main/java/edu/pdx/cs/joy/di/RestLoggingFilter.java +++ b/web/src/main/java/edu/pdx/cs/joy/di/RestLoggingFilter.java @@ -2,9 +2,9 @@ import com.google.inject.Inject; import com.google.inject.Singleton; +import jakarta.servlet.*; +import jakarta.servlet.http.HttpServletRequest; -import javax.servlet.*; -import javax.servlet.http.HttpServletRequest; import java.io.IOException; import java.util.logging.Logger; @@ -24,7 +24,8 @@ public RestLoggingFilter(Logger logger, CreditCardDatabase cards) { this.cards = cards; } - public void init( FilterConfig config ) throws ServletException + @Override + public void init(FilterConfig config ) throws ServletException { // Initialize some credit cards for testing purposes. This probably isn't the best place to do this. for (int i = 1; i <= 10; i++) { @@ -33,7 +34,8 @@ public void init( FilterConfig config ) throws ServletException } } - public void doFilter( ServletRequest request, ServletResponse response, FilterChain chain ) + @Override + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain ) throws IOException, ServletException { long begin = System.currentTimeMillis(); @@ -56,6 +58,7 @@ public void doFilter( ServletRequest request, ServletResponse response, FilterCh } + @Override public void destroy() { diff --git a/web/src/main/java/edu/pdx/cs/joy/di/RestfulCreditCardService.java b/web/src/main/java/edu/pdx/cs/joy/di/RestfulCreditCardService.java index 6bc254066..cb4ae4437 100644 --- a/web/src/main/java/edu/pdx/cs/joy/di/RestfulCreditCardService.java +++ b/web/src/main/java/edu/pdx/cs/joy/di/RestfulCreditCardService.java @@ -2,10 +2,8 @@ import com.google.common.collect.ImmutableMap; import com.google.inject.Inject; +import jakarta.ws.rs.*; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; import java.util.Map; /** diff --git a/web/src/main/java/edu/pdx/cs/joy/servlets/FamilyTreeServlet.java b/web/src/main/java/edu/pdx/cs/joy/servlets/FamilyTreeServlet.java index 52de9579c..7ef88afe7 100644 --- a/web/src/main/java/edu/pdx/cs/joy/servlets/FamilyTreeServlet.java +++ b/web/src/main/java/edu/pdx/cs/joy/servlets/FamilyTreeServlet.java @@ -3,16 +3,15 @@ import edu.pdx.cs.joy.family.FamilyTree; import edu.pdx.cs.joy.family.Person; import edu.pdx.cs.joy.family.XmlDumper; +import jakarta.servlet.ServletConfig; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.ServletConfig; -import javax.servlet.ServletException; import java.io.IOException; import java.io.PrintWriter; -import java.util.Date; import java.util.Collection; +import java.util.Date; /** * A servlet that provides access to a {@link FamilyTree} via REST @@ -24,15 +23,18 @@ public class FamilyTreeServlet extends HttpServlet { private int nextPersonId = 1; - public void init(ServletConfig servletConfig) throws ServletException { + @Override + public void init(ServletConfig servletConfig) { tree = new FamilyTree(); } - protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException { createPerson(request, response); } - protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { String uri = request.getRequestURI(); String lastPart = uri.substring(uri.lastIndexOf('/') + 1, uri.length()); diff --git a/web/src/main/java/edu/pdx/cs/joy/servlets/FileUploadServlet.java b/web/src/main/java/edu/pdx/cs/joy/servlets/FileUploadServlet.java index bb37ef66b..0d18fd782 100644 --- a/web/src/main/java/edu/pdx/cs/joy/servlets/FileUploadServlet.java +++ b/web/src/main/java/edu/pdx/cs/joy/servlets/FileUploadServlet.java @@ -1,21 +1,19 @@ package edu.pdx.cs.joy.servlets; -import org.apache.commons.fileupload.servlet.ServletFileUpload; -import org.apache.commons.fileupload.FileItemFactory; -import org.apache.commons.fileupload.FileUploadException; -import org.apache.commons.fileupload.FileItem; -import org.apache.commons.fileupload.disk.DiskFileItemFactory; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import org.apache.commons.fileupload2.core.DiskFileItem; +import org.apache.commons.fileupload2.core.DiskFileItemFactory; +import org.apache.commons.fileupload2.core.FileUploadException; +import org.apache.commons.fileupload2.jakarta.servlet6.JakartaServletFileUpload; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.ServletException; -import java.io.IOException; import java.io.BufferedReader; +import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.List; -import java.util.Iterator; /** * A servlet that demonstrates how to upload a file to a web server. It uses the Apache Commons @@ -26,16 +24,17 @@ */ public class FileUploadServlet extends HttpServlet { + @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter pw = response.getWriter(); pw.println(""); pw.println(""); - if (ServletFileUpload.isMultipartContent(request)) { - FileItemFactory factory = new DiskFileItemFactory(); - ServletFileUpload upload = new ServletFileUpload(factory); - List items; + if (JakartaServletFileUpload.isMultipartContent(request)) { + DiskFileItemFactory factory = new DiskFileItemFactory.Builder().get(); + JakartaServletFileUpload upload = new JakartaServletFileUpload<>(factory); + List items; try { items = upload.parseRequest(request); @@ -43,17 +42,13 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) throw new ServletException("Could not upload file", ex); } - for (Iterator iter = items.iterator(); iter.hasNext(); ) { - FileItem item = (FileItem) iter.next(); - if (item.isFormField()) { - // Non-file field in the form - - } else { + for (DiskFileItem item : items) { + if (!item.isFormField()) { String fileName = item.getName(); String contentType = item.getContentType(); pw.println("

You uploaded " + fileName + "

"); pw.println("

Content type is " + contentType + "

"); - + if (contentType.equals("text/plain")) { pw.println("
");
 
@@ -65,6 +60,7 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
             pw.println("
"); } } + } } else { diff --git a/web/src/main/java/edu/pdx/cs/joy/servlets/LastVisitServlet.java b/web/src/main/java/edu/pdx/cs/joy/servlets/LastVisitServlet.java index ca715fb6e..0c5303f07 100644 --- a/web/src/main/java/edu/pdx/cs/joy/servlets/LastVisitServlet.java +++ b/web/src/main/java/edu/pdx/cs/joy/servlets/LastVisitServlet.java @@ -1,9 +1,9 @@ package edu.pdx.cs.joy.servlets; -import javax.servlet.http.Cookie; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.http.Cookie; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.PrintWriter; import java.time.LocalDateTime; diff --git a/web/src/main/java/edu/pdx/cs/joy/servlets/MovieDatabaseServlet.java b/web/src/main/java/edu/pdx/cs/joy/servlets/MovieDatabaseServlet.java index 3935b3a24..f4e09c27b 100644 --- a/web/src/main/java/edu/pdx/cs/joy/servlets/MovieDatabaseServlet.java +++ b/web/src/main/java/edu/pdx/cs/joy/servlets/MovieDatabaseServlet.java @@ -4,10 +4,10 @@ import edu.pdx.cs.joy.rmi.MovieDatabase; import edu.pdx.cs.joy.rmi.MovieDatabaseImpl; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import java.io.BufferedReader; import java.io.IOException; import java.io.PrintWriter; @@ -16,8 +16,8 @@ import java.util.HashMap; import java.util.Map; -import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST; -import static javax.servlet.http.HttpServletResponse.SC_NOT_FOUND; +import static jakarta.servlet.http.HttpServletResponse.SC_BAD_REQUEST; +import static jakarta.servlet.http.HttpServletResponse.SC_NOT_FOUND; /** * A servlet that provides REST access to a movie database diff --git a/web/src/main/java/edu/pdx/cs/joy/servlets/ServletInfoServlet.java b/web/src/main/java/edu/pdx/cs/joy/servlets/ServletInfoServlet.java index b3a3d77ff..7a9b7abb7 100644 --- a/web/src/main/java/edu/pdx/cs/joy/servlets/ServletInfoServlet.java +++ b/web/src/main/java/edu/pdx/cs/joy/servlets/ServletInfoServlet.java @@ -2,8 +2,8 @@ import java.io.*; import java.util.*; -import javax.servlet.*; -import javax.servlet.http.*; +import jakarta.servlet.*; +import jakarta.servlet.http.*; /** * A servlet that returns all sorts of information available from the diff --git a/web/src/main/java/edu/pdx/cs/joy/servlets/SessionServlet.java b/web/src/main/java/edu/pdx/cs/joy/servlets/SessionServlet.java index ac2f41d14..cf5777ef7 100644 --- a/web/src/main/java/edu/pdx/cs/joy/servlets/SessionServlet.java +++ b/web/src/main/java/edu/pdx/cs/joy/servlets/SessionServlet.java @@ -1,7 +1,7 @@ package edu.pdx.cs.joy.servlets; -import javax.servlet.http.*; -import javax.servlet.ServletException; +import jakarta.servlet.http.*; +import jakarta.servlet.ServletException; import java.io.IOException; import java.io.PrintWriter; import java.util.Date; diff --git a/web/src/main/webapp/WEB-INF/web.xml b/web/src/main/webapp/WEB-INF/web.xml index 6a1551eb2..f488f8984 100644 --- a/web/src/main/webapp/WEB-INF/web.xml +++ b/web/src/main/webapp/WEB-INF/web.xml @@ -20,7 +20,7 @@ - org.jboss.resteasy.plugins.guice.GuiceResteasyBootstrapServletContextListener + dev.resteasy.guice.GuiceResteasyBootstrapServletContextListener From cbafc329d539817779c8366500a34adcf6857da5 Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Fri, 29 Nov 2024 08:57:47 -0800 Subject: [PATCH 32/59] Get the Phone Bill web project working with Jetty 11. --- .../originals-parent/phonebill-web/pom.xml | 13 ++++++++++--- .../phonebill-web/src/main/webapp/error.jsp | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/projects-parent/originals-parent/phonebill-web/pom.xml b/projects-parent/originals-parent/phonebill-web/pom.xml index abdafc5f7..6b56dec28 100644 --- a/projects-parent/originals-parent/phonebill-web/pom.xml +++ b/projects-parent/originals-parent/phonebill-web/pom.xml @@ -37,9 +37,16 @@ test
- javax.servlet - javax.servlet-api - 4.0.1 + jakarta.servlet + jakarta.servlet-api + 6.1.0 + + + jakarta.platform + jakarta.jakartaee-bom + 10.0.0 + import + pom
diff --git a/projects-parent/originals-parent/phonebill-web/src/main/webapp/error.jsp b/projects-parent/originals-parent/phonebill-web/src/main/webapp/error.jsp index a5fce9653..21bbda4ae 100644 --- a/projects-parent/originals-parent/phonebill-web/src/main/webapp/error.jsp +++ b/projects-parent/originals-parent/phonebill-web/src/main/webapp/error.jsp @@ -1,2 +1,2 @@ <%@ page contentType="text/plain;charset=UTF-8" language="java" isErrorPage="true" %> -<%out.println( request.getAttribute("javax.servlet.error.message") );%> \ No newline at end of file +<%out.println( request.getAttribute("jakarta.servlet.error.message") );%> \ No newline at end of file From 26e1206cf37c833bb53003f29e10811e4398a9c5 Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Fri, 29 Nov 2024 09:01:54 -0800 Subject: [PATCH 33/59] Rename the servlet error message. --- .../resources/archetype-resources/src/main/webapp/error.jsp | 2 +- .../resources/archetype-resources/src/main/webapp/error.jsp | 2 +- .../resources/archetype-resources/src/main/webapp/error.jsp | 2 +- .../originals-parent/airline-web/src/main/webapp/error.jsp | 2 +- .../originals-parent/apptbook-web/src/main/webapp/error.jsp | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/src/main/webapp/error.jsp b/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/src/main/webapp/error.jsp index 6eb9635a2..2f1fe30d2 100644 --- a/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/src/main/webapp/error.jsp +++ b/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/src/main/webapp/error.jsp @@ -2,4 +2,4 @@ #set( $symbol_dollar = '$' ) #set( $symbol_escape = '\' ) <%@ page contentType="text/plain;charset=UTF-8" language="java" isErrorPage="true" %> -<%out.println( request.getAttribute("javax.servlet.error.message") );%> \ No newline at end of file +<%out.println( request.getAttribute("jakarta.servlet.error.message") );%> \ No newline at end of file diff --git a/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/src/main/webapp/error.jsp b/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/src/main/webapp/error.jsp index 6eb9635a2..2f1fe30d2 100644 --- a/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/src/main/webapp/error.jsp +++ b/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/src/main/webapp/error.jsp @@ -2,4 +2,4 @@ #set( $symbol_dollar = '$' ) #set( $symbol_escape = '\' ) <%@ page contentType="text/plain;charset=UTF-8" language="java" isErrorPage="true" %> -<%out.println( request.getAttribute("javax.servlet.error.message") );%> \ No newline at end of file +<%out.println( request.getAttribute("jakarta.servlet.error.message") );%> \ No newline at end of file diff --git a/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/src/main/webapp/error.jsp b/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/src/main/webapp/error.jsp index 6eb9635a2..2f1fe30d2 100644 --- a/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/src/main/webapp/error.jsp +++ b/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/src/main/webapp/error.jsp @@ -2,4 +2,4 @@ #set( $symbol_dollar = '$' ) #set( $symbol_escape = '\' ) <%@ page contentType="text/plain;charset=UTF-8" language="java" isErrorPage="true" %> -<%out.println( request.getAttribute("javax.servlet.error.message") );%> \ No newline at end of file +<%out.println( request.getAttribute("jakarta.servlet.error.message") );%> \ No newline at end of file diff --git a/projects-parent/originals-parent/airline-web/src/main/webapp/error.jsp b/projects-parent/originals-parent/airline-web/src/main/webapp/error.jsp index a5fce9653..21bbda4ae 100644 --- a/projects-parent/originals-parent/airline-web/src/main/webapp/error.jsp +++ b/projects-parent/originals-parent/airline-web/src/main/webapp/error.jsp @@ -1,2 +1,2 @@ <%@ page contentType="text/plain;charset=UTF-8" language="java" isErrorPage="true" %> -<%out.println( request.getAttribute("javax.servlet.error.message") );%> \ No newline at end of file +<%out.println( request.getAttribute("jakarta.servlet.error.message") );%> \ No newline at end of file diff --git a/projects-parent/originals-parent/apptbook-web/src/main/webapp/error.jsp b/projects-parent/originals-parent/apptbook-web/src/main/webapp/error.jsp index a5fce9653..21bbda4ae 100644 --- a/projects-parent/originals-parent/apptbook-web/src/main/webapp/error.jsp +++ b/projects-parent/originals-parent/apptbook-web/src/main/webapp/error.jsp @@ -1,2 +1,2 @@ <%@ page contentType="text/plain;charset=UTF-8" language="java" isErrorPage="true" %> -<%out.println( request.getAttribute("javax.servlet.error.message") );%> \ No newline at end of file +<%out.println( request.getAttribute("jakarta.servlet.error.message") );%> \ No newline at end of file From 51cff54a21c0ee95daa1bcd6e35bd535b6d432ce Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Fri, 29 Nov 2024 09:07:08 -0800 Subject: [PATCH 34/59] Get original web projects working with Jetty 11. --- pom.xml | 1 + projects-parent/originals-parent/airline-web/pom.xml | 6 +++--- projects-parent/originals-parent/apptbook-web/pom.xml | 6 +++--- projects-parent/originals-parent/phonebill-web/pom.xml | 2 +- web/pom.xml | 8 +++----- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/pom.xml b/pom.xml index 809a2e5e8..895a7ba34 100644 --- a/pom.xml +++ b/pom.xml @@ -59,6 +59,7 @@ 33.3.1-jre 7.0.0 + 6.1.0 UTF-8 UTF-8 diff --git a/projects-parent/originals-parent/airline-web/pom.xml b/projects-parent/originals-parent/airline-web/pom.xml index ed9bd0aeb..7ef0aa126 100644 --- a/projects-parent/originals-parent/airline-web/pom.xml +++ b/projects-parent/originals-parent/airline-web/pom.xml @@ -36,9 +36,9 @@ test
- javax.servlet - javax.servlet-api - 4.0.1 + jakarta.servlet + jakarta.servlet-api + ${jakarta.servlet-api.version}
diff --git a/projects-parent/originals-parent/apptbook-web/pom.xml b/projects-parent/originals-parent/apptbook-web/pom.xml index 3db222a4e..2d84e0d37 100644 --- a/projects-parent/originals-parent/apptbook-web/pom.xml +++ b/projects-parent/originals-parent/apptbook-web/pom.xml @@ -36,9 +36,9 @@ test
- javax.servlet - javax.servlet-api - 4.0.1 + jakarta.servlet + jakarta.servlet-api + ${jakarta.servlet-api.version} diff --git a/projects-parent/originals-parent/phonebill-web/pom.xml b/projects-parent/originals-parent/phonebill-web/pom.xml index 6b56dec28..914b4bbfe 100644 --- a/projects-parent/originals-parent/phonebill-web/pom.xml +++ b/projects-parent/originals-parent/phonebill-web/pom.xml @@ -39,7 +39,7 @@ jakarta.servlet jakarta.servlet-api - 6.1.0 + ${jakarta.servlet-api.version} jakarta.platform diff --git a/web/pom.xml b/web/pom.xml index 41480b3bf..d8c431422 100644 --- a/web/pom.xml +++ b/web/pom.xml @@ -100,11 +100,9 @@ - jakarta.platform - jakarta.jakartaee-bom - 10.0.0 - import - pom + jakarta.servlet + jakarta.servlet-api + ${jakarta.servlet-api.version} org.apache.commons From 2b57073a4cf951ac1c7d4c9b42a2596300ea5245 Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Fri, 29 Nov 2024 09:28:36 -0800 Subject: [PATCH 35/59] Adjust some imports so that there are fewer changes to the archetype source code. --- .../pdx/cs/joy/airlineweb/AirlineRestClientIT.java | 2 +- .../edu/pdx/cs/joy/airlineweb/IndexDotHtmlIT.java | 9 +++++---- .../java/edu/pdx/cs/joy/airlineweb/Project5IT.java | 4 ++-- .../pdx/cs/joy/airlineweb/AirlineRestClient.java | 14 ++++++++------ .../cs/joy/airlineweb/AirlineRestClientTest.java | 5 +++-- 5 files changed, 19 insertions(+), 15 deletions(-) diff --git a/projects-parent/originals-parent/airline-web/src/it/java/edu/pdx/cs/joy/airlineweb/AirlineRestClientIT.java b/projects-parent/originals-parent/airline-web/src/it/java/edu/pdx/cs/joy/airlineweb/AirlineRestClientIT.java index 804f46e31..bf8c045b7 100644 --- a/projects-parent/originals-parent/airline-web/src/it/java/edu/pdx/cs/joy/airlineweb/AirlineRestClientIT.java +++ b/projects-parent/originals-parent/airline-web/src/it/java/edu/pdx/cs/joy/airlineweb/AirlineRestClientIT.java @@ -1,7 +1,7 @@ package edu.pdx.cs.joy.airlineweb; -import edu.pdx.cs.joy.web.HttpRequestHelper; import edu.pdx.cs.joy.ParserException; +import edu.pdx.cs.joy.web.HttpRequestHelper; import org.junit.jupiter.api.MethodOrderer.MethodName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestMethodOrder; diff --git a/projects-parent/originals-parent/airline-web/src/it/java/edu/pdx/cs/joy/airlineweb/IndexDotHtmlIT.java b/projects-parent/originals-parent/airline-web/src/it/java/edu/pdx/cs/joy/airlineweb/IndexDotHtmlIT.java index 43e70d65c..35e71a27b 100644 --- a/projects-parent/originals-parent/airline-web/src/it/java/edu/pdx/cs/joy/airlineweb/IndexDotHtmlIT.java +++ b/projects-parent/originals-parent/airline-web/src/it/java/edu/pdx/cs/joy/airlineweb/IndexDotHtmlIT.java @@ -1,6 +1,7 @@ package edu.pdx.cs.joy.airlineweb; import edu.pdx.cs.joy.web.HttpRequestHelper; +import edu.pdx.cs.joy.web.HttpRequestHelper.Response; import org.junit.jupiter.api.Test; import java.io.IOException; @@ -16,17 +17,17 @@ class IndexDotHtmlIT { @Test void indexDotHtmlExists() throws IOException { - HttpRequestHelper.Response indexDotHtml = fetchIndexDotHtml(); + Response indexDotHtml = fetchIndexDotHtml(); assertThat(indexDotHtml.getHttpStatusCode(), equalTo(200)); } @Test void indexDotHtmlHasReasonableContent() throws IOException { - HttpRequestHelper.Response indexDotHtml = fetchIndexDotHtml(); + Response indexDotHtml = fetchIndexDotHtml(); assertThat(indexDotHtml.getContent(), containsString(" getAllDictionaryEntries() throws IOException, ParserException { - HttpRequestHelper.Response response = http.get(Map.of()); + Response response = http.get(Map.of()); throwExceptionIfNotOkayHttpStatus(response); TextParser parser = new TextParser(new StringReader(response.getContent())); @@ -53,7 +55,7 @@ public Map getAllDictionaryEntries() throws IOException, ParserE * Returns the definition for the given word */ public String getDefinition(String word) throws IOException, ParserException { - HttpRequestHelper.Response response = http.get(Map.of(AirlineServlet.WORD_PARAMETER, word)); + Response response = http.get(Map.of(AirlineServlet.WORD_PARAMETER, word)); throwExceptionIfNotOkayHttpStatus(response); String content = response.getContent(); @@ -62,20 +64,20 @@ public String getDefinition(String word) throws IOException, ParserException { } public void addDictionaryEntry(String word, String definition) throws IOException { - HttpRequestHelper.Response response = http.post(Map.of(AirlineServlet.WORD_PARAMETER, word, AirlineServlet.DEFINITION_PARAMETER, definition)); + Response response = http.post(Map.of(AirlineServlet.WORD_PARAMETER, word, AirlineServlet.DEFINITION_PARAMETER, definition)); throwExceptionIfNotOkayHttpStatus(response); } public void removeAllDictionaryEntries() throws IOException { - HttpRequestHelper.Response response = http.delete(Map.of()); + Response response = http.delete(Map.of()); throwExceptionIfNotOkayHttpStatus(response); } - private void throwExceptionIfNotOkayHttpStatus(HttpRequestHelper.Response response) { + private void throwExceptionIfNotOkayHttpStatus(Response response) { int code = response.getHttpStatusCode(); if (code != HTTP_OK) { String message = response.getContent(); - throw new HttpRequestHelper.RestException(code, message); + throw new RestException(code, message); } } diff --git a/projects-parent/originals-parent/airline-web/src/test/java/edu/pdx/cs/joy/airlineweb/AirlineRestClientTest.java b/projects-parent/originals-parent/airline-web/src/test/java/edu/pdx/cs/joy/airlineweb/AirlineRestClientTest.java index 22617fd08..c2e687399 100644 --- a/projects-parent/originals-parent/airline-web/src/test/java/edu/pdx/cs/joy/airlineweb/AirlineRestClientTest.java +++ b/projects-parent/originals-parent/airline-web/src/test/java/edu/pdx/cs/joy/airlineweb/AirlineRestClientTest.java @@ -1,7 +1,7 @@ package edu.pdx.cs.joy.airlineweb; -import edu.pdx.cs.joy.web.HttpRequestHelper; import edu.pdx.cs.joy.ParserException; +import edu.pdx.cs.joy.web.HttpRequestHelper; import org.junit.jupiter.api.Test; import java.io.IOException; @@ -11,7 +11,8 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; /** * A unit test for the REST client that demonstrates using mocks and From ebd8e2813e4e7e7a6c93e9846cdcadc5596a3ce7 Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Fri, 29 Nov 2024 09:28:59 -0800 Subject: [PATCH 36/59] Apply changes for Jetty 11 to Airline Web archetype. --- .../main/resources/META-INF/maven/archetype-metadata.xml | 4 ++-- .../src/main/resources/archetype-resources/pom.xml | 8 ++++---- .../src/main/java/AirlineRestClient.java | 4 ++-- .../src/test/java/AirlineRestClientTest.java | 3 ++- .../test/resources/projects/basic/archetype.properties | 4 ++-- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml b/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml index f1a1ce8eb..20b6e398c 100644 --- a/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml +++ b/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -1,6 +1,6 @@ - diff --git a/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/pom.xml index aedc40e7c..b6409d74f 100644 --- a/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/pom.xml @@ -8,13 +8,13 @@ 4.0.0 ${groupId} ${artifactId} + ${version} 8080 war - ${version} Airline Web/REST Project http://maven.apache.org @@ -36,9 +36,9 @@ test - javax.servlet - javax.servlet-api - 4.0.1 + jakarta.servlet + jakarta.servlet-api + ${jakarta.servlet-api.version} diff --git a/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/src/main/java/AirlineRestClient.java b/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/src/main/java/AirlineRestClient.java index 8eb8f021d..718f2d050 100644 --- a/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/src/main/java/AirlineRestClient.java +++ b/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/src/main/java/AirlineRestClient.java @@ -6,13 +6,13 @@ import com.google.common.annotations.VisibleForTesting; import edu.pdx.cs.joy.ParserException; import edu.pdx.cs.joy.web.HttpRequestHelper; +import edu.pdx.cs.joy.web.HttpRequestHelper.Response; import java.io.IOException; import java.io.StringReader; import java.util.Map; -import static edu.pdx.cs.joy.web.HttpRequestHelper.Response; -import static edu.pdx.cs.joy.web.HttpRequestHelper.RestException; +import static edu.pdx.cs.joy.web.HttpRequestHelper.*; import static java.net.HttpURLConnection.HTTP_OK; /** diff --git a/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/src/test/java/AirlineRestClientTest.java b/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/src/test/java/AirlineRestClientTest.java index 84606e67a..8ac00a180 100644 --- a/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/src/test/java/AirlineRestClientTest.java +++ b/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/src/test/java/AirlineRestClientTest.java @@ -14,7 +14,8 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; /** * A unit test for the REST client that demonstrates using mocks and diff --git a/projects-parent/archetypes-parent/airline-web-archetype/src/test/resources/projects/basic/archetype.properties b/projects-parent/archetypes-parent/airline-web-archetype/src/test/resources/projects/basic/archetype.properties index 4f4c05de2..cff279279 100644 --- a/projects-parent/archetypes-parent/airline-web-archetype/src/test/resources/projects/basic/archetype.properties +++ b/projects-parent/archetypes-parent/airline-web-archetype/src/test/resources/projects/basic/archetype.properties @@ -1,5 +1,5 @@ -#Sat Dec 05 20:02:17 PST 2015 +#Fri Nov 29 09:22:12 PST 2024 package=it.pkg -version=0.1-SNAPSHOT groupId=archetype.it artifactId=basic +version=0.1-SNAPSHOT From 79896044f327f770bdc51c6c48a60d2844fd4c0f Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Fri, 29 Nov 2024 09:34:14 -0800 Subject: [PATCH 37/59] Increment the major version number for web-related projects. --- projects-parent/archetypes-parent/airline-web-archetype/pom.xml | 2 +- .../archetypes-parent/apptbook-web-archetype/pom.xml | 2 +- .../archetypes-parent/phonebill-web-archetype/pom.xml | 2 +- projects-parent/originals-parent/airline-web/pom.xml | 2 +- projects-parent/originals-parent/apptbook-web/pom.xml | 2 +- projects-parent/originals-parent/phonebill-web/pom.xml | 2 +- web/pom.xml | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/projects-parent/archetypes-parent/airline-web-archetype/pom.xml b/projects-parent/archetypes-parent/airline-web-archetype/pom.xml index 49ee431bd..aed85f9d8 100644 --- a/projects-parent/archetypes-parent/airline-web-archetype/pom.xml +++ b/projects-parent/archetypes-parent/airline-web-archetype/pom.xml @@ -7,7 +7,7 @@ 2.2.0-SNAPSHOT airline-web-archetype - 2.3.0-SNAPSHOT + 3.0.0-SNAPSHOT maven-archetype airline-web-archetype diff --git a/projects-parent/archetypes-parent/apptbook-web-archetype/pom.xml b/projects-parent/archetypes-parent/apptbook-web-archetype/pom.xml index e4d5143f2..b17fda530 100644 --- a/projects-parent/archetypes-parent/apptbook-web-archetype/pom.xml +++ b/projects-parent/archetypes-parent/apptbook-web-archetype/pom.xml @@ -7,7 +7,7 @@ 2.2.0-SNAPSHOT apptbook-web-archetype - 2.3.0-SNAPSHOT + 3.0.0-SNAPSHOT maven-archetype apptbook-web-archetype diff --git a/projects-parent/archetypes-parent/phonebill-web-archetype/pom.xml b/projects-parent/archetypes-parent/phonebill-web-archetype/pom.xml index 4f9e6b005..03cfa7f74 100644 --- a/projects-parent/archetypes-parent/phonebill-web-archetype/pom.xml +++ b/projects-parent/archetypes-parent/phonebill-web-archetype/pom.xml @@ -7,7 +7,7 @@ 2.2.0-SNAPSHOT phonebill-web-archetype - 2.3.0-SNAPSHOT + 3.0.0-SNAPSHOT maven-archetype phonebill-web-archetype diff --git a/projects-parent/originals-parent/airline-web/pom.xml b/projects-parent/originals-parent/airline-web/pom.xml index 7ef0aa126..89282a362 100644 --- a/projects-parent/originals-parent/airline-web/pom.xml +++ b/projects-parent/originals-parent/airline-web/pom.xml @@ -8,7 +8,7 @@ 4.0.0 io.github.davidwhitlock.joy.original airline-web - 2.3.0-SNAPSHOT + 3.0.0-SNAPSHOT 8080 diff --git a/projects-parent/originals-parent/apptbook-web/pom.xml b/projects-parent/originals-parent/apptbook-web/pom.xml index 2d84e0d37..9132f0500 100644 --- a/projects-parent/originals-parent/apptbook-web/pom.xml +++ b/projects-parent/originals-parent/apptbook-web/pom.xml @@ -8,7 +8,7 @@ 4.0.0 io.github.davidwhitlock.joy.original apptbook-web - 2.3.0-SNAPSHOT + 3.0.0-SNAPSHOT 8080 diff --git a/projects-parent/originals-parent/phonebill-web/pom.xml b/projects-parent/originals-parent/phonebill-web/pom.xml index 914b4bbfe..b725e9b20 100644 --- a/projects-parent/originals-parent/phonebill-web/pom.xml +++ b/projects-parent/originals-parent/phonebill-web/pom.xml @@ -8,7 +8,7 @@ 4.0.0 io.github.davidwhitlock.joy.original phonebill-web - 2.3.0-SNAPSHOT + 3.0.0-SNAPSHOT 8080 diff --git a/web/pom.xml b/web/pom.xml index d8c431422..2ccd306ad 100644 --- a/web/pom.xml +++ b/web/pom.xml @@ -9,7 +9,7 @@ web war Web Application examples - 1.3.0-SNAPSHOT + 2.0.0-SNAPSHOT http://www.cs.pdx.edu/~whitlock 6.2.11.Final From e97ff105eee223880e79c63a7939fa123aa32107 Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Fri, 29 Nov 2024 10:14:33 -0800 Subject: [PATCH 38/59] Adjust some imports so that there are fewer changes to the archetype source code. --- .../apptbookweb/AppointmentBookRestClientIT.java | 5 ++--- .../pdx/cs/joy/apptbookweb/IndexDotHtmlIT.java | 9 +++++---- .../edu/pdx/cs/joy/apptbookweb/Project4IT.java | 4 ++-- .../apptbookweb/AppointmentBookRestClient.java | 16 +++++++++------- .../AppointmentBookRestClientTest.java | 2 +- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/projects-parent/originals-parent/apptbook-web/src/it/java/edu/pdx/cs/joy/apptbookweb/AppointmentBookRestClientIT.java b/projects-parent/originals-parent/apptbook-web/src/it/java/edu/pdx/cs/joy/apptbookweb/AppointmentBookRestClientIT.java index 713721ad2..c26d5cb44 100644 --- a/projects-parent/originals-parent/apptbook-web/src/it/java/edu/pdx/cs/joy/apptbookweb/AppointmentBookRestClientIT.java +++ b/projects-parent/originals-parent/apptbook-web/src/it/java/edu/pdx/cs/joy/apptbookweb/AppointmentBookRestClientIT.java @@ -1,7 +1,7 @@ package edu.pdx.cs.joy.apptbookweb; -import edu.pdx.cs.joy.web.HttpRequestHelper; import edu.pdx.cs.joy.ParserException; +import edu.pdx.cs.joy.web.HttpRequestHelper.RestException; import org.junit.jupiter.api.MethodOrderer.MethodName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestMethodOrder; @@ -57,8 +57,7 @@ void test4EmptyWordThrowsException() { AppointmentBookRestClient client = newAppointmentBookRestClient(); String emptyString = ""; - HttpRequestHelper.RestException ex = - assertThrows(HttpRequestHelper.RestException.class, () -> client.addDictionaryEntry(emptyString, emptyString)); + RestException ex = assertThrows(RestException.class, () -> client.addDictionaryEntry(emptyString, emptyString)); assertThat(ex.getHttpStatusCode(), equalTo(HttpURLConnection.HTTP_PRECON_FAILED)); assertThat(ex.getMessage(), containsString(Messages.missingRequiredParameter(AppointmentBookServlet.WORD_PARAMETER))); } diff --git a/projects-parent/originals-parent/apptbook-web/src/it/java/edu/pdx/cs/joy/apptbookweb/IndexDotHtmlIT.java b/projects-parent/originals-parent/apptbook-web/src/it/java/edu/pdx/cs/joy/apptbookweb/IndexDotHtmlIT.java index 6dfc1438a..6c136b30a 100644 --- a/projects-parent/originals-parent/apptbook-web/src/it/java/edu/pdx/cs/joy/apptbookweb/IndexDotHtmlIT.java +++ b/projects-parent/originals-parent/apptbook-web/src/it/java/edu/pdx/cs/joy/apptbookweb/IndexDotHtmlIT.java @@ -1,6 +1,7 @@ package edu.pdx.cs.joy.apptbookweb; import edu.pdx.cs.joy.web.HttpRequestHelper; +import edu.pdx.cs.joy.web.HttpRequestHelper.Response; import org.junit.jupiter.api.Test; import java.io.IOException; @@ -16,17 +17,17 @@ class IndexDotHtmlIT { @Test void indexDotHtmlExists() throws IOException { - HttpRequestHelper.Response indexDotHtml = fetchIndexDotHtml(); + Response indexDotHtml = fetchIndexDotHtml(); assertThat(indexDotHtml.getHttpStatusCode(), equalTo(200)); } @Test void indexDotHtmlHasReasonableContent() throws IOException { - HttpRequestHelper.Response indexDotHtml = fetchIndexDotHtml(); + Response indexDotHtml = fetchIndexDotHtml(); assertThat(indexDotHtml.getContent(), containsString(" getAllDictionaryEntries() throws IOException, ParserException { - HttpRequestHelper.Response response = http.get(Map.of()); + Response response = http.get(Map.of()); throwExceptionIfNotOkayHttpStatus(response); TextParser parser = new TextParser(new StringReader(response.getContent())); @@ -52,7 +54,7 @@ public Map getAllDictionaryEntries() throws IOException, ParserE * Returns the definition for the given word */ public String getDefinition(String word) throws IOException, ParserException { - HttpRequestHelper.Response response = http.get(Map.of(AppointmentBookServlet.WORD_PARAMETER, word)); + Response response = http.get(Map.of(AppointmentBookServlet.WORD_PARAMETER, word)); throwExceptionIfNotOkayHttpStatus(response); String content = response.getContent(); @@ -61,25 +63,25 @@ public String getDefinition(String word) throws IOException, ParserException { } public void addDictionaryEntry(String word, String definition) throws IOException { - HttpRequestHelper.Response response = postToMyURL(Map.of(AppointmentBookServlet.WORD_PARAMETER, word, AppointmentBookServlet.DEFINITION_PARAMETER, definition)); + Response response = postToMyURL(Map.of(AppointmentBookServlet.WORD_PARAMETER, word, AppointmentBookServlet.DEFINITION_PARAMETER, definition)); throwExceptionIfNotOkayHttpStatus(response); } @VisibleForTesting - HttpRequestHelper.Response postToMyURL(Map dictionaryEntries) throws IOException { + Response postToMyURL(Map dictionaryEntries) throws IOException { return http.post(dictionaryEntries); } public void removeAllDictionaryEntries() throws IOException { - HttpRequestHelper.Response response = http.delete(Map.of()); + Response response = http.delete(Map.of()); throwExceptionIfNotOkayHttpStatus(response); } - private void throwExceptionIfNotOkayHttpStatus(HttpRequestHelper.Response response) { + private void throwExceptionIfNotOkayHttpStatus(Response response) { int code = response.getHttpStatusCode(); if (code != HTTP_OK) { String message = response.getContent(); - throw new HttpRequestHelper.RestException(code, message); + throw new RestException(code, message); } } diff --git a/projects-parent/originals-parent/apptbook-web/src/test/java/edu/pdx/cs/joy/apptbookweb/AppointmentBookRestClientTest.java b/projects-parent/originals-parent/apptbook-web/src/test/java/edu/pdx/cs/joy/apptbookweb/AppointmentBookRestClientTest.java index a72ca6c1c..e28bce290 100644 --- a/projects-parent/originals-parent/apptbook-web/src/test/java/edu/pdx/cs/joy/apptbookweb/AppointmentBookRestClientTest.java +++ b/projects-parent/originals-parent/apptbook-web/src/test/java/edu/pdx/cs/joy/apptbookweb/AppointmentBookRestClientTest.java @@ -1,7 +1,7 @@ package edu.pdx.cs.joy.apptbookweb; -import edu.pdx.cs.joy.web.HttpRequestHelper; import edu.pdx.cs.joy.ParserException; +import edu.pdx.cs.joy.web.HttpRequestHelper; import org.junit.jupiter.api.Test; import java.io.IOException; From 48748a7049c5e029da09aef2232ceb60db3ee372 Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Fri, 29 Nov 2024 10:14:52 -0800 Subject: [PATCH 39/59] Apply changes for Jetty 11 to Appointment Book Web archetype. --- .../resources/META-INF/maven/archetype-metadata.xml | 4 ++-- .../src/main/resources/archetype-resources/pom.xml | 12 ++++++------ .../src/it/java/AppointmentBookRestClientIT.java | 3 +-- .../src/main/java/AppointmentBookRestClient.java | 6 +++--- .../resources/projects/basic/archetype.properties | 2 +- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml b/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml index 71ede9b0f..30ae06272 100644 --- a/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml +++ b/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -1,6 +1,6 @@ - diff --git a/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/pom.xml index 3adeab2d2..4497eb529 100644 --- a/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/pom.xml @@ -1,20 +1,20 @@ - joy + originals-parent io.github.davidwhitlock.joy - 1.2.0-SNAPSHOT + 2.2.0-SNAPSHOT 4.0.0 ${groupId} ${artifactId} + ${version} 8080 war - ${version} Appointment Book Web/REST Project http://maven.apache.org @@ -36,9 +36,9 @@ test
- javax.servlet - javax.servlet-api - 4.0.1 + jakarta.servlet + jakarta.servlet-api + ${jakarta.servlet-api.version} diff --git a/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/src/it/java/AppointmentBookRestClientIT.java b/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/src/it/java/AppointmentBookRestClientIT.java index 4a477dfae..ae9d1cde9 100644 --- a/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/src/it/java/AppointmentBookRestClientIT.java +++ b/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/src/it/java/AppointmentBookRestClientIT.java @@ -60,8 +60,7 @@ void test4EmptyWordThrowsException() { AppointmentBookRestClient client = newAppointmentBookRestClient(); String emptyString = ""; - RestException ex = - assertThrows(RestException.class, () -> client.addDictionaryEntry(emptyString, emptyString)); + RestException ex = assertThrows(RestException.class, () -> client.addDictionaryEntry(emptyString, emptyString)); assertThat(ex.getHttpStatusCode(), equalTo(HttpURLConnection.HTTP_PRECON_FAILED)); assertThat(ex.getMessage(), containsString(Messages.missingRequiredParameter(AppointmentBookServlet.WORD_PARAMETER))); } diff --git a/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/src/main/java/AppointmentBookRestClient.java b/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/src/main/java/AppointmentBookRestClient.java index 2ed209979..d1fbd7c45 100644 --- a/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/src/main/java/AppointmentBookRestClient.java +++ b/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/src/main/java/AppointmentBookRestClient.java @@ -4,15 +4,15 @@ package ${package}; import com.google.common.annotations.VisibleForTesting; -import edu.pdx.cs.joy.ParserException; import edu.pdx.cs.joy.web.HttpRequestHelper; +import edu.pdx.cs.joy.ParserException; +import edu.pdx.cs.joy.web.HttpRequestHelper.Response; +import edu.pdx.cs.joy.web.HttpRequestHelper.RestException; import java.io.IOException; import java.io.StringReader; import java.util.Map; -import static edu.pdx.cs.joy.web.HttpRequestHelper.Response; -import static edu.pdx.cs.joy.web.HttpRequestHelper.RestException; import static java.net.HttpURLConnection.HTTP_OK; /** diff --git a/projects-parent/archetypes-parent/apptbook-web-archetype/src/test/resources/projects/basic/archetype.properties b/projects-parent/archetypes-parent/apptbook-web-archetype/src/test/resources/projects/basic/archetype.properties index aa321b3c7..c5c0aa899 100644 --- a/projects-parent/archetypes-parent/apptbook-web-archetype/src/test/resources/projects/basic/archetype.properties +++ b/projects-parent/archetypes-parent/apptbook-web-archetype/src/test/resources/projects/basic/archetype.properties @@ -1,4 +1,4 @@ -#Mon Nov 22 19:43:39 PST 2021 +#Fri Nov 29 10:10:43 PST 2024 package=it.pkg groupId=archetype.it artifactId=basic From d77a1cc8c4c8c338fd474cd0c5ece63c02ad2cb1 Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Fri, 29 Nov 2024 10:27:42 -0800 Subject: [PATCH 40/59] Adjust some imports so that there are fewer changes to the archetype source code. --- .../originals-parent/phonebill-web/pom.xml | 7 ------- .../pdx/cs/joy/phonebillweb/IndexDotHtmlIT.java | 9 +++++---- .../joy/phonebillweb/PhoneBillRestClientIT.java | 5 ++--- .../edu/pdx/cs/joy/phonebillweb/Project4IT.java | 4 ++-- .../cs/joy/phonebillweb/PhoneBillRestClient.java | 16 +++++++++------- .../phonebillweb/PhoneBillRestClientTest.java | 7 ++++--- 6 files changed, 22 insertions(+), 26 deletions(-) diff --git a/projects-parent/originals-parent/phonebill-web/pom.xml b/projects-parent/originals-parent/phonebill-web/pom.xml index b725e9b20..dc84dc30d 100644 --- a/projects-parent/originals-parent/phonebill-web/pom.xml +++ b/projects-parent/originals-parent/phonebill-web/pom.xml @@ -41,13 +41,6 @@ jakarta.servlet-api ${jakarta.servlet-api.version}
- - jakarta.platform - jakarta.jakartaee-bom - 10.0.0 - import - pom - phonebill diff --git a/projects-parent/originals-parent/phonebill-web/src/it/java/edu/pdx/cs/joy/phonebillweb/IndexDotHtmlIT.java b/projects-parent/originals-parent/phonebill-web/src/it/java/edu/pdx/cs/joy/phonebillweb/IndexDotHtmlIT.java index d229e6a7f..7bf76993c 100644 --- a/projects-parent/originals-parent/phonebill-web/src/it/java/edu/pdx/cs/joy/phonebillweb/IndexDotHtmlIT.java +++ b/projects-parent/originals-parent/phonebill-web/src/it/java/edu/pdx/cs/joy/phonebillweb/IndexDotHtmlIT.java @@ -1,6 +1,7 @@ package edu.pdx.cs.joy.phonebillweb; import edu.pdx.cs.joy.web.HttpRequestHelper; +import edu.pdx.cs.joy.web.HttpRequestHelper.Response; import org.junit.jupiter.api.Test; import java.io.IOException; @@ -16,17 +17,17 @@ class IndexDotHtmlIT { @Test void indexDotHtmlExists() throws IOException { - HttpRequestHelper.Response indexDotHtml = fetchIndexDotHtml(); + Response indexDotHtml = fetchIndexDotHtml(); assertThat(indexDotHtml.getHttpStatusCode(), equalTo(200)); } @Test void indexDotHtmlHasReasonableContent() throws IOException { - HttpRequestHelper.Response indexDotHtml = fetchIndexDotHtml(); + Response indexDotHtml = fetchIndexDotHtml(); assertThat(indexDotHtml.getContent(), containsString(" client.addDictionaryEntry(emptyString, emptyString)); + RestException ex = assertThrows(RestException.class, () -> client.addDictionaryEntry(emptyString, emptyString)); assertThat(ex.getHttpStatusCode(), equalTo(HttpURLConnection.HTTP_PRECON_FAILED)); assertThat(ex.getMessage(), containsString(Messages.missingRequiredParameter(PhoneBillServlet.WORD_PARAMETER))); } diff --git a/projects-parent/originals-parent/phonebill-web/src/it/java/edu/pdx/cs/joy/phonebillweb/Project4IT.java b/projects-parent/originals-parent/phonebill-web/src/it/java/edu/pdx/cs/joy/phonebillweb/Project4IT.java index 1fde99e60..1813ef5f1 100644 --- a/projects-parent/originals-parent/phonebill-web/src/it/java/edu/pdx/cs/joy/phonebillweb/Project4IT.java +++ b/projects-parent/originals-parent/phonebill-web/src/it/java/edu/pdx/cs/joy/phonebillweb/Project4IT.java @@ -1,8 +1,8 @@ package edu.pdx.cs.joy.phonebillweb; -import edu.pdx.cs.joy.web.HttpRequestHelper; import edu.pdx.cs.joy.InvokeMainTestCase; import edu.pdx.cs.joy.UncaughtExceptionInMain; +import edu.pdx.cs.joy.web.HttpRequestHelper.RestException; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestMethodOrder; @@ -53,7 +53,7 @@ void test3NoDefinitionsThrowsAppointmentBookRestException() { fail("Expected a RestException to be thrown"); } catch (UncaughtExceptionInMain ex) { - HttpRequestHelper.RestException cause = (HttpRequestHelper.RestException) ex.getCause(); + RestException cause = (RestException) ex.getCause(); assertThat(cause.getHttpStatusCode(), equalTo(HttpURLConnection.HTTP_NOT_FOUND)); } } diff --git a/projects-parent/originals-parent/phonebill-web/src/main/java/edu/pdx/cs/joy/phonebillweb/PhoneBillRestClient.java b/projects-parent/originals-parent/phonebill-web/src/main/java/edu/pdx/cs/joy/phonebillweb/PhoneBillRestClient.java index 16223d281..0753e57fe 100644 --- a/projects-parent/originals-parent/phonebill-web/src/main/java/edu/pdx/cs/joy/phonebillweb/PhoneBillRestClient.java +++ b/projects-parent/originals-parent/phonebill-web/src/main/java/edu/pdx/cs/joy/phonebillweb/PhoneBillRestClient.java @@ -1,8 +1,10 @@ package edu.pdx.cs.joy.phonebillweb; import com.google.common.annotations.VisibleForTesting; -import edu.pdx.cs.joy.web.HttpRequestHelper; import edu.pdx.cs.joy.ParserException; +import edu.pdx.cs.joy.web.HttpRequestHelper; +import edu.pdx.cs.joy.web.HttpRequestHelper.Response; +import edu.pdx.cs.joy.web.HttpRequestHelper.RestException; import java.io.IOException; import java.io.StringReader; @@ -42,7 +44,7 @@ public PhoneBillRestClient( String hostName, int port ) * Returns all dictionary entries from the server */ public Map getAllDictionaryEntries() throws IOException, ParserException { - HttpRequestHelper.Response response = http.get(Map.of()); + Response response = http.get(Map.of()); throwExceptionIfNotOkayHttpStatus(response); TextParser parser = new TextParser(new StringReader(response.getContent())); @@ -53,7 +55,7 @@ public Map getAllDictionaryEntries() throws IOException, ParserE * Returns the definition for the given word */ public String getDefinition(String word) throws IOException, ParserException { - HttpRequestHelper.Response response = http.get(Map.of(PhoneBillServlet.WORD_PARAMETER, word)); + Response response = http.get(Map.of(PhoneBillServlet.WORD_PARAMETER, word)); throwExceptionIfNotOkayHttpStatus(response); String content = response.getContent(); @@ -62,20 +64,20 @@ public String getDefinition(String word) throws IOException, ParserException { } public void addDictionaryEntry(String word, String definition) throws IOException { - HttpRequestHelper.Response response = http.post(Map.of(PhoneBillServlet.WORD_PARAMETER, word, PhoneBillServlet.DEFINITION_PARAMETER, definition)); + Response response = http.post(Map.of(PhoneBillServlet.WORD_PARAMETER, word, PhoneBillServlet.DEFINITION_PARAMETER, definition)); throwExceptionIfNotOkayHttpStatus(response); } public void removeAllDictionaryEntries() throws IOException { - HttpRequestHelper.Response response = http.delete(Map.of()); + Response response = http.delete(Map.of()); throwExceptionIfNotOkayHttpStatus(response); } - private void throwExceptionIfNotOkayHttpStatus(HttpRequestHelper.Response response) { + private void throwExceptionIfNotOkayHttpStatus(Response response) { int code = response.getHttpStatusCode(); if (code != HTTP_OK) { String message = response.getContent(); - throw new HttpRequestHelper.RestException(code, message); + throw new RestException(code, message); } } diff --git a/projects-parent/originals-parent/phonebill-web/src/test/java/edu/pdx/cs/joy/phonebillweb/PhoneBillRestClientTest.java b/projects-parent/originals-parent/phonebill-web/src/test/java/edu/pdx/cs/joy/phonebillweb/PhoneBillRestClientTest.java index 75480731d..0d02f6a7c 100644 --- a/projects-parent/originals-parent/phonebill-web/src/test/java/edu/pdx/cs/joy/phonebillweb/PhoneBillRestClientTest.java +++ b/projects-parent/originals-parent/phonebill-web/src/test/java/edu/pdx/cs/joy/phonebillweb/PhoneBillRestClientTest.java @@ -1,7 +1,8 @@ package edu.pdx.cs.joy.phonebillweb; -import edu.pdx.cs.joy.web.HttpRequestHelper; import edu.pdx.cs.joy.ParserException; +import edu.pdx.cs.joy.web.HttpRequestHelper; +import edu.pdx.cs.joy.web.HttpRequestHelper.Response; import org.junit.jupiter.api.Test; import java.io.IOException; @@ -28,10 +29,10 @@ void getAllDictionaryEntriesPerformsHttpGetWithNoParameters() throws ParserExcep assertThat(client.getAllDictionaryEntries(), equalTo(dictionary)); } - private HttpRequestHelper.Response dictionaryAsText(Map dictionary) { + private Response dictionaryAsText(Map dictionary) { StringWriter writer = new StringWriter(); new TextDumper(writer).dump(dictionary); - return new HttpRequestHelper.Response(writer.toString()); + return new Response(writer.toString()); } } From 61fed682040d87eaadad2b99eccdd3db1ffb1017 Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Fri, 29 Nov 2024 10:27:56 -0800 Subject: [PATCH 41/59] Apply changes for Jetty 11 to Phone Bill Web archetype. --- .../META-INF/maven/archetype-metadata.xml | 4 ++-- .../main/resources/archetype-resources/pom.xml | 16 ++++++++-------- .../src/it/java/PhoneBillRestClientIT.java | 3 +-- .../src/main/java/PhoneBillRestClient.java | 4 ++-- .../src/main/java/Project4.java | 1 - .../src/test/java/PhoneBillRestClientTest.java | 5 +++-- .../projects/basic/archetype.properties | 4 ++-- 7 files changed, 18 insertions(+), 19 deletions(-) diff --git a/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml b/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml index 219bcace4..c91dad1da 100644 --- a/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml +++ b/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -1,6 +1,6 @@ - diff --git a/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/pom.xml index 012c6916d..1de5678df 100644 --- a/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/pom.xml @@ -1,22 +1,22 @@ - + - joy + originals-parent io.github.davidwhitlock.joy - 1.2.0-SNAPSHOT + 2.2.0-SNAPSHOT 4.0.0 ${groupId} ${artifactId} + ${version} 8080 war - ${version} Phone Bill Web/REST Project - http://maven.apache.org + https://maven.apache.org @@ -37,9 +37,9 @@ test - javax.servlet - javax.servlet-api - 4.0.1 + jakarta.servlet + jakarta.servlet-api + ${jakarta.servlet-api.version} diff --git a/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/src/it/java/PhoneBillRestClientIT.java b/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/src/it/java/PhoneBillRestClientIT.java index e8ddc318f..a22effed5 100644 --- a/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/src/it/java/PhoneBillRestClientIT.java +++ b/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/src/it/java/PhoneBillRestClientIT.java @@ -60,8 +60,7 @@ void test4EmptyWordThrowsException() { PhoneBillRestClient client = newPhoneBillRestClient(); String emptyString = ""; - RestException ex = - assertThrows(RestException.class, () -> client.addDictionaryEntry(emptyString, emptyString)); + RestException ex = assertThrows(RestException.class, () -> client.addDictionaryEntry(emptyString, emptyString)); assertThat(ex.getHttpStatusCode(), equalTo(HttpURLConnection.HTTP_PRECON_FAILED)); assertThat(ex.getMessage(), containsString(Messages.missingRequiredParameter(PhoneBillServlet.WORD_PARAMETER))); } diff --git a/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/src/main/java/PhoneBillRestClient.java b/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/src/main/java/PhoneBillRestClient.java index 8796df857..2d80d3e45 100644 --- a/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/src/main/java/PhoneBillRestClient.java +++ b/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/src/main/java/PhoneBillRestClient.java @@ -6,13 +6,13 @@ import com.google.common.annotations.VisibleForTesting; import edu.pdx.cs.joy.ParserException; import edu.pdx.cs.joy.web.HttpRequestHelper; +import edu.pdx.cs.joy.web.HttpRequestHelper.Response; +import edu.pdx.cs.joy.web.HttpRequestHelper.RestException; import java.io.IOException; import java.io.StringReader; import java.util.Map; -import static edu.pdx.cs.joy.web.HttpRequestHelper.Response; -import static edu.pdx.cs.joy.web.HttpRequestHelper.RestException; import static java.net.HttpURLConnection.HTTP_OK; /** diff --git a/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/src/main/java/Project4.java b/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/src/main/java/Project4.java index 33825326e..a7d939874 100644 --- a/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/src/main/java/Project4.java +++ b/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/src/main/java/Project4.java @@ -4,7 +4,6 @@ package ${package}; import edu.pdx.cs.joy.ParserException; -import edu.pdx.cs.joy.web.HttpRequestHelper; import java.io.IOException; import java.io.PrintStream; diff --git a/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/src/test/java/PhoneBillRestClientTest.java b/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/src/test/java/PhoneBillRestClientTest.java index 942cfb1f5..5913584e2 100644 --- a/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/src/test/java/PhoneBillRestClientTest.java +++ b/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/src/test/java/PhoneBillRestClientTest.java @@ -5,6 +5,7 @@ import edu.pdx.cs.joy.ParserException; import edu.pdx.cs.joy.web.HttpRequestHelper; +import edu.pdx.cs.joy.web.HttpRequestHelper.Response; import org.junit.jupiter.api.Test; import java.io.IOException; @@ -31,10 +32,10 @@ void getAllDictionaryEntriesPerformsHttpGetWithNoParameters() throws ParserExcep assertThat(client.getAllDictionaryEntries(), equalTo(dictionary)); } - private HttpRequestHelper.Response dictionaryAsText(Map dictionary) { + private Response dictionaryAsText(Map dictionary) { StringWriter writer = new StringWriter(); new TextDumper(writer).dump(dictionary); - return new HttpRequestHelper.Response(writer.toString()); + return new Response(writer.toString()); } } diff --git a/projects-parent/archetypes-parent/phonebill-web-archetype/src/test/resources/projects/basic/archetype.properties b/projects-parent/archetypes-parent/phonebill-web-archetype/src/test/resources/projects/basic/archetype.properties index b2614f924..8efccef38 100644 --- a/projects-parent/archetypes-parent/phonebill-web-archetype/src/test/resources/projects/basic/archetype.properties +++ b/projects-parent/archetypes-parent/phonebill-web-archetype/src/test/resources/projects/basic/archetype.properties @@ -1,5 +1,5 @@ -#Fri Nov 27 15:58:35 PST 2015 +#Fri Nov 29 10:23:40 PST 2024 package=it.pkg -version=0.1-SNAPSHOT groupId=archetype.it artifactId=basic +version=0.1-SNAPSHOT From 9ce2ae966b75721f64add55e6e6311bda6b49169 Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Fri, 29 Nov 2024 12:45:57 -0800 Subject: [PATCH 42/59] Oops. Restore the parent POM of the archetype-generated projects to get the CI build working again. --- .../src/main/resources/archetype-resources/pom.xml | 4 ++-- .../src/main/resources/archetype-resources/pom.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/pom.xml index 4497eb529..3023e0e98 100644 --- a/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/pom.xml @@ -1,9 +1,9 @@ - originals-parent + joy io.github.davidwhitlock.joy - 2.2.0-SNAPSHOT + 1.2.0-SNAPSHOT 4.0.0 ${groupId} diff --git a/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/pom.xml index 1de5678df..ac90ffb74 100644 --- a/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/pom.xml @@ -1,9 +1,9 @@ - originals-parent + joy io.github.davidwhitlock.joy - 2.2.0-SNAPSHOT + 1.2.0-SNAPSHOT 4.0.0 ${groupId} From 09fef06e51d2592f4c50c301c1544aea5ce340ea Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Fri, 29 Nov 2024 13:09:21 -0800 Subject: [PATCH 43/59] Use the official Maven Wrapper for the entire project. --- .mvn/wrapper/MavenWrapperDownloader.java | 117 ------ .mvn/wrapper/maven-wrapper.properties | 21 +- mvnw | 451 ++++++++++------------- mvnw.cmd | 281 +++++++------- 4 files changed, 343 insertions(+), 527 deletions(-) delete mode 100644 .mvn/wrapper/MavenWrapperDownloader.java diff --git a/.mvn/wrapper/MavenWrapperDownloader.java b/.mvn/wrapper/MavenWrapperDownloader.java deleted file mode 100644 index b901097f2..000000000 --- a/.mvn/wrapper/MavenWrapperDownloader.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright 2007-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import java.net.*; -import java.io.*; -import java.nio.channels.*; -import java.util.Properties; - -public class MavenWrapperDownloader { - - private static final String WRAPPER_VERSION = "0.5.6"; - /** - * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. - */ - private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" - + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; - - /** - * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to - * use instead of the default one. - */ - private static final String MAVEN_WRAPPER_PROPERTIES_PATH = - ".mvn/wrapper/maven-wrapper.properties"; - - /** - * Path where the maven-wrapper.jar will be saved to. - */ - private static final String MAVEN_WRAPPER_JAR_PATH = - ".mvn/wrapper/maven-wrapper.jar"; - - /** - * Name of the property which should be used to override the default download url for the wrapper. - */ - private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; - - public static void main(String args[]) { - System.out.println("- Downloader started"); - File baseDirectory = new File(args[0]); - System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); - - // If the maven-wrapper.properties exists, read it and check if it contains a custom - // wrapperUrl parameter. - File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); - String url = DEFAULT_DOWNLOAD_URL; - if(mavenWrapperPropertyFile.exists()) { - FileInputStream mavenWrapperPropertyFileInputStream = null; - try { - mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); - Properties mavenWrapperProperties = new Properties(); - mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); - url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); - } catch (IOException e) { - System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); - } finally { - try { - if(mavenWrapperPropertyFileInputStream != null) { - mavenWrapperPropertyFileInputStream.close(); - } - } catch (IOException e) { - // Ignore ... - } - } - } - System.out.println("- Downloading from: " + url); - - File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); - if(!outputFile.getParentFile().exists()) { - if(!outputFile.getParentFile().mkdirs()) { - System.out.println( - "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); - } - } - System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); - try { - downloadFileFromURL(url, outputFile); - System.out.println("Done"); - System.exit(0); - } catch (Throwable e) { - System.out.println("- Error downloading"); - e.printStackTrace(); - System.exit(1); - } - } - - private static void downloadFileFromURL(String urlString, File destination) throws Exception { - if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { - String username = System.getenv("MVNW_USERNAME"); - char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); - Authenticator.setDefault(new Authenticator() { - @Override - protected PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication(username, password); - } - }); - } - URL website = new URL(urlString); - ReadableByteChannel rbc; - rbc = Channels.newChannel(website.openStream()); - FileOutputStream fos = new FileOutputStream(destination); - fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); - fos.close(); - rbc.close(); - } - -} diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index 5d43cd338..d58dfb70b 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -1,2 +1,19 @@ -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +wrapperVersion=3.3.2 +distributionType=only-script +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip diff --git a/mvnw b/mvnw index 41c0f0c23..19529ddf8 100755 --- a/mvnw +++ b/mvnw @@ -19,292 +19,241 @@ # ---------------------------------------------------------------------------- # ---------------------------------------------------------------------------- -# Maven Start Up Batch script -# -# Required ENV vars: -# ------------------ -# JAVA_HOME - location of a JDK home dir +# Apache Maven Wrapper startup batch script, version 3.3.2 # # Optional ENV vars # ----------------- -# M2_HOME - location of maven2's installed home dir -# MAVEN_OPTS - parameters passed to the Java VM when running Maven -# e.g. to debug Maven itself, use -# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# JAVA_HOME - location of a JDK home dir, required when download maven via java source +# MVNW_REPOURL - repo url base for downloading maven distribution +# MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +# MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output # ---------------------------------------------------------------------------- -if [ -z "$MAVEN_SKIP_RC" ] ; then - - if [ -f /etc/mavenrc ] ; then - . /etc/mavenrc - fi +set -euf +[ "${MVNW_VERBOSE-}" != debug ] || set -x - if [ -f "$HOME/.mavenrc" ] ; then - . "$HOME/.mavenrc" - fi +# OS specific support. +native_path() { printf %s\\n "$1"; } +case "$(uname)" in +CYGWIN* | MINGW*) + [ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")" + native_path() { cygpath --path --windows "$1"; } + ;; +esac -fi +# set JAVACMD and JAVACCMD +set_java_home() { + # For Cygwin and MinGW, ensure paths are in Unix format before anything is touched + if [ -n "${JAVA_HOME-}" ]; then + if [ -x "$JAVA_HOME/jre/sh/java" ]; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACCMD="$JAVA_HOME/jre/sh/javac" + else + JAVACMD="$JAVA_HOME/bin/java" + JAVACCMD="$JAVA_HOME/bin/javac" -# OS specific support. $var _must_ be set to either true or false. -cygwin=false; -darwin=false; -mingw=false -case "`uname`" in - CYGWIN*) cygwin=true ;; - MINGW*) mingw=true;; - Darwin*) darwin=true - # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home - # See https://developer.apple.com/library/mac/qa/qa1170/_index.html - if [ -z "$JAVA_HOME" ]; then - if [ -x "/usr/libexec/java_home" ]; then - export JAVA_HOME="`/usr/libexec/java_home`" - else - export JAVA_HOME="/Library/Java/Home" + if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then + echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2 + echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2 + return 1 fi fi - ;; -esac - -if [ -z "$JAVA_HOME" ] ; then - if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=`java-config --jre-home` + else + JAVACMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v java + )" || : + JAVACCMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v javac + )" || : + + if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then + echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2 + return 1 + fi fi -fi - -if [ -z "$M2_HOME" ] ; then - ## resolve links - $0 may be a link to maven's home - PRG="$0" +} - # need this for relative symlinks - while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG="`dirname "$PRG"`/$link" - fi +# hash string like Java String::hashCode +hash_string() { + str="${1:-}" h=0 + while [ -n "$str" ]; do + char="${str%"${str#?}"}" + h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296)) + str="${str#?}" done + printf %x\\n $h +} - saveddir=`pwd` +verbose() { :; } +[ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; } - M2_HOME=`dirname "$PRG"`/.. +die() { + printf %s\\n "$1" >&2 + exit 1 +} - # make it fully qualified - M2_HOME=`cd "$M2_HOME" && pwd` +trim() { + # MWRAPPER-139: + # Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds. + # Needed for removing poorly interpreted newline sequences when running in more + # exotic environments such as mingw bash on Windows. + printf "%s" "${1}" | tr -d '[:space:]' +} - cd "$saveddir" - # echo Using m2 at $M2_HOME -fi +# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties +while IFS="=" read -r key value; do + case "${key-}" in + distributionUrl) distributionUrl=$(trim "${value-}") ;; + distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;; + esac +done <"${0%/*}/.mvn/wrapper/maven-wrapper.properties" +[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in ${0%/*}/.mvn/wrapper/maven-wrapper.properties" + +case "${distributionUrl##*/}" in +maven-mvnd-*bin.*) + MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ + case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in + *AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;; + :Darwin*x86_64) distributionPlatform=darwin-amd64 ;; + :Darwin*arm64) distributionPlatform=darwin-aarch64 ;; + :Linux*x86_64*) distributionPlatform=linux-amd64 ;; + *) + echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2 + distributionPlatform=linux-amd64 + ;; + esac + distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip" + ;; +maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;; +*) MVN_CMD="mvn${0##*/mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;; +esac -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin ; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --unix "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` -fi +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}" +distributionUrlName="${distributionUrl##*/}" +distributionUrlNameMain="${distributionUrlName%.*}" +distributionUrlNameMain="${distributionUrlNameMain%-bin}" +MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}" +MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")" + +exec_maven() { + unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || : + exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD" +} -# For Mingw, ensure paths are in UNIX format before anything is touched -if $mingw ; then - [ -n "$M2_HOME" ] && - M2_HOME="`(cd "$M2_HOME"; pwd)`" - [ -n "$JAVA_HOME" ] && - JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +if [ -d "$MAVEN_HOME" ]; then + verbose "found existing MAVEN_HOME at $MAVEN_HOME" + exec_maven "$@" fi -if [ -z "$JAVA_HOME" ]; then - javaExecutable="`which javac`" - if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then - # readlink(1) is not available as standard on Solaris 10. - readLink=`which readlink` - if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then - if $darwin ; then - javaHome="`dirname \"$javaExecutable\"`" - javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" - else - javaExecutable="`readlink -f \"$javaExecutable\"`" - fi - javaHome="`dirname \"$javaExecutable\"`" - javaHome=`expr "$javaHome" : '\(.*\)/bin'` - JAVA_HOME="$javaHome" - export JAVA_HOME - fi - fi -fi +case "${distributionUrl-}" in +*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;; +*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;; +esac -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - else - JAVACMD="`which java`" - fi +# prepare tmp dir +if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then + clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; } + trap clean HUP INT TERM EXIT +else + die "cannot create temp dir" fi -if [ ! -x "$JAVACMD" ] ; then - echo "Error: JAVA_HOME is not defined correctly." >&2 - echo " We cannot execute $JAVACMD" >&2 - exit 1 -fi +mkdir -p -- "${MAVEN_HOME%/*}" + +# Download and Install Apache Maven +verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +verbose "Downloading from: $distributionUrl" +verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" -if [ -z "$JAVA_HOME" ] ; then - echo "Warning: JAVA_HOME environment variable is not set." +# select .zip or .tar.gz +if ! command -v unzip >/dev/null; then + distributionUrl="${distributionUrl%.zip}.tar.gz" + distributionUrlName="${distributionUrl##*/}" fi -CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher +# verbose opt +__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR='' +[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v -# traverses directory structure from process work directory to filesystem root -# first directory with .mvn subdirectory is considered project base directory -find_maven_basedir() { +# normalize http auth +case "${MVNW_PASSWORD:+has-password}" in +'') MVNW_USERNAME='' MVNW_PASSWORD='' ;; +has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;; +esac - if [ -z "$1" ] - then - echo "Path not specified to find_maven_basedir" - return 1 - fi +if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then + verbose "Found wget ... using wget" + wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl" +elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then + verbose "Found curl ... using curl" + curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl" +elif set_java_home; then + verbose "Falling back to use Java to download" + javaSource="$TMP_DOWNLOAD_DIR/Downloader.java" + targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName" + cat >"$javaSource" <<-END + public class Downloader extends java.net.Authenticator + { + protected java.net.PasswordAuthentication getPasswordAuthentication() + { + return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() ); + } + public static void main( String[] args ) throws Exception + { + setDefault( new Downloader() ); + java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() ); + } + } + END + # For Cygwin/MinGW, switch paths to Windows format before running javac and java + verbose " - Compiling Downloader.java ..." + "$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java" + verbose " - Running Downloader.java ..." + "$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")" +fi - basedir="$1" - wdir="$1" - while [ "$wdir" != '/' ] ; do - if [ -d "$wdir"/.mvn ] ; then - basedir=$wdir - break +# If specified, validate the SHA-256 sum of the Maven distribution zip file +if [ -n "${distributionSha256Sum-}" ]; then + distributionSha256Result=false + if [ "$MVN_CMD" = mvnd.sh ]; then + echo "Checksum validation is not supported for maven-mvnd." >&2 + echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + elif command -v sha256sum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c >/dev/null 2>&1; then + distributionSha256Result=true fi - # workaround for JBEAP-8937 (on Solaris 10/Sparc) - if [ -d "${wdir}" ]; then - wdir=`cd "$wdir/.."; pwd` + elif command -v shasum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then + distributionSha256Result=true fi - # end of workaround - done - echo "${basedir}" -} - -# concatenates all lines of a file -concat_lines() { - if [ -f "$1" ]; then - echo "$(tr -s '\n' ' ' < "$1")" + else + echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2 + echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + fi + if [ $distributionSha256Result = false ]; then + echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2 + echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2 + exit 1 fi -} - -BASE_DIR=`find_maven_basedir "$(pwd)"` -if [ -z "$BASE_DIR" ]; then - exit 1; fi -########################################################################################## -# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -# This allows using the maven wrapper in projects that prohibit checking in binary data. -########################################################################################## -if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found .mvn/wrapper/maven-wrapper.jar" - fi +# unzip and move +if command -v unzip >/dev/null; then + unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip" else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." - fi - if [ -n "$MVNW_REPOURL" ]; then - jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - else - jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - fi - while IFS="=" read key value; do - case "$key" in (wrapperUrl) jarUrl="$value"; break ;; - esac - done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" - if [ "$MVNW_VERBOSE" = true ]; then - echo "Downloading from: $jarUrl" - fi - wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" - if $cygwin; then - wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` - fi - - if command -v wget > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found wget ... using wget" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - wget "$jarUrl" -O "$wrapperJarPath" - else - wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" - fi - elif command -v curl > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found curl ... using curl" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - curl -o "$wrapperJarPath" "$jarUrl" -f - else - curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f - fi - - else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Falling back to using Java to download" - fi - javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" - # For Cygwin, switch paths to Windows format before running javac - if $cygwin; then - javaClass=`cygpath --path --windows "$javaClass"` - fi - if [ -e "$javaClass" ]; then - if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Compiling MavenWrapperDownloader.java ..." - fi - # Compiling the Java class - ("$JAVA_HOME/bin/javac" "$javaClass") - fi - if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - # Running the downloader - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Running MavenWrapperDownloader.java ..." - fi - ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") - fi - fi - fi -fi -########################################################################################## -# End of extension -########################################################################################## - -export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} -if [ "$MVNW_VERBOSE" = true ]; then - echo $MAVEN_PROJECTBASEDIR + tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar" fi -MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" - -# For Cygwin, switch paths to Windows format before running java -if $cygwin; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --path --windows "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --windows "$CLASSPATH"` - [ -n "$MAVEN_PROJECTBASEDIR" ] && - MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` -fi - -# Provide a "standardized" way to retrieve the CLI args that will -# work with both Windows and non-Windows executions. -MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" -export MAVEN_CMD_LINE_ARGS - -WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain +printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/mvnw.url" +mv -- "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME" -exec "$JAVACMD" \ - $MAVEN_OPTS \ - -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ - "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" +clean || : +exec_maven "$@" diff --git a/mvnw.cmd b/mvnw.cmd index 86115719e..249bdf382 100644 --- a/mvnw.cmd +++ b/mvnw.cmd @@ -1,3 +1,4 @@ +<# : batch portion @REM ---------------------------------------------------------------------------- @REM Licensed to the Apache Software Foundation (ASF) under one @REM or more contributor license agreements. See the NOTICE file @@ -18,165 +19,131 @@ @REM ---------------------------------------------------------------------------- @REM ---------------------------------------------------------------------------- -@REM Maven Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir +@REM Apache Maven Wrapper startup batch script, version 3.3.2 @REM @REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM MVNW_REPOURL - repo url base for downloading maven distribution +@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output @REM ---------------------------------------------------------------------------- -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - -FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( - IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B -) - -@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -@REM This allows using the maven wrapper in projects that prohibit checking in binary data. -if exist %WRAPPER_JAR% ( - if "%MVNW_VERBOSE%" == "true" ( - echo Found %WRAPPER_JAR% - ) -) else ( - if not "%MVNW_REPOURL%" == "" ( - SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - ) - if "%MVNW_VERBOSE%" == "true" ( - echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %DOWNLOAD_URL% - ) - - powershell -Command "&{"^ - "$webclient = new-object System.Net.WebClient;"^ - "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ - "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ - "}"^ - "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ - "}" - if "%MVNW_VERBOSE%" == "true" ( - echo Finished downloading %WRAPPER_JAR% - ) +@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) +@SET __MVNW_CMD__= +@SET __MVNW_ERROR__= +@SET __MVNW_PSMODULEP_SAVE=%PSModulePath% +@SET PSModulePath= +@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( + IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) ) -@REM End of extension - -@REM Provide a "standardized" way to retrieve the CLI args that will -@REM work with both Windows and non-Windows executions. -set MAVEN_CMD_LINE_ARGS=%* - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% +@SET PSModulePath=%__MVNW_PSMODULEP_SAVE% +@SET __MVNW_PSMODULEP_SAVE= +@SET __MVNW_ARG0_NAME__= +@SET MVNW_USERNAME= +@SET MVNW_PASSWORD= +@IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*) +@echo Cannot start maven from wrapper >&2 && exit /b 1 +@GOTO :EOF +: end batch / begin powershell #> + +$ErrorActionPreference = "Stop" +if ($env:MVNW_VERBOSE -eq "true") { + $VerbosePreference = "Continue" +} + +# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties +$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl +if (!$distributionUrl) { + Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" +} + +switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { + "maven-mvnd-*" { + $USE_MVND = $true + $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" + $MVN_CMD = "mvnd.cmd" + break + } + default { + $USE_MVND = $false + $MVN_CMD = $script -replace '^mvnw','mvn' + break + } +} + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +if ($env:MVNW_REPOURL) { + $MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" } + $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')" +} +$distributionUrlName = $distributionUrl -replace '^.*/','' +$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' +$MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain" +if ($env:MAVEN_USER_HOME) { + $MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain" +} +$MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' +$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" + +if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { + Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" + Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" + exit $? +} + +if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { + Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" +} + +# prepare tmp dir +$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile +$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" +$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null +trap { + if ($TMP_DOWNLOAD_DIR.Exists) { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } + } +} + +New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null + +# Download and Install Apache Maven +Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +Write-Verbose "Downloading from: $distributionUrl" +Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +$webclient = New-Object System.Net.WebClient +if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { + $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) +} +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 +$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum +if ($distributionSha256Sum) { + if ($USE_MVND) { + Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." + } + Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash + if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { + Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." + } +} + +# unzip and move +Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null +Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null +try { + Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null +} catch { + if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { + Write-Error "fail to move MAVEN_HOME" + } +} finally { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } +} + +Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" From c2662e8bc75f02f1b35a6797a4ddbde27dc17e43 Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Fri, 29 Nov 2024 13:24:07 -0800 Subject: [PATCH 44/59] Use the official Maven Wrapper for the original projects. --- .../.mvn/wrapper/MavenWrapperDownloader.java | 117 ----- .../.mvn/wrapper/maven-wrapper.properties | 21 +- .../originals-parent/airline-web/mvnw | 451 ++++++++---------- .../originals-parent/airline-web/mvnw.cmd | 281 +++++------ .../.mvn/wrapper/MavenWrapperDownloader.java | 117 ----- .../.mvn/wrapper/maven-wrapper.properties | 21 +- projects-parent/originals-parent/airline/mvnw | 451 ++++++++---------- .../originals-parent/airline/mvnw.cmd | 281 +++++------ .../.mvn/wrapper/MavenWrapperDownloader.java | 117 ----- .../.mvn/wrapper/maven-wrapper.properties | 21 +- .../originals-parent/apptbook-web/mvnw | 451 ++++++++---------- .../originals-parent/apptbook-web/mvnw.cmd | 281 +++++------ .../.mvn/wrapper/MavenWrapperDownloader.java | 117 ----- .../.mvn/wrapper/maven-wrapper.properties | 21 +- .../originals-parent/apptbook/mvnw | 451 ++++++++---------- .../originals-parent/apptbook/mvnw.cmd | 281 +++++------ .../.mvn/wrapper/MavenWrapperDownloader.java | 117 ----- .../.mvn/wrapper/maven-wrapper.properties | 21 +- projects-parent/originals-parent/kata/mvnw | 451 ++++++++---------- .../originals-parent/kata/mvnw.cmd | 281 +++++------ .../.mvn/wrapper/MavenWrapperDownloader.java | 117 ----- .../.mvn/wrapper/maven-wrapper.properties | 21 +- .../originals-parent/phonebill-web/mvnw | 451 ++++++++---------- .../originals-parent/phonebill-web/mvnw.cmd | 281 +++++------ .../.mvn/wrapper/MavenWrapperDownloader.java | 117 ----- .../.mvn/wrapper/maven-wrapper.properties | 21 +- .../originals-parent/phonebill/mvnw | 451 ++++++++---------- .../originals-parent/phonebill/mvnw.cmd | 281 +++++------ .../.mvn/wrapper/MavenWrapperDownloader.java | 117 ----- .../.mvn/wrapper/maven-wrapper.properties | 21 +- projects-parent/originals-parent/student/mvnw | 451 ++++++++---------- .../originals-parent/student/mvnw.cmd | 281 +++++------ 32 files changed, 2744 insertions(+), 4216 deletions(-) delete mode 100644 projects-parent/originals-parent/airline-web/.mvn/wrapper/MavenWrapperDownloader.java delete mode 100644 projects-parent/originals-parent/airline/.mvn/wrapper/MavenWrapperDownloader.java delete mode 100644 projects-parent/originals-parent/apptbook-web/.mvn/wrapper/MavenWrapperDownloader.java delete mode 100644 projects-parent/originals-parent/apptbook/.mvn/wrapper/MavenWrapperDownloader.java delete mode 100644 projects-parent/originals-parent/kata/.mvn/wrapper/MavenWrapperDownloader.java delete mode 100644 projects-parent/originals-parent/phonebill-web/.mvn/wrapper/MavenWrapperDownloader.java delete mode 100644 projects-parent/originals-parent/phonebill/.mvn/wrapper/MavenWrapperDownloader.java delete mode 100644 projects-parent/originals-parent/student/.mvn/wrapper/MavenWrapperDownloader.java diff --git a/projects-parent/originals-parent/airline-web/.mvn/wrapper/MavenWrapperDownloader.java b/projects-parent/originals-parent/airline-web/.mvn/wrapper/MavenWrapperDownloader.java deleted file mode 100644 index b901097f2..000000000 --- a/projects-parent/originals-parent/airline-web/.mvn/wrapper/MavenWrapperDownloader.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright 2007-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import java.net.*; -import java.io.*; -import java.nio.channels.*; -import java.util.Properties; - -public class MavenWrapperDownloader { - - private static final String WRAPPER_VERSION = "0.5.6"; - /** - * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. - */ - private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" - + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; - - /** - * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to - * use instead of the default one. - */ - private static final String MAVEN_WRAPPER_PROPERTIES_PATH = - ".mvn/wrapper/maven-wrapper.properties"; - - /** - * Path where the maven-wrapper.jar will be saved to. - */ - private static final String MAVEN_WRAPPER_JAR_PATH = - ".mvn/wrapper/maven-wrapper.jar"; - - /** - * Name of the property which should be used to override the default download url for the wrapper. - */ - private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; - - public static void main(String args[]) { - System.out.println("- Downloader started"); - File baseDirectory = new File(args[0]); - System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); - - // If the maven-wrapper.properties exists, read it and check if it contains a custom - // wrapperUrl parameter. - File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); - String url = DEFAULT_DOWNLOAD_URL; - if(mavenWrapperPropertyFile.exists()) { - FileInputStream mavenWrapperPropertyFileInputStream = null; - try { - mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); - Properties mavenWrapperProperties = new Properties(); - mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); - url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); - } catch (IOException e) { - System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); - } finally { - try { - if(mavenWrapperPropertyFileInputStream != null) { - mavenWrapperPropertyFileInputStream.close(); - } - } catch (IOException e) { - // Ignore ... - } - } - } - System.out.println("- Downloading from: " + url); - - File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); - if(!outputFile.getParentFile().exists()) { - if(!outputFile.getParentFile().mkdirs()) { - System.out.println( - "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); - } - } - System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); - try { - downloadFileFromURL(url, outputFile); - System.out.println("Done"); - System.exit(0); - } catch (Throwable e) { - System.out.println("- Error downloading"); - e.printStackTrace(); - System.exit(1); - } - } - - private static void downloadFileFromURL(String urlString, File destination) throws Exception { - if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { - String username = System.getenv("MVNW_USERNAME"); - char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); - Authenticator.setDefault(new Authenticator() { - @Override - protected PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication(username, password); - } - }); - } - URL website = new URL(urlString); - ReadableByteChannel rbc; - rbc = Channels.newChannel(website.openStream()); - FileOutputStream fos = new FileOutputStream(destination); - fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); - fos.close(); - rbc.close(); - } - -} diff --git a/projects-parent/originals-parent/airline-web/.mvn/wrapper/maven-wrapper.properties b/projects-parent/originals-parent/airline-web/.mvn/wrapper/maven-wrapper.properties index 5d43cd338..d58dfb70b 100644 --- a/projects-parent/originals-parent/airline-web/.mvn/wrapper/maven-wrapper.properties +++ b/projects-parent/originals-parent/airline-web/.mvn/wrapper/maven-wrapper.properties @@ -1,2 +1,19 @@ -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +wrapperVersion=3.3.2 +distributionType=only-script +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip diff --git a/projects-parent/originals-parent/airline-web/mvnw b/projects-parent/originals-parent/airline-web/mvnw index 41c0f0c23..19529ddf8 100755 --- a/projects-parent/originals-parent/airline-web/mvnw +++ b/projects-parent/originals-parent/airline-web/mvnw @@ -19,292 +19,241 @@ # ---------------------------------------------------------------------------- # ---------------------------------------------------------------------------- -# Maven Start Up Batch script -# -# Required ENV vars: -# ------------------ -# JAVA_HOME - location of a JDK home dir +# Apache Maven Wrapper startup batch script, version 3.3.2 # # Optional ENV vars # ----------------- -# M2_HOME - location of maven2's installed home dir -# MAVEN_OPTS - parameters passed to the Java VM when running Maven -# e.g. to debug Maven itself, use -# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# JAVA_HOME - location of a JDK home dir, required when download maven via java source +# MVNW_REPOURL - repo url base for downloading maven distribution +# MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +# MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output # ---------------------------------------------------------------------------- -if [ -z "$MAVEN_SKIP_RC" ] ; then - - if [ -f /etc/mavenrc ] ; then - . /etc/mavenrc - fi +set -euf +[ "${MVNW_VERBOSE-}" != debug ] || set -x - if [ -f "$HOME/.mavenrc" ] ; then - . "$HOME/.mavenrc" - fi +# OS specific support. +native_path() { printf %s\\n "$1"; } +case "$(uname)" in +CYGWIN* | MINGW*) + [ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")" + native_path() { cygpath --path --windows "$1"; } + ;; +esac -fi +# set JAVACMD and JAVACCMD +set_java_home() { + # For Cygwin and MinGW, ensure paths are in Unix format before anything is touched + if [ -n "${JAVA_HOME-}" ]; then + if [ -x "$JAVA_HOME/jre/sh/java" ]; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACCMD="$JAVA_HOME/jre/sh/javac" + else + JAVACMD="$JAVA_HOME/bin/java" + JAVACCMD="$JAVA_HOME/bin/javac" -# OS specific support. $var _must_ be set to either true or false. -cygwin=false; -darwin=false; -mingw=false -case "`uname`" in - CYGWIN*) cygwin=true ;; - MINGW*) mingw=true;; - Darwin*) darwin=true - # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home - # See https://developer.apple.com/library/mac/qa/qa1170/_index.html - if [ -z "$JAVA_HOME" ]; then - if [ -x "/usr/libexec/java_home" ]; then - export JAVA_HOME="`/usr/libexec/java_home`" - else - export JAVA_HOME="/Library/Java/Home" + if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then + echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2 + echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2 + return 1 fi fi - ;; -esac - -if [ -z "$JAVA_HOME" ] ; then - if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=`java-config --jre-home` + else + JAVACMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v java + )" || : + JAVACCMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v javac + )" || : + + if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then + echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2 + return 1 + fi fi -fi - -if [ -z "$M2_HOME" ] ; then - ## resolve links - $0 may be a link to maven's home - PRG="$0" +} - # need this for relative symlinks - while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG="`dirname "$PRG"`/$link" - fi +# hash string like Java String::hashCode +hash_string() { + str="${1:-}" h=0 + while [ -n "$str" ]; do + char="${str%"${str#?}"}" + h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296)) + str="${str#?}" done + printf %x\\n $h +} - saveddir=`pwd` +verbose() { :; } +[ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; } - M2_HOME=`dirname "$PRG"`/.. +die() { + printf %s\\n "$1" >&2 + exit 1 +} - # make it fully qualified - M2_HOME=`cd "$M2_HOME" && pwd` +trim() { + # MWRAPPER-139: + # Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds. + # Needed for removing poorly interpreted newline sequences when running in more + # exotic environments such as mingw bash on Windows. + printf "%s" "${1}" | tr -d '[:space:]' +} - cd "$saveddir" - # echo Using m2 at $M2_HOME -fi +# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties +while IFS="=" read -r key value; do + case "${key-}" in + distributionUrl) distributionUrl=$(trim "${value-}") ;; + distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;; + esac +done <"${0%/*}/.mvn/wrapper/maven-wrapper.properties" +[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in ${0%/*}/.mvn/wrapper/maven-wrapper.properties" + +case "${distributionUrl##*/}" in +maven-mvnd-*bin.*) + MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ + case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in + *AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;; + :Darwin*x86_64) distributionPlatform=darwin-amd64 ;; + :Darwin*arm64) distributionPlatform=darwin-aarch64 ;; + :Linux*x86_64*) distributionPlatform=linux-amd64 ;; + *) + echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2 + distributionPlatform=linux-amd64 + ;; + esac + distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip" + ;; +maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;; +*) MVN_CMD="mvn${0##*/mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;; +esac -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin ; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --unix "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` -fi +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}" +distributionUrlName="${distributionUrl##*/}" +distributionUrlNameMain="${distributionUrlName%.*}" +distributionUrlNameMain="${distributionUrlNameMain%-bin}" +MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}" +MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")" + +exec_maven() { + unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || : + exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD" +} -# For Mingw, ensure paths are in UNIX format before anything is touched -if $mingw ; then - [ -n "$M2_HOME" ] && - M2_HOME="`(cd "$M2_HOME"; pwd)`" - [ -n "$JAVA_HOME" ] && - JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +if [ -d "$MAVEN_HOME" ]; then + verbose "found existing MAVEN_HOME at $MAVEN_HOME" + exec_maven "$@" fi -if [ -z "$JAVA_HOME" ]; then - javaExecutable="`which javac`" - if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then - # readlink(1) is not available as standard on Solaris 10. - readLink=`which readlink` - if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then - if $darwin ; then - javaHome="`dirname \"$javaExecutable\"`" - javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" - else - javaExecutable="`readlink -f \"$javaExecutable\"`" - fi - javaHome="`dirname \"$javaExecutable\"`" - javaHome=`expr "$javaHome" : '\(.*\)/bin'` - JAVA_HOME="$javaHome" - export JAVA_HOME - fi - fi -fi +case "${distributionUrl-}" in +*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;; +*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;; +esac -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - else - JAVACMD="`which java`" - fi +# prepare tmp dir +if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then + clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; } + trap clean HUP INT TERM EXIT +else + die "cannot create temp dir" fi -if [ ! -x "$JAVACMD" ] ; then - echo "Error: JAVA_HOME is not defined correctly." >&2 - echo " We cannot execute $JAVACMD" >&2 - exit 1 -fi +mkdir -p -- "${MAVEN_HOME%/*}" + +# Download and Install Apache Maven +verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +verbose "Downloading from: $distributionUrl" +verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" -if [ -z "$JAVA_HOME" ] ; then - echo "Warning: JAVA_HOME environment variable is not set." +# select .zip or .tar.gz +if ! command -v unzip >/dev/null; then + distributionUrl="${distributionUrl%.zip}.tar.gz" + distributionUrlName="${distributionUrl##*/}" fi -CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher +# verbose opt +__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR='' +[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v -# traverses directory structure from process work directory to filesystem root -# first directory with .mvn subdirectory is considered project base directory -find_maven_basedir() { +# normalize http auth +case "${MVNW_PASSWORD:+has-password}" in +'') MVNW_USERNAME='' MVNW_PASSWORD='' ;; +has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;; +esac - if [ -z "$1" ] - then - echo "Path not specified to find_maven_basedir" - return 1 - fi +if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then + verbose "Found wget ... using wget" + wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl" +elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then + verbose "Found curl ... using curl" + curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl" +elif set_java_home; then + verbose "Falling back to use Java to download" + javaSource="$TMP_DOWNLOAD_DIR/Downloader.java" + targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName" + cat >"$javaSource" <<-END + public class Downloader extends java.net.Authenticator + { + protected java.net.PasswordAuthentication getPasswordAuthentication() + { + return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() ); + } + public static void main( String[] args ) throws Exception + { + setDefault( new Downloader() ); + java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() ); + } + } + END + # For Cygwin/MinGW, switch paths to Windows format before running javac and java + verbose " - Compiling Downloader.java ..." + "$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java" + verbose " - Running Downloader.java ..." + "$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")" +fi - basedir="$1" - wdir="$1" - while [ "$wdir" != '/' ] ; do - if [ -d "$wdir"/.mvn ] ; then - basedir=$wdir - break +# If specified, validate the SHA-256 sum of the Maven distribution zip file +if [ -n "${distributionSha256Sum-}" ]; then + distributionSha256Result=false + if [ "$MVN_CMD" = mvnd.sh ]; then + echo "Checksum validation is not supported for maven-mvnd." >&2 + echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + elif command -v sha256sum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c >/dev/null 2>&1; then + distributionSha256Result=true fi - # workaround for JBEAP-8937 (on Solaris 10/Sparc) - if [ -d "${wdir}" ]; then - wdir=`cd "$wdir/.."; pwd` + elif command -v shasum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then + distributionSha256Result=true fi - # end of workaround - done - echo "${basedir}" -} - -# concatenates all lines of a file -concat_lines() { - if [ -f "$1" ]; then - echo "$(tr -s '\n' ' ' < "$1")" + else + echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2 + echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + fi + if [ $distributionSha256Result = false ]; then + echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2 + echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2 + exit 1 fi -} - -BASE_DIR=`find_maven_basedir "$(pwd)"` -if [ -z "$BASE_DIR" ]; then - exit 1; fi -########################################################################################## -# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -# This allows using the maven wrapper in projects that prohibit checking in binary data. -########################################################################################## -if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found .mvn/wrapper/maven-wrapper.jar" - fi +# unzip and move +if command -v unzip >/dev/null; then + unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip" else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." - fi - if [ -n "$MVNW_REPOURL" ]; then - jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - else - jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - fi - while IFS="=" read key value; do - case "$key" in (wrapperUrl) jarUrl="$value"; break ;; - esac - done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" - if [ "$MVNW_VERBOSE" = true ]; then - echo "Downloading from: $jarUrl" - fi - wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" - if $cygwin; then - wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` - fi - - if command -v wget > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found wget ... using wget" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - wget "$jarUrl" -O "$wrapperJarPath" - else - wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" - fi - elif command -v curl > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found curl ... using curl" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - curl -o "$wrapperJarPath" "$jarUrl" -f - else - curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f - fi - - else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Falling back to using Java to download" - fi - javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" - # For Cygwin, switch paths to Windows format before running javac - if $cygwin; then - javaClass=`cygpath --path --windows "$javaClass"` - fi - if [ -e "$javaClass" ]; then - if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Compiling MavenWrapperDownloader.java ..." - fi - # Compiling the Java class - ("$JAVA_HOME/bin/javac" "$javaClass") - fi - if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - # Running the downloader - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Running MavenWrapperDownloader.java ..." - fi - ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") - fi - fi - fi -fi -########################################################################################## -# End of extension -########################################################################################## - -export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} -if [ "$MVNW_VERBOSE" = true ]; then - echo $MAVEN_PROJECTBASEDIR + tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar" fi -MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" - -# For Cygwin, switch paths to Windows format before running java -if $cygwin; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --path --windows "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --windows "$CLASSPATH"` - [ -n "$MAVEN_PROJECTBASEDIR" ] && - MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` -fi - -# Provide a "standardized" way to retrieve the CLI args that will -# work with both Windows and non-Windows executions. -MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" -export MAVEN_CMD_LINE_ARGS - -WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain +printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/mvnw.url" +mv -- "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME" -exec "$JAVACMD" \ - $MAVEN_OPTS \ - -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ - "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" +clean || : +exec_maven "$@" diff --git a/projects-parent/originals-parent/airline-web/mvnw.cmd b/projects-parent/originals-parent/airline-web/mvnw.cmd index 86115719e..249bdf382 100644 --- a/projects-parent/originals-parent/airline-web/mvnw.cmd +++ b/projects-parent/originals-parent/airline-web/mvnw.cmd @@ -1,3 +1,4 @@ +<# : batch portion @REM ---------------------------------------------------------------------------- @REM Licensed to the Apache Software Foundation (ASF) under one @REM or more contributor license agreements. See the NOTICE file @@ -18,165 +19,131 @@ @REM ---------------------------------------------------------------------------- @REM ---------------------------------------------------------------------------- -@REM Maven Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir +@REM Apache Maven Wrapper startup batch script, version 3.3.2 @REM @REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM MVNW_REPOURL - repo url base for downloading maven distribution +@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output @REM ---------------------------------------------------------------------------- -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - -FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( - IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B -) - -@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -@REM This allows using the maven wrapper in projects that prohibit checking in binary data. -if exist %WRAPPER_JAR% ( - if "%MVNW_VERBOSE%" == "true" ( - echo Found %WRAPPER_JAR% - ) -) else ( - if not "%MVNW_REPOURL%" == "" ( - SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - ) - if "%MVNW_VERBOSE%" == "true" ( - echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %DOWNLOAD_URL% - ) - - powershell -Command "&{"^ - "$webclient = new-object System.Net.WebClient;"^ - "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ - "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ - "}"^ - "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ - "}" - if "%MVNW_VERBOSE%" == "true" ( - echo Finished downloading %WRAPPER_JAR% - ) +@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) +@SET __MVNW_CMD__= +@SET __MVNW_ERROR__= +@SET __MVNW_PSMODULEP_SAVE=%PSModulePath% +@SET PSModulePath= +@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( + IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) ) -@REM End of extension - -@REM Provide a "standardized" way to retrieve the CLI args that will -@REM work with both Windows and non-Windows executions. -set MAVEN_CMD_LINE_ARGS=%* - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% +@SET PSModulePath=%__MVNW_PSMODULEP_SAVE% +@SET __MVNW_PSMODULEP_SAVE= +@SET __MVNW_ARG0_NAME__= +@SET MVNW_USERNAME= +@SET MVNW_PASSWORD= +@IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*) +@echo Cannot start maven from wrapper >&2 && exit /b 1 +@GOTO :EOF +: end batch / begin powershell #> + +$ErrorActionPreference = "Stop" +if ($env:MVNW_VERBOSE -eq "true") { + $VerbosePreference = "Continue" +} + +# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties +$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl +if (!$distributionUrl) { + Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" +} + +switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { + "maven-mvnd-*" { + $USE_MVND = $true + $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" + $MVN_CMD = "mvnd.cmd" + break + } + default { + $USE_MVND = $false + $MVN_CMD = $script -replace '^mvnw','mvn' + break + } +} + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +if ($env:MVNW_REPOURL) { + $MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" } + $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')" +} +$distributionUrlName = $distributionUrl -replace '^.*/','' +$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' +$MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain" +if ($env:MAVEN_USER_HOME) { + $MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain" +} +$MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' +$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" + +if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { + Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" + Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" + exit $? +} + +if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { + Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" +} + +# prepare tmp dir +$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile +$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" +$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null +trap { + if ($TMP_DOWNLOAD_DIR.Exists) { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } + } +} + +New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null + +# Download and Install Apache Maven +Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +Write-Verbose "Downloading from: $distributionUrl" +Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +$webclient = New-Object System.Net.WebClient +if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { + $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) +} +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 +$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum +if ($distributionSha256Sum) { + if ($USE_MVND) { + Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." + } + Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash + if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { + Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." + } +} + +# unzip and move +Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null +Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null +try { + Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null +} catch { + if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { + Write-Error "fail to move MAVEN_HOME" + } +} finally { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } +} + +Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" diff --git a/projects-parent/originals-parent/airline/.mvn/wrapper/MavenWrapperDownloader.java b/projects-parent/originals-parent/airline/.mvn/wrapper/MavenWrapperDownloader.java deleted file mode 100644 index b901097f2..000000000 --- a/projects-parent/originals-parent/airline/.mvn/wrapper/MavenWrapperDownloader.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright 2007-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import java.net.*; -import java.io.*; -import java.nio.channels.*; -import java.util.Properties; - -public class MavenWrapperDownloader { - - private static final String WRAPPER_VERSION = "0.5.6"; - /** - * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. - */ - private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" - + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; - - /** - * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to - * use instead of the default one. - */ - private static final String MAVEN_WRAPPER_PROPERTIES_PATH = - ".mvn/wrapper/maven-wrapper.properties"; - - /** - * Path where the maven-wrapper.jar will be saved to. - */ - private static final String MAVEN_WRAPPER_JAR_PATH = - ".mvn/wrapper/maven-wrapper.jar"; - - /** - * Name of the property which should be used to override the default download url for the wrapper. - */ - private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; - - public static void main(String args[]) { - System.out.println("- Downloader started"); - File baseDirectory = new File(args[0]); - System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); - - // If the maven-wrapper.properties exists, read it and check if it contains a custom - // wrapperUrl parameter. - File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); - String url = DEFAULT_DOWNLOAD_URL; - if(mavenWrapperPropertyFile.exists()) { - FileInputStream mavenWrapperPropertyFileInputStream = null; - try { - mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); - Properties mavenWrapperProperties = new Properties(); - mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); - url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); - } catch (IOException e) { - System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); - } finally { - try { - if(mavenWrapperPropertyFileInputStream != null) { - mavenWrapperPropertyFileInputStream.close(); - } - } catch (IOException e) { - // Ignore ... - } - } - } - System.out.println("- Downloading from: " + url); - - File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); - if(!outputFile.getParentFile().exists()) { - if(!outputFile.getParentFile().mkdirs()) { - System.out.println( - "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); - } - } - System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); - try { - downloadFileFromURL(url, outputFile); - System.out.println("Done"); - System.exit(0); - } catch (Throwable e) { - System.out.println("- Error downloading"); - e.printStackTrace(); - System.exit(1); - } - } - - private static void downloadFileFromURL(String urlString, File destination) throws Exception { - if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { - String username = System.getenv("MVNW_USERNAME"); - char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); - Authenticator.setDefault(new Authenticator() { - @Override - protected PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication(username, password); - } - }); - } - URL website = new URL(urlString); - ReadableByteChannel rbc; - rbc = Channels.newChannel(website.openStream()); - FileOutputStream fos = new FileOutputStream(destination); - fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); - fos.close(); - rbc.close(); - } - -} diff --git a/projects-parent/originals-parent/airline/.mvn/wrapper/maven-wrapper.properties b/projects-parent/originals-parent/airline/.mvn/wrapper/maven-wrapper.properties index 5d43cd338..d58dfb70b 100644 --- a/projects-parent/originals-parent/airline/.mvn/wrapper/maven-wrapper.properties +++ b/projects-parent/originals-parent/airline/.mvn/wrapper/maven-wrapper.properties @@ -1,2 +1,19 @@ -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +wrapperVersion=3.3.2 +distributionType=only-script +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip diff --git a/projects-parent/originals-parent/airline/mvnw b/projects-parent/originals-parent/airline/mvnw index 41c0f0c23..19529ddf8 100755 --- a/projects-parent/originals-parent/airline/mvnw +++ b/projects-parent/originals-parent/airline/mvnw @@ -19,292 +19,241 @@ # ---------------------------------------------------------------------------- # ---------------------------------------------------------------------------- -# Maven Start Up Batch script -# -# Required ENV vars: -# ------------------ -# JAVA_HOME - location of a JDK home dir +# Apache Maven Wrapper startup batch script, version 3.3.2 # # Optional ENV vars # ----------------- -# M2_HOME - location of maven2's installed home dir -# MAVEN_OPTS - parameters passed to the Java VM when running Maven -# e.g. to debug Maven itself, use -# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# JAVA_HOME - location of a JDK home dir, required when download maven via java source +# MVNW_REPOURL - repo url base for downloading maven distribution +# MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +# MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output # ---------------------------------------------------------------------------- -if [ -z "$MAVEN_SKIP_RC" ] ; then - - if [ -f /etc/mavenrc ] ; then - . /etc/mavenrc - fi +set -euf +[ "${MVNW_VERBOSE-}" != debug ] || set -x - if [ -f "$HOME/.mavenrc" ] ; then - . "$HOME/.mavenrc" - fi +# OS specific support. +native_path() { printf %s\\n "$1"; } +case "$(uname)" in +CYGWIN* | MINGW*) + [ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")" + native_path() { cygpath --path --windows "$1"; } + ;; +esac -fi +# set JAVACMD and JAVACCMD +set_java_home() { + # For Cygwin and MinGW, ensure paths are in Unix format before anything is touched + if [ -n "${JAVA_HOME-}" ]; then + if [ -x "$JAVA_HOME/jre/sh/java" ]; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACCMD="$JAVA_HOME/jre/sh/javac" + else + JAVACMD="$JAVA_HOME/bin/java" + JAVACCMD="$JAVA_HOME/bin/javac" -# OS specific support. $var _must_ be set to either true or false. -cygwin=false; -darwin=false; -mingw=false -case "`uname`" in - CYGWIN*) cygwin=true ;; - MINGW*) mingw=true;; - Darwin*) darwin=true - # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home - # See https://developer.apple.com/library/mac/qa/qa1170/_index.html - if [ -z "$JAVA_HOME" ]; then - if [ -x "/usr/libexec/java_home" ]; then - export JAVA_HOME="`/usr/libexec/java_home`" - else - export JAVA_HOME="/Library/Java/Home" + if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then + echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2 + echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2 + return 1 fi fi - ;; -esac - -if [ -z "$JAVA_HOME" ] ; then - if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=`java-config --jre-home` + else + JAVACMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v java + )" || : + JAVACCMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v javac + )" || : + + if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then + echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2 + return 1 + fi fi -fi - -if [ -z "$M2_HOME" ] ; then - ## resolve links - $0 may be a link to maven's home - PRG="$0" +} - # need this for relative symlinks - while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG="`dirname "$PRG"`/$link" - fi +# hash string like Java String::hashCode +hash_string() { + str="${1:-}" h=0 + while [ -n "$str" ]; do + char="${str%"${str#?}"}" + h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296)) + str="${str#?}" done + printf %x\\n $h +} - saveddir=`pwd` +verbose() { :; } +[ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; } - M2_HOME=`dirname "$PRG"`/.. +die() { + printf %s\\n "$1" >&2 + exit 1 +} - # make it fully qualified - M2_HOME=`cd "$M2_HOME" && pwd` +trim() { + # MWRAPPER-139: + # Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds. + # Needed for removing poorly interpreted newline sequences when running in more + # exotic environments such as mingw bash on Windows. + printf "%s" "${1}" | tr -d '[:space:]' +} - cd "$saveddir" - # echo Using m2 at $M2_HOME -fi +# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties +while IFS="=" read -r key value; do + case "${key-}" in + distributionUrl) distributionUrl=$(trim "${value-}") ;; + distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;; + esac +done <"${0%/*}/.mvn/wrapper/maven-wrapper.properties" +[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in ${0%/*}/.mvn/wrapper/maven-wrapper.properties" + +case "${distributionUrl##*/}" in +maven-mvnd-*bin.*) + MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ + case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in + *AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;; + :Darwin*x86_64) distributionPlatform=darwin-amd64 ;; + :Darwin*arm64) distributionPlatform=darwin-aarch64 ;; + :Linux*x86_64*) distributionPlatform=linux-amd64 ;; + *) + echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2 + distributionPlatform=linux-amd64 + ;; + esac + distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip" + ;; +maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;; +*) MVN_CMD="mvn${0##*/mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;; +esac -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin ; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --unix "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` -fi +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}" +distributionUrlName="${distributionUrl##*/}" +distributionUrlNameMain="${distributionUrlName%.*}" +distributionUrlNameMain="${distributionUrlNameMain%-bin}" +MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}" +MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")" + +exec_maven() { + unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || : + exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD" +} -# For Mingw, ensure paths are in UNIX format before anything is touched -if $mingw ; then - [ -n "$M2_HOME" ] && - M2_HOME="`(cd "$M2_HOME"; pwd)`" - [ -n "$JAVA_HOME" ] && - JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +if [ -d "$MAVEN_HOME" ]; then + verbose "found existing MAVEN_HOME at $MAVEN_HOME" + exec_maven "$@" fi -if [ -z "$JAVA_HOME" ]; then - javaExecutable="`which javac`" - if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then - # readlink(1) is not available as standard on Solaris 10. - readLink=`which readlink` - if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then - if $darwin ; then - javaHome="`dirname \"$javaExecutable\"`" - javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" - else - javaExecutable="`readlink -f \"$javaExecutable\"`" - fi - javaHome="`dirname \"$javaExecutable\"`" - javaHome=`expr "$javaHome" : '\(.*\)/bin'` - JAVA_HOME="$javaHome" - export JAVA_HOME - fi - fi -fi +case "${distributionUrl-}" in +*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;; +*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;; +esac -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - else - JAVACMD="`which java`" - fi +# prepare tmp dir +if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then + clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; } + trap clean HUP INT TERM EXIT +else + die "cannot create temp dir" fi -if [ ! -x "$JAVACMD" ] ; then - echo "Error: JAVA_HOME is not defined correctly." >&2 - echo " We cannot execute $JAVACMD" >&2 - exit 1 -fi +mkdir -p -- "${MAVEN_HOME%/*}" + +# Download and Install Apache Maven +verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +verbose "Downloading from: $distributionUrl" +verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" -if [ -z "$JAVA_HOME" ] ; then - echo "Warning: JAVA_HOME environment variable is not set." +# select .zip or .tar.gz +if ! command -v unzip >/dev/null; then + distributionUrl="${distributionUrl%.zip}.tar.gz" + distributionUrlName="${distributionUrl##*/}" fi -CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher +# verbose opt +__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR='' +[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v -# traverses directory structure from process work directory to filesystem root -# first directory with .mvn subdirectory is considered project base directory -find_maven_basedir() { +# normalize http auth +case "${MVNW_PASSWORD:+has-password}" in +'') MVNW_USERNAME='' MVNW_PASSWORD='' ;; +has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;; +esac - if [ -z "$1" ] - then - echo "Path not specified to find_maven_basedir" - return 1 - fi +if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then + verbose "Found wget ... using wget" + wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl" +elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then + verbose "Found curl ... using curl" + curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl" +elif set_java_home; then + verbose "Falling back to use Java to download" + javaSource="$TMP_DOWNLOAD_DIR/Downloader.java" + targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName" + cat >"$javaSource" <<-END + public class Downloader extends java.net.Authenticator + { + protected java.net.PasswordAuthentication getPasswordAuthentication() + { + return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() ); + } + public static void main( String[] args ) throws Exception + { + setDefault( new Downloader() ); + java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() ); + } + } + END + # For Cygwin/MinGW, switch paths to Windows format before running javac and java + verbose " - Compiling Downloader.java ..." + "$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java" + verbose " - Running Downloader.java ..." + "$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")" +fi - basedir="$1" - wdir="$1" - while [ "$wdir" != '/' ] ; do - if [ -d "$wdir"/.mvn ] ; then - basedir=$wdir - break +# If specified, validate the SHA-256 sum of the Maven distribution zip file +if [ -n "${distributionSha256Sum-}" ]; then + distributionSha256Result=false + if [ "$MVN_CMD" = mvnd.sh ]; then + echo "Checksum validation is not supported for maven-mvnd." >&2 + echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + elif command -v sha256sum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c >/dev/null 2>&1; then + distributionSha256Result=true fi - # workaround for JBEAP-8937 (on Solaris 10/Sparc) - if [ -d "${wdir}" ]; then - wdir=`cd "$wdir/.."; pwd` + elif command -v shasum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then + distributionSha256Result=true fi - # end of workaround - done - echo "${basedir}" -} - -# concatenates all lines of a file -concat_lines() { - if [ -f "$1" ]; then - echo "$(tr -s '\n' ' ' < "$1")" + else + echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2 + echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + fi + if [ $distributionSha256Result = false ]; then + echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2 + echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2 + exit 1 fi -} - -BASE_DIR=`find_maven_basedir "$(pwd)"` -if [ -z "$BASE_DIR" ]; then - exit 1; fi -########################################################################################## -# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -# This allows using the maven wrapper in projects that prohibit checking in binary data. -########################################################################################## -if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found .mvn/wrapper/maven-wrapper.jar" - fi +# unzip and move +if command -v unzip >/dev/null; then + unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip" else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." - fi - if [ -n "$MVNW_REPOURL" ]; then - jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - else - jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - fi - while IFS="=" read key value; do - case "$key" in (wrapperUrl) jarUrl="$value"; break ;; - esac - done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" - if [ "$MVNW_VERBOSE" = true ]; then - echo "Downloading from: $jarUrl" - fi - wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" - if $cygwin; then - wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` - fi - - if command -v wget > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found wget ... using wget" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - wget "$jarUrl" -O "$wrapperJarPath" - else - wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" - fi - elif command -v curl > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found curl ... using curl" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - curl -o "$wrapperJarPath" "$jarUrl" -f - else - curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f - fi - - else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Falling back to using Java to download" - fi - javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" - # For Cygwin, switch paths to Windows format before running javac - if $cygwin; then - javaClass=`cygpath --path --windows "$javaClass"` - fi - if [ -e "$javaClass" ]; then - if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Compiling MavenWrapperDownloader.java ..." - fi - # Compiling the Java class - ("$JAVA_HOME/bin/javac" "$javaClass") - fi - if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - # Running the downloader - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Running MavenWrapperDownloader.java ..." - fi - ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") - fi - fi - fi -fi -########################################################################################## -# End of extension -########################################################################################## - -export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} -if [ "$MVNW_VERBOSE" = true ]; then - echo $MAVEN_PROJECTBASEDIR + tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar" fi -MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" - -# For Cygwin, switch paths to Windows format before running java -if $cygwin; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --path --windows "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --windows "$CLASSPATH"` - [ -n "$MAVEN_PROJECTBASEDIR" ] && - MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` -fi - -# Provide a "standardized" way to retrieve the CLI args that will -# work with both Windows and non-Windows executions. -MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" -export MAVEN_CMD_LINE_ARGS - -WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain +printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/mvnw.url" +mv -- "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME" -exec "$JAVACMD" \ - $MAVEN_OPTS \ - -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ - "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" +clean || : +exec_maven "$@" diff --git a/projects-parent/originals-parent/airline/mvnw.cmd b/projects-parent/originals-parent/airline/mvnw.cmd index 86115719e..249bdf382 100644 --- a/projects-parent/originals-parent/airline/mvnw.cmd +++ b/projects-parent/originals-parent/airline/mvnw.cmd @@ -1,3 +1,4 @@ +<# : batch portion @REM ---------------------------------------------------------------------------- @REM Licensed to the Apache Software Foundation (ASF) under one @REM or more contributor license agreements. See the NOTICE file @@ -18,165 +19,131 @@ @REM ---------------------------------------------------------------------------- @REM ---------------------------------------------------------------------------- -@REM Maven Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir +@REM Apache Maven Wrapper startup batch script, version 3.3.2 @REM @REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM MVNW_REPOURL - repo url base for downloading maven distribution +@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output @REM ---------------------------------------------------------------------------- -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - -FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( - IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B -) - -@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -@REM This allows using the maven wrapper in projects that prohibit checking in binary data. -if exist %WRAPPER_JAR% ( - if "%MVNW_VERBOSE%" == "true" ( - echo Found %WRAPPER_JAR% - ) -) else ( - if not "%MVNW_REPOURL%" == "" ( - SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - ) - if "%MVNW_VERBOSE%" == "true" ( - echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %DOWNLOAD_URL% - ) - - powershell -Command "&{"^ - "$webclient = new-object System.Net.WebClient;"^ - "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ - "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ - "}"^ - "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ - "}" - if "%MVNW_VERBOSE%" == "true" ( - echo Finished downloading %WRAPPER_JAR% - ) +@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) +@SET __MVNW_CMD__= +@SET __MVNW_ERROR__= +@SET __MVNW_PSMODULEP_SAVE=%PSModulePath% +@SET PSModulePath= +@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( + IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) ) -@REM End of extension - -@REM Provide a "standardized" way to retrieve the CLI args that will -@REM work with both Windows and non-Windows executions. -set MAVEN_CMD_LINE_ARGS=%* - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% +@SET PSModulePath=%__MVNW_PSMODULEP_SAVE% +@SET __MVNW_PSMODULEP_SAVE= +@SET __MVNW_ARG0_NAME__= +@SET MVNW_USERNAME= +@SET MVNW_PASSWORD= +@IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*) +@echo Cannot start maven from wrapper >&2 && exit /b 1 +@GOTO :EOF +: end batch / begin powershell #> + +$ErrorActionPreference = "Stop" +if ($env:MVNW_VERBOSE -eq "true") { + $VerbosePreference = "Continue" +} + +# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties +$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl +if (!$distributionUrl) { + Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" +} + +switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { + "maven-mvnd-*" { + $USE_MVND = $true + $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" + $MVN_CMD = "mvnd.cmd" + break + } + default { + $USE_MVND = $false + $MVN_CMD = $script -replace '^mvnw','mvn' + break + } +} + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +if ($env:MVNW_REPOURL) { + $MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" } + $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')" +} +$distributionUrlName = $distributionUrl -replace '^.*/','' +$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' +$MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain" +if ($env:MAVEN_USER_HOME) { + $MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain" +} +$MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' +$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" + +if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { + Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" + Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" + exit $? +} + +if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { + Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" +} + +# prepare tmp dir +$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile +$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" +$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null +trap { + if ($TMP_DOWNLOAD_DIR.Exists) { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } + } +} + +New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null + +# Download and Install Apache Maven +Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +Write-Verbose "Downloading from: $distributionUrl" +Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +$webclient = New-Object System.Net.WebClient +if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { + $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) +} +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 +$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum +if ($distributionSha256Sum) { + if ($USE_MVND) { + Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." + } + Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash + if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { + Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." + } +} + +# unzip and move +Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null +Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null +try { + Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null +} catch { + if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { + Write-Error "fail to move MAVEN_HOME" + } +} finally { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } +} + +Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" diff --git a/projects-parent/originals-parent/apptbook-web/.mvn/wrapper/MavenWrapperDownloader.java b/projects-parent/originals-parent/apptbook-web/.mvn/wrapper/MavenWrapperDownloader.java deleted file mode 100644 index b901097f2..000000000 --- a/projects-parent/originals-parent/apptbook-web/.mvn/wrapper/MavenWrapperDownloader.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright 2007-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import java.net.*; -import java.io.*; -import java.nio.channels.*; -import java.util.Properties; - -public class MavenWrapperDownloader { - - private static final String WRAPPER_VERSION = "0.5.6"; - /** - * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. - */ - private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" - + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; - - /** - * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to - * use instead of the default one. - */ - private static final String MAVEN_WRAPPER_PROPERTIES_PATH = - ".mvn/wrapper/maven-wrapper.properties"; - - /** - * Path where the maven-wrapper.jar will be saved to. - */ - private static final String MAVEN_WRAPPER_JAR_PATH = - ".mvn/wrapper/maven-wrapper.jar"; - - /** - * Name of the property which should be used to override the default download url for the wrapper. - */ - private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; - - public static void main(String args[]) { - System.out.println("- Downloader started"); - File baseDirectory = new File(args[0]); - System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); - - // If the maven-wrapper.properties exists, read it and check if it contains a custom - // wrapperUrl parameter. - File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); - String url = DEFAULT_DOWNLOAD_URL; - if(mavenWrapperPropertyFile.exists()) { - FileInputStream mavenWrapperPropertyFileInputStream = null; - try { - mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); - Properties mavenWrapperProperties = new Properties(); - mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); - url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); - } catch (IOException e) { - System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); - } finally { - try { - if(mavenWrapperPropertyFileInputStream != null) { - mavenWrapperPropertyFileInputStream.close(); - } - } catch (IOException e) { - // Ignore ... - } - } - } - System.out.println("- Downloading from: " + url); - - File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); - if(!outputFile.getParentFile().exists()) { - if(!outputFile.getParentFile().mkdirs()) { - System.out.println( - "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); - } - } - System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); - try { - downloadFileFromURL(url, outputFile); - System.out.println("Done"); - System.exit(0); - } catch (Throwable e) { - System.out.println("- Error downloading"); - e.printStackTrace(); - System.exit(1); - } - } - - private static void downloadFileFromURL(String urlString, File destination) throws Exception { - if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { - String username = System.getenv("MVNW_USERNAME"); - char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); - Authenticator.setDefault(new Authenticator() { - @Override - protected PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication(username, password); - } - }); - } - URL website = new URL(urlString); - ReadableByteChannel rbc; - rbc = Channels.newChannel(website.openStream()); - FileOutputStream fos = new FileOutputStream(destination); - fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); - fos.close(); - rbc.close(); - } - -} diff --git a/projects-parent/originals-parent/apptbook-web/.mvn/wrapper/maven-wrapper.properties b/projects-parent/originals-parent/apptbook-web/.mvn/wrapper/maven-wrapper.properties index 5d43cd338..d58dfb70b 100644 --- a/projects-parent/originals-parent/apptbook-web/.mvn/wrapper/maven-wrapper.properties +++ b/projects-parent/originals-parent/apptbook-web/.mvn/wrapper/maven-wrapper.properties @@ -1,2 +1,19 @@ -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +wrapperVersion=3.3.2 +distributionType=only-script +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip diff --git a/projects-parent/originals-parent/apptbook-web/mvnw b/projects-parent/originals-parent/apptbook-web/mvnw index 41c0f0c23..19529ddf8 100755 --- a/projects-parent/originals-parent/apptbook-web/mvnw +++ b/projects-parent/originals-parent/apptbook-web/mvnw @@ -19,292 +19,241 @@ # ---------------------------------------------------------------------------- # ---------------------------------------------------------------------------- -# Maven Start Up Batch script -# -# Required ENV vars: -# ------------------ -# JAVA_HOME - location of a JDK home dir +# Apache Maven Wrapper startup batch script, version 3.3.2 # # Optional ENV vars # ----------------- -# M2_HOME - location of maven2's installed home dir -# MAVEN_OPTS - parameters passed to the Java VM when running Maven -# e.g. to debug Maven itself, use -# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# JAVA_HOME - location of a JDK home dir, required when download maven via java source +# MVNW_REPOURL - repo url base for downloading maven distribution +# MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +# MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output # ---------------------------------------------------------------------------- -if [ -z "$MAVEN_SKIP_RC" ] ; then - - if [ -f /etc/mavenrc ] ; then - . /etc/mavenrc - fi +set -euf +[ "${MVNW_VERBOSE-}" != debug ] || set -x - if [ -f "$HOME/.mavenrc" ] ; then - . "$HOME/.mavenrc" - fi +# OS specific support. +native_path() { printf %s\\n "$1"; } +case "$(uname)" in +CYGWIN* | MINGW*) + [ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")" + native_path() { cygpath --path --windows "$1"; } + ;; +esac -fi +# set JAVACMD and JAVACCMD +set_java_home() { + # For Cygwin and MinGW, ensure paths are in Unix format before anything is touched + if [ -n "${JAVA_HOME-}" ]; then + if [ -x "$JAVA_HOME/jre/sh/java" ]; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACCMD="$JAVA_HOME/jre/sh/javac" + else + JAVACMD="$JAVA_HOME/bin/java" + JAVACCMD="$JAVA_HOME/bin/javac" -# OS specific support. $var _must_ be set to either true or false. -cygwin=false; -darwin=false; -mingw=false -case "`uname`" in - CYGWIN*) cygwin=true ;; - MINGW*) mingw=true;; - Darwin*) darwin=true - # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home - # See https://developer.apple.com/library/mac/qa/qa1170/_index.html - if [ -z "$JAVA_HOME" ]; then - if [ -x "/usr/libexec/java_home" ]; then - export JAVA_HOME="`/usr/libexec/java_home`" - else - export JAVA_HOME="/Library/Java/Home" + if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then + echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2 + echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2 + return 1 fi fi - ;; -esac - -if [ -z "$JAVA_HOME" ] ; then - if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=`java-config --jre-home` + else + JAVACMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v java + )" || : + JAVACCMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v javac + )" || : + + if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then + echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2 + return 1 + fi fi -fi - -if [ -z "$M2_HOME" ] ; then - ## resolve links - $0 may be a link to maven's home - PRG="$0" +} - # need this for relative symlinks - while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG="`dirname "$PRG"`/$link" - fi +# hash string like Java String::hashCode +hash_string() { + str="${1:-}" h=0 + while [ -n "$str" ]; do + char="${str%"${str#?}"}" + h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296)) + str="${str#?}" done + printf %x\\n $h +} - saveddir=`pwd` +verbose() { :; } +[ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; } - M2_HOME=`dirname "$PRG"`/.. +die() { + printf %s\\n "$1" >&2 + exit 1 +} - # make it fully qualified - M2_HOME=`cd "$M2_HOME" && pwd` +trim() { + # MWRAPPER-139: + # Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds. + # Needed for removing poorly interpreted newline sequences when running in more + # exotic environments such as mingw bash on Windows. + printf "%s" "${1}" | tr -d '[:space:]' +} - cd "$saveddir" - # echo Using m2 at $M2_HOME -fi +# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties +while IFS="=" read -r key value; do + case "${key-}" in + distributionUrl) distributionUrl=$(trim "${value-}") ;; + distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;; + esac +done <"${0%/*}/.mvn/wrapper/maven-wrapper.properties" +[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in ${0%/*}/.mvn/wrapper/maven-wrapper.properties" + +case "${distributionUrl##*/}" in +maven-mvnd-*bin.*) + MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ + case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in + *AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;; + :Darwin*x86_64) distributionPlatform=darwin-amd64 ;; + :Darwin*arm64) distributionPlatform=darwin-aarch64 ;; + :Linux*x86_64*) distributionPlatform=linux-amd64 ;; + *) + echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2 + distributionPlatform=linux-amd64 + ;; + esac + distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip" + ;; +maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;; +*) MVN_CMD="mvn${0##*/mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;; +esac -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin ; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --unix "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` -fi +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}" +distributionUrlName="${distributionUrl##*/}" +distributionUrlNameMain="${distributionUrlName%.*}" +distributionUrlNameMain="${distributionUrlNameMain%-bin}" +MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}" +MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")" + +exec_maven() { + unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || : + exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD" +} -# For Mingw, ensure paths are in UNIX format before anything is touched -if $mingw ; then - [ -n "$M2_HOME" ] && - M2_HOME="`(cd "$M2_HOME"; pwd)`" - [ -n "$JAVA_HOME" ] && - JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +if [ -d "$MAVEN_HOME" ]; then + verbose "found existing MAVEN_HOME at $MAVEN_HOME" + exec_maven "$@" fi -if [ -z "$JAVA_HOME" ]; then - javaExecutable="`which javac`" - if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then - # readlink(1) is not available as standard on Solaris 10. - readLink=`which readlink` - if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then - if $darwin ; then - javaHome="`dirname \"$javaExecutable\"`" - javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" - else - javaExecutable="`readlink -f \"$javaExecutable\"`" - fi - javaHome="`dirname \"$javaExecutable\"`" - javaHome=`expr "$javaHome" : '\(.*\)/bin'` - JAVA_HOME="$javaHome" - export JAVA_HOME - fi - fi -fi +case "${distributionUrl-}" in +*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;; +*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;; +esac -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - else - JAVACMD="`which java`" - fi +# prepare tmp dir +if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then + clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; } + trap clean HUP INT TERM EXIT +else + die "cannot create temp dir" fi -if [ ! -x "$JAVACMD" ] ; then - echo "Error: JAVA_HOME is not defined correctly." >&2 - echo " We cannot execute $JAVACMD" >&2 - exit 1 -fi +mkdir -p -- "${MAVEN_HOME%/*}" + +# Download and Install Apache Maven +verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +verbose "Downloading from: $distributionUrl" +verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" -if [ -z "$JAVA_HOME" ] ; then - echo "Warning: JAVA_HOME environment variable is not set." +# select .zip or .tar.gz +if ! command -v unzip >/dev/null; then + distributionUrl="${distributionUrl%.zip}.tar.gz" + distributionUrlName="${distributionUrl##*/}" fi -CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher +# verbose opt +__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR='' +[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v -# traverses directory structure from process work directory to filesystem root -# first directory with .mvn subdirectory is considered project base directory -find_maven_basedir() { +# normalize http auth +case "${MVNW_PASSWORD:+has-password}" in +'') MVNW_USERNAME='' MVNW_PASSWORD='' ;; +has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;; +esac - if [ -z "$1" ] - then - echo "Path not specified to find_maven_basedir" - return 1 - fi +if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then + verbose "Found wget ... using wget" + wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl" +elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then + verbose "Found curl ... using curl" + curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl" +elif set_java_home; then + verbose "Falling back to use Java to download" + javaSource="$TMP_DOWNLOAD_DIR/Downloader.java" + targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName" + cat >"$javaSource" <<-END + public class Downloader extends java.net.Authenticator + { + protected java.net.PasswordAuthentication getPasswordAuthentication() + { + return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() ); + } + public static void main( String[] args ) throws Exception + { + setDefault( new Downloader() ); + java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() ); + } + } + END + # For Cygwin/MinGW, switch paths to Windows format before running javac and java + verbose " - Compiling Downloader.java ..." + "$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java" + verbose " - Running Downloader.java ..." + "$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")" +fi - basedir="$1" - wdir="$1" - while [ "$wdir" != '/' ] ; do - if [ -d "$wdir"/.mvn ] ; then - basedir=$wdir - break +# If specified, validate the SHA-256 sum of the Maven distribution zip file +if [ -n "${distributionSha256Sum-}" ]; then + distributionSha256Result=false + if [ "$MVN_CMD" = mvnd.sh ]; then + echo "Checksum validation is not supported for maven-mvnd." >&2 + echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + elif command -v sha256sum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c >/dev/null 2>&1; then + distributionSha256Result=true fi - # workaround for JBEAP-8937 (on Solaris 10/Sparc) - if [ -d "${wdir}" ]; then - wdir=`cd "$wdir/.."; pwd` + elif command -v shasum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then + distributionSha256Result=true fi - # end of workaround - done - echo "${basedir}" -} - -# concatenates all lines of a file -concat_lines() { - if [ -f "$1" ]; then - echo "$(tr -s '\n' ' ' < "$1")" + else + echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2 + echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + fi + if [ $distributionSha256Result = false ]; then + echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2 + echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2 + exit 1 fi -} - -BASE_DIR=`find_maven_basedir "$(pwd)"` -if [ -z "$BASE_DIR" ]; then - exit 1; fi -########################################################################################## -# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -# This allows using the maven wrapper in projects that prohibit checking in binary data. -########################################################################################## -if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found .mvn/wrapper/maven-wrapper.jar" - fi +# unzip and move +if command -v unzip >/dev/null; then + unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip" else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." - fi - if [ -n "$MVNW_REPOURL" ]; then - jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - else - jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - fi - while IFS="=" read key value; do - case "$key" in (wrapperUrl) jarUrl="$value"; break ;; - esac - done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" - if [ "$MVNW_VERBOSE" = true ]; then - echo "Downloading from: $jarUrl" - fi - wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" - if $cygwin; then - wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` - fi - - if command -v wget > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found wget ... using wget" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - wget "$jarUrl" -O "$wrapperJarPath" - else - wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" - fi - elif command -v curl > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found curl ... using curl" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - curl -o "$wrapperJarPath" "$jarUrl" -f - else - curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f - fi - - else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Falling back to using Java to download" - fi - javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" - # For Cygwin, switch paths to Windows format before running javac - if $cygwin; then - javaClass=`cygpath --path --windows "$javaClass"` - fi - if [ -e "$javaClass" ]; then - if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Compiling MavenWrapperDownloader.java ..." - fi - # Compiling the Java class - ("$JAVA_HOME/bin/javac" "$javaClass") - fi - if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - # Running the downloader - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Running MavenWrapperDownloader.java ..." - fi - ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") - fi - fi - fi -fi -########################################################################################## -# End of extension -########################################################################################## - -export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} -if [ "$MVNW_VERBOSE" = true ]; then - echo $MAVEN_PROJECTBASEDIR + tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar" fi -MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" - -# For Cygwin, switch paths to Windows format before running java -if $cygwin; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --path --windows "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --windows "$CLASSPATH"` - [ -n "$MAVEN_PROJECTBASEDIR" ] && - MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` -fi - -# Provide a "standardized" way to retrieve the CLI args that will -# work with both Windows and non-Windows executions. -MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" -export MAVEN_CMD_LINE_ARGS - -WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain +printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/mvnw.url" +mv -- "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME" -exec "$JAVACMD" \ - $MAVEN_OPTS \ - -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ - "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" +clean || : +exec_maven "$@" diff --git a/projects-parent/originals-parent/apptbook-web/mvnw.cmd b/projects-parent/originals-parent/apptbook-web/mvnw.cmd index 86115719e..249bdf382 100644 --- a/projects-parent/originals-parent/apptbook-web/mvnw.cmd +++ b/projects-parent/originals-parent/apptbook-web/mvnw.cmd @@ -1,3 +1,4 @@ +<# : batch portion @REM ---------------------------------------------------------------------------- @REM Licensed to the Apache Software Foundation (ASF) under one @REM or more contributor license agreements. See the NOTICE file @@ -18,165 +19,131 @@ @REM ---------------------------------------------------------------------------- @REM ---------------------------------------------------------------------------- -@REM Maven Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir +@REM Apache Maven Wrapper startup batch script, version 3.3.2 @REM @REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM MVNW_REPOURL - repo url base for downloading maven distribution +@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output @REM ---------------------------------------------------------------------------- -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - -FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( - IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B -) - -@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -@REM This allows using the maven wrapper in projects that prohibit checking in binary data. -if exist %WRAPPER_JAR% ( - if "%MVNW_VERBOSE%" == "true" ( - echo Found %WRAPPER_JAR% - ) -) else ( - if not "%MVNW_REPOURL%" == "" ( - SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - ) - if "%MVNW_VERBOSE%" == "true" ( - echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %DOWNLOAD_URL% - ) - - powershell -Command "&{"^ - "$webclient = new-object System.Net.WebClient;"^ - "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ - "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ - "}"^ - "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ - "}" - if "%MVNW_VERBOSE%" == "true" ( - echo Finished downloading %WRAPPER_JAR% - ) +@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) +@SET __MVNW_CMD__= +@SET __MVNW_ERROR__= +@SET __MVNW_PSMODULEP_SAVE=%PSModulePath% +@SET PSModulePath= +@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( + IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) ) -@REM End of extension - -@REM Provide a "standardized" way to retrieve the CLI args that will -@REM work with both Windows and non-Windows executions. -set MAVEN_CMD_LINE_ARGS=%* - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% +@SET PSModulePath=%__MVNW_PSMODULEP_SAVE% +@SET __MVNW_PSMODULEP_SAVE= +@SET __MVNW_ARG0_NAME__= +@SET MVNW_USERNAME= +@SET MVNW_PASSWORD= +@IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*) +@echo Cannot start maven from wrapper >&2 && exit /b 1 +@GOTO :EOF +: end batch / begin powershell #> + +$ErrorActionPreference = "Stop" +if ($env:MVNW_VERBOSE -eq "true") { + $VerbosePreference = "Continue" +} + +# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties +$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl +if (!$distributionUrl) { + Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" +} + +switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { + "maven-mvnd-*" { + $USE_MVND = $true + $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" + $MVN_CMD = "mvnd.cmd" + break + } + default { + $USE_MVND = $false + $MVN_CMD = $script -replace '^mvnw','mvn' + break + } +} + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +if ($env:MVNW_REPOURL) { + $MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" } + $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')" +} +$distributionUrlName = $distributionUrl -replace '^.*/','' +$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' +$MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain" +if ($env:MAVEN_USER_HOME) { + $MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain" +} +$MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' +$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" + +if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { + Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" + Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" + exit $? +} + +if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { + Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" +} + +# prepare tmp dir +$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile +$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" +$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null +trap { + if ($TMP_DOWNLOAD_DIR.Exists) { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } + } +} + +New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null + +# Download and Install Apache Maven +Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +Write-Verbose "Downloading from: $distributionUrl" +Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +$webclient = New-Object System.Net.WebClient +if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { + $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) +} +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 +$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum +if ($distributionSha256Sum) { + if ($USE_MVND) { + Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." + } + Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash + if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { + Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." + } +} + +# unzip and move +Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null +Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null +try { + Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null +} catch { + if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { + Write-Error "fail to move MAVEN_HOME" + } +} finally { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } +} + +Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" diff --git a/projects-parent/originals-parent/apptbook/.mvn/wrapper/MavenWrapperDownloader.java b/projects-parent/originals-parent/apptbook/.mvn/wrapper/MavenWrapperDownloader.java deleted file mode 100644 index b901097f2..000000000 --- a/projects-parent/originals-parent/apptbook/.mvn/wrapper/MavenWrapperDownloader.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright 2007-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import java.net.*; -import java.io.*; -import java.nio.channels.*; -import java.util.Properties; - -public class MavenWrapperDownloader { - - private static final String WRAPPER_VERSION = "0.5.6"; - /** - * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. - */ - private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" - + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; - - /** - * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to - * use instead of the default one. - */ - private static final String MAVEN_WRAPPER_PROPERTIES_PATH = - ".mvn/wrapper/maven-wrapper.properties"; - - /** - * Path where the maven-wrapper.jar will be saved to. - */ - private static final String MAVEN_WRAPPER_JAR_PATH = - ".mvn/wrapper/maven-wrapper.jar"; - - /** - * Name of the property which should be used to override the default download url for the wrapper. - */ - private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; - - public static void main(String args[]) { - System.out.println("- Downloader started"); - File baseDirectory = new File(args[0]); - System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); - - // If the maven-wrapper.properties exists, read it and check if it contains a custom - // wrapperUrl parameter. - File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); - String url = DEFAULT_DOWNLOAD_URL; - if(mavenWrapperPropertyFile.exists()) { - FileInputStream mavenWrapperPropertyFileInputStream = null; - try { - mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); - Properties mavenWrapperProperties = new Properties(); - mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); - url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); - } catch (IOException e) { - System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); - } finally { - try { - if(mavenWrapperPropertyFileInputStream != null) { - mavenWrapperPropertyFileInputStream.close(); - } - } catch (IOException e) { - // Ignore ... - } - } - } - System.out.println("- Downloading from: " + url); - - File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); - if(!outputFile.getParentFile().exists()) { - if(!outputFile.getParentFile().mkdirs()) { - System.out.println( - "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); - } - } - System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); - try { - downloadFileFromURL(url, outputFile); - System.out.println("Done"); - System.exit(0); - } catch (Throwable e) { - System.out.println("- Error downloading"); - e.printStackTrace(); - System.exit(1); - } - } - - private static void downloadFileFromURL(String urlString, File destination) throws Exception { - if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { - String username = System.getenv("MVNW_USERNAME"); - char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); - Authenticator.setDefault(new Authenticator() { - @Override - protected PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication(username, password); - } - }); - } - URL website = new URL(urlString); - ReadableByteChannel rbc; - rbc = Channels.newChannel(website.openStream()); - FileOutputStream fos = new FileOutputStream(destination); - fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); - fos.close(); - rbc.close(); - } - -} diff --git a/projects-parent/originals-parent/apptbook/.mvn/wrapper/maven-wrapper.properties b/projects-parent/originals-parent/apptbook/.mvn/wrapper/maven-wrapper.properties index 5d43cd338..d58dfb70b 100644 --- a/projects-parent/originals-parent/apptbook/.mvn/wrapper/maven-wrapper.properties +++ b/projects-parent/originals-parent/apptbook/.mvn/wrapper/maven-wrapper.properties @@ -1,2 +1,19 @@ -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +wrapperVersion=3.3.2 +distributionType=only-script +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip diff --git a/projects-parent/originals-parent/apptbook/mvnw b/projects-parent/originals-parent/apptbook/mvnw index 41c0f0c23..19529ddf8 100755 --- a/projects-parent/originals-parent/apptbook/mvnw +++ b/projects-parent/originals-parent/apptbook/mvnw @@ -19,292 +19,241 @@ # ---------------------------------------------------------------------------- # ---------------------------------------------------------------------------- -# Maven Start Up Batch script -# -# Required ENV vars: -# ------------------ -# JAVA_HOME - location of a JDK home dir +# Apache Maven Wrapper startup batch script, version 3.3.2 # # Optional ENV vars # ----------------- -# M2_HOME - location of maven2's installed home dir -# MAVEN_OPTS - parameters passed to the Java VM when running Maven -# e.g. to debug Maven itself, use -# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# JAVA_HOME - location of a JDK home dir, required when download maven via java source +# MVNW_REPOURL - repo url base for downloading maven distribution +# MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +# MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output # ---------------------------------------------------------------------------- -if [ -z "$MAVEN_SKIP_RC" ] ; then - - if [ -f /etc/mavenrc ] ; then - . /etc/mavenrc - fi +set -euf +[ "${MVNW_VERBOSE-}" != debug ] || set -x - if [ -f "$HOME/.mavenrc" ] ; then - . "$HOME/.mavenrc" - fi +# OS specific support. +native_path() { printf %s\\n "$1"; } +case "$(uname)" in +CYGWIN* | MINGW*) + [ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")" + native_path() { cygpath --path --windows "$1"; } + ;; +esac -fi +# set JAVACMD and JAVACCMD +set_java_home() { + # For Cygwin and MinGW, ensure paths are in Unix format before anything is touched + if [ -n "${JAVA_HOME-}" ]; then + if [ -x "$JAVA_HOME/jre/sh/java" ]; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACCMD="$JAVA_HOME/jre/sh/javac" + else + JAVACMD="$JAVA_HOME/bin/java" + JAVACCMD="$JAVA_HOME/bin/javac" -# OS specific support. $var _must_ be set to either true or false. -cygwin=false; -darwin=false; -mingw=false -case "`uname`" in - CYGWIN*) cygwin=true ;; - MINGW*) mingw=true;; - Darwin*) darwin=true - # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home - # See https://developer.apple.com/library/mac/qa/qa1170/_index.html - if [ -z "$JAVA_HOME" ]; then - if [ -x "/usr/libexec/java_home" ]; then - export JAVA_HOME="`/usr/libexec/java_home`" - else - export JAVA_HOME="/Library/Java/Home" + if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then + echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2 + echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2 + return 1 fi fi - ;; -esac - -if [ -z "$JAVA_HOME" ] ; then - if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=`java-config --jre-home` + else + JAVACMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v java + )" || : + JAVACCMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v javac + )" || : + + if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then + echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2 + return 1 + fi fi -fi - -if [ -z "$M2_HOME" ] ; then - ## resolve links - $0 may be a link to maven's home - PRG="$0" +} - # need this for relative symlinks - while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG="`dirname "$PRG"`/$link" - fi +# hash string like Java String::hashCode +hash_string() { + str="${1:-}" h=0 + while [ -n "$str" ]; do + char="${str%"${str#?}"}" + h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296)) + str="${str#?}" done + printf %x\\n $h +} - saveddir=`pwd` +verbose() { :; } +[ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; } - M2_HOME=`dirname "$PRG"`/.. +die() { + printf %s\\n "$1" >&2 + exit 1 +} - # make it fully qualified - M2_HOME=`cd "$M2_HOME" && pwd` +trim() { + # MWRAPPER-139: + # Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds. + # Needed for removing poorly interpreted newline sequences when running in more + # exotic environments such as mingw bash on Windows. + printf "%s" "${1}" | tr -d '[:space:]' +} - cd "$saveddir" - # echo Using m2 at $M2_HOME -fi +# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties +while IFS="=" read -r key value; do + case "${key-}" in + distributionUrl) distributionUrl=$(trim "${value-}") ;; + distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;; + esac +done <"${0%/*}/.mvn/wrapper/maven-wrapper.properties" +[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in ${0%/*}/.mvn/wrapper/maven-wrapper.properties" + +case "${distributionUrl##*/}" in +maven-mvnd-*bin.*) + MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ + case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in + *AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;; + :Darwin*x86_64) distributionPlatform=darwin-amd64 ;; + :Darwin*arm64) distributionPlatform=darwin-aarch64 ;; + :Linux*x86_64*) distributionPlatform=linux-amd64 ;; + *) + echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2 + distributionPlatform=linux-amd64 + ;; + esac + distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip" + ;; +maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;; +*) MVN_CMD="mvn${0##*/mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;; +esac -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin ; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --unix "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` -fi +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}" +distributionUrlName="${distributionUrl##*/}" +distributionUrlNameMain="${distributionUrlName%.*}" +distributionUrlNameMain="${distributionUrlNameMain%-bin}" +MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}" +MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")" + +exec_maven() { + unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || : + exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD" +} -# For Mingw, ensure paths are in UNIX format before anything is touched -if $mingw ; then - [ -n "$M2_HOME" ] && - M2_HOME="`(cd "$M2_HOME"; pwd)`" - [ -n "$JAVA_HOME" ] && - JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +if [ -d "$MAVEN_HOME" ]; then + verbose "found existing MAVEN_HOME at $MAVEN_HOME" + exec_maven "$@" fi -if [ -z "$JAVA_HOME" ]; then - javaExecutable="`which javac`" - if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then - # readlink(1) is not available as standard on Solaris 10. - readLink=`which readlink` - if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then - if $darwin ; then - javaHome="`dirname \"$javaExecutable\"`" - javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" - else - javaExecutable="`readlink -f \"$javaExecutable\"`" - fi - javaHome="`dirname \"$javaExecutable\"`" - javaHome=`expr "$javaHome" : '\(.*\)/bin'` - JAVA_HOME="$javaHome" - export JAVA_HOME - fi - fi -fi +case "${distributionUrl-}" in +*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;; +*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;; +esac -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - else - JAVACMD="`which java`" - fi +# prepare tmp dir +if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then + clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; } + trap clean HUP INT TERM EXIT +else + die "cannot create temp dir" fi -if [ ! -x "$JAVACMD" ] ; then - echo "Error: JAVA_HOME is not defined correctly." >&2 - echo " We cannot execute $JAVACMD" >&2 - exit 1 -fi +mkdir -p -- "${MAVEN_HOME%/*}" + +# Download and Install Apache Maven +verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +verbose "Downloading from: $distributionUrl" +verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" -if [ -z "$JAVA_HOME" ] ; then - echo "Warning: JAVA_HOME environment variable is not set." +# select .zip or .tar.gz +if ! command -v unzip >/dev/null; then + distributionUrl="${distributionUrl%.zip}.tar.gz" + distributionUrlName="${distributionUrl##*/}" fi -CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher +# verbose opt +__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR='' +[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v -# traverses directory structure from process work directory to filesystem root -# first directory with .mvn subdirectory is considered project base directory -find_maven_basedir() { +# normalize http auth +case "${MVNW_PASSWORD:+has-password}" in +'') MVNW_USERNAME='' MVNW_PASSWORD='' ;; +has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;; +esac - if [ -z "$1" ] - then - echo "Path not specified to find_maven_basedir" - return 1 - fi +if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then + verbose "Found wget ... using wget" + wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl" +elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then + verbose "Found curl ... using curl" + curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl" +elif set_java_home; then + verbose "Falling back to use Java to download" + javaSource="$TMP_DOWNLOAD_DIR/Downloader.java" + targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName" + cat >"$javaSource" <<-END + public class Downloader extends java.net.Authenticator + { + protected java.net.PasswordAuthentication getPasswordAuthentication() + { + return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() ); + } + public static void main( String[] args ) throws Exception + { + setDefault( new Downloader() ); + java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() ); + } + } + END + # For Cygwin/MinGW, switch paths to Windows format before running javac and java + verbose " - Compiling Downloader.java ..." + "$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java" + verbose " - Running Downloader.java ..." + "$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")" +fi - basedir="$1" - wdir="$1" - while [ "$wdir" != '/' ] ; do - if [ -d "$wdir"/.mvn ] ; then - basedir=$wdir - break +# If specified, validate the SHA-256 sum of the Maven distribution zip file +if [ -n "${distributionSha256Sum-}" ]; then + distributionSha256Result=false + if [ "$MVN_CMD" = mvnd.sh ]; then + echo "Checksum validation is not supported for maven-mvnd." >&2 + echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + elif command -v sha256sum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c >/dev/null 2>&1; then + distributionSha256Result=true fi - # workaround for JBEAP-8937 (on Solaris 10/Sparc) - if [ -d "${wdir}" ]; then - wdir=`cd "$wdir/.."; pwd` + elif command -v shasum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then + distributionSha256Result=true fi - # end of workaround - done - echo "${basedir}" -} - -# concatenates all lines of a file -concat_lines() { - if [ -f "$1" ]; then - echo "$(tr -s '\n' ' ' < "$1")" + else + echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2 + echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + fi + if [ $distributionSha256Result = false ]; then + echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2 + echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2 + exit 1 fi -} - -BASE_DIR=`find_maven_basedir "$(pwd)"` -if [ -z "$BASE_DIR" ]; then - exit 1; fi -########################################################################################## -# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -# This allows using the maven wrapper in projects that prohibit checking in binary data. -########################################################################################## -if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found .mvn/wrapper/maven-wrapper.jar" - fi +# unzip and move +if command -v unzip >/dev/null; then + unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip" else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." - fi - if [ -n "$MVNW_REPOURL" ]; then - jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - else - jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - fi - while IFS="=" read key value; do - case "$key" in (wrapperUrl) jarUrl="$value"; break ;; - esac - done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" - if [ "$MVNW_VERBOSE" = true ]; then - echo "Downloading from: $jarUrl" - fi - wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" - if $cygwin; then - wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` - fi - - if command -v wget > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found wget ... using wget" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - wget "$jarUrl" -O "$wrapperJarPath" - else - wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" - fi - elif command -v curl > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found curl ... using curl" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - curl -o "$wrapperJarPath" "$jarUrl" -f - else - curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f - fi - - else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Falling back to using Java to download" - fi - javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" - # For Cygwin, switch paths to Windows format before running javac - if $cygwin; then - javaClass=`cygpath --path --windows "$javaClass"` - fi - if [ -e "$javaClass" ]; then - if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Compiling MavenWrapperDownloader.java ..." - fi - # Compiling the Java class - ("$JAVA_HOME/bin/javac" "$javaClass") - fi - if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - # Running the downloader - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Running MavenWrapperDownloader.java ..." - fi - ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") - fi - fi - fi -fi -########################################################################################## -# End of extension -########################################################################################## - -export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} -if [ "$MVNW_VERBOSE" = true ]; then - echo $MAVEN_PROJECTBASEDIR + tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar" fi -MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" - -# For Cygwin, switch paths to Windows format before running java -if $cygwin; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --path --windows "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --windows "$CLASSPATH"` - [ -n "$MAVEN_PROJECTBASEDIR" ] && - MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` -fi - -# Provide a "standardized" way to retrieve the CLI args that will -# work with both Windows and non-Windows executions. -MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" -export MAVEN_CMD_LINE_ARGS - -WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain +printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/mvnw.url" +mv -- "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME" -exec "$JAVACMD" \ - $MAVEN_OPTS \ - -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ - "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" +clean || : +exec_maven "$@" diff --git a/projects-parent/originals-parent/apptbook/mvnw.cmd b/projects-parent/originals-parent/apptbook/mvnw.cmd index 86115719e..249bdf382 100644 --- a/projects-parent/originals-parent/apptbook/mvnw.cmd +++ b/projects-parent/originals-parent/apptbook/mvnw.cmd @@ -1,3 +1,4 @@ +<# : batch portion @REM ---------------------------------------------------------------------------- @REM Licensed to the Apache Software Foundation (ASF) under one @REM or more contributor license agreements. See the NOTICE file @@ -18,165 +19,131 @@ @REM ---------------------------------------------------------------------------- @REM ---------------------------------------------------------------------------- -@REM Maven Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir +@REM Apache Maven Wrapper startup batch script, version 3.3.2 @REM @REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM MVNW_REPOURL - repo url base for downloading maven distribution +@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output @REM ---------------------------------------------------------------------------- -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - -FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( - IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B -) - -@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -@REM This allows using the maven wrapper in projects that prohibit checking in binary data. -if exist %WRAPPER_JAR% ( - if "%MVNW_VERBOSE%" == "true" ( - echo Found %WRAPPER_JAR% - ) -) else ( - if not "%MVNW_REPOURL%" == "" ( - SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - ) - if "%MVNW_VERBOSE%" == "true" ( - echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %DOWNLOAD_URL% - ) - - powershell -Command "&{"^ - "$webclient = new-object System.Net.WebClient;"^ - "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ - "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ - "}"^ - "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ - "}" - if "%MVNW_VERBOSE%" == "true" ( - echo Finished downloading %WRAPPER_JAR% - ) +@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) +@SET __MVNW_CMD__= +@SET __MVNW_ERROR__= +@SET __MVNW_PSMODULEP_SAVE=%PSModulePath% +@SET PSModulePath= +@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( + IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) ) -@REM End of extension - -@REM Provide a "standardized" way to retrieve the CLI args that will -@REM work with both Windows and non-Windows executions. -set MAVEN_CMD_LINE_ARGS=%* - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% +@SET PSModulePath=%__MVNW_PSMODULEP_SAVE% +@SET __MVNW_PSMODULEP_SAVE= +@SET __MVNW_ARG0_NAME__= +@SET MVNW_USERNAME= +@SET MVNW_PASSWORD= +@IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*) +@echo Cannot start maven from wrapper >&2 && exit /b 1 +@GOTO :EOF +: end batch / begin powershell #> + +$ErrorActionPreference = "Stop" +if ($env:MVNW_VERBOSE -eq "true") { + $VerbosePreference = "Continue" +} + +# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties +$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl +if (!$distributionUrl) { + Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" +} + +switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { + "maven-mvnd-*" { + $USE_MVND = $true + $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" + $MVN_CMD = "mvnd.cmd" + break + } + default { + $USE_MVND = $false + $MVN_CMD = $script -replace '^mvnw','mvn' + break + } +} + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +if ($env:MVNW_REPOURL) { + $MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" } + $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')" +} +$distributionUrlName = $distributionUrl -replace '^.*/','' +$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' +$MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain" +if ($env:MAVEN_USER_HOME) { + $MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain" +} +$MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' +$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" + +if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { + Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" + Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" + exit $? +} + +if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { + Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" +} + +# prepare tmp dir +$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile +$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" +$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null +trap { + if ($TMP_DOWNLOAD_DIR.Exists) { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } + } +} + +New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null + +# Download and Install Apache Maven +Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +Write-Verbose "Downloading from: $distributionUrl" +Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +$webclient = New-Object System.Net.WebClient +if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { + $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) +} +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 +$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum +if ($distributionSha256Sum) { + if ($USE_MVND) { + Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." + } + Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash + if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { + Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." + } +} + +# unzip and move +Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null +Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null +try { + Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null +} catch { + if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { + Write-Error "fail to move MAVEN_HOME" + } +} finally { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } +} + +Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" diff --git a/projects-parent/originals-parent/kata/.mvn/wrapper/MavenWrapperDownloader.java b/projects-parent/originals-parent/kata/.mvn/wrapper/MavenWrapperDownloader.java deleted file mode 100644 index b901097f2..000000000 --- a/projects-parent/originals-parent/kata/.mvn/wrapper/MavenWrapperDownloader.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright 2007-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import java.net.*; -import java.io.*; -import java.nio.channels.*; -import java.util.Properties; - -public class MavenWrapperDownloader { - - private static final String WRAPPER_VERSION = "0.5.6"; - /** - * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. - */ - private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" - + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; - - /** - * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to - * use instead of the default one. - */ - private static final String MAVEN_WRAPPER_PROPERTIES_PATH = - ".mvn/wrapper/maven-wrapper.properties"; - - /** - * Path where the maven-wrapper.jar will be saved to. - */ - private static final String MAVEN_WRAPPER_JAR_PATH = - ".mvn/wrapper/maven-wrapper.jar"; - - /** - * Name of the property which should be used to override the default download url for the wrapper. - */ - private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; - - public static void main(String args[]) { - System.out.println("- Downloader started"); - File baseDirectory = new File(args[0]); - System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); - - // If the maven-wrapper.properties exists, read it and check if it contains a custom - // wrapperUrl parameter. - File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); - String url = DEFAULT_DOWNLOAD_URL; - if(mavenWrapperPropertyFile.exists()) { - FileInputStream mavenWrapperPropertyFileInputStream = null; - try { - mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); - Properties mavenWrapperProperties = new Properties(); - mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); - url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); - } catch (IOException e) { - System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); - } finally { - try { - if(mavenWrapperPropertyFileInputStream != null) { - mavenWrapperPropertyFileInputStream.close(); - } - } catch (IOException e) { - // Ignore ... - } - } - } - System.out.println("- Downloading from: " + url); - - File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); - if(!outputFile.getParentFile().exists()) { - if(!outputFile.getParentFile().mkdirs()) { - System.out.println( - "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); - } - } - System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); - try { - downloadFileFromURL(url, outputFile); - System.out.println("Done"); - System.exit(0); - } catch (Throwable e) { - System.out.println("- Error downloading"); - e.printStackTrace(); - System.exit(1); - } - } - - private static void downloadFileFromURL(String urlString, File destination) throws Exception { - if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { - String username = System.getenv("MVNW_USERNAME"); - char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); - Authenticator.setDefault(new Authenticator() { - @Override - protected PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication(username, password); - } - }); - } - URL website = new URL(urlString); - ReadableByteChannel rbc; - rbc = Channels.newChannel(website.openStream()); - FileOutputStream fos = new FileOutputStream(destination); - fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); - fos.close(); - rbc.close(); - } - -} diff --git a/projects-parent/originals-parent/kata/.mvn/wrapper/maven-wrapper.properties b/projects-parent/originals-parent/kata/.mvn/wrapper/maven-wrapper.properties index 5d43cd338..d58dfb70b 100644 --- a/projects-parent/originals-parent/kata/.mvn/wrapper/maven-wrapper.properties +++ b/projects-parent/originals-parent/kata/.mvn/wrapper/maven-wrapper.properties @@ -1,2 +1,19 @@ -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +wrapperVersion=3.3.2 +distributionType=only-script +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip diff --git a/projects-parent/originals-parent/kata/mvnw b/projects-parent/originals-parent/kata/mvnw index 41c0f0c23..19529ddf8 100755 --- a/projects-parent/originals-parent/kata/mvnw +++ b/projects-parent/originals-parent/kata/mvnw @@ -19,292 +19,241 @@ # ---------------------------------------------------------------------------- # ---------------------------------------------------------------------------- -# Maven Start Up Batch script -# -# Required ENV vars: -# ------------------ -# JAVA_HOME - location of a JDK home dir +# Apache Maven Wrapper startup batch script, version 3.3.2 # # Optional ENV vars # ----------------- -# M2_HOME - location of maven2's installed home dir -# MAVEN_OPTS - parameters passed to the Java VM when running Maven -# e.g. to debug Maven itself, use -# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# JAVA_HOME - location of a JDK home dir, required when download maven via java source +# MVNW_REPOURL - repo url base for downloading maven distribution +# MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +# MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output # ---------------------------------------------------------------------------- -if [ -z "$MAVEN_SKIP_RC" ] ; then - - if [ -f /etc/mavenrc ] ; then - . /etc/mavenrc - fi +set -euf +[ "${MVNW_VERBOSE-}" != debug ] || set -x - if [ -f "$HOME/.mavenrc" ] ; then - . "$HOME/.mavenrc" - fi +# OS specific support. +native_path() { printf %s\\n "$1"; } +case "$(uname)" in +CYGWIN* | MINGW*) + [ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")" + native_path() { cygpath --path --windows "$1"; } + ;; +esac -fi +# set JAVACMD and JAVACCMD +set_java_home() { + # For Cygwin and MinGW, ensure paths are in Unix format before anything is touched + if [ -n "${JAVA_HOME-}" ]; then + if [ -x "$JAVA_HOME/jre/sh/java" ]; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACCMD="$JAVA_HOME/jre/sh/javac" + else + JAVACMD="$JAVA_HOME/bin/java" + JAVACCMD="$JAVA_HOME/bin/javac" -# OS specific support. $var _must_ be set to either true or false. -cygwin=false; -darwin=false; -mingw=false -case "`uname`" in - CYGWIN*) cygwin=true ;; - MINGW*) mingw=true;; - Darwin*) darwin=true - # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home - # See https://developer.apple.com/library/mac/qa/qa1170/_index.html - if [ -z "$JAVA_HOME" ]; then - if [ -x "/usr/libexec/java_home" ]; then - export JAVA_HOME="`/usr/libexec/java_home`" - else - export JAVA_HOME="/Library/Java/Home" + if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then + echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2 + echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2 + return 1 fi fi - ;; -esac - -if [ -z "$JAVA_HOME" ] ; then - if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=`java-config --jre-home` + else + JAVACMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v java + )" || : + JAVACCMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v javac + )" || : + + if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then + echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2 + return 1 + fi fi -fi - -if [ -z "$M2_HOME" ] ; then - ## resolve links - $0 may be a link to maven's home - PRG="$0" +} - # need this for relative symlinks - while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG="`dirname "$PRG"`/$link" - fi +# hash string like Java String::hashCode +hash_string() { + str="${1:-}" h=0 + while [ -n "$str" ]; do + char="${str%"${str#?}"}" + h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296)) + str="${str#?}" done + printf %x\\n $h +} - saveddir=`pwd` +verbose() { :; } +[ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; } - M2_HOME=`dirname "$PRG"`/.. +die() { + printf %s\\n "$1" >&2 + exit 1 +} - # make it fully qualified - M2_HOME=`cd "$M2_HOME" && pwd` +trim() { + # MWRAPPER-139: + # Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds. + # Needed for removing poorly interpreted newline sequences when running in more + # exotic environments such as mingw bash on Windows. + printf "%s" "${1}" | tr -d '[:space:]' +} - cd "$saveddir" - # echo Using m2 at $M2_HOME -fi +# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties +while IFS="=" read -r key value; do + case "${key-}" in + distributionUrl) distributionUrl=$(trim "${value-}") ;; + distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;; + esac +done <"${0%/*}/.mvn/wrapper/maven-wrapper.properties" +[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in ${0%/*}/.mvn/wrapper/maven-wrapper.properties" + +case "${distributionUrl##*/}" in +maven-mvnd-*bin.*) + MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ + case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in + *AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;; + :Darwin*x86_64) distributionPlatform=darwin-amd64 ;; + :Darwin*arm64) distributionPlatform=darwin-aarch64 ;; + :Linux*x86_64*) distributionPlatform=linux-amd64 ;; + *) + echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2 + distributionPlatform=linux-amd64 + ;; + esac + distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip" + ;; +maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;; +*) MVN_CMD="mvn${0##*/mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;; +esac -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin ; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --unix "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` -fi +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}" +distributionUrlName="${distributionUrl##*/}" +distributionUrlNameMain="${distributionUrlName%.*}" +distributionUrlNameMain="${distributionUrlNameMain%-bin}" +MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}" +MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")" + +exec_maven() { + unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || : + exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD" +} -# For Mingw, ensure paths are in UNIX format before anything is touched -if $mingw ; then - [ -n "$M2_HOME" ] && - M2_HOME="`(cd "$M2_HOME"; pwd)`" - [ -n "$JAVA_HOME" ] && - JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +if [ -d "$MAVEN_HOME" ]; then + verbose "found existing MAVEN_HOME at $MAVEN_HOME" + exec_maven "$@" fi -if [ -z "$JAVA_HOME" ]; then - javaExecutable="`which javac`" - if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then - # readlink(1) is not available as standard on Solaris 10. - readLink=`which readlink` - if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then - if $darwin ; then - javaHome="`dirname \"$javaExecutable\"`" - javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" - else - javaExecutable="`readlink -f \"$javaExecutable\"`" - fi - javaHome="`dirname \"$javaExecutable\"`" - javaHome=`expr "$javaHome" : '\(.*\)/bin'` - JAVA_HOME="$javaHome" - export JAVA_HOME - fi - fi -fi +case "${distributionUrl-}" in +*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;; +*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;; +esac -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - else - JAVACMD="`which java`" - fi +# prepare tmp dir +if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then + clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; } + trap clean HUP INT TERM EXIT +else + die "cannot create temp dir" fi -if [ ! -x "$JAVACMD" ] ; then - echo "Error: JAVA_HOME is not defined correctly." >&2 - echo " We cannot execute $JAVACMD" >&2 - exit 1 -fi +mkdir -p -- "${MAVEN_HOME%/*}" + +# Download and Install Apache Maven +verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +verbose "Downloading from: $distributionUrl" +verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" -if [ -z "$JAVA_HOME" ] ; then - echo "Warning: JAVA_HOME environment variable is not set." +# select .zip or .tar.gz +if ! command -v unzip >/dev/null; then + distributionUrl="${distributionUrl%.zip}.tar.gz" + distributionUrlName="${distributionUrl##*/}" fi -CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher +# verbose opt +__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR='' +[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v -# traverses directory structure from process work directory to filesystem root -# first directory with .mvn subdirectory is considered project base directory -find_maven_basedir() { +# normalize http auth +case "${MVNW_PASSWORD:+has-password}" in +'') MVNW_USERNAME='' MVNW_PASSWORD='' ;; +has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;; +esac - if [ -z "$1" ] - then - echo "Path not specified to find_maven_basedir" - return 1 - fi +if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then + verbose "Found wget ... using wget" + wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl" +elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then + verbose "Found curl ... using curl" + curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl" +elif set_java_home; then + verbose "Falling back to use Java to download" + javaSource="$TMP_DOWNLOAD_DIR/Downloader.java" + targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName" + cat >"$javaSource" <<-END + public class Downloader extends java.net.Authenticator + { + protected java.net.PasswordAuthentication getPasswordAuthentication() + { + return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() ); + } + public static void main( String[] args ) throws Exception + { + setDefault( new Downloader() ); + java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() ); + } + } + END + # For Cygwin/MinGW, switch paths to Windows format before running javac and java + verbose " - Compiling Downloader.java ..." + "$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java" + verbose " - Running Downloader.java ..." + "$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")" +fi - basedir="$1" - wdir="$1" - while [ "$wdir" != '/' ] ; do - if [ -d "$wdir"/.mvn ] ; then - basedir=$wdir - break +# If specified, validate the SHA-256 sum of the Maven distribution zip file +if [ -n "${distributionSha256Sum-}" ]; then + distributionSha256Result=false + if [ "$MVN_CMD" = mvnd.sh ]; then + echo "Checksum validation is not supported for maven-mvnd." >&2 + echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + elif command -v sha256sum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c >/dev/null 2>&1; then + distributionSha256Result=true fi - # workaround for JBEAP-8937 (on Solaris 10/Sparc) - if [ -d "${wdir}" ]; then - wdir=`cd "$wdir/.."; pwd` + elif command -v shasum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then + distributionSha256Result=true fi - # end of workaround - done - echo "${basedir}" -} - -# concatenates all lines of a file -concat_lines() { - if [ -f "$1" ]; then - echo "$(tr -s '\n' ' ' < "$1")" + else + echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2 + echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + fi + if [ $distributionSha256Result = false ]; then + echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2 + echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2 + exit 1 fi -} - -BASE_DIR=`find_maven_basedir "$(pwd)"` -if [ -z "$BASE_DIR" ]; then - exit 1; fi -########################################################################################## -# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -# This allows using the maven wrapper in projects that prohibit checking in binary data. -########################################################################################## -if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found .mvn/wrapper/maven-wrapper.jar" - fi +# unzip and move +if command -v unzip >/dev/null; then + unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip" else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." - fi - if [ -n "$MVNW_REPOURL" ]; then - jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - else - jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - fi - while IFS="=" read key value; do - case "$key" in (wrapperUrl) jarUrl="$value"; break ;; - esac - done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" - if [ "$MVNW_VERBOSE" = true ]; then - echo "Downloading from: $jarUrl" - fi - wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" - if $cygwin; then - wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` - fi - - if command -v wget > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found wget ... using wget" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - wget "$jarUrl" -O "$wrapperJarPath" - else - wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" - fi - elif command -v curl > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found curl ... using curl" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - curl -o "$wrapperJarPath" "$jarUrl" -f - else - curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f - fi - - else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Falling back to using Java to download" - fi - javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" - # For Cygwin, switch paths to Windows format before running javac - if $cygwin; then - javaClass=`cygpath --path --windows "$javaClass"` - fi - if [ -e "$javaClass" ]; then - if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Compiling MavenWrapperDownloader.java ..." - fi - # Compiling the Java class - ("$JAVA_HOME/bin/javac" "$javaClass") - fi - if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - # Running the downloader - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Running MavenWrapperDownloader.java ..." - fi - ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") - fi - fi - fi -fi -########################################################################################## -# End of extension -########################################################################################## - -export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} -if [ "$MVNW_VERBOSE" = true ]; then - echo $MAVEN_PROJECTBASEDIR + tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar" fi -MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" - -# For Cygwin, switch paths to Windows format before running java -if $cygwin; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --path --windows "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --windows "$CLASSPATH"` - [ -n "$MAVEN_PROJECTBASEDIR" ] && - MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` -fi - -# Provide a "standardized" way to retrieve the CLI args that will -# work with both Windows and non-Windows executions. -MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" -export MAVEN_CMD_LINE_ARGS - -WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain +printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/mvnw.url" +mv -- "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME" -exec "$JAVACMD" \ - $MAVEN_OPTS \ - -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ - "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" +clean || : +exec_maven "$@" diff --git a/projects-parent/originals-parent/kata/mvnw.cmd b/projects-parent/originals-parent/kata/mvnw.cmd index 86115719e..249bdf382 100644 --- a/projects-parent/originals-parent/kata/mvnw.cmd +++ b/projects-parent/originals-parent/kata/mvnw.cmd @@ -1,3 +1,4 @@ +<# : batch portion @REM ---------------------------------------------------------------------------- @REM Licensed to the Apache Software Foundation (ASF) under one @REM or more contributor license agreements. See the NOTICE file @@ -18,165 +19,131 @@ @REM ---------------------------------------------------------------------------- @REM ---------------------------------------------------------------------------- -@REM Maven Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir +@REM Apache Maven Wrapper startup batch script, version 3.3.2 @REM @REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM MVNW_REPOURL - repo url base for downloading maven distribution +@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output @REM ---------------------------------------------------------------------------- -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - -FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( - IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B -) - -@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -@REM This allows using the maven wrapper in projects that prohibit checking in binary data. -if exist %WRAPPER_JAR% ( - if "%MVNW_VERBOSE%" == "true" ( - echo Found %WRAPPER_JAR% - ) -) else ( - if not "%MVNW_REPOURL%" == "" ( - SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - ) - if "%MVNW_VERBOSE%" == "true" ( - echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %DOWNLOAD_URL% - ) - - powershell -Command "&{"^ - "$webclient = new-object System.Net.WebClient;"^ - "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ - "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ - "}"^ - "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ - "}" - if "%MVNW_VERBOSE%" == "true" ( - echo Finished downloading %WRAPPER_JAR% - ) +@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) +@SET __MVNW_CMD__= +@SET __MVNW_ERROR__= +@SET __MVNW_PSMODULEP_SAVE=%PSModulePath% +@SET PSModulePath= +@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( + IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) ) -@REM End of extension - -@REM Provide a "standardized" way to retrieve the CLI args that will -@REM work with both Windows and non-Windows executions. -set MAVEN_CMD_LINE_ARGS=%* - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% +@SET PSModulePath=%__MVNW_PSMODULEP_SAVE% +@SET __MVNW_PSMODULEP_SAVE= +@SET __MVNW_ARG0_NAME__= +@SET MVNW_USERNAME= +@SET MVNW_PASSWORD= +@IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*) +@echo Cannot start maven from wrapper >&2 && exit /b 1 +@GOTO :EOF +: end batch / begin powershell #> + +$ErrorActionPreference = "Stop" +if ($env:MVNW_VERBOSE -eq "true") { + $VerbosePreference = "Continue" +} + +# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties +$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl +if (!$distributionUrl) { + Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" +} + +switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { + "maven-mvnd-*" { + $USE_MVND = $true + $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" + $MVN_CMD = "mvnd.cmd" + break + } + default { + $USE_MVND = $false + $MVN_CMD = $script -replace '^mvnw','mvn' + break + } +} + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +if ($env:MVNW_REPOURL) { + $MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" } + $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')" +} +$distributionUrlName = $distributionUrl -replace '^.*/','' +$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' +$MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain" +if ($env:MAVEN_USER_HOME) { + $MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain" +} +$MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' +$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" + +if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { + Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" + Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" + exit $? +} + +if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { + Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" +} + +# prepare tmp dir +$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile +$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" +$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null +trap { + if ($TMP_DOWNLOAD_DIR.Exists) { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } + } +} + +New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null + +# Download and Install Apache Maven +Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +Write-Verbose "Downloading from: $distributionUrl" +Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +$webclient = New-Object System.Net.WebClient +if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { + $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) +} +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 +$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum +if ($distributionSha256Sum) { + if ($USE_MVND) { + Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." + } + Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash + if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { + Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." + } +} + +# unzip and move +Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null +Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null +try { + Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null +} catch { + if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { + Write-Error "fail to move MAVEN_HOME" + } +} finally { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } +} + +Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" diff --git a/projects-parent/originals-parent/phonebill-web/.mvn/wrapper/MavenWrapperDownloader.java b/projects-parent/originals-parent/phonebill-web/.mvn/wrapper/MavenWrapperDownloader.java deleted file mode 100644 index b901097f2..000000000 --- a/projects-parent/originals-parent/phonebill-web/.mvn/wrapper/MavenWrapperDownloader.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright 2007-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import java.net.*; -import java.io.*; -import java.nio.channels.*; -import java.util.Properties; - -public class MavenWrapperDownloader { - - private static final String WRAPPER_VERSION = "0.5.6"; - /** - * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. - */ - private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" - + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; - - /** - * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to - * use instead of the default one. - */ - private static final String MAVEN_WRAPPER_PROPERTIES_PATH = - ".mvn/wrapper/maven-wrapper.properties"; - - /** - * Path where the maven-wrapper.jar will be saved to. - */ - private static final String MAVEN_WRAPPER_JAR_PATH = - ".mvn/wrapper/maven-wrapper.jar"; - - /** - * Name of the property which should be used to override the default download url for the wrapper. - */ - private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; - - public static void main(String args[]) { - System.out.println("- Downloader started"); - File baseDirectory = new File(args[0]); - System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); - - // If the maven-wrapper.properties exists, read it and check if it contains a custom - // wrapperUrl parameter. - File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); - String url = DEFAULT_DOWNLOAD_URL; - if(mavenWrapperPropertyFile.exists()) { - FileInputStream mavenWrapperPropertyFileInputStream = null; - try { - mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); - Properties mavenWrapperProperties = new Properties(); - mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); - url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); - } catch (IOException e) { - System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); - } finally { - try { - if(mavenWrapperPropertyFileInputStream != null) { - mavenWrapperPropertyFileInputStream.close(); - } - } catch (IOException e) { - // Ignore ... - } - } - } - System.out.println("- Downloading from: " + url); - - File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); - if(!outputFile.getParentFile().exists()) { - if(!outputFile.getParentFile().mkdirs()) { - System.out.println( - "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); - } - } - System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); - try { - downloadFileFromURL(url, outputFile); - System.out.println("Done"); - System.exit(0); - } catch (Throwable e) { - System.out.println("- Error downloading"); - e.printStackTrace(); - System.exit(1); - } - } - - private static void downloadFileFromURL(String urlString, File destination) throws Exception { - if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { - String username = System.getenv("MVNW_USERNAME"); - char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); - Authenticator.setDefault(new Authenticator() { - @Override - protected PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication(username, password); - } - }); - } - URL website = new URL(urlString); - ReadableByteChannel rbc; - rbc = Channels.newChannel(website.openStream()); - FileOutputStream fos = new FileOutputStream(destination); - fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); - fos.close(); - rbc.close(); - } - -} diff --git a/projects-parent/originals-parent/phonebill-web/.mvn/wrapper/maven-wrapper.properties b/projects-parent/originals-parent/phonebill-web/.mvn/wrapper/maven-wrapper.properties index 5d43cd338..d58dfb70b 100644 --- a/projects-parent/originals-parent/phonebill-web/.mvn/wrapper/maven-wrapper.properties +++ b/projects-parent/originals-parent/phonebill-web/.mvn/wrapper/maven-wrapper.properties @@ -1,2 +1,19 @@ -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +wrapperVersion=3.3.2 +distributionType=only-script +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip diff --git a/projects-parent/originals-parent/phonebill-web/mvnw b/projects-parent/originals-parent/phonebill-web/mvnw index 41c0f0c23..19529ddf8 100755 --- a/projects-parent/originals-parent/phonebill-web/mvnw +++ b/projects-parent/originals-parent/phonebill-web/mvnw @@ -19,292 +19,241 @@ # ---------------------------------------------------------------------------- # ---------------------------------------------------------------------------- -# Maven Start Up Batch script -# -# Required ENV vars: -# ------------------ -# JAVA_HOME - location of a JDK home dir +# Apache Maven Wrapper startup batch script, version 3.3.2 # # Optional ENV vars # ----------------- -# M2_HOME - location of maven2's installed home dir -# MAVEN_OPTS - parameters passed to the Java VM when running Maven -# e.g. to debug Maven itself, use -# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# JAVA_HOME - location of a JDK home dir, required when download maven via java source +# MVNW_REPOURL - repo url base for downloading maven distribution +# MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +# MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output # ---------------------------------------------------------------------------- -if [ -z "$MAVEN_SKIP_RC" ] ; then - - if [ -f /etc/mavenrc ] ; then - . /etc/mavenrc - fi +set -euf +[ "${MVNW_VERBOSE-}" != debug ] || set -x - if [ -f "$HOME/.mavenrc" ] ; then - . "$HOME/.mavenrc" - fi +# OS specific support. +native_path() { printf %s\\n "$1"; } +case "$(uname)" in +CYGWIN* | MINGW*) + [ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")" + native_path() { cygpath --path --windows "$1"; } + ;; +esac -fi +# set JAVACMD and JAVACCMD +set_java_home() { + # For Cygwin and MinGW, ensure paths are in Unix format before anything is touched + if [ -n "${JAVA_HOME-}" ]; then + if [ -x "$JAVA_HOME/jre/sh/java" ]; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACCMD="$JAVA_HOME/jre/sh/javac" + else + JAVACMD="$JAVA_HOME/bin/java" + JAVACCMD="$JAVA_HOME/bin/javac" -# OS specific support. $var _must_ be set to either true or false. -cygwin=false; -darwin=false; -mingw=false -case "`uname`" in - CYGWIN*) cygwin=true ;; - MINGW*) mingw=true;; - Darwin*) darwin=true - # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home - # See https://developer.apple.com/library/mac/qa/qa1170/_index.html - if [ -z "$JAVA_HOME" ]; then - if [ -x "/usr/libexec/java_home" ]; then - export JAVA_HOME="`/usr/libexec/java_home`" - else - export JAVA_HOME="/Library/Java/Home" + if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then + echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2 + echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2 + return 1 fi fi - ;; -esac - -if [ -z "$JAVA_HOME" ] ; then - if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=`java-config --jre-home` + else + JAVACMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v java + )" || : + JAVACCMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v javac + )" || : + + if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then + echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2 + return 1 + fi fi -fi - -if [ -z "$M2_HOME" ] ; then - ## resolve links - $0 may be a link to maven's home - PRG="$0" +} - # need this for relative symlinks - while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG="`dirname "$PRG"`/$link" - fi +# hash string like Java String::hashCode +hash_string() { + str="${1:-}" h=0 + while [ -n "$str" ]; do + char="${str%"${str#?}"}" + h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296)) + str="${str#?}" done + printf %x\\n $h +} - saveddir=`pwd` +verbose() { :; } +[ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; } - M2_HOME=`dirname "$PRG"`/.. +die() { + printf %s\\n "$1" >&2 + exit 1 +} - # make it fully qualified - M2_HOME=`cd "$M2_HOME" && pwd` +trim() { + # MWRAPPER-139: + # Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds. + # Needed for removing poorly interpreted newline sequences when running in more + # exotic environments such as mingw bash on Windows. + printf "%s" "${1}" | tr -d '[:space:]' +} - cd "$saveddir" - # echo Using m2 at $M2_HOME -fi +# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties +while IFS="=" read -r key value; do + case "${key-}" in + distributionUrl) distributionUrl=$(trim "${value-}") ;; + distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;; + esac +done <"${0%/*}/.mvn/wrapper/maven-wrapper.properties" +[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in ${0%/*}/.mvn/wrapper/maven-wrapper.properties" + +case "${distributionUrl##*/}" in +maven-mvnd-*bin.*) + MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ + case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in + *AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;; + :Darwin*x86_64) distributionPlatform=darwin-amd64 ;; + :Darwin*arm64) distributionPlatform=darwin-aarch64 ;; + :Linux*x86_64*) distributionPlatform=linux-amd64 ;; + *) + echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2 + distributionPlatform=linux-amd64 + ;; + esac + distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip" + ;; +maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;; +*) MVN_CMD="mvn${0##*/mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;; +esac -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin ; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --unix "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` -fi +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}" +distributionUrlName="${distributionUrl##*/}" +distributionUrlNameMain="${distributionUrlName%.*}" +distributionUrlNameMain="${distributionUrlNameMain%-bin}" +MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}" +MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")" + +exec_maven() { + unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || : + exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD" +} -# For Mingw, ensure paths are in UNIX format before anything is touched -if $mingw ; then - [ -n "$M2_HOME" ] && - M2_HOME="`(cd "$M2_HOME"; pwd)`" - [ -n "$JAVA_HOME" ] && - JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +if [ -d "$MAVEN_HOME" ]; then + verbose "found existing MAVEN_HOME at $MAVEN_HOME" + exec_maven "$@" fi -if [ -z "$JAVA_HOME" ]; then - javaExecutable="`which javac`" - if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then - # readlink(1) is not available as standard on Solaris 10. - readLink=`which readlink` - if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then - if $darwin ; then - javaHome="`dirname \"$javaExecutable\"`" - javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" - else - javaExecutable="`readlink -f \"$javaExecutable\"`" - fi - javaHome="`dirname \"$javaExecutable\"`" - javaHome=`expr "$javaHome" : '\(.*\)/bin'` - JAVA_HOME="$javaHome" - export JAVA_HOME - fi - fi -fi +case "${distributionUrl-}" in +*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;; +*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;; +esac -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - else - JAVACMD="`which java`" - fi +# prepare tmp dir +if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then + clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; } + trap clean HUP INT TERM EXIT +else + die "cannot create temp dir" fi -if [ ! -x "$JAVACMD" ] ; then - echo "Error: JAVA_HOME is not defined correctly." >&2 - echo " We cannot execute $JAVACMD" >&2 - exit 1 -fi +mkdir -p -- "${MAVEN_HOME%/*}" + +# Download and Install Apache Maven +verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +verbose "Downloading from: $distributionUrl" +verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" -if [ -z "$JAVA_HOME" ] ; then - echo "Warning: JAVA_HOME environment variable is not set." +# select .zip or .tar.gz +if ! command -v unzip >/dev/null; then + distributionUrl="${distributionUrl%.zip}.tar.gz" + distributionUrlName="${distributionUrl##*/}" fi -CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher +# verbose opt +__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR='' +[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v -# traverses directory structure from process work directory to filesystem root -# first directory with .mvn subdirectory is considered project base directory -find_maven_basedir() { +# normalize http auth +case "${MVNW_PASSWORD:+has-password}" in +'') MVNW_USERNAME='' MVNW_PASSWORD='' ;; +has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;; +esac - if [ -z "$1" ] - then - echo "Path not specified to find_maven_basedir" - return 1 - fi +if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then + verbose "Found wget ... using wget" + wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl" +elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then + verbose "Found curl ... using curl" + curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl" +elif set_java_home; then + verbose "Falling back to use Java to download" + javaSource="$TMP_DOWNLOAD_DIR/Downloader.java" + targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName" + cat >"$javaSource" <<-END + public class Downloader extends java.net.Authenticator + { + protected java.net.PasswordAuthentication getPasswordAuthentication() + { + return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() ); + } + public static void main( String[] args ) throws Exception + { + setDefault( new Downloader() ); + java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() ); + } + } + END + # For Cygwin/MinGW, switch paths to Windows format before running javac and java + verbose " - Compiling Downloader.java ..." + "$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java" + verbose " - Running Downloader.java ..." + "$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")" +fi - basedir="$1" - wdir="$1" - while [ "$wdir" != '/' ] ; do - if [ -d "$wdir"/.mvn ] ; then - basedir=$wdir - break +# If specified, validate the SHA-256 sum of the Maven distribution zip file +if [ -n "${distributionSha256Sum-}" ]; then + distributionSha256Result=false + if [ "$MVN_CMD" = mvnd.sh ]; then + echo "Checksum validation is not supported for maven-mvnd." >&2 + echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + elif command -v sha256sum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c >/dev/null 2>&1; then + distributionSha256Result=true fi - # workaround for JBEAP-8937 (on Solaris 10/Sparc) - if [ -d "${wdir}" ]; then - wdir=`cd "$wdir/.."; pwd` + elif command -v shasum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then + distributionSha256Result=true fi - # end of workaround - done - echo "${basedir}" -} - -# concatenates all lines of a file -concat_lines() { - if [ -f "$1" ]; then - echo "$(tr -s '\n' ' ' < "$1")" + else + echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2 + echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + fi + if [ $distributionSha256Result = false ]; then + echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2 + echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2 + exit 1 fi -} - -BASE_DIR=`find_maven_basedir "$(pwd)"` -if [ -z "$BASE_DIR" ]; then - exit 1; fi -########################################################################################## -# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -# This allows using the maven wrapper in projects that prohibit checking in binary data. -########################################################################################## -if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found .mvn/wrapper/maven-wrapper.jar" - fi +# unzip and move +if command -v unzip >/dev/null; then + unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip" else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." - fi - if [ -n "$MVNW_REPOURL" ]; then - jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - else - jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - fi - while IFS="=" read key value; do - case "$key" in (wrapperUrl) jarUrl="$value"; break ;; - esac - done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" - if [ "$MVNW_VERBOSE" = true ]; then - echo "Downloading from: $jarUrl" - fi - wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" - if $cygwin; then - wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` - fi - - if command -v wget > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found wget ... using wget" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - wget "$jarUrl" -O "$wrapperJarPath" - else - wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" - fi - elif command -v curl > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found curl ... using curl" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - curl -o "$wrapperJarPath" "$jarUrl" -f - else - curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f - fi - - else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Falling back to using Java to download" - fi - javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" - # For Cygwin, switch paths to Windows format before running javac - if $cygwin; then - javaClass=`cygpath --path --windows "$javaClass"` - fi - if [ -e "$javaClass" ]; then - if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Compiling MavenWrapperDownloader.java ..." - fi - # Compiling the Java class - ("$JAVA_HOME/bin/javac" "$javaClass") - fi - if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - # Running the downloader - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Running MavenWrapperDownloader.java ..." - fi - ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") - fi - fi - fi -fi -########################################################################################## -# End of extension -########################################################################################## - -export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} -if [ "$MVNW_VERBOSE" = true ]; then - echo $MAVEN_PROJECTBASEDIR + tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar" fi -MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" - -# For Cygwin, switch paths to Windows format before running java -if $cygwin; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --path --windows "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --windows "$CLASSPATH"` - [ -n "$MAVEN_PROJECTBASEDIR" ] && - MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` -fi - -# Provide a "standardized" way to retrieve the CLI args that will -# work with both Windows and non-Windows executions. -MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" -export MAVEN_CMD_LINE_ARGS - -WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain +printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/mvnw.url" +mv -- "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME" -exec "$JAVACMD" \ - $MAVEN_OPTS \ - -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ - "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" +clean || : +exec_maven "$@" diff --git a/projects-parent/originals-parent/phonebill-web/mvnw.cmd b/projects-parent/originals-parent/phonebill-web/mvnw.cmd index 86115719e..249bdf382 100644 --- a/projects-parent/originals-parent/phonebill-web/mvnw.cmd +++ b/projects-parent/originals-parent/phonebill-web/mvnw.cmd @@ -1,3 +1,4 @@ +<# : batch portion @REM ---------------------------------------------------------------------------- @REM Licensed to the Apache Software Foundation (ASF) under one @REM or more contributor license agreements. See the NOTICE file @@ -18,165 +19,131 @@ @REM ---------------------------------------------------------------------------- @REM ---------------------------------------------------------------------------- -@REM Maven Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir +@REM Apache Maven Wrapper startup batch script, version 3.3.2 @REM @REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM MVNW_REPOURL - repo url base for downloading maven distribution +@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output @REM ---------------------------------------------------------------------------- -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - -FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( - IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B -) - -@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -@REM This allows using the maven wrapper in projects that prohibit checking in binary data. -if exist %WRAPPER_JAR% ( - if "%MVNW_VERBOSE%" == "true" ( - echo Found %WRAPPER_JAR% - ) -) else ( - if not "%MVNW_REPOURL%" == "" ( - SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - ) - if "%MVNW_VERBOSE%" == "true" ( - echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %DOWNLOAD_URL% - ) - - powershell -Command "&{"^ - "$webclient = new-object System.Net.WebClient;"^ - "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ - "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ - "}"^ - "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ - "}" - if "%MVNW_VERBOSE%" == "true" ( - echo Finished downloading %WRAPPER_JAR% - ) +@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) +@SET __MVNW_CMD__= +@SET __MVNW_ERROR__= +@SET __MVNW_PSMODULEP_SAVE=%PSModulePath% +@SET PSModulePath= +@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( + IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) ) -@REM End of extension - -@REM Provide a "standardized" way to retrieve the CLI args that will -@REM work with both Windows and non-Windows executions. -set MAVEN_CMD_LINE_ARGS=%* - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% +@SET PSModulePath=%__MVNW_PSMODULEP_SAVE% +@SET __MVNW_PSMODULEP_SAVE= +@SET __MVNW_ARG0_NAME__= +@SET MVNW_USERNAME= +@SET MVNW_PASSWORD= +@IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*) +@echo Cannot start maven from wrapper >&2 && exit /b 1 +@GOTO :EOF +: end batch / begin powershell #> + +$ErrorActionPreference = "Stop" +if ($env:MVNW_VERBOSE -eq "true") { + $VerbosePreference = "Continue" +} + +# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties +$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl +if (!$distributionUrl) { + Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" +} + +switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { + "maven-mvnd-*" { + $USE_MVND = $true + $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" + $MVN_CMD = "mvnd.cmd" + break + } + default { + $USE_MVND = $false + $MVN_CMD = $script -replace '^mvnw','mvn' + break + } +} + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +if ($env:MVNW_REPOURL) { + $MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" } + $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')" +} +$distributionUrlName = $distributionUrl -replace '^.*/','' +$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' +$MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain" +if ($env:MAVEN_USER_HOME) { + $MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain" +} +$MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' +$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" + +if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { + Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" + Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" + exit $? +} + +if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { + Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" +} + +# prepare tmp dir +$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile +$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" +$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null +trap { + if ($TMP_DOWNLOAD_DIR.Exists) { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } + } +} + +New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null + +# Download and Install Apache Maven +Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +Write-Verbose "Downloading from: $distributionUrl" +Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +$webclient = New-Object System.Net.WebClient +if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { + $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) +} +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 +$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum +if ($distributionSha256Sum) { + if ($USE_MVND) { + Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." + } + Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash + if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { + Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." + } +} + +# unzip and move +Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null +Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null +try { + Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null +} catch { + if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { + Write-Error "fail to move MAVEN_HOME" + } +} finally { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } +} + +Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" diff --git a/projects-parent/originals-parent/phonebill/.mvn/wrapper/MavenWrapperDownloader.java b/projects-parent/originals-parent/phonebill/.mvn/wrapper/MavenWrapperDownloader.java deleted file mode 100644 index b901097f2..000000000 --- a/projects-parent/originals-parent/phonebill/.mvn/wrapper/MavenWrapperDownloader.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright 2007-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import java.net.*; -import java.io.*; -import java.nio.channels.*; -import java.util.Properties; - -public class MavenWrapperDownloader { - - private static final String WRAPPER_VERSION = "0.5.6"; - /** - * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. - */ - private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" - + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; - - /** - * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to - * use instead of the default one. - */ - private static final String MAVEN_WRAPPER_PROPERTIES_PATH = - ".mvn/wrapper/maven-wrapper.properties"; - - /** - * Path where the maven-wrapper.jar will be saved to. - */ - private static final String MAVEN_WRAPPER_JAR_PATH = - ".mvn/wrapper/maven-wrapper.jar"; - - /** - * Name of the property which should be used to override the default download url for the wrapper. - */ - private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; - - public static void main(String args[]) { - System.out.println("- Downloader started"); - File baseDirectory = new File(args[0]); - System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); - - // If the maven-wrapper.properties exists, read it and check if it contains a custom - // wrapperUrl parameter. - File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); - String url = DEFAULT_DOWNLOAD_URL; - if(mavenWrapperPropertyFile.exists()) { - FileInputStream mavenWrapperPropertyFileInputStream = null; - try { - mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); - Properties mavenWrapperProperties = new Properties(); - mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); - url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); - } catch (IOException e) { - System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); - } finally { - try { - if(mavenWrapperPropertyFileInputStream != null) { - mavenWrapperPropertyFileInputStream.close(); - } - } catch (IOException e) { - // Ignore ... - } - } - } - System.out.println("- Downloading from: " + url); - - File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); - if(!outputFile.getParentFile().exists()) { - if(!outputFile.getParentFile().mkdirs()) { - System.out.println( - "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); - } - } - System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); - try { - downloadFileFromURL(url, outputFile); - System.out.println("Done"); - System.exit(0); - } catch (Throwable e) { - System.out.println("- Error downloading"); - e.printStackTrace(); - System.exit(1); - } - } - - private static void downloadFileFromURL(String urlString, File destination) throws Exception { - if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { - String username = System.getenv("MVNW_USERNAME"); - char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); - Authenticator.setDefault(new Authenticator() { - @Override - protected PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication(username, password); - } - }); - } - URL website = new URL(urlString); - ReadableByteChannel rbc; - rbc = Channels.newChannel(website.openStream()); - FileOutputStream fos = new FileOutputStream(destination); - fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); - fos.close(); - rbc.close(); - } - -} diff --git a/projects-parent/originals-parent/phonebill/.mvn/wrapper/maven-wrapper.properties b/projects-parent/originals-parent/phonebill/.mvn/wrapper/maven-wrapper.properties index 5d43cd338..d58dfb70b 100644 --- a/projects-parent/originals-parent/phonebill/.mvn/wrapper/maven-wrapper.properties +++ b/projects-parent/originals-parent/phonebill/.mvn/wrapper/maven-wrapper.properties @@ -1,2 +1,19 @@ -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +wrapperVersion=3.3.2 +distributionType=only-script +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip diff --git a/projects-parent/originals-parent/phonebill/mvnw b/projects-parent/originals-parent/phonebill/mvnw index 41c0f0c23..19529ddf8 100755 --- a/projects-parent/originals-parent/phonebill/mvnw +++ b/projects-parent/originals-parent/phonebill/mvnw @@ -19,292 +19,241 @@ # ---------------------------------------------------------------------------- # ---------------------------------------------------------------------------- -# Maven Start Up Batch script -# -# Required ENV vars: -# ------------------ -# JAVA_HOME - location of a JDK home dir +# Apache Maven Wrapper startup batch script, version 3.3.2 # # Optional ENV vars # ----------------- -# M2_HOME - location of maven2's installed home dir -# MAVEN_OPTS - parameters passed to the Java VM when running Maven -# e.g. to debug Maven itself, use -# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# JAVA_HOME - location of a JDK home dir, required when download maven via java source +# MVNW_REPOURL - repo url base for downloading maven distribution +# MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +# MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output # ---------------------------------------------------------------------------- -if [ -z "$MAVEN_SKIP_RC" ] ; then - - if [ -f /etc/mavenrc ] ; then - . /etc/mavenrc - fi +set -euf +[ "${MVNW_VERBOSE-}" != debug ] || set -x - if [ -f "$HOME/.mavenrc" ] ; then - . "$HOME/.mavenrc" - fi +# OS specific support. +native_path() { printf %s\\n "$1"; } +case "$(uname)" in +CYGWIN* | MINGW*) + [ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")" + native_path() { cygpath --path --windows "$1"; } + ;; +esac -fi +# set JAVACMD and JAVACCMD +set_java_home() { + # For Cygwin and MinGW, ensure paths are in Unix format before anything is touched + if [ -n "${JAVA_HOME-}" ]; then + if [ -x "$JAVA_HOME/jre/sh/java" ]; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACCMD="$JAVA_HOME/jre/sh/javac" + else + JAVACMD="$JAVA_HOME/bin/java" + JAVACCMD="$JAVA_HOME/bin/javac" -# OS specific support. $var _must_ be set to either true or false. -cygwin=false; -darwin=false; -mingw=false -case "`uname`" in - CYGWIN*) cygwin=true ;; - MINGW*) mingw=true;; - Darwin*) darwin=true - # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home - # See https://developer.apple.com/library/mac/qa/qa1170/_index.html - if [ -z "$JAVA_HOME" ]; then - if [ -x "/usr/libexec/java_home" ]; then - export JAVA_HOME="`/usr/libexec/java_home`" - else - export JAVA_HOME="/Library/Java/Home" + if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then + echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2 + echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2 + return 1 fi fi - ;; -esac - -if [ -z "$JAVA_HOME" ] ; then - if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=`java-config --jre-home` + else + JAVACMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v java + )" || : + JAVACCMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v javac + )" || : + + if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then + echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2 + return 1 + fi fi -fi - -if [ -z "$M2_HOME" ] ; then - ## resolve links - $0 may be a link to maven's home - PRG="$0" +} - # need this for relative symlinks - while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG="`dirname "$PRG"`/$link" - fi +# hash string like Java String::hashCode +hash_string() { + str="${1:-}" h=0 + while [ -n "$str" ]; do + char="${str%"${str#?}"}" + h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296)) + str="${str#?}" done + printf %x\\n $h +} - saveddir=`pwd` +verbose() { :; } +[ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; } - M2_HOME=`dirname "$PRG"`/.. +die() { + printf %s\\n "$1" >&2 + exit 1 +} - # make it fully qualified - M2_HOME=`cd "$M2_HOME" && pwd` +trim() { + # MWRAPPER-139: + # Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds. + # Needed for removing poorly interpreted newline sequences when running in more + # exotic environments such as mingw bash on Windows. + printf "%s" "${1}" | tr -d '[:space:]' +} - cd "$saveddir" - # echo Using m2 at $M2_HOME -fi +# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties +while IFS="=" read -r key value; do + case "${key-}" in + distributionUrl) distributionUrl=$(trim "${value-}") ;; + distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;; + esac +done <"${0%/*}/.mvn/wrapper/maven-wrapper.properties" +[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in ${0%/*}/.mvn/wrapper/maven-wrapper.properties" + +case "${distributionUrl##*/}" in +maven-mvnd-*bin.*) + MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ + case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in + *AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;; + :Darwin*x86_64) distributionPlatform=darwin-amd64 ;; + :Darwin*arm64) distributionPlatform=darwin-aarch64 ;; + :Linux*x86_64*) distributionPlatform=linux-amd64 ;; + *) + echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2 + distributionPlatform=linux-amd64 + ;; + esac + distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip" + ;; +maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;; +*) MVN_CMD="mvn${0##*/mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;; +esac -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin ; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --unix "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` -fi +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}" +distributionUrlName="${distributionUrl##*/}" +distributionUrlNameMain="${distributionUrlName%.*}" +distributionUrlNameMain="${distributionUrlNameMain%-bin}" +MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}" +MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")" + +exec_maven() { + unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || : + exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD" +} -# For Mingw, ensure paths are in UNIX format before anything is touched -if $mingw ; then - [ -n "$M2_HOME" ] && - M2_HOME="`(cd "$M2_HOME"; pwd)`" - [ -n "$JAVA_HOME" ] && - JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +if [ -d "$MAVEN_HOME" ]; then + verbose "found existing MAVEN_HOME at $MAVEN_HOME" + exec_maven "$@" fi -if [ -z "$JAVA_HOME" ]; then - javaExecutable="`which javac`" - if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then - # readlink(1) is not available as standard on Solaris 10. - readLink=`which readlink` - if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then - if $darwin ; then - javaHome="`dirname \"$javaExecutable\"`" - javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" - else - javaExecutable="`readlink -f \"$javaExecutable\"`" - fi - javaHome="`dirname \"$javaExecutable\"`" - javaHome=`expr "$javaHome" : '\(.*\)/bin'` - JAVA_HOME="$javaHome" - export JAVA_HOME - fi - fi -fi +case "${distributionUrl-}" in +*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;; +*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;; +esac -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - else - JAVACMD="`which java`" - fi +# prepare tmp dir +if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then + clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; } + trap clean HUP INT TERM EXIT +else + die "cannot create temp dir" fi -if [ ! -x "$JAVACMD" ] ; then - echo "Error: JAVA_HOME is not defined correctly." >&2 - echo " We cannot execute $JAVACMD" >&2 - exit 1 -fi +mkdir -p -- "${MAVEN_HOME%/*}" + +# Download and Install Apache Maven +verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +verbose "Downloading from: $distributionUrl" +verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" -if [ -z "$JAVA_HOME" ] ; then - echo "Warning: JAVA_HOME environment variable is not set." +# select .zip or .tar.gz +if ! command -v unzip >/dev/null; then + distributionUrl="${distributionUrl%.zip}.tar.gz" + distributionUrlName="${distributionUrl##*/}" fi -CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher +# verbose opt +__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR='' +[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v -# traverses directory structure from process work directory to filesystem root -# first directory with .mvn subdirectory is considered project base directory -find_maven_basedir() { +# normalize http auth +case "${MVNW_PASSWORD:+has-password}" in +'') MVNW_USERNAME='' MVNW_PASSWORD='' ;; +has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;; +esac - if [ -z "$1" ] - then - echo "Path not specified to find_maven_basedir" - return 1 - fi +if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then + verbose "Found wget ... using wget" + wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl" +elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then + verbose "Found curl ... using curl" + curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl" +elif set_java_home; then + verbose "Falling back to use Java to download" + javaSource="$TMP_DOWNLOAD_DIR/Downloader.java" + targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName" + cat >"$javaSource" <<-END + public class Downloader extends java.net.Authenticator + { + protected java.net.PasswordAuthentication getPasswordAuthentication() + { + return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() ); + } + public static void main( String[] args ) throws Exception + { + setDefault( new Downloader() ); + java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() ); + } + } + END + # For Cygwin/MinGW, switch paths to Windows format before running javac and java + verbose " - Compiling Downloader.java ..." + "$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java" + verbose " - Running Downloader.java ..." + "$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")" +fi - basedir="$1" - wdir="$1" - while [ "$wdir" != '/' ] ; do - if [ -d "$wdir"/.mvn ] ; then - basedir=$wdir - break +# If specified, validate the SHA-256 sum of the Maven distribution zip file +if [ -n "${distributionSha256Sum-}" ]; then + distributionSha256Result=false + if [ "$MVN_CMD" = mvnd.sh ]; then + echo "Checksum validation is not supported for maven-mvnd." >&2 + echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + elif command -v sha256sum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c >/dev/null 2>&1; then + distributionSha256Result=true fi - # workaround for JBEAP-8937 (on Solaris 10/Sparc) - if [ -d "${wdir}" ]; then - wdir=`cd "$wdir/.."; pwd` + elif command -v shasum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then + distributionSha256Result=true fi - # end of workaround - done - echo "${basedir}" -} - -# concatenates all lines of a file -concat_lines() { - if [ -f "$1" ]; then - echo "$(tr -s '\n' ' ' < "$1")" + else + echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2 + echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + fi + if [ $distributionSha256Result = false ]; then + echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2 + echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2 + exit 1 fi -} - -BASE_DIR=`find_maven_basedir "$(pwd)"` -if [ -z "$BASE_DIR" ]; then - exit 1; fi -########################################################################################## -# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -# This allows using the maven wrapper in projects that prohibit checking in binary data. -########################################################################################## -if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found .mvn/wrapper/maven-wrapper.jar" - fi +# unzip and move +if command -v unzip >/dev/null; then + unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip" else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." - fi - if [ -n "$MVNW_REPOURL" ]; then - jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - else - jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - fi - while IFS="=" read key value; do - case "$key" in (wrapperUrl) jarUrl="$value"; break ;; - esac - done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" - if [ "$MVNW_VERBOSE" = true ]; then - echo "Downloading from: $jarUrl" - fi - wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" - if $cygwin; then - wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` - fi - - if command -v wget > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found wget ... using wget" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - wget "$jarUrl" -O "$wrapperJarPath" - else - wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" - fi - elif command -v curl > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found curl ... using curl" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - curl -o "$wrapperJarPath" "$jarUrl" -f - else - curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f - fi - - else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Falling back to using Java to download" - fi - javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" - # For Cygwin, switch paths to Windows format before running javac - if $cygwin; then - javaClass=`cygpath --path --windows "$javaClass"` - fi - if [ -e "$javaClass" ]; then - if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Compiling MavenWrapperDownloader.java ..." - fi - # Compiling the Java class - ("$JAVA_HOME/bin/javac" "$javaClass") - fi - if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - # Running the downloader - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Running MavenWrapperDownloader.java ..." - fi - ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") - fi - fi - fi -fi -########################################################################################## -# End of extension -########################################################################################## - -export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} -if [ "$MVNW_VERBOSE" = true ]; then - echo $MAVEN_PROJECTBASEDIR + tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar" fi -MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" - -# For Cygwin, switch paths to Windows format before running java -if $cygwin; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --path --windows "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --windows "$CLASSPATH"` - [ -n "$MAVEN_PROJECTBASEDIR" ] && - MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` -fi - -# Provide a "standardized" way to retrieve the CLI args that will -# work with both Windows and non-Windows executions. -MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" -export MAVEN_CMD_LINE_ARGS - -WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain +printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/mvnw.url" +mv -- "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME" -exec "$JAVACMD" \ - $MAVEN_OPTS \ - -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ - "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" +clean || : +exec_maven "$@" diff --git a/projects-parent/originals-parent/phonebill/mvnw.cmd b/projects-parent/originals-parent/phonebill/mvnw.cmd index 86115719e..249bdf382 100644 --- a/projects-parent/originals-parent/phonebill/mvnw.cmd +++ b/projects-parent/originals-parent/phonebill/mvnw.cmd @@ -1,3 +1,4 @@ +<# : batch portion @REM ---------------------------------------------------------------------------- @REM Licensed to the Apache Software Foundation (ASF) under one @REM or more contributor license agreements. See the NOTICE file @@ -18,165 +19,131 @@ @REM ---------------------------------------------------------------------------- @REM ---------------------------------------------------------------------------- -@REM Maven Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir +@REM Apache Maven Wrapper startup batch script, version 3.3.2 @REM @REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM MVNW_REPOURL - repo url base for downloading maven distribution +@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output @REM ---------------------------------------------------------------------------- -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - -FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( - IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B -) - -@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -@REM This allows using the maven wrapper in projects that prohibit checking in binary data. -if exist %WRAPPER_JAR% ( - if "%MVNW_VERBOSE%" == "true" ( - echo Found %WRAPPER_JAR% - ) -) else ( - if not "%MVNW_REPOURL%" == "" ( - SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - ) - if "%MVNW_VERBOSE%" == "true" ( - echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %DOWNLOAD_URL% - ) - - powershell -Command "&{"^ - "$webclient = new-object System.Net.WebClient;"^ - "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ - "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ - "}"^ - "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ - "}" - if "%MVNW_VERBOSE%" == "true" ( - echo Finished downloading %WRAPPER_JAR% - ) +@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) +@SET __MVNW_CMD__= +@SET __MVNW_ERROR__= +@SET __MVNW_PSMODULEP_SAVE=%PSModulePath% +@SET PSModulePath= +@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( + IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) ) -@REM End of extension - -@REM Provide a "standardized" way to retrieve the CLI args that will -@REM work with both Windows and non-Windows executions. -set MAVEN_CMD_LINE_ARGS=%* - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% +@SET PSModulePath=%__MVNW_PSMODULEP_SAVE% +@SET __MVNW_PSMODULEP_SAVE= +@SET __MVNW_ARG0_NAME__= +@SET MVNW_USERNAME= +@SET MVNW_PASSWORD= +@IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*) +@echo Cannot start maven from wrapper >&2 && exit /b 1 +@GOTO :EOF +: end batch / begin powershell #> + +$ErrorActionPreference = "Stop" +if ($env:MVNW_VERBOSE -eq "true") { + $VerbosePreference = "Continue" +} + +# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties +$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl +if (!$distributionUrl) { + Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" +} + +switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { + "maven-mvnd-*" { + $USE_MVND = $true + $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" + $MVN_CMD = "mvnd.cmd" + break + } + default { + $USE_MVND = $false + $MVN_CMD = $script -replace '^mvnw','mvn' + break + } +} + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +if ($env:MVNW_REPOURL) { + $MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" } + $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')" +} +$distributionUrlName = $distributionUrl -replace '^.*/','' +$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' +$MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain" +if ($env:MAVEN_USER_HOME) { + $MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain" +} +$MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' +$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" + +if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { + Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" + Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" + exit $? +} + +if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { + Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" +} + +# prepare tmp dir +$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile +$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" +$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null +trap { + if ($TMP_DOWNLOAD_DIR.Exists) { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } + } +} + +New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null + +# Download and Install Apache Maven +Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +Write-Verbose "Downloading from: $distributionUrl" +Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +$webclient = New-Object System.Net.WebClient +if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { + $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) +} +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 +$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum +if ($distributionSha256Sum) { + if ($USE_MVND) { + Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." + } + Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash + if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { + Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." + } +} + +# unzip and move +Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null +Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null +try { + Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null +} catch { + if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { + Write-Error "fail to move MAVEN_HOME" + } +} finally { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } +} + +Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" diff --git a/projects-parent/originals-parent/student/.mvn/wrapper/MavenWrapperDownloader.java b/projects-parent/originals-parent/student/.mvn/wrapper/MavenWrapperDownloader.java deleted file mode 100644 index b901097f2..000000000 --- a/projects-parent/originals-parent/student/.mvn/wrapper/MavenWrapperDownloader.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright 2007-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import java.net.*; -import java.io.*; -import java.nio.channels.*; -import java.util.Properties; - -public class MavenWrapperDownloader { - - private static final String WRAPPER_VERSION = "0.5.6"; - /** - * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. - */ - private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" - + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; - - /** - * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to - * use instead of the default one. - */ - private static final String MAVEN_WRAPPER_PROPERTIES_PATH = - ".mvn/wrapper/maven-wrapper.properties"; - - /** - * Path where the maven-wrapper.jar will be saved to. - */ - private static final String MAVEN_WRAPPER_JAR_PATH = - ".mvn/wrapper/maven-wrapper.jar"; - - /** - * Name of the property which should be used to override the default download url for the wrapper. - */ - private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; - - public static void main(String args[]) { - System.out.println("- Downloader started"); - File baseDirectory = new File(args[0]); - System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); - - // If the maven-wrapper.properties exists, read it and check if it contains a custom - // wrapperUrl parameter. - File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); - String url = DEFAULT_DOWNLOAD_URL; - if(mavenWrapperPropertyFile.exists()) { - FileInputStream mavenWrapperPropertyFileInputStream = null; - try { - mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); - Properties mavenWrapperProperties = new Properties(); - mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); - url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); - } catch (IOException e) { - System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); - } finally { - try { - if(mavenWrapperPropertyFileInputStream != null) { - mavenWrapperPropertyFileInputStream.close(); - } - } catch (IOException e) { - // Ignore ... - } - } - } - System.out.println("- Downloading from: " + url); - - File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); - if(!outputFile.getParentFile().exists()) { - if(!outputFile.getParentFile().mkdirs()) { - System.out.println( - "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); - } - } - System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); - try { - downloadFileFromURL(url, outputFile); - System.out.println("Done"); - System.exit(0); - } catch (Throwable e) { - System.out.println("- Error downloading"); - e.printStackTrace(); - System.exit(1); - } - } - - private static void downloadFileFromURL(String urlString, File destination) throws Exception { - if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { - String username = System.getenv("MVNW_USERNAME"); - char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); - Authenticator.setDefault(new Authenticator() { - @Override - protected PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication(username, password); - } - }); - } - URL website = new URL(urlString); - ReadableByteChannel rbc; - rbc = Channels.newChannel(website.openStream()); - FileOutputStream fos = new FileOutputStream(destination); - fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); - fos.close(); - rbc.close(); - } - -} diff --git a/projects-parent/originals-parent/student/.mvn/wrapper/maven-wrapper.properties b/projects-parent/originals-parent/student/.mvn/wrapper/maven-wrapper.properties index 5d43cd338..d58dfb70b 100644 --- a/projects-parent/originals-parent/student/.mvn/wrapper/maven-wrapper.properties +++ b/projects-parent/originals-parent/student/.mvn/wrapper/maven-wrapper.properties @@ -1,2 +1,19 @@ -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +wrapperVersion=3.3.2 +distributionType=only-script +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip diff --git a/projects-parent/originals-parent/student/mvnw b/projects-parent/originals-parent/student/mvnw index 41c0f0c23..19529ddf8 100755 --- a/projects-parent/originals-parent/student/mvnw +++ b/projects-parent/originals-parent/student/mvnw @@ -19,292 +19,241 @@ # ---------------------------------------------------------------------------- # ---------------------------------------------------------------------------- -# Maven Start Up Batch script -# -# Required ENV vars: -# ------------------ -# JAVA_HOME - location of a JDK home dir +# Apache Maven Wrapper startup batch script, version 3.3.2 # # Optional ENV vars # ----------------- -# M2_HOME - location of maven2's installed home dir -# MAVEN_OPTS - parameters passed to the Java VM when running Maven -# e.g. to debug Maven itself, use -# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# JAVA_HOME - location of a JDK home dir, required when download maven via java source +# MVNW_REPOURL - repo url base for downloading maven distribution +# MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +# MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output # ---------------------------------------------------------------------------- -if [ -z "$MAVEN_SKIP_RC" ] ; then - - if [ -f /etc/mavenrc ] ; then - . /etc/mavenrc - fi +set -euf +[ "${MVNW_VERBOSE-}" != debug ] || set -x - if [ -f "$HOME/.mavenrc" ] ; then - . "$HOME/.mavenrc" - fi +# OS specific support. +native_path() { printf %s\\n "$1"; } +case "$(uname)" in +CYGWIN* | MINGW*) + [ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")" + native_path() { cygpath --path --windows "$1"; } + ;; +esac -fi +# set JAVACMD and JAVACCMD +set_java_home() { + # For Cygwin and MinGW, ensure paths are in Unix format before anything is touched + if [ -n "${JAVA_HOME-}" ]; then + if [ -x "$JAVA_HOME/jre/sh/java" ]; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACCMD="$JAVA_HOME/jre/sh/javac" + else + JAVACMD="$JAVA_HOME/bin/java" + JAVACCMD="$JAVA_HOME/bin/javac" -# OS specific support. $var _must_ be set to either true or false. -cygwin=false; -darwin=false; -mingw=false -case "`uname`" in - CYGWIN*) cygwin=true ;; - MINGW*) mingw=true;; - Darwin*) darwin=true - # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home - # See https://developer.apple.com/library/mac/qa/qa1170/_index.html - if [ -z "$JAVA_HOME" ]; then - if [ -x "/usr/libexec/java_home" ]; then - export JAVA_HOME="`/usr/libexec/java_home`" - else - export JAVA_HOME="/Library/Java/Home" + if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then + echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2 + echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2 + return 1 fi fi - ;; -esac - -if [ -z "$JAVA_HOME" ] ; then - if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=`java-config --jre-home` + else + JAVACMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v java + )" || : + JAVACCMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v javac + )" || : + + if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then + echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2 + return 1 + fi fi -fi - -if [ -z "$M2_HOME" ] ; then - ## resolve links - $0 may be a link to maven's home - PRG="$0" +} - # need this for relative symlinks - while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG="`dirname "$PRG"`/$link" - fi +# hash string like Java String::hashCode +hash_string() { + str="${1:-}" h=0 + while [ -n "$str" ]; do + char="${str%"${str#?}"}" + h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296)) + str="${str#?}" done + printf %x\\n $h +} - saveddir=`pwd` +verbose() { :; } +[ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; } - M2_HOME=`dirname "$PRG"`/.. +die() { + printf %s\\n "$1" >&2 + exit 1 +} - # make it fully qualified - M2_HOME=`cd "$M2_HOME" && pwd` +trim() { + # MWRAPPER-139: + # Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds. + # Needed for removing poorly interpreted newline sequences when running in more + # exotic environments such as mingw bash on Windows. + printf "%s" "${1}" | tr -d '[:space:]' +} - cd "$saveddir" - # echo Using m2 at $M2_HOME -fi +# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties +while IFS="=" read -r key value; do + case "${key-}" in + distributionUrl) distributionUrl=$(trim "${value-}") ;; + distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;; + esac +done <"${0%/*}/.mvn/wrapper/maven-wrapper.properties" +[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in ${0%/*}/.mvn/wrapper/maven-wrapper.properties" + +case "${distributionUrl##*/}" in +maven-mvnd-*bin.*) + MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ + case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in + *AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;; + :Darwin*x86_64) distributionPlatform=darwin-amd64 ;; + :Darwin*arm64) distributionPlatform=darwin-aarch64 ;; + :Linux*x86_64*) distributionPlatform=linux-amd64 ;; + *) + echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2 + distributionPlatform=linux-amd64 + ;; + esac + distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip" + ;; +maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;; +*) MVN_CMD="mvn${0##*/mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;; +esac -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin ; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --unix "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` -fi +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}" +distributionUrlName="${distributionUrl##*/}" +distributionUrlNameMain="${distributionUrlName%.*}" +distributionUrlNameMain="${distributionUrlNameMain%-bin}" +MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}" +MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")" + +exec_maven() { + unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || : + exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD" +} -# For Mingw, ensure paths are in UNIX format before anything is touched -if $mingw ; then - [ -n "$M2_HOME" ] && - M2_HOME="`(cd "$M2_HOME"; pwd)`" - [ -n "$JAVA_HOME" ] && - JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +if [ -d "$MAVEN_HOME" ]; then + verbose "found existing MAVEN_HOME at $MAVEN_HOME" + exec_maven "$@" fi -if [ -z "$JAVA_HOME" ]; then - javaExecutable="`which javac`" - if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then - # readlink(1) is not available as standard on Solaris 10. - readLink=`which readlink` - if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then - if $darwin ; then - javaHome="`dirname \"$javaExecutable\"`" - javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" - else - javaExecutable="`readlink -f \"$javaExecutable\"`" - fi - javaHome="`dirname \"$javaExecutable\"`" - javaHome=`expr "$javaHome" : '\(.*\)/bin'` - JAVA_HOME="$javaHome" - export JAVA_HOME - fi - fi -fi +case "${distributionUrl-}" in +*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;; +*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;; +esac -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - else - JAVACMD="`which java`" - fi +# prepare tmp dir +if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then + clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; } + trap clean HUP INT TERM EXIT +else + die "cannot create temp dir" fi -if [ ! -x "$JAVACMD" ] ; then - echo "Error: JAVA_HOME is not defined correctly." >&2 - echo " We cannot execute $JAVACMD" >&2 - exit 1 -fi +mkdir -p -- "${MAVEN_HOME%/*}" + +# Download and Install Apache Maven +verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +verbose "Downloading from: $distributionUrl" +verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" -if [ -z "$JAVA_HOME" ] ; then - echo "Warning: JAVA_HOME environment variable is not set." +# select .zip or .tar.gz +if ! command -v unzip >/dev/null; then + distributionUrl="${distributionUrl%.zip}.tar.gz" + distributionUrlName="${distributionUrl##*/}" fi -CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher +# verbose opt +__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR='' +[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v -# traverses directory structure from process work directory to filesystem root -# first directory with .mvn subdirectory is considered project base directory -find_maven_basedir() { +# normalize http auth +case "${MVNW_PASSWORD:+has-password}" in +'') MVNW_USERNAME='' MVNW_PASSWORD='' ;; +has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;; +esac - if [ -z "$1" ] - then - echo "Path not specified to find_maven_basedir" - return 1 - fi +if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then + verbose "Found wget ... using wget" + wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl" +elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then + verbose "Found curl ... using curl" + curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl" +elif set_java_home; then + verbose "Falling back to use Java to download" + javaSource="$TMP_DOWNLOAD_DIR/Downloader.java" + targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName" + cat >"$javaSource" <<-END + public class Downloader extends java.net.Authenticator + { + protected java.net.PasswordAuthentication getPasswordAuthentication() + { + return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() ); + } + public static void main( String[] args ) throws Exception + { + setDefault( new Downloader() ); + java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() ); + } + } + END + # For Cygwin/MinGW, switch paths to Windows format before running javac and java + verbose " - Compiling Downloader.java ..." + "$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java" + verbose " - Running Downloader.java ..." + "$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")" +fi - basedir="$1" - wdir="$1" - while [ "$wdir" != '/' ] ; do - if [ -d "$wdir"/.mvn ] ; then - basedir=$wdir - break +# If specified, validate the SHA-256 sum of the Maven distribution zip file +if [ -n "${distributionSha256Sum-}" ]; then + distributionSha256Result=false + if [ "$MVN_CMD" = mvnd.sh ]; then + echo "Checksum validation is not supported for maven-mvnd." >&2 + echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + elif command -v sha256sum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c >/dev/null 2>&1; then + distributionSha256Result=true fi - # workaround for JBEAP-8937 (on Solaris 10/Sparc) - if [ -d "${wdir}" ]; then - wdir=`cd "$wdir/.."; pwd` + elif command -v shasum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then + distributionSha256Result=true fi - # end of workaround - done - echo "${basedir}" -} - -# concatenates all lines of a file -concat_lines() { - if [ -f "$1" ]; then - echo "$(tr -s '\n' ' ' < "$1")" + else + echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2 + echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + fi + if [ $distributionSha256Result = false ]; then + echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2 + echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2 + exit 1 fi -} - -BASE_DIR=`find_maven_basedir "$(pwd)"` -if [ -z "$BASE_DIR" ]; then - exit 1; fi -########################################################################################## -# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -# This allows using the maven wrapper in projects that prohibit checking in binary data. -########################################################################################## -if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found .mvn/wrapper/maven-wrapper.jar" - fi +# unzip and move +if command -v unzip >/dev/null; then + unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip" else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." - fi - if [ -n "$MVNW_REPOURL" ]; then - jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - else - jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - fi - while IFS="=" read key value; do - case "$key" in (wrapperUrl) jarUrl="$value"; break ;; - esac - done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" - if [ "$MVNW_VERBOSE" = true ]; then - echo "Downloading from: $jarUrl" - fi - wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" - if $cygwin; then - wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` - fi - - if command -v wget > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found wget ... using wget" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - wget "$jarUrl" -O "$wrapperJarPath" - else - wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" - fi - elif command -v curl > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found curl ... using curl" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - curl -o "$wrapperJarPath" "$jarUrl" -f - else - curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f - fi - - else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Falling back to using Java to download" - fi - javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" - # For Cygwin, switch paths to Windows format before running javac - if $cygwin; then - javaClass=`cygpath --path --windows "$javaClass"` - fi - if [ -e "$javaClass" ]; then - if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Compiling MavenWrapperDownloader.java ..." - fi - # Compiling the Java class - ("$JAVA_HOME/bin/javac" "$javaClass") - fi - if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - # Running the downloader - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Running MavenWrapperDownloader.java ..." - fi - ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") - fi - fi - fi -fi -########################################################################################## -# End of extension -########################################################################################## - -export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} -if [ "$MVNW_VERBOSE" = true ]; then - echo $MAVEN_PROJECTBASEDIR + tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar" fi -MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" - -# For Cygwin, switch paths to Windows format before running java -if $cygwin; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --path --windows "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --windows "$CLASSPATH"` - [ -n "$MAVEN_PROJECTBASEDIR" ] && - MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` -fi - -# Provide a "standardized" way to retrieve the CLI args that will -# work with both Windows and non-Windows executions. -MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" -export MAVEN_CMD_LINE_ARGS - -WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain +printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/mvnw.url" +mv -- "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME" -exec "$JAVACMD" \ - $MAVEN_OPTS \ - -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ - "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" +clean || : +exec_maven "$@" diff --git a/projects-parent/originals-parent/student/mvnw.cmd b/projects-parent/originals-parent/student/mvnw.cmd index 86115719e..249bdf382 100644 --- a/projects-parent/originals-parent/student/mvnw.cmd +++ b/projects-parent/originals-parent/student/mvnw.cmd @@ -1,3 +1,4 @@ +<# : batch portion @REM ---------------------------------------------------------------------------- @REM Licensed to the Apache Software Foundation (ASF) under one @REM or more contributor license agreements. See the NOTICE file @@ -18,165 +19,131 @@ @REM ---------------------------------------------------------------------------- @REM ---------------------------------------------------------------------------- -@REM Maven Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir +@REM Apache Maven Wrapper startup batch script, version 3.3.2 @REM @REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM MVNW_REPOURL - repo url base for downloading maven distribution +@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output @REM ---------------------------------------------------------------------------- -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - -FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( - IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B -) - -@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -@REM This allows using the maven wrapper in projects that prohibit checking in binary data. -if exist %WRAPPER_JAR% ( - if "%MVNW_VERBOSE%" == "true" ( - echo Found %WRAPPER_JAR% - ) -) else ( - if not "%MVNW_REPOURL%" == "" ( - SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - ) - if "%MVNW_VERBOSE%" == "true" ( - echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %DOWNLOAD_URL% - ) - - powershell -Command "&{"^ - "$webclient = new-object System.Net.WebClient;"^ - "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ - "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ - "}"^ - "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ - "}" - if "%MVNW_VERBOSE%" == "true" ( - echo Finished downloading %WRAPPER_JAR% - ) +@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) +@SET __MVNW_CMD__= +@SET __MVNW_ERROR__= +@SET __MVNW_PSMODULEP_SAVE=%PSModulePath% +@SET PSModulePath= +@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( + IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) ) -@REM End of extension - -@REM Provide a "standardized" way to retrieve the CLI args that will -@REM work with both Windows and non-Windows executions. -set MAVEN_CMD_LINE_ARGS=%* - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% +@SET PSModulePath=%__MVNW_PSMODULEP_SAVE% +@SET __MVNW_PSMODULEP_SAVE= +@SET __MVNW_ARG0_NAME__= +@SET MVNW_USERNAME= +@SET MVNW_PASSWORD= +@IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*) +@echo Cannot start maven from wrapper >&2 && exit /b 1 +@GOTO :EOF +: end batch / begin powershell #> + +$ErrorActionPreference = "Stop" +if ($env:MVNW_VERBOSE -eq "true") { + $VerbosePreference = "Continue" +} + +# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties +$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl +if (!$distributionUrl) { + Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" +} + +switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { + "maven-mvnd-*" { + $USE_MVND = $true + $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" + $MVN_CMD = "mvnd.cmd" + break + } + default { + $USE_MVND = $false + $MVN_CMD = $script -replace '^mvnw','mvn' + break + } +} + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +if ($env:MVNW_REPOURL) { + $MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" } + $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')" +} +$distributionUrlName = $distributionUrl -replace '^.*/','' +$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' +$MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain" +if ($env:MAVEN_USER_HOME) { + $MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain" +} +$MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' +$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" + +if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { + Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" + Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" + exit $? +} + +if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { + Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" +} + +# prepare tmp dir +$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile +$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" +$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null +trap { + if ($TMP_DOWNLOAD_DIR.Exists) { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } + } +} + +New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null + +# Download and Install Apache Maven +Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +Write-Verbose "Downloading from: $distributionUrl" +Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +$webclient = New-Object System.Net.WebClient +if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { + $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) +} +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 +$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum +if ($distributionSha256Sum) { + if ($USE_MVND) { + Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." + } + Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash + if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { + Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." + } +} + +# unzip and move +Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null +Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null +try { + Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null +} catch { + if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { + Write-Error "fail to move MAVEN_HOME" + } +} finally { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } +} + +Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" From 5a439795cd45391f94e5705da6d1f63ec1fdb93c Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Fri, 29 Nov 2024 13:35:23 -0800 Subject: [PATCH 45/59] Use the official Maven Wrapper for the Airline archetype. --- .../.mvn/wrapper/maven-wrapper.properties | 21 +- .../resources/archetype-resources/mvnw.cmd | 281 ++++++++---------- 2 files changed, 143 insertions(+), 159 deletions(-) diff --git a/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/.mvn/wrapper/maven-wrapper.properties b/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/.mvn/wrapper/maven-wrapper.properties index 95d55bc41..20c81b37a 100644 --- a/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/.mvn/wrapper/maven-wrapper.properties +++ b/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/.mvn/wrapper/maven-wrapper.properties @@ -1,5 +1,22 @@ #set( $symbol_pound = '#' ) #set( $symbol_dollar = '$' ) #set( $symbol_escape = '\' ) -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar +${symbol_pound} Licensed to the Apache Software Foundation (ASF) under one +${symbol_pound} or more contributor license agreements. See the NOTICE file +${symbol_pound} distributed with this work for additional information +${symbol_pound} regarding copyright ownership. The ASF licenses this file +${symbol_pound} to you under the Apache License, Version 2.0 (the +${symbol_pound} "License"); you may not use this file except in compliance +${symbol_pound} with the License. You may obtain a copy of the License at +${symbol_pound} +${symbol_pound} http://www.apache.org/licenses/LICENSE-2.0 +${symbol_pound} +${symbol_pound} Unless required by applicable law or agreed to in writing, +${symbol_pound} software distributed under the License is distributed on an +${symbol_pound} "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +${symbol_pound} KIND, either express or implied. See the License for the +${symbol_pound} specific language governing permissions and limitations +${symbol_pound} under the License. +wrapperVersion=3.3.2 +distributionType=only-script +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip diff --git a/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/mvnw.cmd b/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/mvnw.cmd index 86115719e..249bdf382 100644 --- a/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/mvnw.cmd +++ b/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/mvnw.cmd @@ -1,3 +1,4 @@ +<# : batch portion @REM ---------------------------------------------------------------------------- @REM Licensed to the Apache Software Foundation (ASF) under one @REM or more contributor license agreements. See the NOTICE file @@ -18,165 +19,131 @@ @REM ---------------------------------------------------------------------------- @REM ---------------------------------------------------------------------------- -@REM Maven Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir +@REM Apache Maven Wrapper startup batch script, version 3.3.2 @REM @REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM MVNW_REPOURL - repo url base for downloading maven distribution +@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output @REM ---------------------------------------------------------------------------- -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - -FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( - IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B -) - -@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -@REM This allows using the maven wrapper in projects that prohibit checking in binary data. -if exist %WRAPPER_JAR% ( - if "%MVNW_VERBOSE%" == "true" ( - echo Found %WRAPPER_JAR% - ) -) else ( - if not "%MVNW_REPOURL%" == "" ( - SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - ) - if "%MVNW_VERBOSE%" == "true" ( - echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %DOWNLOAD_URL% - ) - - powershell -Command "&{"^ - "$webclient = new-object System.Net.WebClient;"^ - "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ - "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ - "}"^ - "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ - "}" - if "%MVNW_VERBOSE%" == "true" ( - echo Finished downloading %WRAPPER_JAR% - ) +@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) +@SET __MVNW_CMD__= +@SET __MVNW_ERROR__= +@SET __MVNW_PSMODULEP_SAVE=%PSModulePath% +@SET PSModulePath= +@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( + IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) ) -@REM End of extension - -@REM Provide a "standardized" way to retrieve the CLI args that will -@REM work with both Windows and non-Windows executions. -set MAVEN_CMD_LINE_ARGS=%* - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% +@SET PSModulePath=%__MVNW_PSMODULEP_SAVE% +@SET __MVNW_PSMODULEP_SAVE= +@SET __MVNW_ARG0_NAME__= +@SET MVNW_USERNAME= +@SET MVNW_PASSWORD= +@IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*) +@echo Cannot start maven from wrapper >&2 && exit /b 1 +@GOTO :EOF +: end batch / begin powershell #> + +$ErrorActionPreference = "Stop" +if ($env:MVNW_VERBOSE -eq "true") { + $VerbosePreference = "Continue" +} + +# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties +$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl +if (!$distributionUrl) { + Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" +} + +switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { + "maven-mvnd-*" { + $USE_MVND = $true + $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" + $MVN_CMD = "mvnd.cmd" + break + } + default { + $USE_MVND = $false + $MVN_CMD = $script -replace '^mvnw','mvn' + break + } +} + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +if ($env:MVNW_REPOURL) { + $MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" } + $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')" +} +$distributionUrlName = $distributionUrl -replace '^.*/','' +$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' +$MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain" +if ($env:MAVEN_USER_HOME) { + $MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain" +} +$MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' +$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" + +if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { + Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" + Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" + exit $? +} + +if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { + Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" +} + +# prepare tmp dir +$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile +$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" +$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null +trap { + if ($TMP_DOWNLOAD_DIR.Exists) { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } + } +} + +New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null + +# Download and Install Apache Maven +Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +Write-Verbose "Downloading from: $distributionUrl" +Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +$webclient = New-Object System.Net.WebClient +if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { + $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) +} +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 +$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum +if ($distributionSha256Sum) { + if ($USE_MVND) { + Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." + } + Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash + if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { + Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." + } +} + +# unzip and move +Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null +Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null +try { + Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null +} catch { + if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { + Write-Error "fail to move MAVEN_HOME" + } +} finally { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } +} + +Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" From 6486218fe86fdd93a2e2e1d57ed4d1c60d9cb014 Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Fri, 29 Nov 2024 13:38:43 -0800 Subject: [PATCH 46/59] Use the official Maven Wrapper for the Airline Web archetype. --- .../.mvn/wrapper/maven-wrapper.properties | 21 +- .../resources/archetype-resources/mvnw.cmd | 281 ++++++++---------- 2 files changed, 143 insertions(+), 159 deletions(-) diff --git a/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/.mvn/wrapper/maven-wrapper.properties b/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/.mvn/wrapper/maven-wrapper.properties index 95d55bc41..20c81b37a 100644 --- a/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/.mvn/wrapper/maven-wrapper.properties +++ b/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/.mvn/wrapper/maven-wrapper.properties @@ -1,5 +1,22 @@ #set( $symbol_pound = '#' ) #set( $symbol_dollar = '$' ) #set( $symbol_escape = '\' ) -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar +${symbol_pound} Licensed to the Apache Software Foundation (ASF) under one +${symbol_pound} or more contributor license agreements. See the NOTICE file +${symbol_pound} distributed with this work for additional information +${symbol_pound} regarding copyright ownership. The ASF licenses this file +${symbol_pound} to you under the Apache License, Version 2.0 (the +${symbol_pound} "License"); you may not use this file except in compliance +${symbol_pound} with the License. You may obtain a copy of the License at +${symbol_pound} +${symbol_pound} http://www.apache.org/licenses/LICENSE-2.0 +${symbol_pound} +${symbol_pound} Unless required by applicable law or agreed to in writing, +${symbol_pound} software distributed under the License is distributed on an +${symbol_pound} "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +${symbol_pound} KIND, either express or implied. See the License for the +${symbol_pound} specific language governing permissions and limitations +${symbol_pound} under the License. +wrapperVersion=3.3.2 +distributionType=only-script +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip diff --git a/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/mvnw.cmd b/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/mvnw.cmd index 86115719e..249bdf382 100644 --- a/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/mvnw.cmd +++ b/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/mvnw.cmd @@ -1,3 +1,4 @@ +<# : batch portion @REM ---------------------------------------------------------------------------- @REM Licensed to the Apache Software Foundation (ASF) under one @REM or more contributor license agreements. See the NOTICE file @@ -18,165 +19,131 @@ @REM ---------------------------------------------------------------------------- @REM ---------------------------------------------------------------------------- -@REM Maven Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir +@REM Apache Maven Wrapper startup batch script, version 3.3.2 @REM @REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM MVNW_REPOURL - repo url base for downloading maven distribution +@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output @REM ---------------------------------------------------------------------------- -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - -FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( - IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B -) - -@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -@REM This allows using the maven wrapper in projects that prohibit checking in binary data. -if exist %WRAPPER_JAR% ( - if "%MVNW_VERBOSE%" == "true" ( - echo Found %WRAPPER_JAR% - ) -) else ( - if not "%MVNW_REPOURL%" == "" ( - SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - ) - if "%MVNW_VERBOSE%" == "true" ( - echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %DOWNLOAD_URL% - ) - - powershell -Command "&{"^ - "$webclient = new-object System.Net.WebClient;"^ - "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ - "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ - "}"^ - "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ - "}" - if "%MVNW_VERBOSE%" == "true" ( - echo Finished downloading %WRAPPER_JAR% - ) +@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) +@SET __MVNW_CMD__= +@SET __MVNW_ERROR__= +@SET __MVNW_PSMODULEP_SAVE=%PSModulePath% +@SET PSModulePath= +@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( + IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) ) -@REM End of extension - -@REM Provide a "standardized" way to retrieve the CLI args that will -@REM work with both Windows and non-Windows executions. -set MAVEN_CMD_LINE_ARGS=%* - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% +@SET PSModulePath=%__MVNW_PSMODULEP_SAVE% +@SET __MVNW_PSMODULEP_SAVE= +@SET __MVNW_ARG0_NAME__= +@SET MVNW_USERNAME= +@SET MVNW_PASSWORD= +@IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*) +@echo Cannot start maven from wrapper >&2 && exit /b 1 +@GOTO :EOF +: end batch / begin powershell #> + +$ErrorActionPreference = "Stop" +if ($env:MVNW_VERBOSE -eq "true") { + $VerbosePreference = "Continue" +} + +# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties +$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl +if (!$distributionUrl) { + Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" +} + +switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { + "maven-mvnd-*" { + $USE_MVND = $true + $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" + $MVN_CMD = "mvnd.cmd" + break + } + default { + $USE_MVND = $false + $MVN_CMD = $script -replace '^mvnw','mvn' + break + } +} + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +if ($env:MVNW_REPOURL) { + $MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" } + $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')" +} +$distributionUrlName = $distributionUrl -replace '^.*/','' +$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' +$MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain" +if ($env:MAVEN_USER_HOME) { + $MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain" +} +$MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' +$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" + +if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { + Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" + Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" + exit $? +} + +if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { + Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" +} + +# prepare tmp dir +$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile +$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" +$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null +trap { + if ($TMP_DOWNLOAD_DIR.Exists) { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } + } +} + +New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null + +# Download and Install Apache Maven +Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +Write-Verbose "Downloading from: $distributionUrl" +Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +$webclient = New-Object System.Net.WebClient +if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { + $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) +} +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 +$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum +if ($distributionSha256Sum) { + if ($USE_MVND) { + Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." + } + Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash + if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { + Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." + } +} + +# unzip and move +Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null +Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null +try { + Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null +} catch { + if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { + Write-Error "fail to move MAVEN_HOME" + } +} finally { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } +} + +Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" From 02a79f6fded7998c1dfa4476d72d15166e8736b7 Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Fri, 29 Nov 2024 13:42:44 -0800 Subject: [PATCH 47/59] Use the official Maven Wrapper for the Appointment Book archetype. --- .../.mvn/wrapper/maven-wrapper.properties | 21 +- .../resources/archetype-resources/mvnw.cmd | 281 ++++++++---------- 2 files changed, 143 insertions(+), 159 deletions(-) diff --git a/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/.mvn/wrapper/maven-wrapper.properties b/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/.mvn/wrapper/maven-wrapper.properties index 95d55bc41..20c81b37a 100644 --- a/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/.mvn/wrapper/maven-wrapper.properties +++ b/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/.mvn/wrapper/maven-wrapper.properties @@ -1,5 +1,22 @@ #set( $symbol_pound = '#' ) #set( $symbol_dollar = '$' ) #set( $symbol_escape = '\' ) -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar +${symbol_pound} Licensed to the Apache Software Foundation (ASF) under one +${symbol_pound} or more contributor license agreements. See the NOTICE file +${symbol_pound} distributed with this work for additional information +${symbol_pound} regarding copyright ownership. The ASF licenses this file +${symbol_pound} to you under the Apache License, Version 2.0 (the +${symbol_pound} "License"); you may not use this file except in compliance +${symbol_pound} with the License. You may obtain a copy of the License at +${symbol_pound} +${symbol_pound} http://www.apache.org/licenses/LICENSE-2.0 +${symbol_pound} +${symbol_pound} Unless required by applicable law or agreed to in writing, +${symbol_pound} software distributed under the License is distributed on an +${symbol_pound} "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +${symbol_pound} KIND, either express or implied. See the License for the +${symbol_pound} specific language governing permissions and limitations +${symbol_pound} under the License. +wrapperVersion=3.3.2 +distributionType=only-script +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip diff --git a/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/mvnw.cmd b/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/mvnw.cmd index 86115719e..249bdf382 100644 --- a/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/mvnw.cmd +++ b/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/mvnw.cmd @@ -1,3 +1,4 @@ +<# : batch portion @REM ---------------------------------------------------------------------------- @REM Licensed to the Apache Software Foundation (ASF) under one @REM or more contributor license agreements. See the NOTICE file @@ -18,165 +19,131 @@ @REM ---------------------------------------------------------------------------- @REM ---------------------------------------------------------------------------- -@REM Maven Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir +@REM Apache Maven Wrapper startup batch script, version 3.3.2 @REM @REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM MVNW_REPOURL - repo url base for downloading maven distribution +@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output @REM ---------------------------------------------------------------------------- -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - -FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( - IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B -) - -@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -@REM This allows using the maven wrapper in projects that prohibit checking in binary data. -if exist %WRAPPER_JAR% ( - if "%MVNW_VERBOSE%" == "true" ( - echo Found %WRAPPER_JAR% - ) -) else ( - if not "%MVNW_REPOURL%" == "" ( - SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - ) - if "%MVNW_VERBOSE%" == "true" ( - echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %DOWNLOAD_URL% - ) - - powershell -Command "&{"^ - "$webclient = new-object System.Net.WebClient;"^ - "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ - "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ - "}"^ - "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ - "}" - if "%MVNW_VERBOSE%" == "true" ( - echo Finished downloading %WRAPPER_JAR% - ) +@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) +@SET __MVNW_CMD__= +@SET __MVNW_ERROR__= +@SET __MVNW_PSMODULEP_SAVE=%PSModulePath% +@SET PSModulePath= +@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( + IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) ) -@REM End of extension - -@REM Provide a "standardized" way to retrieve the CLI args that will -@REM work with both Windows and non-Windows executions. -set MAVEN_CMD_LINE_ARGS=%* - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% +@SET PSModulePath=%__MVNW_PSMODULEP_SAVE% +@SET __MVNW_PSMODULEP_SAVE= +@SET __MVNW_ARG0_NAME__= +@SET MVNW_USERNAME= +@SET MVNW_PASSWORD= +@IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*) +@echo Cannot start maven from wrapper >&2 && exit /b 1 +@GOTO :EOF +: end batch / begin powershell #> + +$ErrorActionPreference = "Stop" +if ($env:MVNW_VERBOSE -eq "true") { + $VerbosePreference = "Continue" +} + +# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties +$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl +if (!$distributionUrl) { + Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" +} + +switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { + "maven-mvnd-*" { + $USE_MVND = $true + $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" + $MVN_CMD = "mvnd.cmd" + break + } + default { + $USE_MVND = $false + $MVN_CMD = $script -replace '^mvnw','mvn' + break + } +} + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +if ($env:MVNW_REPOURL) { + $MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" } + $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')" +} +$distributionUrlName = $distributionUrl -replace '^.*/','' +$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' +$MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain" +if ($env:MAVEN_USER_HOME) { + $MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain" +} +$MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' +$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" + +if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { + Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" + Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" + exit $? +} + +if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { + Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" +} + +# prepare tmp dir +$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile +$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" +$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null +trap { + if ($TMP_DOWNLOAD_DIR.Exists) { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } + } +} + +New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null + +# Download and Install Apache Maven +Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +Write-Verbose "Downloading from: $distributionUrl" +Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +$webclient = New-Object System.Net.WebClient +if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { + $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) +} +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 +$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum +if ($distributionSha256Sum) { + if ($USE_MVND) { + Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." + } + Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash + if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { + Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." + } +} + +# unzip and move +Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null +Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null +try { + Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null +} catch { + if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { + Write-Error "fail to move MAVEN_HOME" + } +} finally { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } +} + +Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" From ad9cbe91abda6e54985b3eb48ca716a1bd796053 Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Fri, 29 Nov 2024 13:45:08 -0800 Subject: [PATCH 48/59] Use the official Maven Wrapper for the Appointment Book Web archetype. --- .../.mvn/wrapper/maven-wrapper.properties | 21 +- .../resources/archetype-resources/mvnw.cmd | 281 ++++++++---------- 2 files changed, 143 insertions(+), 159 deletions(-) diff --git a/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/.mvn/wrapper/maven-wrapper.properties b/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/.mvn/wrapper/maven-wrapper.properties index 95d55bc41..20c81b37a 100644 --- a/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/.mvn/wrapper/maven-wrapper.properties +++ b/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/.mvn/wrapper/maven-wrapper.properties @@ -1,5 +1,22 @@ #set( $symbol_pound = '#' ) #set( $symbol_dollar = '$' ) #set( $symbol_escape = '\' ) -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar +${symbol_pound} Licensed to the Apache Software Foundation (ASF) under one +${symbol_pound} or more contributor license agreements. See the NOTICE file +${symbol_pound} distributed with this work for additional information +${symbol_pound} regarding copyright ownership. The ASF licenses this file +${symbol_pound} to you under the Apache License, Version 2.0 (the +${symbol_pound} "License"); you may not use this file except in compliance +${symbol_pound} with the License. You may obtain a copy of the License at +${symbol_pound} +${symbol_pound} http://www.apache.org/licenses/LICENSE-2.0 +${symbol_pound} +${symbol_pound} Unless required by applicable law or agreed to in writing, +${symbol_pound} software distributed under the License is distributed on an +${symbol_pound} "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +${symbol_pound} KIND, either express or implied. See the License for the +${symbol_pound} specific language governing permissions and limitations +${symbol_pound} under the License. +wrapperVersion=3.3.2 +distributionType=only-script +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip diff --git a/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/mvnw.cmd b/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/mvnw.cmd index 86115719e..249bdf382 100644 --- a/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/mvnw.cmd +++ b/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/mvnw.cmd @@ -1,3 +1,4 @@ +<# : batch portion @REM ---------------------------------------------------------------------------- @REM Licensed to the Apache Software Foundation (ASF) under one @REM or more contributor license agreements. See the NOTICE file @@ -18,165 +19,131 @@ @REM ---------------------------------------------------------------------------- @REM ---------------------------------------------------------------------------- -@REM Maven Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir +@REM Apache Maven Wrapper startup batch script, version 3.3.2 @REM @REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM MVNW_REPOURL - repo url base for downloading maven distribution +@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output @REM ---------------------------------------------------------------------------- -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - -FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( - IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B -) - -@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -@REM This allows using the maven wrapper in projects that prohibit checking in binary data. -if exist %WRAPPER_JAR% ( - if "%MVNW_VERBOSE%" == "true" ( - echo Found %WRAPPER_JAR% - ) -) else ( - if not "%MVNW_REPOURL%" == "" ( - SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - ) - if "%MVNW_VERBOSE%" == "true" ( - echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %DOWNLOAD_URL% - ) - - powershell -Command "&{"^ - "$webclient = new-object System.Net.WebClient;"^ - "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ - "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ - "}"^ - "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ - "}" - if "%MVNW_VERBOSE%" == "true" ( - echo Finished downloading %WRAPPER_JAR% - ) +@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) +@SET __MVNW_CMD__= +@SET __MVNW_ERROR__= +@SET __MVNW_PSMODULEP_SAVE=%PSModulePath% +@SET PSModulePath= +@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( + IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) ) -@REM End of extension - -@REM Provide a "standardized" way to retrieve the CLI args that will -@REM work with both Windows and non-Windows executions. -set MAVEN_CMD_LINE_ARGS=%* - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% +@SET PSModulePath=%__MVNW_PSMODULEP_SAVE% +@SET __MVNW_PSMODULEP_SAVE= +@SET __MVNW_ARG0_NAME__= +@SET MVNW_USERNAME= +@SET MVNW_PASSWORD= +@IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*) +@echo Cannot start maven from wrapper >&2 && exit /b 1 +@GOTO :EOF +: end batch / begin powershell #> + +$ErrorActionPreference = "Stop" +if ($env:MVNW_VERBOSE -eq "true") { + $VerbosePreference = "Continue" +} + +# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties +$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl +if (!$distributionUrl) { + Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" +} + +switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { + "maven-mvnd-*" { + $USE_MVND = $true + $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" + $MVN_CMD = "mvnd.cmd" + break + } + default { + $USE_MVND = $false + $MVN_CMD = $script -replace '^mvnw','mvn' + break + } +} + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +if ($env:MVNW_REPOURL) { + $MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" } + $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')" +} +$distributionUrlName = $distributionUrl -replace '^.*/','' +$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' +$MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain" +if ($env:MAVEN_USER_HOME) { + $MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain" +} +$MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' +$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" + +if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { + Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" + Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" + exit $? +} + +if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { + Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" +} + +# prepare tmp dir +$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile +$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" +$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null +trap { + if ($TMP_DOWNLOAD_DIR.Exists) { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } + } +} + +New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null + +# Download and Install Apache Maven +Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +Write-Verbose "Downloading from: $distributionUrl" +Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +$webclient = New-Object System.Net.WebClient +if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { + $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) +} +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 +$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum +if ($distributionSha256Sum) { + if ($USE_MVND) { + Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." + } + Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash + if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { + Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." + } +} + +# unzip and move +Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null +Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null +try { + Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null +} catch { + if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { + Write-Error "fail to move MAVEN_HOME" + } +} finally { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } +} + +Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" From 1f0fd858557f0083cb4dd031f2076ac10541b3ee Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Fri, 29 Nov 2024 13:50:02 -0800 Subject: [PATCH 49/59] Use the official Maven Wrapper for the Kata archetype. --- .../.mvn/wrapper/maven-wrapper.properties | 21 +- .../resources/archetype-resources/mvnw.cmd | 281 ++++++++---------- 2 files changed, 143 insertions(+), 159 deletions(-) diff --git a/projects-parent/archetypes-parent/kata-archetype/src/main/resources/archetype-resources/.mvn/wrapper/maven-wrapper.properties b/projects-parent/archetypes-parent/kata-archetype/src/main/resources/archetype-resources/.mvn/wrapper/maven-wrapper.properties index 95d55bc41..20c81b37a 100644 --- a/projects-parent/archetypes-parent/kata-archetype/src/main/resources/archetype-resources/.mvn/wrapper/maven-wrapper.properties +++ b/projects-parent/archetypes-parent/kata-archetype/src/main/resources/archetype-resources/.mvn/wrapper/maven-wrapper.properties @@ -1,5 +1,22 @@ #set( $symbol_pound = '#' ) #set( $symbol_dollar = '$' ) #set( $symbol_escape = '\' ) -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar +${symbol_pound} Licensed to the Apache Software Foundation (ASF) under one +${symbol_pound} or more contributor license agreements. See the NOTICE file +${symbol_pound} distributed with this work for additional information +${symbol_pound} regarding copyright ownership. The ASF licenses this file +${symbol_pound} to you under the Apache License, Version 2.0 (the +${symbol_pound} "License"); you may not use this file except in compliance +${symbol_pound} with the License. You may obtain a copy of the License at +${symbol_pound} +${symbol_pound} http://www.apache.org/licenses/LICENSE-2.0 +${symbol_pound} +${symbol_pound} Unless required by applicable law or agreed to in writing, +${symbol_pound} software distributed under the License is distributed on an +${symbol_pound} "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +${symbol_pound} KIND, either express or implied. See the License for the +${symbol_pound} specific language governing permissions and limitations +${symbol_pound} under the License. +wrapperVersion=3.3.2 +distributionType=only-script +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip diff --git a/projects-parent/archetypes-parent/kata-archetype/src/main/resources/archetype-resources/mvnw.cmd b/projects-parent/archetypes-parent/kata-archetype/src/main/resources/archetype-resources/mvnw.cmd index 86115719e..249bdf382 100644 --- a/projects-parent/archetypes-parent/kata-archetype/src/main/resources/archetype-resources/mvnw.cmd +++ b/projects-parent/archetypes-parent/kata-archetype/src/main/resources/archetype-resources/mvnw.cmd @@ -1,3 +1,4 @@ +<# : batch portion @REM ---------------------------------------------------------------------------- @REM Licensed to the Apache Software Foundation (ASF) under one @REM or more contributor license agreements. See the NOTICE file @@ -18,165 +19,131 @@ @REM ---------------------------------------------------------------------------- @REM ---------------------------------------------------------------------------- -@REM Maven Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir +@REM Apache Maven Wrapper startup batch script, version 3.3.2 @REM @REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM MVNW_REPOURL - repo url base for downloading maven distribution +@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output @REM ---------------------------------------------------------------------------- -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - -FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( - IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B -) - -@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -@REM This allows using the maven wrapper in projects that prohibit checking in binary data. -if exist %WRAPPER_JAR% ( - if "%MVNW_VERBOSE%" == "true" ( - echo Found %WRAPPER_JAR% - ) -) else ( - if not "%MVNW_REPOURL%" == "" ( - SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - ) - if "%MVNW_VERBOSE%" == "true" ( - echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %DOWNLOAD_URL% - ) - - powershell -Command "&{"^ - "$webclient = new-object System.Net.WebClient;"^ - "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ - "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ - "}"^ - "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ - "}" - if "%MVNW_VERBOSE%" == "true" ( - echo Finished downloading %WRAPPER_JAR% - ) +@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) +@SET __MVNW_CMD__= +@SET __MVNW_ERROR__= +@SET __MVNW_PSMODULEP_SAVE=%PSModulePath% +@SET PSModulePath= +@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( + IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) ) -@REM End of extension - -@REM Provide a "standardized" way to retrieve the CLI args that will -@REM work with both Windows and non-Windows executions. -set MAVEN_CMD_LINE_ARGS=%* - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% +@SET PSModulePath=%__MVNW_PSMODULEP_SAVE% +@SET __MVNW_PSMODULEP_SAVE= +@SET __MVNW_ARG0_NAME__= +@SET MVNW_USERNAME= +@SET MVNW_PASSWORD= +@IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*) +@echo Cannot start maven from wrapper >&2 && exit /b 1 +@GOTO :EOF +: end batch / begin powershell #> + +$ErrorActionPreference = "Stop" +if ($env:MVNW_VERBOSE -eq "true") { + $VerbosePreference = "Continue" +} + +# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties +$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl +if (!$distributionUrl) { + Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" +} + +switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { + "maven-mvnd-*" { + $USE_MVND = $true + $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" + $MVN_CMD = "mvnd.cmd" + break + } + default { + $USE_MVND = $false + $MVN_CMD = $script -replace '^mvnw','mvn' + break + } +} + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +if ($env:MVNW_REPOURL) { + $MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" } + $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')" +} +$distributionUrlName = $distributionUrl -replace '^.*/','' +$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' +$MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain" +if ($env:MAVEN_USER_HOME) { + $MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain" +} +$MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' +$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" + +if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { + Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" + Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" + exit $? +} + +if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { + Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" +} + +# prepare tmp dir +$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile +$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" +$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null +trap { + if ($TMP_DOWNLOAD_DIR.Exists) { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } + } +} + +New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null + +# Download and Install Apache Maven +Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +Write-Verbose "Downloading from: $distributionUrl" +Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +$webclient = New-Object System.Net.WebClient +if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { + $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) +} +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 +$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum +if ($distributionSha256Sum) { + if ($USE_MVND) { + Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." + } + Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash + if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { + Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." + } +} + +# unzip and move +Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null +Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null +try { + Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null +} catch { + if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { + Write-Error "fail to move MAVEN_HOME" + } +} finally { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } +} + +Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" From beb22ff01169dda0d90283f078146c3db748de45 Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Fri, 29 Nov 2024 13:54:12 -0800 Subject: [PATCH 50/59] Use the official Maven Wrapper for the Phone Bill archetype. --- .../.mvn/wrapper/maven-wrapper.properties | 21 +- .../resources/archetype-resources/mvnw.cmd | 281 ++++++++---------- 2 files changed, 143 insertions(+), 159 deletions(-) diff --git a/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/.mvn/wrapper/maven-wrapper.properties b/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/.mvn/wrapper/maven-wrapper.properties index 95d55bc41..20c81b37a 100644 --- a/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/.mvn/wrapper/maven-wrapper.properties +++ b/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/.mvn/wrapper/maven-wrapper.properties @@ -1,5 +1,22 @@ #set( $symbol_pound = '#' ) #set( $symbol_dollar = '$' ) #set( $symbol_escape = '\' ) -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar +${symbol_pound} Licensed to the Apache Software Foundation (ASF) under one +${symbol_pound} or more contributor license agreements. See the NOTICE file +${symbol_pound} distributed with this work for additional information +${symbol_pound} regarding copyright ownership. The ASF licenses this file +${symbol_pound} to you under the Apache License, Version 2.0 (the +${symbol_pound} "License"); you may not use this file except in compliance +${symbol_pound} with the License. You may obtain a copy of the License at +${symbol_pound} +${symbol_pound} http://www.apache.org/licenses/LICENSE-2.0 +${symbol_pound} +${symbol_pound} Unless required by applicable law or agreed to in writing, +${symbol_pound} software distributed under the License is distributed on an +${symbol_pound} "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +${symbol_pound} KIND, either express or implied. See the License for the +${symbol_pound} specific language governing permissions and limitations +${symbol_pound} under the License. +wrapperVersion=3.3.2 +distributionType=only-script +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip diff --git a/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/mvnw.cmd b/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/mvnw.cmd index 86115719e..249bdf382 100644 --- a/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/mvnw.cmd +++ b/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/mvnw.cmd @@ -1,3 +1,4 @@ +<# : batch portion @REM ---------------------------------------------------------------------------- @REM Licensed to the Apache Software Foundation (ASF) under one @REM or more contributor license agreements. See the NOTICE file @@ -18,165 +19,131 @@ @REM ---------------------------------------------------------------------------- @REM ---------------------------------------------------------------------------- -@REM Maven Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir +@REM Apache Maven Wrapper startup batch script, version 3.3.2 @REM @REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM MVNW_REPOURL - repo url base for downloading maven distribution +@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output @REM ---------------------------------------------------------------------------- -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - -FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( - IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B -) - -@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -@REM This allows using the maven wrapper in projects that prohibit checking in binary data. -if exist %WRAPPER_JAR% ( - if "%MVNW_VERBOSE%" == "true" ( - echo Found %WRAPPER_JAR% - ) -) else ( - if not "%MVNW_REPOURL%" == "" ( - SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - ) - if "%MVNW_VERBOSE%" == "true" ( - echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %DOWNLOAD_URL% - ) - - powershell -Command "&{"^ - "$webclient = new-object System.Net.WebClient;"^ - "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ - "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ - "}"^ - "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ - "}" - if "%MVNW_VERBOSE%" == "true" ( - echo Finished downloading %WRAPPER_JAR% - ) +@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) +@SET __MVNW_CMD__= +@SET __MVNW_ERROR__= +@SET __MVNW_PSMODULEP_SAVE=%PSModulePath% +@SET PSModulePath= +@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( + IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) ) -@REM End of extension - -@REM Provide a "standardized" way to retrieve the CLI args that will -@REM work with both Windows and non-Windows executions. -set MAVEN_CMD_LINE_ARGS=%* - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% +@SET PSModulePath=%__MVNW_PSMODULEP_SAVE% +@SET __MVNW_PSMODULEP_SAVE= +@SET __MVNW_ARG0_NAME__= +@SET MVNW_USERNAME= +@SET MVNW_PASSWORD= +@IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*) +@echo Cannot start maven from wrapper >&2 && exit /b 1 +@GOTO :EOF +: end batch / begin powershell #> + +$ErrorActionPreference = "Stop" +if ($env:MVNW_VERBOSE -eq "true") { + $VerbosePreference = "Continue" +} + +# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties +$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl +if (!$distributionUrl) { + Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" +} + +switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { + "maven-mvnd-*" { + $USE_MVND = $true + $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" + $MVN_CMD = "mvnd.cmd" + break + } + default { + $USE_MVND = $false + $MVN_CMD = $script -replace '^mvnw','mvn' + break + } +} + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +if ($env:MVNW_REPOURL) { + $MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" } + $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')" +} +$distributionUrlName = $distributionUrl -replace '^.*/','' +$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' +$MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain" +if ($env:MAVEN_USER_HOME) { + $MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain" +} +$MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' +$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" + +if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { + Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" + Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" + exit $? +} + +if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { + Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" +} + +# prepare tmp dir +$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile +$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" +$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null +trap { + if ($TMP_DOWNLOAD_DIR.Exists) { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } + } +} + +New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null + +# Download and Install Apache Maven +Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +Write-Verbose "Downloading from: $distributionUrl" +Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +$webclient = New-Object System.Net.WebClient +if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { + $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) +} +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 +$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum +if ($distributionSha256Sum) { + if ($USE_MVND) { + Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." + } + Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash + if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { + Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." + } +} + +# unzip and move +Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null +Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null +try { + Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null +} catch { + if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { + Write-Error "fail to move MAVEN_HOME" + } +} finally { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } +} + +Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" From cb5a836c14cfefdcbe32bb52bd34c4110c74f328 Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Fri, 29 Nov 2024 13:59:38 -0800 Subject: [PATCH 51/59] Use the official Maven Wrapper for the Phone Bill Web archetype. --- .../.mvn/wrapper/maven-wrapper.properties | 21 +- .../resources/archetype-resources/mvnw.cmd | 281 ++++++++---------- 2 files changed, 143 insertions(+), 159 deletions(-) diff --git a/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/.mvn/wrapper/maven-wrapper.properties b/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/.mvn/wrapper/maven-wrapper.properties index 95d55bc41..20c81b37a 100644 --- a/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/.mvn/wrapper/maven-wrapper.properties +++ b/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/.mvn/wrapper/maven-wrapper.properties @@ -1,5 +1,22 @@ #set( $symbol_pound = '#' ) #set( $symbol_dollar = '$' ) #set( $symbol_escape = '\' ) -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar +${symbol_pound} Licensed to the Apache Software Foundation (ASF) under one +${symbol_pound} or more contributor license agreements. See the NOTICE file +${symbol_pound} distributed with this work for additional information +${symbol_pound} regarding copyright ownership. The ASF licenses this file +${symbol_pound} to you under the Apache License, Version 2.0 (the +${symbol_pound} "License"); you may not use this file except in compliance +${symbol_pound} with the License. You may obtain a copy of the License at +${symbol_pound} +${symbol_pound} http://www.apache.org/licenses/LICENSE-2.0 +${symbol_pound} +${symbol_pound} Unless required by applicable law or agreed to in writing, +${symbol_pound} software distributed under the License is distributed on an +${symbol_pound} "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +${symbol_pound} KIND, either express or implied. See the License for the +${symbol_pound} specific language governing permissions and limitations +${symbol_pound} under the License. +wrapperVersion=3.3.2 +distributionType=only-script +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip diff --git a/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/mvnw.cmd b/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/mvnw.cmd index 86115719e..249bdf382 100644 --- a/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/mvnw.cmd +++ b/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/mvnw.cmd @@ -1,3 +1,4 @@ +<# : batch portion @REM ---------------------------------------------------------------------------- @REM Licensed to the Apache Software Foundation (ASF) under one @REM or more contributor license agreements. See the NOTICE file @@ -18,165 +19,131 @@ @REM ---------------------------------------------------------------------------- @REM ---------------------------------------------------------------------------- -@REM Maven Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir +@REM Apache Maven Wrapper startup batch script, version 3.3.2 @REM @REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM MVNW_REPOURL - repo url base for downloading maven distribution +@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output @REM ---------------------------------------------------------------------------- -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - -FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( - IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B -) - -@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -@REM This allows using the maven wrapper in projects that prohibit checking in binary data. -if exist %WRAPPER_JAR% ( - if "%MVNW_VERBOSE%" == "true" ( - echo Found %WRAPPER_JAR% - ) -) else ( - if not "%MVNW_REPOURL%" == "" ( - SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - ) - if "%MVNW_VERBOSE%" == "true" ( - echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %DOWNLOAD_URL% - ) - - powershell -Command "&{"^ - "$webclient = new-object System.Net.WebClient;"^ - "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ - "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ - "}"^ - "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ - "}" - if "%MVNW_VERBOSE%" == "true" ( - echo Finished downloading %WRAPPER_JAR% - ) +@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) +@SET __MVNW_CMD__= +@SET __MVNW_ERROR__= +@SET __MVNW_PSMODULEP_SAVE=%PSModulePath% +@SET PSModulePath= +@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( + IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) ) -@REM End of extension - -@REM Provide a "standardized" way to retrieve the CLI args that will -@REM work with both Windows and non-Windows executions. -set MAVEN_CMD_LINE_ARGS=%* - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% +@SET PSModulePath=%__MVNW_PSMODULEP_SAVE% +@SET __MVNW_PSMODULEP_SAVE= +@SET __MVNW_ARG0_NAME__= +@SET MVNW_USERNAME= +@SET MVNW_PASSWORD= +@IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*) +@echo Cannot start maven from wrapper >&2 && exit /b 1 +@GOTO :EOF +: end batch / begin powershell #> + +$ErrorActionPreference = "Stop" +if ($env:MVNW_VERBOSE -eq "true") { + $VerbosePreference = "Continue" +} + +# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties +$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl +if (!$distributionUrl) { + Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" +} + +switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { + "maven-mvnd-*" { + $USE_MVND = $true + $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" + $MVN_CMD = "mvnd.cmd" + break + } + default { + $USE_MVND = $false + $MVN_CMD = $script -replace '^mvnw','mvn' + break + } +} + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +if ($env:MVNW_REPOURL) { + $MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" } + $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')" +} +$distributionUrlName = $distributionUrl -replace '^.*/','' +$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' +$MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain" +if ($env:MAVEN_USER_HOME) { + $MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain" +} +$MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' +$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" + +if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { + Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" + Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" + exit $? +} + +if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { + Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" +} + +# prepare tmp dir +$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile +$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" +$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null +trap { + if ($TMP_DOWNLOAD_DIR.Exists) { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } + } +} + +New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null + +# Download and Install Apache Maven +Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +Write-Verbose "Downloading from: $distributionUrl" +Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +$webclient = New-Object System.Net.WebClient +if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { + $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) +} +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 +$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum +if ($distributionSha256Sum) { + if ($USE_MVND) { + Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." + } + Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash + if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { + Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." + } +} + +# unzip and move +Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null +Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null +try { + Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null +} catch { + if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { + Write-Error "fail to move MAVEN_HOME" + } +} finally { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } +} + +Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" From 4c6623beaee3d8df95d22fb3773b5aec0e779dd2 Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Fri, 29 Nov 2024 14:04:48 -0800 Subject: [PATCH 52/59] Use the official Maven Wrapper for the Student archetype. --- .../.mvn/wrapper/maven-wrapper.properties | 21 +- .../resources/archetype-resources/mvnw.cmd | 281 ++++++++---------- 2 files changed, 143 insertions(+), 159 deletions(-) diff --git a/projects-parent/archetypes-parent/student-archetype/src/main/resources/archetype-resources/.mvn/wrapper/maven-wrapper.properties b/projects-parent/archetypes-parent/student-archetype/src/main/resources/archetype-resources/.mvn/wrapper/maven-wrapper.properties index 95d55bc41..20c81b37a 100644 --- a/projects-parent/archetypes-parent/student-archetype/src/main/resources/archetype-resources/.mvn/wrapper/maven-wrapper.properties +++ b/projects-parent/archetypes-parent/student-archetype/src/main/resources/archetype-resources/.mvn/wrapper/maven-wrapper.properties @@ -1,5 +1,22 @@ #set( $symbol_pound = '#' ) #set( $symbol_dollar = '$' ) #set( $symbol_escape = '\' ) -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar +${symbol_pound} Licensed to the Apache Software Foundation (ASF) under one +${symbol_pound} or more contributor license agreements. See the NOTICE file +${symbol_pound} distributed with this work for additional information +${symbol_pound} regarding copyright ownership. The ASF licenses this file +${symbol_pound} to you under the Apache License, Version 2.0 (the +${symbol_pound} "License"); you may not use this file except in compliance +${symbol_pound} with the License. You may obtain a copy of the License at +${symbol_pound} +${symbol_pound} http://www.apache.org/licenses/LICENSE-2.0 +${symbol_pound} +${symbol_pound} Unless required by applicable law or agreed to in writing, +${symbol_pound} software distributed under the License is distributed on an +${symbol_pound} "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +${symbol_pound} KIND, either express or implied. See the License for the +${symbol_pound} specific language governing permissions and limitations +${symbol_pound} under the License. +wrapperVersion=3.3.2 +distributionType=only-script +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip diff --git a/projects-parent/archetypes-parent/student-archetype/src/main/resources/archetype-resources/mvnw.cmd b/projects-parent/archetypes-parent/student-archetype/src/main/resources/archetype-resources/mvnw.cmd index 86115719e..249bdf382 100644 --- a/projects-parent/archetypes-parent/student-archetype/src/main/resources/archetype-resources/mvnw.cmd +++ b/projects-parent/archetypes-parent/student-archetype/src/main/resources/archetype-resources/mvnw.cmd @@ -1,3 +1,4 @@ +<# : batch portion @REM ---------------------------------------------------------------------------- @REM Licensed to the Apache Software Foundation (ASF) under one @REM or more contributor license agreements. See the NOTICE file @@ -18,165 +19,131 @@ @REM ---------------------------------------------------------------------------- @REM ---------------------------------------------------------------------------- -@REM Maven Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir +@REM Apache Maven Wrapper startup batch script, version 3.3.2 @REM @REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM MVNW_REPOURL - repo url base for downloading maven distribution +@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output @REM ---------------------------------------------------------------------------- -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - -FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( - IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B -) - -@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -@REM This allows using the maven wrapper in projects that prohibit checking in binary data. -if exist %WRAPPER_JAR% ( - if "%MVNW_VERBOSE%" == "true" ( - echo Found %WRAPPER_JAR% - ) -) else ( - if not "%MVNW_REPOURL%" == "" ( - SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - ) - if "%MVNW_VERBOSE%" == "true" ( - echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %DOWNLOAD_URL% - ) - - powershell -Command "&{"^ - "$webclient = new-object System.Net.WebClient;"^ - "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ - "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ - "}"^ - "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ - "}" - if "%MVNW_VERBOSE%" == "true" ( - echo Finished downloading %WRAPPER_JAR% - ) +@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) +@SET __MVNW_CMD__= +@SET __MVNW_ERROR__= +@SET __MVNW_PSMODULEP_SAVE=%PSModulePath% +@SET PSModulePath= +@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( + IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) ) -@REM End of extension - -@REM Provide a "standardized" way to retrieve the CLI args that will -@REM work with both Windows and non-Windows executions. -set MAVEN_CMD_LINE_ARGS=%* - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% +@SET PSModulePath=%__MVNW_PSMODULEP_SAVE% +@SET __MVNW_PSMODULEP_SAVE= +@SET __MVNW_ARG0_NAME__= +@SET MVNW_USERNAME= +@SET MVNW_PASSWORD= +@IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*) +@echo Cannot start maven from wrapper >&2 && exit /b 1 +@GOTO :EOF +: end batch / begin powershell #> + +$ErrorActionPreference = "Stop" +if ($env:MVNW_VERBOSE -eq "true") { + $VerbosePreference = "Continue" +} + +# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties +$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl +if (!$distributionUrl) { + Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" +} + +switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { + "maven-mvnd-*" { + $USE_MVND = $true + $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" + $MVN_CMD = "mvnd.cmd" + break + } + default { + $USE_MVND = $false + $MVN_CMD = $script -replace '^mvnw','mvn' + break + } +} + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +if ($env:MVNW_REPOURL) { + $MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" } + $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')" +} +$distributionUrlName = $distributionUrl -replace '^.*/','' +$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' +$MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain" +if ($env:MAVEN_USER_HOME) { + $MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain" +} +$MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' +$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" + +if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { + Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" + Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" + exit $? +} + +if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { + Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" +} + +# prepare tmp dir +$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile +$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" +$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null +trap { + if ($TMP_DOWNLOAD_DIR.Exists) { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } + } +} + +New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null + +# Download and Install Apache Maven +Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +Write-Verbose "Downloading from: $distributionUrl" +Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +$webclient = New-Object System.Net.WebClient +if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { + $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) +} +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 +$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum +if ($distributionSha256Sum) { + if ($USE_MVND) { + Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." + } + Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash + if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { + Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." + } +} + +# unzip and move +Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null +Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null +try { + Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null +} catch { + if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { + Write-Error "fail to move MAVEN_HOME" + } +} finally { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } +} + +Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" From 7dfc8ffc8c5f977e6a2e49be35fe82a4f7c71867 Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Fri, 29 Nov 2024 15:02:33 -0800 Subject: [PATCH 53/59] Upgrade to version 3 of CodeQL. --- .github/workflows/codeql-analysis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 7e752f8fa..9bc33ae4d 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -53,7 +53,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -64,7 +64,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@v2 + uses: github/codeql-action/autobuild@v3 # ℹ️ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl @@ -78,4 +78,4 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 From 1d7a4226849e94b702f3cd857e61cb85ce26f022 Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Sat, 30 Nov 2024 16:28:10 -0800 Subject: [PATCH 54/59] Add the latest koans code to archetype. --- .../java-koans-archetype/pom.xml | 2 +- .../META-INF/maven/archetype-metadata.xml | 14 +- .../.mvn/wrapper/maven-wrapper.properties | 21 +- .../app/config/i18n/messages_en.properties | 2 +- .../main/resources/archetype-resources/mvnw | 451 ++++++++---------- .../resources/archetype-resources/mvnw.cmd | 281 +++++------ .../resources/archetype-resources/pom.xml | 27 +- .../src/beginner/AboutPrimitives.java | 2 +- .../src/intermediate/AboutDates.java | 52 +- .../projects/basic/archetype.properties | 2 +- 10 files changed, 378 insertions(+), 476 deletions(-) diff --git a/projects-parent/archetypes-parent/java-koans-archetype/pom.xml b/projects-parent/archetypes-parent/java-koans-archetype/pom.xml index 9f8454688..f0088d6b4 100644 --- a/projects-parent/archetypes-parent/java-koans-archetype/pom.xml +++ b/projects-parent/archetypes-parent/java-koans-archetype/pom.xml @@ -13,7 +13,7 @@ maven-archetype java-koans-archetype - 2012 + diff --git a/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml b/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml index a5d3e5721..c1e07bf75 100644 --- a/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml +++ b/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -1,6 +1,6 @@ - @@ -12,7 +12,6 @@ .mvn/wrapper - **/*.java **/*.properties @@ -53,12 +52,6 @@ **/*.gitignore - - .mvn/wrapper - - **/*.jar - - app/lib @@ -72,12 +65,9 @@ - LICENSE mvnw.cmd - run.bat - run.sh mvnw diff --git a/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/.mvn/wrapper/maven-wrapper.properties b/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/.mvn/wrapper/maven-wrapper.properties index 95d55bc41..20c81b37a 100644 --- a/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/.mvn/wrapper/maven-wrapper.properties +++ b/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/.mvn/wrapper/maven-wrapper.properties @@ -1,5 +1,22 @@ #set( $symbol_pound = '#' ) #set( $symbol_dollar = '$' ) #set( $symbol_escape = '\' ) -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar +${symbol_pound} Licensed to the Apache Software Foundation (ASF) under one +${symbol_pound} or more contributor license agreements. See the NOTICE file +${symbol_pound} distributed with this work for additional information +${symbol_pound} regarding copyright ownership. The ASF licenses this file +${symbol_pound} to you under the Apache License, Version 2.0 (the +${symbol_pound} "License"); you may not use this file except in compliance +${symbol_pound} with the License. You may obtain a copy of the License at +${symbol_pound} +${symbol_pound} http://www.apache.org/licenses/LICENSE-2.0 +${symbol_pound} +${symbol_pound} Unless required by applicable law or agreed to in writing, +${symbol_pound} software distributed under the License is distributed on an +${symbol_pound} "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +${symbol_pound} KIND, either express or implied. See the License for the +${symbol_pound} specific language governing permissions and limitations +${symbol_pound} under the License. +wrapperVersion=3.3.2 +distributionType=only-script +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip diff --git a/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/app/config/i18n/messages_en.properties b/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/app/config/i18n/messages_en.properties index b49e980a7..d9bd65fde 100644 --- a/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/app/config/i18n/messages_en.properties +++ b/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/app/config/i18n/messages_en.properties @@ -46,7 +46,7 @@ advanced.AboutMocks.simpleAnonymousMock=How can this pass without touching the C ${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound} ${symbol_pound} Koans libraries properties ${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound}${symbol_pound} -__=REPLACE ME +__=__ all_koans_succeeded=Way to go! You've completed all of the koans! Feel like writing any? expected=expected may_offer_clue=may offer a clue as to how you may progress, now make haste! diff --git a/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/mvnw b/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/mvnw index 41c0f0c23..19529ddf8 100755 --- a/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/mvnw +++ b/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/mvnw @@ -19,292 +19,241 @@ # ---------------------------------------------------------------------------- # ---------------------------------------------------------------------------- -# Maven Start Up Batch script -# -# Required ENV vars: -# ------------------ -# JAVA_HOME - location of a JDK home dir +# Apache Maven Wrapper startup batch script, version 3.3.2 # # Optional ENV vars # ----------------- -# M2_HOME - location of maven2's installed home dir -# MAVEN_OPTS - parameters passed to the Java VM when running Maven -# e.g. to debug Maven itself, use -# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# JAVA_HOME - location of a JDK home dir, required when download maven via java source +# MVNW_REPOURL - repo url base for downloading maven distribution +# MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +# MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output # ---------------------------------------------------------------------------- -if [ -z "$MAVEN_SKIP_RC" ] ; then - - if [ -f /etc/mavenrc ] ; then - . /etc/mavenrc - fi +set -euf +[ "${MVNW_VERBOSE-}" != debug ] || set -x - if [ -f "$HOME/.mavenrc" ] ; then - . "$HOME/.mavenrc" - fi +# OS specific support. +native_path() { printf %s\\n "$1"; } +case "$(uname)" in +CYGWIN* | MINGW*) + [ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")" + native_path() { cygpath --path --windows "$1"; } + ;; +esac -fi +# set JAVACMD and JAVACCMD +set_java_home() { + # For Cygwin and MinGW, ensure paths are in Unix format before anything is touched + if [ -n "${JAVA_HOME-}" ]; then + if [ -x "$JAVA_HOME/jre/sh/java" ]; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACCMD="$JAVA_HOME/jre/sh/javac" + else + JAVACMD="$JAVA_HOME/bin/java" + JAVACCMD="$JAVA_HOME/bin/javac" -# OS specific support. $var _must_ be set to either true or false. -cygwin=false; -darwin=false; -mingw=false -case "`uname`" in - CYGWIN*) cygwin=true ;; - MINGW*) mingw=true;; - Darwin*) darwin=true - # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home - # See https://developer.apple.com/library/mac/qa/qa1170/_index.html - if [ -z "$JAVA_HOME" ]; then - if [ -x "/usr/libexec/java_home" ]; then - export JAVA_HOME="`/usr/libexec/java_home`" - else - export JAVA_HOME="/Library/Java/Home" + if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then + echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2 + echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2 + return 1 fi fi - ;; -esac - -if [ -z "$JAVA_HOME" ] ; then - if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=`java-config --jre-home` + else + JAVACMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v java + )" || : + JAVACCMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v javac + )" || : + + if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then + echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2 + return 1 + fi fi -fi - -if [ -z "$M2_HOME" ] ; then - ## resolve links - $0 may be a link to maven's home - PRG="$0" +} - # need this for relative symlinks - while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG="`dirname "$PRG"`/$link" - fi +# hash string like Java String::hashCode +hash_string() { + str="${1:-}" h=0 + while [ -n "$str" ]; do + char="${str%"${str#?}"}" + h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296)) + str="${str#?}" done + printf %x\\n $h +} - saveddir=`pwd` +verbose() { :; } +[ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; } - M2_HOME=`dirname "$PRG"`/.. +die() { + printf %s\\n "$1" >&2 + exit 1 +} - # make it fully qualified - M2_HOME=`cd "$M2_HOME" && pwd` +trim() { + # MWRAPPER-139: + # Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds. + # Needed for removing poorly interpreted newline sequences when running in more + # exotic environments such as mingw bash on Windows. + printf "%s" "${1}" | tr -d '[:space:]' +} - cd "$saveddir" - # echo Using m2 at $M2_HOME -fi +# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties +while IFS="=" read -r key value; do + case "${key-}" in + distributionUrl) distributionUrl=$(trim "${value-}") ;; + distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;; + esac +done <"${0%/*}/.mvn/wrapper/maven-wrapper.properties" +[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in ${0%/*}/.mvn/wrapper/maven-wrapper.properties" + +case "${distributionUrl##*/}" in +maven-mvnd-*bin.*) + MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ + case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in + *AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;; + :Darwin*x86_64) distributionPlatform=darwin-amd64 ;; + :Darwin*arm64) distributionPlatform=darwin-aarch64 ;; + :Linux*x86_64*) distributionPlatform=linux-amd64 ;; + *) + echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2 + distributionPlatform=linux-amd64 + ;; + esac + distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip" + ;; +maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;; +*) MVN_CMD="mvn${0##*/mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;; +esac -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin ; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --unix "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` -fi +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}" +distributionUrlName="${distributionUrl##*/}" +distributionUrlNameMain="${distributionUrlName%.*}" +distributionUrlNameMain="${distributionUrlNameMain%-bin}" +MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}" +MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")" + +exec_maven() { + unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || : + exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD" +} -# For Mingw, ensure paths are in UNIX format before anything is touched -if $mingw ; then - [ -n "$M2_HOME" ] && - M2_HOME="`(cd "$M2_HOME"; pwd)`" - [ -n "$JAVA_HOME" ] && - JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +if [ -d "$MAVEN_HOME" ]; then + verbose "found existing MAVEN_HOME at $MAVEN_HOME" + exec_maven "$@" fi -if [ -z "$JAVA_HOME" ]; then - javaExecutable="`which javac`" - if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then - # readlink(1) is not available as standard on Solaris 10. - readLink=`which readlink` - if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then - if $darwin ; then - javaHome="`dirname \"$javaExecutable\"`" - javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" - else - javaExecutable="`readlink -f \"$javaExecutable\"`" - fi - javaHome="`dirname \"$javaExecutable\"`" - javaHome=`expr "$javaHome" : '\(.*\)/bin'` - JAVA_HOME="$javaHome" - export JAVA_HOME - fi - fi -fi +case "${distributionUrl-}" in +*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;; +*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;; +esac -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - else - JAVACMD="`which java`" - fi +# prepare tmp dir +if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then + clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; } + trap clean HUP INT TERM EXIT +else + die "cannot create temp dir" fi -if [ ! -x "$JAVACMD" ] ; then - echo "Error: JAVA_HOME is not defined correctly." >&2 - echo " We cannot execute $JAVACMD" >&2 - exit 1 -fi +mkdir -p -- "${MAVEN_HOME%/*}" + +# Download and Install Apache Maven +verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +verbose "Downloading from: $distributionUrl" +verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" -if [ -z "$JAVA_HOME" ] ; then - echo "Warning: JAVA_HOME environment variable is not set." +# select .zip or .tar.gz +if ! command -v unzip >/dev/null; then + distributionUrl="${distributionUrl%.zip}.tar.gz" + distributionUrlName="${distributionUrl##*/}" fi -CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher +# verbose opt +__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR='' +[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v -# traverses directory structure from process work directory to filesystem root -# first directory with .mvn subdirectory is considered project base directory -find_maven_basedir() { +# normalize http auth +case "${MVNW_PASSWORD:+has-password}" in +'') MVNW_USERNAME='' MVNW_PASSWORD='' ;; +has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;; +esac - if [ -z "$1" ] - then - echo "Path not specified to find_maven_basedir" - return 1 - fi +if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then + verbose "Found wget ... using wget" + wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl" +elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then + verbose "Found curl ... using curl" + curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl" +elif set_java_home; then + verbose "Falling back to use Java to download" + javaSource="$TMP_DOWNLOAD_DIR/Downloader.java" + targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName" + cat >"$javaSource" <<-END + public class Downloader extends java.net.Authenticator + { + protected java.net.PasswordAuthentication getPasswordAuthentication() + { + return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() ); + } + public static void main( String[] args ) throws Exception + { + setDefault( new Downloader() ); + java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() ); + } + } + END + # For Cygwin/MinGW, switch paths to Windows format before running javac and java + verbose " - Compiling Downloader.java ..." + "$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java" + verbose " - Running Downloader.java ..." + "$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")" +fi - basedir="$1" - wdir="$1" - while [ "$wdir" != '/' ] ; do - if [ -d "$wdir"/.mvn ] ; then - basedir=$wdir - break +# If specified, validate the SHA-256 sum of the Maven distribution zip file +if [ -n "${distributionSha256Sum-}" ]; then + distributionSha256Result=false + if [ "$MVN_CMD" = mvnd.sh ]; then + echo "Checksum validation is not supported for maven-mvnd." >&2 + echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + elif command -v sha256sum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c >/dev/null 2>&1; then + distributionSha256Result=true fi - # workaround for JBEAP-8937 (on Solaris 10/Sparc) - if [ -d "${wdir}" ]; then - wdir=`cd "$wdir/.."; pwd` + elif command -v shasum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then + distributionSha256Result=true fi - # end of workaround - done - echo "${basedir}" -} - -# concatenates all lines of a file -concat_lines() { - if [ -f "$1" ]; then - echo "$(tr -s '\n' ' ' < "$1")" + else + echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2 + echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + fi + if [ $distributionSha256Result = false ]; then + echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2 + echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2 + exit 1 fi -} - -BASE_DIR=`find_maven_basedir "$(pwd)"` -if [ -z "$BASE_DIR" ]; then - exit 1; fi -########################################################################################## -# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -# This allows using the maven wrapper in projects that prohibit checking in binary data. -########################################################################################## -if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found .mvn/wrapper/maven-wrapper.jar" - fi +# unzip and move +if command -v unzip >/dev/null; then + unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip" else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." - fi - if [ -n "$MVNW_REPOURL" ]; then - jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - else - jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - fi - while IFS="=" read key value; do - case "$key" in (wrapperUrl) jarUrl="$value"; break ;; - esac - done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" - if [ "$MVNW_VERBOSE" = true ]; then - echo "Downloading from: $jarUrl" - fi - wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" - if $cygwin; then - wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` - fi - - if command -v wget > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found wget ... using wget" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - wget "$jarUrl" -O "$wrapperJarPath" - else - wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" - fi - elif command -v curl > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found curl ... using curl" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - curl -o "$wrapperJarPath" "$jarUrl" -f - else - curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f - fi - - else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Falling back to using Java to download" - fi - javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" - # For Cygwin, switch paths to Windows format before running javac - if $cygwin; then - javaClass=`cygpath --path --windows "$javaClass"` - fi - if [ -e "$javaClass" ]; then - if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Compiling MavenWrapperDownloader.java ..." - fi - # Compiling the Java class - ("$JAVA_HOME/bin/javac" "$javaClass") - fi - if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - # Running the downloader - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Running MavenWrapperDownloader.java ..." - fi - ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") - fi - fi - fi -fi -########################################################################################## -# End of extension -########################################################################################## - -export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} -if [ "$MVNW_VERBOSE" = true ]; then - echo $MAVEN_PROJECTBASEDIR + tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar" fi -MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" - -# For Cygwin, switch paths to Windows format before running java -if $cygwin; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --path --windows "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --windows "$CLASSPATH"` - [ -n "$MAVEN_PROJECTBASEDIR" ] && - MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` -fi - -# Provide a "standardized" way to retrieve the CLI args that will -# work with both Windows and non-Windows executions. -MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" -export MAVEN_CMD_LINE_ARGS - -WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain +printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/mvnw.url" +mv -- "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME" -exec "$JAVACMD" \ - $MAVEN_OPTS \ - -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ - "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" +clean || : +exec_maven "$@" diff --git a/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/mvnw.cmd b/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/mvnw.cmd index 86115719e..249bdf382 100644 --- a/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/mvnw.cmd +++ b/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/mvnw.cmd @@ -1,3 +1,4 @@ +<# : batch portion @REM ---------------------------------------------------------------------------- @REM Licensed to the Apache Software Foundation (ASF) under one @REM or more contributor license agreements. See the NOTICE file @@ -18,165 +19,131 @@ @REM ---------------------------------------------------------------------------- @REM ---------------------------------------------------------------------------- -@REM Maven Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir +@REM Apache Maven Wrapper startup batch script, version 3.3.2 @REM @REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM MVNW_REPOURL - repo url base for downloading maven distribution +@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output @REM ---------------------------------------------------------------------------- -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - -FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( - IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B -) - -@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -@REM This allows using the maven wrapper in projects that prohibit checking in binary data. -if exist %WRAPPER_JAR% ( - if "%MVNW_VERBOSE%" == "true" ( - echo Found %WRAPPER_JAR% - ) -) else ( - if not "%MVNW_REPOURL%" == "" ( - SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - ) - if "%MVNW_VERBOSE%" == "true" ( - echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %DOWNLOAD_URL% - ) - - powershell -Command "&{"^ - "$webclient = new-object System.Net.WebClient;"^ - "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ - "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ - "}"^ - "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ - "}" - if "%MVNW_VERBOSE%" == "true" ( - echo Finished downloading %WRAPPER_JAR% - ) +@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) +@SET __MVNW_CMD__= +@SET __MVNW_ERROR__= +@SET __MVNW_PSMODULEP_SAVE=%PSModulePath% +@SET PSModulePath= +@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( + IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) ) -@REM End of extension - -@REM Provide a "standardized" way to retrieve the CLI args that will -@REM work with both Windows and non-Windows executions. -set MAVEN_CMD_LINE_ARGS=%* - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% +@SET PSModulePath=%__MVNW_PSMODULEP_SAVE% +@SET __MVNW_PSMODULEP_SAVE= +@SET __MVNW_ARG0_NAME__= +@SET MVNW_USERNAME= +@SET MVNW_PASSWORD= +@IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*) +@echo Cannot start maven from wrapper >&2 && exit /b 1 +@GOTO :EOF +: end batch / begin powershell #> + +$ErrorActionPreference = "Stop" +if ($env:MVNW_VERBOSE -eq "true") { + $VerbosePreference = "Continue" +} + +# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties +$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl +if (!$distributionUrl) { + Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" +} + +switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { + "maven-mvnd-*" { + $USE_MVND = $true + $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" + $MVN_CMD = "mvnd.cmd" + break + } + default { + $USE_MVND = $false + $MVN_CMD = $script -replace '^mvnw','mvn' + break + } +} + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +if ($env:MVNW_REPOURL) { + $MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" } + $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')" +} +$distributionUrlName = $distributionUrl -replace '^.*/','' +$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' +$MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain" +if ($env:MAVEN_USER_HOME) { + $MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain" +} +$MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' +$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" + +if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { + Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" + Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" + exit $? +} + +if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { + Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" +} + +# prepare tmp dir +$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile +$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" +$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null +trap { + if ($TMP_DOWNLOAD_DIR.Exists) { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } + } +} + +New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null + +# Download and Install Apache Maven +Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +Write-Verbose "Downloading from: $distributionUrl" +Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +$webclient = New-Object System.Net.WebClient +if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { + $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) +} +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 +$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum +if ($distributionSha256Sum) { + if ($USE_MVND) { + Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." + } + Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash + if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { + Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." + } +} + +# unzip and move +Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null +Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null +try { + Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null +} catch { + if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { + Write-Error "fail to move MAVEN_HOME" + } +} finally { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } +} + +Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" diff --git a/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/pom.xml index 0951f8c55..2269b201e 100644 --- a/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/pom.xml @@ -1,13 +1,13 @@ - + 4.0.0 joy io.github.davidwhitlock.joy 1.2.0-SNAPSHOT - ${groupId} ${artifactId} + ${groupId} jar ${version} Java Koans @@ -25,7 +25,7 @@ dwhitlock David Whitlock - http://www.cs.pdx.edu/~whitlock + https://www.cs.pdx.edu/~whitlock Maven-izer @@ -34,16 +34,18 @@ YOU Your name here you@youremail.com - http://www.cs.pdx.edu/~YOU + https://www.cs.pdx.edu/~YOU PSU Department of Computer Science - http://www.cs.pdx.edu + https://www.cs.pdx.edu Student who does koans -7 - + + 3.5.2 + io.github.davidwhitlock.joy.com.sandwich @@ -107,19 +109,6 @@ - - - maven-snapshots - https://s01.oss.sonatype.org/content/repositories/snapshots - default - - false - - - true - - - grader diff --git a/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/src/beginner/AboutPrimitives.java b/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/src/beginner/AboutPrimitives.java index 7ccf04519..d56558e7b 100644 --- a/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/src/beginner/AboutPrimitives.java +++ b/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/src/beginner/AboutPrimitives.java @@ -120,7 +120,7 @@ public void primitivesOfTypeCharHaveAnObjectTypeCharacter() { } @Koan - public void charsCanOnlyBePositive() { + public void charsAreNotNegative() { assertEquals((int) Character.MIN_VALUE, __); assertEquals((int) Character.MAX_VALUE, __); diff --git a/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/src/intermediate/AboutDates.java b/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/src/intermediate/AboutDates.java index 75e1bc6d1..ee6c0b412 100644 --- a/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/src/intermediate/AboutDates.java +++ b/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/src/intermediate/AboutDates.java @@ -5,11 +5,12 @@ import com.sandwich.koan.Koan; -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Date; +import java.time.Instant; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; +import java.time.format.FormatStyle; import static com.sandwich.koan.constant.KoanConstants.__; import static com.sandwich.util.Assert.assertEquals; @@ -17,7 +18,7 @@ public class AboutDates { - private Date date = new Date(100010001000L); + private LocalDateTime date = LocalDateTime.ofInstant(Instant.ofEpochMilli(100010001000L), ZoneId.systemDefault()); @Koan public void dateToString() { @@ -26,50 +27,39 @@ public void dateToString() { @Koan public void changingDateValue() { - int oneHourInMiliseconds = 3600000; - date.setTime(date.getTime() + oneHourInMiliseconds); + date = date.plusHours(1); assertEquals(date.toString(), __); } @Koan - public void usingCalendarToChangeDates() { - Calendar cal = Calendar.getInstance(); - cal.setTime(date); - cal.add(Calendar.MONTH, 1); - assertEquals(cal.getTime().toString(), __); - } - - @Koan - public void usingRollToChangeDatesDoesntWrapOtherFields() { - Calendar cal = Calendar.getInstance(); - cal.setTime(date); - cal.roll(Calendar.MONTH, 12); - assertEquals(cal.getTime().toString(), __); + public void usingPlusToChangeDatesDoesntWrapOtherFields() { + date = date.plusMonths(12); + assertEquals(date.toString(), __); } @Koan - public void usingDateFormatToFormatDate() { - String formattedDate = DateFormat.getDateInstance().format(date); + public void usingDateTimeFormatterToFormatDate() { + String formattedDate = DateTimeFormatter.ISO_DATE.format(date); assertEquals(formattedDate, __); } @Koan - public void usingDateFormatToFormatDateShort() { - String formattedDate = DateFormat.getDateInstance(DateFormat.SHORT).format(date); + public void usingDateTimeFormatterToFormatDateShort() { + String formattedDate = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT).format(date); assertEquals(formattedDate, __); } @Koan - public void usingDateFormatToFormatDateFull() { - String formattedDate = DateFormat.getDateInstance(DateFormat.FULL).format(date); - // There is also DateFormat.MEDIUM and DateFormat.LONG... you get the idea ;-) + public void usingDateTimeFormatterToFormatDateFull() { + String formattedDate = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM).format(date); + // There is also FormatStyle.LONG and FormatStyle.FULL... you get the idea ;-) assertEquals(formattedDate, __); } @Koan - public void usingDateFormatToParseDates() throws ParseException { - DateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy"); - Date date2 = dateFormat.parse("01-01-2000"); + public void usingDateTimeFormatterToParseDates() { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM-dd-yyyy"); + LocalDate date2 = LocalDate.parse("01-01-2000", formatter); assertEquals(date2.toString(), __); // What happened to the time? What do you need to change to keep the time as well? } diff --git a/projects-parent/archetypes-parent/java-koans-archetype/src/test/resources/projects/basic/archetype.properties b/projects-parent/archetypes-parent/java-koans-archetype/src/test/resources/projects/basic/archetype.properties index 35f6864a2..155dca640 100644 --- a/projects-parent/archetypes-parent/java-koans-archetype/src/test/resources/projects/basic/archetype.properties +++ b/projects-parent/archetypes-parent/java-koans-archetype/src/test/resources/projects/basic/archetype.properties @@ -1,4 +1,4 @@ -#Thu Jul 01 22:17:10 PDT 2021 +#Sat Nov 30 16:10:47 PST 2024 package=it.pkg groupId=archetype.it artifactId=basic From 2b08ba329475025507da70d7b9ce83e4a6661724 Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Sat, 30 Nov 2024 16:50:23 -0800 Subject: [PATCH 55/59] Oops. Deleted something I shouldn't have. --- .../src/main/resources/META-INF/maven/archetype-metadata.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml b/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml index c1e07bf75..f528a8f45 100644 --- a/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml +++ b/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -65,6 +65,7 @@ + LICENSE mvnw.cmd From ba79886e1285fe789ba2d574d6d2c6469c7c2b00 Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Sat, 30 Nov 2024 18:22:41 -0800 Subject: [PATCH 56/59] Oops. Deleted something I shouldn't have. Again. --- .../src/main/resources/archetype-resources/pom.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/pom.xml index 2269b201e..17bc4693f 100644 --- a/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/pom.xml @@ -109,6 +109,19 @@ + + + maven-snapshots + https://s01.oss.sonatype.org/content/repositories/snapshots + default + + false + + + true + + + grader From 9d9351171be75153e8b7978c0ef6ae4e67ad191d Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Sat, 30 Nov 2024 18:42:11 -0800 Subject: [PATCH 57/59] Remove -SNAPSHOT from versions. --- examples/pom.xml | 10 +++++----- family/pom.xml | 6 +++--- grader/pom.xml | 4 ++-- pom.xml | 4 ++-- .../archetypes-parent/airline-archetype/pom.xml | 4 ++-- .../src/main/resources/archetype-resources/pom.xml | 6 +++--- .../archetypes-parent/airline-web-archetype/pom.xml | 4 ++-- .../src/main/resources/archetype-resources/pom.xml | 8 ++++---- .../archetypes-parent/apptbook-archetype/pom.xml | 4 ++-- .../src/main/resources/archetype-resources/pom.xml | 6 +++--- .../archetypes-parent/apptbook-web-archetype/pom.xml | 4 ++-- .../src/main/resources/archetype-resources/pom.xml | 8 ++++---- .../archetypes-parent/java-koans-archetype/pom.xml | 4 ++-- .../src/main/resources/archetype-resources/pom.xml | 4 ++-- .../archetypes-parent/kata-archetype/pom.xml | 4 ++-- .../src/main/resources/archetype-resources/pom.xml | 4 ++-- .../archetypes-parent/phonebill-archetype/pom.xml | 4 ++-- .../src/main/resources/archetype-resources/pom.xml | 6 +++--- .../archetypes-parent/phonebill-web-archetype/pom.xml | 4 ++-- .../src/main/resources/archetype-resources/pom.xml | 8 ++++---- projects-parent/archetypes-parent/pom.xml | 4 ++-- .../archetypes-parent/student-archetype/pom.xml | 4 ++-- .../src/main/resources/archetype-resources/pom.xml | 6 +++--- projects-parent/originals-parent/airline-web/pom.xml | 10 +++++----- projects-parent/originals-parent/airline/pom.xml | 8 ++++---- projects-parent/originals-parent/apptbook-web/pom.xml | 10 +++++----- projects-parent/originals-parent/apptbook/pom.xml | 8 ++++---- projects-parent/originals-parent/kata/pom.xml | 6 +++--- projects-parent/originals-parent/phonebill-web/pom.xml | 10 +++++----- projects-parent/originals-parent/phonebill/pom.xml | 8 ++++---- projects-parent/originals-parent/pom.xml | 4 ++-- projects-parent/originals-parent/student/pom.xml | 8 ++++---- projects-parent/pom.xml | 4 ++-- projects-parent/projects/pom.xml | 4 ++-- web/pom.xml | 6 +++--- 35 files changed, 103 insertions(+), 103 deletions(-) diff --git a/examples/pom.xml b/examples/pom.xml index 9f399b2de..96add4850 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -3,23 +3,23 @@ joy io.github.davidwhitlock.joy - 1.2.0-SNAPSHOT + 1.2.0 4.0.0 examples examples - 1.3.0-SNAPSHOT + 1.3.0 https://www.cs.pdx.edu/~whitlock io.github.davidwhitlock.joy family - 1.1.2-SNAPSHOT + 1.1.2 io.github.davidwhitlock.joy projects - 3.0.0-SNAPSHOT + 3.0.0 com.sun.mail @@ -45,7 +45,7 @@ io.github.davidwhitlock.joy projects - 3.0.0-SNAPSHOT + 3.0.0 tests test diff --git a/family/pom.xml b/family/pom.xml index 8d7e15408..6892e5f3e 100644 --- a/family/pom.xml +++ b/family/pom.xml @@ -3,12 +3,12 @@ joy io.github.davidwhitlock.joy - 1.2.0-SNAPSHOT + 1.2.0 4.0.0 family jar - 1.1.2-SNAPSHOT + 1.1.2 Family Tree Application An Family Tree application for The Joy of Coding https://www.cs.pdx.edu/~whitlock @@ -16,7 +16,7 @@ io.github.davidwhitlock.joy projects - 3.0.0-SNAPSHOT + 3.0.0 diff --git a/grader/pom.xml b/grader/pom.xml index a19a00e53..caeef26b5 100644 --- a/grader/pom.xml +++ b/grader/pom.xml @@ -2,7 +2,7 @@ joy io.github.davidwhitlock.joy - 1.2.0-SNAPSHOT + 1.2.0 4.0.0 grader @@ -19,7 +19,7 @@ io.github.davidwhitlock.joy projects - 3.0.0-SNAPSHOT + 3.0.0 com.opencsv diff --git a/pom.xml b/pom.xml index 895a7ba34..b098d8e4a 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 io.github.davidwhitlock.joy - 1.2.0-SNAPSHOT + 1.2.0 joy pom Java Example Code @@ -93,7 +93,7 @@ 0.75 0 - 1.3.1-SNAPSHOT + 1.3.1 diff --git a/projects-parent/archetypes-parent/airline-archetype/pom.xml b/projects-parent/archetypes-parent/airline-archetype/pom.xml index bb988ee31..ec5db4b01 100644 --- a/projects-parent/archetypes-parent/airline-archetype/pom.xml +++ b/projects-parent/archetypes-parent/airline-archetype/pom.xml @@ -5,10 +5,10 @@ archetypes-parent io.github.davidwhitlock.joy - 2.2.0-SNAPSHOT + 2.2.0 airline-archetype - 2.2.0-SNAPSHOT + 2.2.0 maven-archetype airline-archetype diff --git a/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/pom.xml index 12e908909..9e6b639ec 100644 --- a/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/airline-archetype/src/main/resources/archetype-resources/pom.xml @@ -3,7 +3,7 @@ joy io.github.davidwhitlock.joy - 1.2.0-SNAPSHOT + 1.2.0 4.0.0 ${groupId} @@ -32,12 +32,12 @@ io.github.davidwhitlock.joy projects - 3.0.0-SNAPSHOT + 3.0.0 io.github.davidwhitlock.joy projects - 3.0.0-SNAPSHOT + 3.0.0 tests test diff --git a/projects-parent/archetypes-parent/airline-web-archetype/pom.xml b/projects-parent/archetypes-parent/airline-web-archetype/pom.xml index aed85f9d8..f27a0cac6 100644 --- a/projects-parent/archetypes-parent/airline-web-archetype/pom.xml +++ b/projects-parent/archetypes-parent/airline-web-archetype/pom.xml @@ -4,10 +4,10 @@ archetypes-parent io.github.davidwhitlock.joy - 2.2.0-SNAPSHOT + 2.2.0 airline-web-archetype - 3.0.0-SNAPSHOT + 3.0.0 maven-archetype airline-web-archetype diff --git a/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/pom.xml index b6409d74f..056366887 100644 --- a/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/airline-web-archetype/src/main/resources/archetype-resources/pom.xml @@ -3,7 +3,7 @@ joy io.github.davidwhitlock.joy - 1.2.0-SNAPSHOT + 1.2.0 4.0.0 ${groupId} @@ -21,17 +21,17 @@ io.github.davidwhitlock.joy projects - 3.0.0-SNAPSHOT + 3.0.0 io.github.davidwhitlock.joy examples - 1.3.0-SNAPSHOT + 1.3.0 io.github.davidwhitlock.joy projects - 3.0.0-SNAPSHOT + 3.0.0 tests test diff --git a/projects-parent/archetypes-parent/apptbook-archetype/pom.xml b/projects-parent/archetypes-parent/apptbook-archetype/pom.xml index 8c4dffa53..6d1ff5023 100644 --- a/projects-parent/archetypes-parent/apptbook-archetype/pom.xml +++ b/projects-parent/archetypes-parent/apptbook-archetype/pom.xml @@ -4,10 +4,10 @@ archetypes-parent io.github.davidwhitlock.joy - 2.2.0-SNAPSHOT + 2.2.0 apptbook-archetype - 2.2.0-SNAPSHOT + 2.2.0 maven-archetype apptbook-archetype diff --git a/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/pom.xml index a20fcbdfc..48caab94e 100644 --- a/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/apptbook-archetype/src/main/resources/archetype-resources/pom.xml @@ -3,7 +3,7 @@ joy io.github.davidwhitlock.joy - 1.2.0-SNAPSHOT + 1.2.0 4.0.0 ${groupId} @@ -32,12 +32,12 @@ io.github.davidwhitlock.joy projects - 3.0.0-SNAPSHOT + 3.0.0 io.github.davidwhitlock.joy projects - 3.0.0-SNAPSHOT + 3.0.0 tests test diff --git a/projects-parent/archetypes-parent/apptbook-web-archetype/pom.xml b/projects-parent/archetypes-parent/apptbook-web-archetype/pom.xml index b17fda530..1e31d9ed7 100644 --- a/projects-parent/archetypes-parent/apptbook-web-archetype/pom.xml +++ b/projects-parent/archetypes-parent/apptbook-web-archetype/pom.xml @@ -4,10 +4,10 @@ archetypes-parent io.github.davidwhitlock.joy - 2.2.0-SNAPSHOT + 2.2.0 apptbook-web-archetype - 3.0.0-SNAPSHOT + 3.0.0 maven-archetype apptbook-web-archetype diff --git a/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/pom.xml index 3023e0e98..753dbaa04 100644 --- a/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/apptbook-web-archetype/src/main/resources/archetype-resources/pom.xml @@ -3,7 +3,7 @@ joy io.github.davidwhitlock.joy - 1.2.0-SNAPSHOT + 1.2.0 4.0.0 ${groupId} @@ -21,17 +21,17 @@ io.github.davidwhitlock.joy projects - 3.0.0-SNAPSHOT + 3.0.0 io.github.davidwhitlock.joy examples - 1.3.0-SNAPSHOT + 1.3.0 io.github.davidwhitlock.joy projects - 3.0.0-SNAPSHOT + 3.0.0 tests test diff --git a/projects-parent/archetypes-parent/java-koans-archetype/pom.xml b/projects-parent/archetypes-parent/java-koans-archetype/pom.xml index f0088d6b4..2319df03c 100644 --- a/projects-parent/archetypes-parent/java-koans-archetype/pom.xml +++ b/projects-parent/archetypes-parent/java-koans-archetype/pom.xml @@ -3,13 +3,13 @@ archetypes-parent io.github.davidwhitlock.joy - 2.2.0-SNAPSHOT + 2.2.0 4.0.0 java-koans-archetype - 2.2.0-SNAPSHOT + 2.2.0 maven-archetype java-koans-archetype diff --git a/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/pom.xml index 17bc4693f..5b45a4b8e 100644 --- a/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/java-koans-archetype/src/main/resources/archetype-resources/pom.xml @@ -4,7 +4,7 @@ joy io.github.davidwhitlock.joy - 1.2.0-SNAPSHOT + 1.2.0 ${artifactId} ${groupId} @@ -50,7 +50,7 @@ io.github.davidwhitlock.joy.com.sandwich koans-lib - 1.2.0-SNAPSHOT + 1.2.0 diff --git a/projects-parent/archetypes-parent/kata-archetype/pom.xml b/projects-parent/archetypes-parent/kata-archetype/pom.xml index 6fb09e6ff..7062b4497 100644 --- a/projects-parent/archetypes-parent/kata-archetype/pom.xml +++ b/projects-parent/archetypes-parent/kata-archetype/pom.xml @@ -5,10 +5,10 @@ archetypes-parent io.github.davidwhitlock.joy - 2.2.0-SNAPSHOT + 2.2.0 kata-archetype - 2.2.0-SNAPSHOT + 2.2.0 maven-archetype kata-archetype diff --git a/projects-parent/archetypes-parent/kata-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/kata-archetype/src/main/resources/archetype-resources/pom.xml index eeba1df13..34a56ff07 100644 --- a/projects-parent/archetypes-parent/kata-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/kata-archetype/src/main/resources/archetype-resources/pom.xml @@ -4,7 +4,7 @@ joy io.github.davidwhitlock.joy - 1.2.0-SNAPSHOT + 1.2.0 ${groupId} ${artifactId} @@ -88,7 +88,7 @@ io.github.davidwhitlock.joy projects - 3.0.0-SNAPSHOT + 3.0.0 tests test diff --git a/projects-parent/archetypes-parent/phonebill-archetype/pom.xml b/projects-parent/archetypes-parent/phonebill-archetype/pom.xml index 1c6df1fc5..724ac2046 100644 --- a/projects-parent/archetypes-parent/phonebill-archetype/pom.xml +++ b/projects-parent/archetypes-parent/phonebill-archetype/pom.xml @@ -3,11 +3,11 @@ archetypes-parent io.github.davidwhitlock.joy - 2.2.0-SNAPSHOT + 2.2.0 4.0.0 phonebill-archetype - 2.2.0-SNAPSHOT + 2.2.0 maven-archetype phonebill-archetype diff --git a/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/pom.xml index dbaf8d3ba..672245f01 100644 --- a/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/pom.xml @@ -3,7 +3,7 @@ joy io.github.davidwhitlock.joy - 1.2.0-SNAPSHOT + 1.2.0 4.0.0 ${groupId} @@ -38,12 +38,12 @@ io.github.davidwhitlock.joy projects - 3.0.0-SNAPSHOT + 3.0.0 io.github.davidwhitlock.joy projects - 3.0.0-SNAPSHOT + 3.0.0 tests test diff --git a/projects-parent/archetypes-parent/phonebill-web-archetype/pom.xml b/projects-parent/archetypes-parent/phonebill-web-archetype/pom.xml index 03cfa7f74..80491a691 100644 --- a/projects-parent/archetypes-parent/phonebill-web-archetype/pom.xml +++ b/projects-parent/archetypes-parent/phonebill-web-archetype/pom.xml @@ -4,10 +4,10 @@ archetypes-parent io.github.davidwhitlock.joy - 2.2.0-SNAPSHOT + 2.2.0 phonebill-web-archetype - 3.0.0-SNAPSHOT + 3.0.0 maven-archetype phonebill-web-archetype diff --git a/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/pom.xml index ac90ffb74..50c08c31a 100644 --- a/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/phonebill-web-archetype/src/main/resources/archetype-resources/pom.xml @@ -3,7 +3,7 @@ joy io.github.davidwhitlock.joy - 1.2.0-SNAPSHOT + 1.2.0 4.0.0 ${groupId} @@ -22,17 +22,17 @@ io.github.davidwhitlock.joy projects - 3.0.0-SNAPSHOT + 3.0.0 io.github.davidwhitlock.joy examples - 1.3.0-SNAPSHOT + 1.3.0 io.github.davidwhitlock.joy projects - 3.0.0-SNAPSHOT + 3.0.0 tests test diff --git a/projects-parent/archetypes-parent/pom.xml b/projects-parent/archetypes-parent/pom.xml index d0b112ded..e44ae12a6 100644 --- a/projects-parent/archetypes-parent/pom.xml +++ b/projects-parent/archetypes-parent/pom.xml @@ -7,11 +7,11 @@ io.github.davidwhitlock.joy projects-parent - 2.2.0-SNAPSHOT + 2.2.0 archetypes-parent - 2.2.0-SNAPSHOT + 2.2.0 pom diff --git a/projects-parent/archetypes-parent/student-archetype/pom.xml b/projects-parent/archetypes-parent/student-archetype/pom.xml index 8203266e5..8001154fb 100644 --- a/projects-parent/archetypes-parent/student-archetype/pom.xml +++ b/projects-parent/archetypes-parent/student-archetype/pom.xml @@ -5,11 +5,11 @@ archetypes-parent io.github.davidwhitlock.joy - 2.2.0-SNAPSHOT + 2.2.0 student-archetype - 2.3.0-SNAPSHOT + 2.3.0 maven-archetype Archetype for Student project diff --git a/projects-parent/archetypes-parent/student-archetype/src/main/resources/archetype-resources/pom.xml b/projects-parent/archetypes-parent/student-archetype/src/main/resources/archetype-resources/pom.xml index 4470f6bdf..da88f580c 100644 --- a/projects-parent/archetypes-parent/student-archetype/src/main/resources/archetype-resources/pom.xml +++ b/projects-parent/archetypes-parent/student-archetype/src/main/resources/archetype-resources/pom.xml @@ -4,7 +4,7 @@ joy io.github.davidwhitlock.joy - 1.2.0-SNAPSHOT + 1.2.0 ${groupId} ${artifactId} @@ -102,12 +102,12 @@ io.github.davidwhitlock.joy examples - 1.3.0-SNAPSHOT + 1.3.0 io.github.davidwhitlock.joy projects - 3.0.0-SNAPSHOT + 3.0.0 tests test diff --git a/projects-parent/originals-parent/airline-web/pom.xml b/projects-parent/originals-parent/airline-web/pom.xml index 89282a362..056079670 100644 --- a/projects-parent/originals-parent/airline-web/pom.xml +++ b/projects-parent/originals-parent/airline-web/pom.xml @@ -3,12 +3,12 @@ originals-parent io.github.davidwhitlock.joy - 2.2.0-SNAPSHOT + 2.2.0 4.0.0 io.github.davidwhitlock.joy.original airline-web - 3.0.0-SNAPSHOT + 3.0.0 8080 @@ -21,17 +21,17 @@ io.github.davidwhitlock.joy projects - 3.0.0-SNAPSHOT + 3.0.0 io.github.davidwhitlock.joy examples - 1.3.0-SNAPSHOT + 1.3.0 io.github.davidwhitlock.joy projects - 3.0.0-SNAPSHOT + 3.0.0 tests test diff --git a/projects-parent/originals-parent/airline/pom.xml b/projects-parent/originals-parent/airline/pom.xml index d48f0b57b..0f3cb2b65 100644 --- a/projects-parent/originals-parent/airline/pom.xml +++ b/projects-parent/originals-parent/airline/pom.xml @@ -3,13 +3,13 @@ originals-parent io.github.davidwhitlock.joy - 2.2.0-SNAPSHOT + 2.2.0 4.0.0 io.github.davidwhitlock.joy.original airline jar - 2.2.0-SNAPSHOT + 2.2.0 Airline Project An Airline application for The Joy of Coding at Portland State University 2000 @@ -32,12 +32,12 @@ io.github.davidwhitlock.joy projects - 3.0.0-SNAPSHOT + 3.0.0 io.github.davidwhitlock.joy projects - 3.0.0-SNAPSHOT + 3.0.0 tests test diff --git a/projects-parent/originals-parent/apptbook-web/pom.xml b/projects-parent/originals-parent/apptbook-web/pom.xml index 9132f0500..94cd8a112 100644 --- a/projects-parent/originals-parent/apptbook-web/pom.xml +++ b/projects-parent/originals-parent/apptbook-web/pom.xml @@ -3,12 +3,12 @@ originals-parent io.github.davidwhitlock.joy - 2.2.0-SNAPSHOT + 2.2.0 4.0.0 io.github.davidwhitlock.joy.original apptbook-web - 3.0.0-SNAPSHOT + 3.0.0 8080 @@ -21,17 +21,17 @@ io.github.davidwhitlock.joy projects - 3.0.0-SNAPSHOT + 3.0.0 io.github.davidwhitlock.joy examples - 1.3.0-SNAPSHOT + 1.3.0 io.github.davidwhitlock.joy projects - 3.0.0-SNAPSHOT + 3.0.0 tests test diff --git a/projects-parent/originals-parent/apptbook/pom.xml b/projects-parent/originals-parent/apptbook/pom.xml index 7344134a1..4936844e7 100644 --- a/projects-parent/originals-parent/apptbook/pom.xml +++ b/projects-parent/originals-parent/apptbook/pom.xml @@ -3,13 +3,13 @@ originals-parent io.github.davidwhitlock.joy - 2.2.0-SNAPSHOT + 2.2.0 4.0.0 io.github.davidwhitlock.joy.original apptbook jar - 2.2.0-SNAPSHOT + 2.2.0 Appointment Book Project An Appointment Book application for The Joy of Coding at Portland State University 2000 @@ -32,12 +32,12 @@ io.github.davidwhitlock.joy projects - 3.0.0-SNAPSHOT + 3.0.0 io.github.davidwhitlock.joy projects - 3.0.0-SNAPSHOT + 3.0.0 tests test diff --git a/projects-parent/originals-parent/kata/pom.xml b/projects-parent/originals-parent/kata/pom.xml index 5779e68e9..0d9392a76 100644 --- a/projects-parent/originals-parent/kata/pom.xml +++ b/projects-parent/originals-parent/kata/pom.xml @@ -4,11 +4,11 @@ originals-parent io.github.davidwhitlock.joy - 2.2.0-SNAPSHOT + 2.2.0 io.github.davidwhitlock.joy.original kata - 2.2.0-SNAPSHOT + 2.2.0 jar Kata Project @@ -88,7 +88,7 @@ io.github.davidwhitlock.joy projects - 3.0.0-SNAPSHOT + 3.0.0 tests test diff --git a/projects-parent/originals-parent/phonebill-web/pom.xml b/projects-parent/originals-parent/phonebill-web/pom.xml index dc84dc30d..fc4ad1360 100644 --- a/projects-parent/originals-parent/phonebill-web/pom.xml +++ b/projects-parent/originals-parent/phonebill-web/pom.xml @@ -3,12 +3,12 @@ originals-parent io.github.davidwhitlock.joy - 2.2.0-SNAPSHOT + 2.2.0 4.0.0 io.github.davidwhitlock.joy.original phonebill-web - 3.0.0-SNAPSHOT + 3.0.0 8080 @@ -22,17 +22,17 @@ io.github.davidwhitlock.joy projects - 3.0.0-SNAPSHOT + 3.0.0 io.github.davidwhitlock.joy examples - 1.3.0-SNAPSHOT + 1.3.0 io.github.davidwhitlock.joy projects - 3.0.0-SNAPSHOT + 3.0.0 tests test diff --git a/projects-parent/originals-parent/phonebill/pom.xml b/projects-parent/originals-parent/phonebill/pom.xml index 24f7e3c10..d70423a55 100644 --- a/projects-parent/originals-parent/phonebill/pom.xml +++ b/projects-parent/originals-parent/phonebill/pom.xml @@ -3,13 +3,13 @@ originals-parent io.github.davidwhitlock.joy - 2.2.0-SNAPSHOT + 2.2.0 4.0.0 io.github.davidwhitlock.joy.original phonebill jar - 2.2.0-SNAPSHOT + 2.2.0 Phone Bill Project A Phone Bill application for The Joy of Coding at Portland State University 2000 @@ -38,12 +38,12 @@ io.github.davidwhitlock.joy projects - 3.0.0-SNAPSHOT + 3.0.0 io.github.davidwhitlock.joy projects - 3.0.0-SNAPSHOT + 3.0.0 tests test diff --git a/projects-parent/originals-parent/pom.xml b/projects-parent/originals-parent/pom.xml index da9c4ec51..4ceaa38b8 100644 --- a/projects-parent/originals-parent/pom.xml +++ b/projects-parent/originals-parent/pom.xml @@ -5,11 +5,11 @@ io.github.davidwhitlock.joy projects-parent - 2.2.0-SNAPSHOT + 2.2.0 originals-parent - 2.2.0-SNAPSHOT + 2.2.0 pom diff --git a/projects-parent/originals-parent/student/pom.xml b/projects-parent/originals-parent/student/pom.xml index a3dd3c728..c31a07f56 100644 --- a/projects-parent/originals-parent/student/pom.xml +++ b/projects-parent/originals-parent/student/pom.xml @@ -4,11 +4,11 @@ originals-parent io.github.davidwhitlock.joy - 2.2.0-SNAPSHOT + 2.2.0 io.github.davidwhitlock.joy.original student - 2.2.0-SNAPSHOT + 2.2.0 jar Student Project @@ -88,12 +88,12 @@ io.github.davidwhitlock.joy examples - 1.3.0-SNAPSHOT + 1.3.0 io.github.davidwhitlock.joy projects - 3.0.0-SNAPSHOT + 3.0.0 tests test diff --git a/projects-parent/pom.xml b/projects-parent/pom.xml index 8bbb85991..0abd54173 100644 --- a/projects-parent/pom.xml +++ b/projects-parent/pom.xml @@ -7,11 +7,11 @@ io.github.davidwhitlock.joy joy - 1.2.0-SNAPSHOT + 1.2.0 projects-parent - 2.2.0-SNAPSHOT + 2.2.0 pom diff --git a/projects-parent/projects/pom.xml b/projects-parent/projects/pom.xml index 3952a041a..be9243866 100644 --- a/projects-parent/projects/pom.xml +++ b/projects-parent/projects/pom.xml @@ -2,13 +2,13 @@ projects-parent io.github.davidwhitlock.joy - 2.2.0-SNAPSHOT + 2.2.0 4.0.0 projects Project APIs Classes needed for the Projects in The Joy of Coding - 3.0.0-SNAPSHOT + 3.0.0 http://www.cs.pdx.edu/~whitlock diff --git a/web/pom.xml b/web/pom.xml index 2ccd306ad..a8f202e0f 100644 --- a/web/pom.xml +++ b/web/pom.xml @@ -3,13 +3,13 @@ joy io.github.davidwhitlock.joy - 1.2.0-SNAPSHOT + 1.2.0 4.0.0 web war Web Application examples - 2.0.0-SNAPSHOT + 2.0.0 http://www.cs.pdx.edu/~whitlock 6.2.11.Final @@ -117,7 +117,7 @@ io.github.davidwhitlock.joy examples - 1.3.0-SNAPSHOT + 1.3.0 jakarta.xml.bind From 4cd061bba7ee27c187a8c48fa47f69bf5105bca6 Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Sat, 30 Nov 2024 19:05:08 -0800 Subject: [PATCH 58/59] Oops. There was already a version 2.2.0 of the student project deployed to Maven Central. So, increment the version to 2.3.0. --- projects-parent/originals-parent/student/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects-parent/originals-parent/student/pom.xml b/projects-parent/originals-parent/student/pom.xml index c31a07f56..390028f6f 100644 --- a/projects-parent/originals-parent/student/pom.xml +++ b/projects-parent/originals-parent/student/pom.xml @@ -8,7 +8,7 @@ io.github.davidwhitlock.joy.original student - 2.2.0 + 2.3.0 jar Student Project From d2aad41f02af09f2e89e945835f1c86d7d0a0418 Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Sun, 1 Dec 2024 08:22:11 -0800 Subject: [PATCH 59/59] Oops. The initial deployment of release artifacts didn't take. Incrementing student version so that I can deploy it again. --- projects-parent/originals-parent/student/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects-parent/originals-parent/student/pom.xml b/projects-parent/originals-parent/student/pom.xml index 390028f6f..83743141b 100644 --- a/projects-parent/originals-parent/student/pom.xml +++ b/projects-parent/originals-parent/student/pom.xml @@ -8,7 +8,7 @@ io.github.davidwhitlock.joy.original student - 2.3.0 + 2.3.1 jar Student Project