【问题标题】:exec-maven-plugin difference between arguments and commandlineArgsexec-maven-plugin arguments 和 commandlineArgs 之间的区别
【发布时间】: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>

问题是&lt;commandlineArgs&gt; 会变得很长。这就是为什么我更喜欢使用&lt;arguments&gt; 参数的原因。

谁能向我解释两者之间的区别和/或我是否/如何使用arguments 参数?

【问题讨论】:

    标签: java maven exec-maven-plugin


    【解决方案1】:

    也许您必须以这种方式单独提供您的论点? 根据Maven - pass argument to use in exec-maven-plugin中的帖子

        <arguments>
            <argument>-action</argument>
            <argument>GetAppList</argument>
            <argument>-vuser</argument>
            <argument>${veracode.username}</argument>
            <argument>-vpassword</argument>
            <argument>${veracode.password}</argument>
        </arguments>
    

    【讨论】:

    • 看起来就是这样。在对源代码进行了一些挖掘并运行了一些测试之后,我正要自己发布答案。
    猜你喜欢
    • 2015-09-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-16
    • 2014-10-10
    • 1970-01-01
    • 2013-10-30
    • 1970-01-01
    相关资源
    最近更新 更多