Thrift
  1. Thrift
  2. THRIFT-1069

Add command line option to prevent thrift from inserting gen-* directories

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.5
    • Fix Version/s: 0.7
    • Component/s: Compiler (General)
    • Labels:
      None
    • Environment:

      OSX

    • Patch Info:
      Patch Available

      Description

      I maintain a plug-in to execute thrift under maven:

      https://github.com/dtrott/maven-thrift-plugin

      The gen-* directories do not add any value for me (I have to add additional code to move the files back up one level after generation - for IDE integration).

      Would it be possible to add an additional command line option to either:

      • Suppress the insertion of the gen- directory
      • or, Allow me to specify the full path to the output directory (without the gen- postfix)

        Activity

        Hide
        JCF added a comment -

        Nice plugin. The maven build helper and the eclipse plugins will take care of what you are looking for. I've been using an ant task to accomplish what your plugin does. Here is a the section from the pom which should help you not have to copy files around and provides eclipse integration

        <!-- Run an ant task to generate the thrift source -->
        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.6</version>
        <executions>
        <execution>
        <id>thrift-gen</id>
        <phase>generate-sources</phase>
        <goals>
        <goal>run</goal>
        </goals>
        <configuration>
        <tasks>
        <property name="target.dir" value="$

        {project.build.directory}/generated-sources"/>
        <mkdir dir="${target.dir}"/>
        <exec executable="/usr/bin/thrift">
        <arg line="-o ${target.dir} --gen java interface/${project.artifactId}.thrift"/>
        </exec>
        </tasks>
        </configuration>
        </execution>
        </executions>
        </plugin>
        <!-- Include the thrift generated sources in the build -->
        <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>1.5</version>
        <executions>
        <execution>
        <id>add-source</id>
        <phase>generate-sources</phase>
        <goals>
        <goal>add-source</goal>
        </goals>
        <configuration>
        <sources>
        <source>${project.build.directory}

        /generated-sources/gen-java</source>
        </sources>
        </configuration>
        </execution>
        </executions>
        </plugin>
        <!-- Add generated sources to eclipse build sources list -->
        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-eclipse-plugin</artifactId>
        <version>2.8</version>
        <configuration>
        <sourceIncludes>
        <sourceInclude>$

        {project.build.directory}

        /generated-sources/gen-java/*/.java</sourceInclude>
        </sourceIncludes>
        </configuration>
        </plugin>

        Show
        JCF added a comment - Nice plugin. The maven build helper and the eclipse plugins will take care of what you are looking for. I've been using an ant task to accomplish what your plugin does. Here is a the section from the pom which should help you not have to copy files around and provides eclipse integration <!-- Run an ant task to generate the thrift source --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <version>1.6</version> <executions> <execution> <id>thrift-gen</id> <phase>generate-sources</phase> <goals> <goal>run</goal> </goals> <configuration> <tasks> <property name="target.dir" value="$ {project.build.directory}/generated-sources"/> <mkdir dir="${target.dir}"/> <exec executable="/usr/bin/thrift"> <arg line="-o ${target.dir} --gen java interface/${project.artifactId}.thrift"/> </exec> </tasks> </configuration> </execution> </executions> </plugin> <!-- Include the thrift generated sources in the build --> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <version>1.5</version> <executions> <execution> <id>add-source</id> <phase>generate-sources</phase> <goals> <goal>add-source</goal> </goals> <configuration> <sources> <source>${project.build.directory} /generated-sources/gen-java</source> </sources> </configuration> </execution> </executions> </plugin> <!-- Add generated sources to eclipse build sources list --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-eclipse-plugin</artifactId> <version>2.8</version> <configuration> <sourceIncludes> <sourceInclude>$ {project.build.directory} /generated-sources/gen-java/* / .java</sourceInclude> </sourceIncludes> </configuration> </plugin>
        Hide
        Bryan Duxbury added a comment -

        I'd love to see a patch for this effect.

        Show
        Bryan Duxbury added a comment - I'd love to see a patch for this effect.
        Hide
        JCF added a comment -

        Adds a out option which will set the specified directory as an absolute path for generated files without creating the gen* folder

        Options:
        o dir Set the output directory for gen* packages
        (default: current directory)
        -out dir Set the ouput location for generated files.
        (no gen-* folder will be created)

        Example:
        [jfarrell]$ mkdir src src_orig
        [jfarrell]$ thrift -o src_orig --gen java scribe.thrift
        [jfarrell]$ tree src_orig/
        src_orig/
        `-- gen-java
        `-- scribe
        `-- thrift

        – LogEntry.java
        – ResultCode.java
        `-- scribe.java

        [jfarrell]$ thrift -out src --gen java scribe.thrift
        [jfarrell]$ tree src/
        src/
        `-- scribe
        `-- thrift

        – LogEntry.java
        – ResultCode.java
        `-- scribe.java
        Show
        JCF added a comment - Adds a out option which will set the specified directory as an absolute path for generated files without creating the gen * folder Options: o dir Set the output directory for gen * packages (default: current directory) -out dir Set the ouput location for generated files. (no gen-* folder will be created) Example: [jfarrell] $ mkdir src src_orig [jfarrell] $ thrift -o src_orig --gen java scribe.thrift [jfarrell] $ tree src_orig/ src_orig/ `-- gen-java `-- scribe `-- thrift – LogEntry.java – ResultCode.java `-- scribe.java [jfarrell] $ thrift -out src --gen java scribe.thrift [jfarrell] $ tree src/ src/ `-- scribe `-- thrift – LogEntry.java – ResultCode.java `-- scribe.java
        Hide
        Bryan Duxbury added a comment -

        I just committed this patch. Thanks for the contribution, Jake!

        Show
        Bryan Duxbury added a comment - I just committed this patch. Thanks for the contribution, Jake!
        Hide
        David Trott added a comment -

        Thanks Guys,

        I have updated the plug-in to use the new -out parameter (works great).

        The code is committed, but I will wait for your next release before doing the plug-in release.

        Show
        David Trott added a comment - Thanks Guys, I have updated the plug-in to use the new -out parameter (works great). The code is committed, but I will wait for your next release before doing the plug-in release.

          People

          • Assignee:
            JCF
            Reporter:
            David Trott
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development