For my current purposes I have a Maven project which creates a war
file, and I want to see what actual classpath it is using when creating the war
.
This is a single command solution but does compile the code.
mvn -e -X -Dmaven.test.skip=true clean compile | grep -o -P '\-classpath .*? ' | awk '{print $2}'
Shell script example usage
MAVEN_CLASSPATH=$(mvn -e -X -Dmaven.test.skip=true clean compile | grep -o -P '\-classpath .*? ' | awk '{print $2}')
I used a variation of it in a shell script to run a standalone main() (for Hibernate schema generation) this way
#/bin/bash
MAVEN_TEST_CLASSPATH=$(mvn -e -X clean package | grep -o -P '\-classpath .*?test.*? ')
java $MAVEN_TEST_CLASSPATH foo.bar.DBSchemaCreate
File output example
mvn -e -X -Dmaven.test.skip=true clean compile | grep -o -P '\-classpath .*? ' | awk '{print $2}' > maven.classpath