Permalink
Browse files

Merge branch 'add-language-option-tag' of https://github.com/eirslett…

…/scrooge

Conflicts:
	demos/scrooge-maven-demo/pom.xml
  • Loading branch information...
2 parents 284bf0a + fdf784f commit e1e883c43b59ffc5e87740c89abdb9a8815a2244 @chunyan committed Apr 15, 2013
@@ -152,6 +152,7 @@
<to>com.twitter.mydemo.renamed</to>
</thriftNamespaceMapping>
</thriftNamespaceMappings>
+ <language>scala</language> <!-- default is scala, can also be java -->
<thriftOpts>
<!-- add other Scrooge command line options using thriftOpts -->
<thriftOpt>--finagle</thriftOpt>
@@ -63,6 +63,17 @@
private Set<File> thriftIncludes = new HashSet<File>();
/**
+ * Which language the generated files should be ("java" or "scala")
+ * @parameter default-value="scala"
+ * {@code
+ * <configuration>
+ * <language>java</language>
+ * </configuration>
+ * }
+ */
+ private String language;
+
+ /**
* Command line options to pass to scrooge, e.g.
* {@code
* <thriftOpts>
@@ -177,6 +188,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
thriftFiles,
includes,
thriftNamespaceMap,
+ language,
thriftOpts);
}
attachFiles(compileRoots);
@@ -20,7 +20,8 @@ import org.apache.maven.plugin.logging.Log
import java.io.File
import java.util.{Map, Set}
import scala.collection.JavaConverters._
-import scrooge.{Main, Compiler}
+import scrooge.{Language, Main, Compiler}
+import org.apache.maven.plugin.MojoExecutionException
class ScroogeRunner {
@@ -30,6 +31,7 @@ class ScroogeRunner {
thriftFiles: Set[File],
thriftIncludes: Set[File],
namespaceMappings: Map[String, String],
+ language: String,
flags: Set[String]
) {
@@ -39,6 +41,11 @@ class ScroogeRunner {
thriftIncludes.asScala.map { compiler.includePaths += _.getPath }
namespaceMappings.asScala.map { e => compiler.namespaceMappings.put(e._1, e._2)}
Main.parseOptions(compiler, flags.asScala.toSeq ++ thriftFiles.asScala.map { _.getPath })
+ compiler.language = language.toLowerCase match {
+ case "java" => Language.Java
+ case "scala" => Language.Scala
+ case _ => throw new MojoExecutionException("Unknown language option \""+language+"\"")
+ }
compiler.run()
}
}

0 comments on commit e1e883c

Please sign in to comment.