create directory when needed in maven

Instead of the exec plugin, use the antrun plugin to first create the directory and then invoke the thrift compiler.

<plugin>
  <artifactId>maven-antrun-plugin</artifactId>
  <executions>
    <execution>
      <id>generate-sources</id>
      <phase>generate-sources</phase>
      <configuration>
        <tasks>
          <mkdir dir="target/generated-sources/thrift"/>
          <exec executable="${thrift.executable}">
            <arg value="--gen"/>
            <arg value="java:beans"/>
            <arg value="-o"/>
            <arg value="target/generated-sources/thrift"/>
            <arg value="src/main/resources/MyThriftMessages.thrift"/>
          </exec>
        </tasks>
      </configuration>
      <goals>
        <goal>run</goal>
      </goals>
    </execution>
  </executions>
</plugin>

You may also want to take a look at the maven-thrift-plugin.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)