Skip to content

Instantly share code, notes, and snippets.

@mesaglio
Last active November 13, 2020 13:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mesaglio/a3202cce9063272cc11093b139dcb142 to your computer and use it in GitHub Desktop.
Save mesaglio/a3202cce9063272cc11093b139dcb142 to your computer and use it in GitHub Desktop.
CMVN - Create mvn project from console

CMVN

  1. Download or copy the script content un home directory.

  2. Create tarminal alias, like in ~/.bashrc alias cmvn='/c/Users/juan\ mesaglio/deploy-scripts/create-maven-project.sh'.

  3. Enjoy.

#!/bin/bash
GORUPID=$1
ARTIFACTID=$2
if [ "$1" = "--help" ]
then
echo "La finalidad del siguiente script es automatizar la creacion de proyectos maven."
echo "La arquitectura base es maven-archetype-quickstart, version 1.4 ."
echo "Crea un directorio con el nombre del artifacId (segundo parametro)."
exit
fi
echo "Si tiene alguna duda sobre el funcionamiento del script, pasarle --help como argumento."
echo "Ingrese el groupId son \"\" "
read GORUPID
echo "groupId: $GORUPID"
echo "Ingrese el artifactId son \"\" "
read ARTIFACTID
echo "artifacId: $ARTIFACTID"
echo "Generando el proyecto ..."
mkdir $ARTIFACTID
cd $ARTIFACTID
mvn archetype:generate -DgroupId=$GORUPID -DartifactId=$ARTIFACTID -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4 -DinteractiveMode=false
curl -L https://gist.github.com/mesaglio/399511b9092f447e6d673b78ff0317fb/raw/pom.xml > $ARTIFACTID/pom.xml
curl -L https://gist.github.com/mesaglio/3e794332434a1d4844439b8265249556/raw/.gitignore > $ARTIFACTID/.gitignore
sed -i "s/ARTIFACT/$ARTIFACTID/" "$ARTIFACTID/pom.xml"
sed -i "s/GROUP/$GORUPID/" "$ARTIFACTID/pom.xml"
shopt -s dotglob
mv -f $ARTIFACTID/* .
rmdir $ARTIFACTID
shopt -u dotglob
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment