You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@netbeans.apache.org by Steve Hannah <st...@weblite.ca> on 2021/01/11 14:51:30 UTC

Fwd: Run goal in parent or sibling maven project

I have a multi-module maven project with layout:

parent-project
      - main-project
      - javase-project

javase-project depends on main-project, and running and debugging the
project is done in the javase-project.

But most of the time I'm working in the "main-project", so I'd like to
press "run" in the "main-project" and have the "run" goal executed in the
"javase-project".

After several hours of googling and reading every nbactions.xml file I can
find on github I've resigned myself to the likely fact that this isn't
really possible, but as a workaround, I'm currently attempting using the
exec:exec task to run the mvn executable in the sibling directory.  Eg.

<?xml version="1.0" encoding="UTF-8"?>
<actions>
        <action>
            <actionName>run</actionName>
            <packagings>
                <packaging>jar</packaging>
            </packagings>
            <goals>
                <goal>org.codehaus.mojo:exec-maven-plugin:3.0.0:exec</goal>
            </goals>
            <properties>
                <exec.executable>$M2_HOME/bin/mvn</exec.executable>
                <exec.args>my-run-goal</exec.args>
                <exec.workingdir>../javase-project</exec.workingdir>
            </properties>
        </action>
    </actions>

I have an immediate problem here and a broader problem.  The immediate
problem is that I can't figure out how to get the path to the mvn
executable inside the nbactions.xml file.  (That $M2_HOME in my snippet
there doesn't work).

The broader problem is that, even if I do manage to get the M2_HOME
environment variable, I fear that differences on windows (e.g. mvn.bat vs
mvn) will be difficult to account for using this syntax.

Can anyone suggest a better way to accomplish this?  And if now, does
anyone know how to get the location to the mvn executable inside the
nbactions.xml file?

Thanks for any pointers.

Steve