Skip to content
This repository
  • 4 commits
  • 3 files changed
  • 0 comments
  • 2 contributors
1  demos/scrooge-maven-demo/pom.xml
@@ -152,6 +152,7 @@
152 152
               <to>com.twitter.mydemo.renamed</to>
153 153
             </thriftNamespaceMapping>
154 154
           </thriftNamespaceMappings>
  155
+          <language>scala</language> <!-- default is scala, can also be java -->
155 156
           <thriftOpts>
156 157
             <!-- add other Scrooge command line options using thriftOpts -->
157 158
             <thriftOpt>--finagle</thriftOpt>
12  scrooge-maven-plugin/src/main/java/com/twitter/AbstractMavenScroogeMojo.java
@@ -63,6 +63,17 @@
63 63
   private Set<File> thriftIncludes = new HashSet<File>();
64 64
 
65 65
   /**
  66
+  * Which language the generated files should be ("java" or "scala")
  67
+  * @parameter default-value="scala"
  68
+   * {@code
  69
+   * <configuration>
  70
+   *     <language>java</language>
  71
+   * </configuration>
  72
+   * }
  73
+  */
  74
+  private String language;
  75
+
  76
+  /**
66 77
    * Command line options to pass to scrooge, e.g.
67 78
    * {@code
68 79
    * <thriftOpts>
@@ -177,6 +188,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
177 188
                   thriftFiles,
178 189
                   includes,
179 190
                   thriftNamespaceMap,
  191
+                  language,
180 192
                   thriftOpts);
181 193
         }
182 194
         attachFiles(compileRoots);
9  scrooge-maven-plugin/src/main/scala/com/twitter/ScroogeRunner.scala
@@ -20,7 +20,8 @@ import org.apache.maven.plugin.logging.Log
20 20
 import java.io.File
21 21
 import java.util.{Map, Set}
22 22
 import scala.collection.JavaConverters._
23  
-import scrooge.{Main, Compiler}
  23
+import scrooge.{Language, Main, Compiler}
  24
+import org.apache.maven.plugin.MojoExecutionException
24 25
 
25 26
 class ScroogeRunner {
26 27
 
@@ -30,6 +31,7 @@ class ScroogeRunner {
30 31
     thriftFiles: Set[File],
31 32
     thriftIncludes: Set[File],
32 33
     namespaceMappings: Map[String, String],
  34
+    language: String,
33 35
     flags: Set[String]
34 36
   ) {
35 37
 
@@ -39,6 +41,11 @@ class ScroogeRunner {
39 41
     thriftIncludes.asScala.map { compiler.includePaths += _.getPath }
40 42
     namespaceMappings.asScala.map { e => compiler.namespaceMappings.put(e._1, e._2)}
41 43
     Main.parseOptions(compiler, flags.asScala.toSeq ++ thriftFiles.asScala.map { _.getPath })
  44
+    compiler.language = language.toLowerCase match {
  45
+      case "java" => Language.Java
  46
+      case "scala" => Language.Scala
  47
+      case _ => throw new MojoExecutionException("Unknown language option \""+language+"\"")
  48
+    }
42 49
     compiler.run()
43 50
   }
44 51
 }

No commit comments for this range

Something went wrong with that request. Please try again.