Created
January 28, 2022 06:38
-
-
Save eggplants/8f45b3cfc50098acc26963ad61f05f9a to your computer and use it in GitHub Desktop.
Easy Converter of pom.{xml,yml} into pom.{yml,xml} with https://github.com/takari/polyglot-maven
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -euo pipefail | |
USAGE="usage: $0 <x2y|y2x>" | |
if ! command -v mvn &>/dev/null; then | |
echo 'err: install maven' >&2 | |
exit 1 | |
elif [ "$({ echo 3.3.0;mvn --version|head -1|cut -f3 -d ' ';}|sort -V|head -1)" != '3.3.0' ]; then | |
echo 'err: update maven to 3.3.1' >&2 | |
exit 1 | |
elif ! { [ -f ./.mvn/extensions.xml ] && grep -q 'io.takari.polyglot' ./.mvn/extensions.xml;}; then | |
cat<<'A'>&2 | |
err: create ./.mvn/extensions.xml and edit: | |
``` | |
<?xml version="1.0" encoding="UTF-8"?> | |
<extensions> | |
<extension> | |
<groupId>io.takari.polyglot</groupId> | |
<artifactId>ARTIFACTID</artifactId> | |
<version>0.4.6</version> | |
</extension> | |
</extensions> | |
``` | |
A | |
exit 1 | |
fi | |
if [ $# != 1 ]; then | |
echo "$USAGE" | |
exit 1 | |
elif [ "$1" = 'x2y' ]; then | |
if ! [ -f pom.xml ]; then | |
echo 'err: where is pom.xml?' >&2 | |
exit 1 | |
fi | |
mvn io.takari.polyglot:polyglot-translate-plugin:translate -Dinput=pom.xml -Doutput=pom.yml | |
elif [ "$1" = 'y2x' ]; then | |
if ! [ -f pom.yml ]; then | |
echo 'err: where is pom.yml?' >&2 | |
exit 1 | |
fi | |
mvn io.takari.polyglot:polyglot-translate-plugin:translate -Dinput=pom.yml -Doutput=pom.xml | |
else | |
echo "$USAGE" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment