0

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

Jason
  • 2,246
  • 6
  • 34
  • 53
  • The [exec-maven-plugin](http://mojo.codehaus.org/exec-maven-plugin/exec-mojo.html#outputFile) has a parameter `outputFile` which handles redirecting into file out of the box. – khmarbaise Oct 19 '14 at 07:44

1 Answers1

1

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.

Eldad Assis
  • 10,464
  • 11
  • 52
  • 78
  • Hey Guys. Thanks for helping me out. Using outputFile actually worked and I was able to create a file as below: env.properties. Also, this puts the file in the same location as pom.xml, so to put it to my desired location, I ended up doing as below: src/main/env.properties – Jason Nov 09 '14 at 02:46