Search code examples
mavenexec-maven-plugin

multiple arguments using exec-maven-plugin - no such file or directory error


I am new to maven and while playing with it, I tried to execute simple bash commands.

However when I tried to append something to a file using exec-maven-plugin, it always throws a "No such file or directory" error.

I have added the whole pom.xml below.

<project xmlns="http://maven.apache.org/POM/4.0.0"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
   http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.company.projectgroup</groupId>
  <artifactId>project</artifactId>
  <version>1.0</version>
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.3.2</version>
        <executions>
      <execution>
        <id>some-execution</id>
        <phase>compile</phase>
        <goals>
          <goal>exec</goal>
        </goals>
        <configuration>
          <executable>env</executable>
          <workingDirectory>src/main</workingDirectory>
          <arguments>
        <argument> |tee -a env.properties </argument>
          </arguments>
        </configuration>
      </execution>
    </executions>
      </plugin>
    </plugins>
  </build>
</project>

Can anyone please help.

Thanks, Jason


Solution

  • As @khmarbaise suggested, I also think you should use the outputFile parameter of the exec-maven-plugin.
    It works with your pom.xml.

    I hope this helps.