1

I want to add a custom classpath when I'm running my maven project from within netbeans. So far I've tried adding 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 no luck, the custom runtime classpath is not set.

LordDoskias
  • 3,121
  • 3
  • 30
  • 44

1 Answers1

1

You should add a new profile run-with-netbeans in your pom that declares the additional dependencies (use the provided scope to not include them in the release).

Then you'll have to add the new profile to your IDE to run the pom with the -P run-with-netbeans option in 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 add log4j only when running with the run-with-netbeans profile. It also sets a property my-dynamic-scope that can be used in your dependency block to change the scope.

HIH M.

poussma
  • 7,033
  • 3
  • 43
  • 68
  • Could some one expand on this Answer? This is exactly what I want to do, include a library during programming & compiling but not include in the build. I'm a little familiar with editing a POM file, but I've no idea how to do these steps. – Basil Bourque Aug 19 '15 at 05:26
  • Similar Question, [Include a library while programming & compiling, but exclude from build, in NetBeans Maven-based project](http://stackoverflow.com/q/32087445/642706) with good Answer. – Basil Bourque Aug 19 '15 at 06:52