Skip to content

Commit 16d5dcf

Browse files
fwilhe2gunnarmorling
authored andcommitted
🔨 Allow running script on Linux
On linux, gsed is typically not a command, but GNU sed is available as sed. This change should allow using it on both Mac and Linux without issues, assuming gsed is installed on the Mac.
1 parent b000ddd commit 16d5dcf

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

update-from-templates.sh

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,30 @@ rm -rf oss-quickstart-simple-archetype/src/main/resources/archetype-resources/sr
2828

2929
# Adjusting pom.xml
3030

31-
# The archetype creation process drops the line-wrap after the license header in the pom.xml; adding this back
31+
# OS specific support. $var _must_ be set to either true or false.
32+
# Inspired by mvnw
33+
cygwin=false;
34+
darwin=false;
35+
mingw=false;
36+
case "`uname`" in
37+
CYGWIN*) cygwin=true ;;
38+
MINGW*) mingw=true;;
39+
Darwin*) darwin=true;;
40+
esac
41+
3242
# using gsed on macOS to have flag compatibility with gnu sed on Linux
33-
gsed -i 's/--><project/-->\n<project/g' oss-quickstart-simple-archetype/src/main/resources/archetype-resources/pom.xml
34-
gsed -i 's/<name>OSS.*<\/name>/<name>My OSS Project<\/name>/g' oss-quickstart-simple-archetype/src/main/resources/archetype-resources/pom.xml
35-
gsed -i 's/<description>.*<\/description>/<description>My Latest OSS Project<\/description>/g' oss-quickstart-simple-archetype/src/main/resources/archetype-resources/pom.xml
36-
gsed -i 's/<url>https.*<\/url>/<url>tbd.<\/url>/g' oss-quickstart-simple-archetype/src/main/resources/archetype-resources/pom.xml
43+
SED_COMMAND='sed'
44+
if $darwin ; then
45+
SED_COMMAND='gsed'
46+
fi
47+
48+
# The archetype creation process drops the line-wrap after the license header in the pom.xml; adding this back
49+
# Also replace some other values from the template with generic placeholders
50+
$SED_COMMAND -i 's/--><project/-->\n<project/g' oss-quickstart-simple-archetype/src/main/resources/archetype-resources/pom.xml
51+
$SED_COMMAND -i 's/<name>OSS.*<\/name>/<name>My OSS Project<\/name>/g' oss-quickstart-simple-archetype/src/main/resources/archetype-resources/pom.xml
52+
$SED_COMMAND -i 's/<description>.*<\/description>/<description>My Latest OSS Project<\/description>/g' oss-quickstart-simple-archetype/src/main/resources/archetype-resources/pom.xml
53+
$SED_COMMAND -i 's/<url>https.*<\/url>/<url>tbd.<\/url>/g' oss-quickstart-simple-archetype/src/main/resources/archetype-resources/pom.xml
3754

3855
# Adjusting module-info.java
3956

40-
gsed -i 's/module \${package}/module \${moduleName}/g' oss-quickstart-simple-archetype/src/main/resources/archetype-resources/src/main/java/module-info.java
57+
$SED_COMMAND -i 's/module \${package}/module \${moduleName}/g' oss-quickstart-simple-archetype/src/main/resources/archetype-resources/src/main/java/module-info.java

0 commit comments

Comments
 (0)