I try to execute a shell script(actually it is ldapmodify of OpenLDAP) with some arguments. This is how I did in pom.xml:
In Maven Profile I defined some values
<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>
This is how I use 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>
Then after mvn install
, I got this error:
[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
If I run /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
directly in commnad line, it would succeed. So why the option is invalid during mvn install?
The problem is that you embed the <commandlineArgs>
within the <arguments>
section. Just remvoe the <arguments>
section:
<configuration>
<executable>${executable}</executable>
<commandlineArgs>${argument}</commandlineArgs>
</configuration>