【问题标题】:exec-maven-plugin cannot correctly use argumentsexec-maven-plugin 无法正确使用参数
【发布时间】:2019-03-26 20:40:57
【问题描述】:

我尝试使用一些参数执行一个 shell 脚本(实际上是 OpenLDAP 的 ldapmodify)。这就是我在 pom.xml 中所做的:

在 Maven Profile 中我定义了一些值

<profile>
    <id>Linux-OpenLDAP</id>
         <activation>
             <os>
                  <family>Unix</family>
             </os>
         </activation>
    <properties>
        <OpenLdap.ClientTools.home></OpenLdap.ClientTools.home>
        <executable>/usr/local/bin/ldapmodify</executable>
        <argument>-a -x -h localhost -p 389 -D "cn=manager,dc=my-domain,dc=com" -f ${test-users.idif.path} -w secret</argument>
    </properties>
</profile>

这就是我使用 exec-maven-plugin 的方式:

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>exec</goal>
                    </goals>
                    <configuration>
                        <executable>${executable}</executable>
                        <arguments>
                            <commandlineArgs>${argument}</commandlineArgs>
                        </arguments>
                    </configuration>
                </execution>
            </executions>
        </plugin>

然后在mvn install之后,我得到了这个错误:

[INFO] --- exec-maven-plugin:1.4.0:exec (default) @ entity-matching-bootstrap ---
/usr/local/bin/ldapmodify: invalid option -- ' '
ldapmodify: unrecognized option -
Add or modify entries from an LDAP server

如果我直接在命令行中运行/usr/local/bin/ldapmodify -a -x -h localhost -p 389 -D "cn=manager,dc=ibm,dc=com" -f /home/entity-matching/entity-matching-bootstrap/src/test/resources/test_users.ldif -w secret,它会成功。那么为什么在 mvn install 时该选项无效呢?

【问题讨论】:

    标签: maven openldap exec-maven-plugin


    【解决方案1】:

    问题是您将&lt;commandlineArgs&gt; 嵌入到&lt;arguments&gt; 部分中。只需删除&lt;arguments&gt; 部分:

    <configuration>
      <executable>${executable}</executable>
      <commandlineArgs>${argument}</commandlineArgs>
    </configuration>
    

    【讨论】:

    • 天啊...我太粗心了。谢谢。
    猜你喜欢
    • 2011-03-26
    • 2019-02-13
    • 1970-01-01
    • 2018-07-09
    • 2018-10-20
    • 2014-12-25
    • 1970-01-01
    • 2014-03-10
    • 2020-10-04
    相关资源
    最近更新 更多