peter.murray.rust
peter.murray.rust

Reputation: 38043

Running mvn exec:java from a remote directory not containing the pom.xml

I have a maven project built in '/some/where' which I wish to run/execute from another directory '/foo/bar'. I am currently running commands such as:

cd /some/where
mvn exec:java -Dexec.mainClass=org.xmlcml.cml.rest.Client 

with

/some/where/pom.xml

I wish to do something like:

cd /foo/bar
mvn -p /some/where/pom.xml exec:java -Dexec.mainClass=org.xmlcml.cml.rest.Client 

but don't know the syntax or whether it is allowed.

If it is allowed where are relative filenames referenced to (a) the directory containing the pom.xml , i.e. /some/where or (b) the current directory /foo/bar

Upvotes: 2

Views: 2026

Answers (1)

Stephen C
Stephen C

Reputation: 718826

Try this:

mvn -f /some/where/pom.xml exec:java -Dexec.mainClass=org.xmlcml.cml.rest.Client

To find out the maven command line options:

mvn --help

If it is allowed where are relative filenames referenced to (a) the directory containing the pom.xml , i.e. /some/where or (b) the current directory /foo/bar

Relative pathnames in POM file are resolved relative to the directory containing the POM.

Upvotes: 8

Related Questions