Setting up custom execution path for maven project in netbeans

I want to add a custom classpath when I run my maven project from inside netbeans. So far I've tried to add the following to the Run Project action in the project properties:

exec.args=-classpath %classpath;c:/QUASR/duplicateRemoval.jar;c:/QUASR/lib/QUASR.jar ${packageClassName} 

exec.args=-cp %classpath;c:/QUASR/duplicateRemoval.jar;c:/QUASR/lib/QUASR.jar ${packageClassName}

exec.args=-cp c:/QUASR/duplicateRemoval.jar;c:/QUASR/lib/QUASR.jar ${packageClassName}  

      

but not luck, the custom runtime classpath is not set.

+1


source to share


1 answer


You have to add a new profile run-with-netbeans

to your pom that declares additional dependencies (use scope provided

to not include them in release).

Then you will need to add a new profile to your IDE in order to run the pom with a parameter -P run-with-netbeans

on the command line.

<properties>
    <!-- provided by default -->
    <my-dynamic-scope>provided</my-dynamic-scope>
</properties>

<profiles>
    <profile>
        <id>run-with-netbeans</id>
        <properties>
            <!-- compile when running in IDE -->
            <my-dynamic-scope>compile</my-dynamic-scope>
        </properties>
        <dependencies>
            <dependency>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
                <version>${log4j.version}</version>
            </dependency>
        </dependencies>
    </profile>
</profiles>


<dependencies>
    <dependency>
        <groupId>commons-lang</groupId>
        <artifactId>commons-lang</artifactId>
        <version>${commons-lang.version}</version>
        <scope>${my-dynamic-scope}</scope>
    </dependency>
</dependencies>

      



The snippet above adds log4j only when working with a profile run-with-netbeans

. It also sets a property my-dynamic-scope

that can be used in your dependency block to change scope.

E.I.V. M.

+1


source







All Articles