【发布时间】:2015-09-16 08:27:24
【问题描述】:
我正在尝试将 exec-maven-plugin 与 java 目标一起使用。但是,我对这两个选项之间的区别感到困惑:
- 参数
- 命令行参数
如果我尝试使用参数,对我的 java 类的调用将失败。
我的班级被调用的签名是:
public static void main(String[] args)
{
VeracodeParser parser = new VeracodeParser();
parser.parse(args);
}
我的 pom:
<plugin>
<artifactId>exec-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
<executions>
<execution>
<id>Zip packaging and deployment</id>
<phase>process-sources</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>com.veracode.apiwrapper.cli.VeracodeCommand</mainClass>
<arguments>
<argument>-action GetAppList</argument>
<argument>-vuser ${veracode.username}</argument>
<argument>-vpassword ${veracode.password}</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
但是,我从 VeracodeCommand 类收到错误消息,表明我缺少 -action、-vuser 和 -vpassword 参数。
但是,当我将其切换为使用单个字符串 commandlineArgs 参数时,它会按预期工作:
<plugin>
<artifactId>exec-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
<executions>
<execution>
<id>Zip packaging and deployment</id>
<phase>process-sources</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>com.veracode.apiwrapper.cli.VeracodeCommand</mainClass>
<commandlineArgs>-action UploadFile -vuser ${veracode.username} -vpassword ${veracode.password} -appid ${veracode.appId} -filepath ${project.build.directory}/dependency/sbip_ear_pres.ear</commandlineArgs>
</configuration>
</execution>
</executions>
</plugin>
问题是<commandlineArgs> 会变得很长。这就是为什么我更喜欢使用<arguments> 参数的原因。
谁能向我解释两者之间的区别和/或我是否/如何使用arguments 参数?
【问题讨论】:
标签: java maven exec-maven-plugin