A parent pom for projects.
Determine the latest version of the parent pom in Maven Central.
Set the parent to your pom:
<parent>
<groupId>com.arpnetworking.build</groupId>
<artifactId>arpnetworking-parent-pom</artifactId>
<version>VERSION</version>
</parent>
The Maven Central repository is included by default.
The checkstyle configuration is obtained from the build-resources package. The checkstyle mojo is executed as part of the verify lifecycle. However, the mojo can also be executed directly. In order to execute the checkstyle mojo directly you need to also ensure the build-resources are extracted.
project> mvn dependency:unpack-dependencies checkstyle:check
The parent pom enables the use of Maven Wrapper in child projects and it also uses Maven Wrapper itself. In order to ensure consistent builds you should invoke mvnw instead of mvn to build the project locally and from continuous integration.
To allow developers to build wrapper and unwrapper projects seamlessly you can use this shell script to invoke either mvnw or mvn depending on which is available. Simply copy the script, make it executable and ensure it is first on PATH. Now continue to invoke mvn and it will actually run mvnw if available in the current project.
#!/bin/bash
JDKW_OPTIONS=""
# Look for maven wrapper
MVN_COMMAND=""
if [ -f "./mvnw" ]; then
echo "Maven wrapper found; invoking mvnw"
MVN_COMMAND="./mvnw"
else
echo "Maven wrapper not found; invoking mvn"
MVN_COMMAND="/usr/local/bin/mvn"
fi
# Look for jdk wrapper
if [ -f "jdk-wrapper.sh" ]; then
MVN_COMMAND="./jdk-wrapper.sh ${JDKW_OPTIONS} ${MVN_COMMAND}"
elif [ -f ".jdkw" ]; then
JDKW_REMOTE="https://raw.githubusercontent.com/vjkoskela/jdk-wrapper/master/jdk-wrapper.sh"
JDKW_LOCAL="${HOME}/.jdk/jdk-wrapper.sh"
mkdir -p "$(dirname "${JDKW_LOCAL}")"
if [ -f "${JDKW_LOCAL}" ]; then
curl "${JDKW_REMOTE}" -z "${JDKW_LOCAL}" -o "${JDKW_LOCAL}" --silent --location
else
curl "${JDKW_REMOTE}" -o "${JDKW_LOCAL}" --silent --location
fi
chmod +x "${JDKW_LOCAL}"
MVN_COMMAND="${JDKW_LOCAL} ${JDKW_OPTIONS} ${MVN_COMMAND}"
fi
# Execute
eval "${MVN_COMMAND}" "$@"
exit $?
Please note that your environment should have JAVA_HOME set correctly.
Prerequisites:
- JDK8 (Or Invoke with JDK Wrapper)
Building:
arpnetworking-parent-pom> ./jdk-wrapper.sh ./mvnw verify
To use the local version you must first install it locally:
arpnetworking-parent-pom> ./jdk-wrapper.sh ./mvnw install
You can determine the version of the local build from the pom file. Using the local version is intended only for testing or development.
Published under Apache Software License 2.0, see LICENSE
© Arpnetworking Inc., 2015