Maven Plugin¶
In addition to SBT, Scrooge is also capable of integrating with Apache Maven.
Code Dependency Additions¶
To add Scrooge to an existing Maven project, add the following dependencies to the project’s ‘pom.xml’ file:
Apache Thrift
Scrooge Core
Finagle Thrift (Required if using Finagle)
<dependency>
<groupId>org.apache.thrift</groupId>
<artifactId>libthrift</artifactId>
<version>0.10.0</version>
</dependency>
<dependency>
<groupId>com.twitter</groupId>
<artifactId>scrooge-core_2.12</artifactId>
<version>24.2.0</version>
</dependency>
<dependency>
<groupId>com.twitter</groupId>
<artifactId>finagle-thrift_2.12</artifactId>
<version>24.2.0</version>
</dependency>
Plugin Addition¶
Then add the ‘scrooge-maven-plugin’ itself to the ‘build/plugins’ section of the project’s ‘pom.xml’ file.
<plugin>
<groupId>com.twitter</groupId>
<artifactId>scrooge-maven-plugin</artifactId>
<version>24.2.0</version>
<configuration>
<thriftNamespaceMappings>
<thriftNamespaceMapping>
<from>com.twitter.demo.thriftscala</from>
<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>
</thriftOpts>
</configuration>
<executions>
<execution>
<id>thrift-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>thrift-test-sources</id>
<phase>generate-test-sources</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
Scrooge Maven Plugin Configuration Options¶
In the ‘build/plugin’ section, the behavior of the ‘scrooge-maven-plugin’ can be modified by adding additional Scrooge command line options to the ‘thriftOpts’ section, as indicated above by ‘–finagle’. For reference, a working example is provided in scrooge-maven-demo.