我想在exec-maven-plugin中添加一个额外的类路径。
除了%classpath之外,我还想为包含资源的目录(/Users/kornp/ resources )添加一个额外的路径。目前,我的pom是这样的:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1.1</version>
<configuration>
<executable>java</executable>
<classpathScope>runtime</classpathScope>
<arguments>
<argument>%classpath:/Users/kornp/resources</argument>
<argument>org.drrabbit.maventest.App</argument>
</arguments>
</configuration>
</plugin>我应该如何配置它?
发布于 2012-09-19 20:55:41
我在我的源文件夹之外的特定目录中有一些配置文件。因此,我在pom.xml文件中定义了额外的资源。
我的示例目录结构是:
+ src
+ conf
- app.properties
- log4j.xml
- pom.xml我的pom.xml:
<build>
<resources>
<resource>
<directory>conf</directory>
</resource>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<executable>java</executable>
<mainClass>com.mycompany.MyMainClass</mainClass>
</configuration>
</plugin>
</plugins>
<build>现在我们可以执行程序了:
mvn clean compile exec:java发布于 2010-04-07 04:51:12
您是否尝试过使用commandlineArgs参数(如exec example中所述)?
发布于 2011-09-19 11:46:44
虽然它看起来不那么优雅,但切换到antrun插件应该是可行的:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>runSomething</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<property name="runtime_classpath" refid="maven.runtime.classpath"/>
<java classname="org.drrabbit.maventest.App"
fork="true"
failonerror="true"
maxmemory="512m">
<classpath>
<pathelement path="${project.build.directory}/some/extra/resources" />
<pathelement path="${runtime_classpath}" />
</classpath>
</java>
</target>
</configuration>
</execution>
</executions>
</plugin>然而,像你的操作人员建议的那样,将额外的资源放在项目之外的某个地方似乎不是一个好主意。您应该考虑将其作为项目的一部分,或者将其作为jar并部署到maven repo,这样您就可以将其作为插件依赖项。
https://stackoverflow.com/questions/2587935
复制相似问题