Running Maven in the first ancestor dir that contains a pom.xml file

Oxygen general issues.
dcramer
Posts: 161
Joined: Sat Aug 28, 2010 1:23 am

Running Maven in the first ancestor dir that contains a pom.xml file

Post by dcramer »

Hi there,
Our projects are use Maven and are set up such that the xml files are at various depths in a directory tree and there is a pom.xml file in a containing folder. So you might have:

project-name/pom.xml
project-name/src/docbkx/somefile.xml
project-name/src/docbkx/chapters/somechapter.xml

I'd like to set up an External Tool to kick off Maven such that it works even if you're editing somechapter.xml (i.e. a file not in the same dir as pom.xml). I thought I'd write a simple shell script that walks up the tree until it finds a pom file and then runs maven on it:

Code: Select all


while true; do [ -f pom.xml ] && break; cd ..; done; mvn clean generate-sources
I figured I could store the script in my framework and have the external tool invoke it from there, but when I try, I always get errors like:

Code: Select all


Could not start: Cannot run program "/home/dcramer/.local/share/applications/Oxygen13-2/frameworks/rackbook/test2.sh
" (in directory "/home/dcramer/Documents/rax/rackspace-template/src/docbkx"): java.io.IOException: error=2, No such file or directory
Process ended with exit code: -1234567
Is there a way to do what I want? I.e. run mvn against the pom even if the pom is in some directory above the currently edited file (and the number of levels up is an arbitrary number)?

Thanks,
David
adrian
Posts: 2855
Joined: Tue May 17, 2005 4:01 pm

Re: Running Maven in the first ancestor dir that contains a pom.xml file

Post by adrian »

Hello,

When you configure the external tool in Oxygen make sure you use "/bin/sh" at the beginning of the "Command line", before the .sh script path.

e.g.
Command line:

Code: Select all

/bin/sh /home/dcramer/.local/share/applications/Oxygen13-2/frameworks/rackbook/test2.sh
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
dcramer
Posts: 161
Joined: Sat Aug 28, 2010 1:23 am

Re: Running Maven in the first ancestor dir that contains a pom.xml file

Post by dcramer »

That does the trick.

Thanks,
David
Post Reply