Search code examples
mavenpom.xmlthrift

Maven Thrift Plugin


I am trying to automate the generation of source files from the .thrift files and later the packaging. As far as I know, the maven-thrift-plugin is restrictive in the sense that source and destination directories are fixed. Is there any way I can specify the source and destination directories? I could probably achieve this by using the maven-antrun-plugin but I don't want to pollute my pom unnecessarily if I don't have to.

Thanks.


Solution

  • As far as I can see from the source (https://github.com/dtrott/maven-thrift-plugin/blob/master/src/main/java/org/apache/thrift/maven/ThriftCompileMojo.java) there are configuration properties that control this behaviour.

    Try these properties, they should work:

    • thriftSourceRoot
    • thriftTestSourceRoot
    • outputDirectory

    These props should be added to the <configuration> section along with <thriftExecutable>, etc:

    <plugin>
        <groupId>org.apache.thrift.tools</groupId>
        <artifactId>maven-thrift-plugin</artifactId>
        <version>0.1.10</version>
        <configuration>
            <thriftExecutable>/usr/local/bin/thrift</thriftExecutable>
            <thriftSourceRoot>${basedir}/src/main/my_custom_thrift_root</thriftSourceRoot>
        </configuration>
        <executions>
        ...
    </plugin>