Maven (Application)

From campisano.org
Jump to navigation Jump to search

Maven

Install

# shared/opt install schema v1.5.6

#### as common user ####
# define applications vars
export SOFTWARE_PATH="/home/shared/opt/software"
export NAME="maven"
export VERSION="3.8.4"
export URL="https://archive.apache.org/dist/maven/maven-3/${VERSION}/binaries/apache-maven-${VERSION}-bin.tar.gz"
su - -w SOFTWARE_PATH,NAME,VERSION

#### as root ####
# install packages and prepare destination path
apt-get -q -y install wget coreutils findutils < /dev/null
apt-get -q -y install tar gzip < /dev/null
mkdir -m 777 "${SOFTWARE_PATH}/tmp_install/" "${SOFTWARE_PATH}/${NAME}_${VERSION}/"
exit

#### as common user ####
umask 0027
cd "${SOFTWARE_PATH}/tmp_install"
wget -c --no-check-certificate "${URL}"
tar -xzf "apache-maven-${VERSION}-bin.tar.gz"
cd "apache-maven-${VERSION}"
mv * "${SOFTWARE_PATH}/${NAME}_${VERSION}"
cd
su - -w SOFTWARE_PATH,NAME,VERSION

#### as root ####
# ensure permissions to destination path
cd "${SOFTWARE_PATH}"
chown -R root:users "${NAME}_${VERSION}"
find "${NAME}_${VERSION}" -type d -exec chmod a-s,u+rwx,g+rx,g-w,o-rwx {} \;
find "${NAME}_${VERSION}" -type f -exec chmod a-s,u+rw,g+r,g-w,o-rwx {} \;
rm -rf tmp_install
ln -s -f -T "${NAME}_${VERSION}" "${NAME}"
exit

#### as common user ####
# test the application (you can put the follow in ~/.profile)
export SOFTWARE_PATH="/home/shared/opt/software"
export MAVEN_HOME="${SOFTWARE_PATH}/maven"
export PATH="${PATH}:${MAVEN_HOME}/bin"
mvn --version

Generate a basic project structure

mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart -DgroupId=org.example -DartifactId=test_maven_quickstart_app -Dversion=0.1.0 -DinteractiveMode=false
cd test_maven_quickstart_app
mvn clean package

Links

https://codesteps.com/2020/02/10/spring-boot-create-a-web-application-using-maven-our-first-application/