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.

4

1 回答 1

1

你应该在你的 pom 中添加一个新的配置文件run-with-netbeans来声明额外的依赖项(使用provided范围不包括在发布中)。

然后,您必须将新配置文件添加到您的 IDE 以使用-P run-with-netbeans命令行中的选项运行 pom。

<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>

上面的代码片段仅在使用配置文件运行时添加 log4j run-with-netbeans。它还设置了一个属性my-dynamic-scope,可以在您的依赖块中使用来更改范围。

嗨,M。

于 2012-07-23T15:19:04.743 回答