Skip to content

Latest commit

 

History

History
 
 

swift-maven-plugin

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Swift Maven Plugin

Generate Swift compatible java code from thrift IDL files.

Usage

Add the plugin to the build plugins section of the pom.

<build>
  <plugins>
    <plugin>
      <groupId>com.facebook.mojo</groupId>
      <artifactId>swift-maven-plugin</artifactId>
      <version>0.2-SNAPSHOT</version>
      <executions>
        <execution>
          <goals>
            <goal>generate</goal>
          </goals>
        </execution>
      </executions>
      <configuration>
       ...
      </configuration>
    </plugin>
  </plugins>
</build>

Additional help can be displayed with mvn com.facebook.mojo:swift-maven-plugin:help.

Supported configuration parameters

skip

Skip the plugin completely. Can be used to turn plugin execution on or off.

skip is optional, default is "false".

<skip>true|false</skip>

overridePackage

Sets the package name for the generated classes. If this value is set, any package name provided by the IDL files or default package name is ignored and all classes will be in this package.

This is almost always the wrong value to use. Prefer using the package defined in the Thrift IDL files or set a default package name.

overridePackage is optional. If not set, the plugin uses the package names from the IDL files or a default package name.

<overridePackage>... valid java package name ...</overridePackage>

defaultPackage

Defines a Java package name if a Thrift IDL file does not contain a package name. This is used only as fallback.

defaultPackage is optional. Trying to generate Java code from a Thrift IDL file without java namespace definition will fail with an error if no default package is set.

<defaultPackage>... valid java package name ...</defaultPackage>

idlFiles

Defines a fileset to include for IDL parsing and code generation.

idFiles must be defined in the POM, otherwise the plugin will report an error.

Usage:

<idlFiles>
  <directory>... base directory ...</directory>
  <includes>
    <include>... include pattern ...</include>
  </includes>
  <excludes>
    <exclude>... exclude pattern ...</exclude>
  </excludes>
</idlFiles>

directory, includes and excludes are used to select the IDL files to process:

  • directory: Base directory, defines where the IDL files are to be found. There is no default.
  • includes: A set of files patterns which specify the files to include.
  • excludes: The same structure as includes, but specifies which files to ignore. In conflicts between include and exclude, exclude wins.

Wildcards support '*' for all files in a given directory and '**/*' for all files in a given subtree.

outputFolder

Determines the output folder for the generated sources. This folder is added to the sources for the project so any generated class is in turn picked up by the compiler plugin.

outputFolder is optional with a default of ${project.build.directory}/generated-sources/swift.

generateIncludedCode

If set to true, generate Java code for all referenced Thrift IDL files. If false, only generate code for IDL files listed in idlFiles.

generateIncludedCode is optional, default value is "false".

<generateIncludedCode>true</generateIncludedCode>

codeFlavor

Selects the type of code generated by the plugin. Currently, only two flavors are supported: java-regular and java-immutable.

codeFlavor is optional, default value is "java-regular".

<codeFlavor>java-immutable</codeFlavor>

addThriftExceptions

If set to true, adds org.apache.thrift.TException to each generated method signature (this is the default).

addThriftExceptions is optional, default value is "true".

<addThriftExceptions>false</addThriftExceptions>

addCloseableInterface

If set to true, add the java.io.Closeable interface as a parent to all created service classes and also add a void close() method.

addCloseableInterface is optional, default value is "false".

extendRuntimeException

If set to true, all created exceptions will inherit from java.lang.RuntimeException and therefore be unchecked exceptions. If false, all created exceptions are checked exceptions and inherit from java.lang.Exception.

extendRuntimeException is optional, default value is "true".

Maven lifecycle

The generate goal of the plugin is by default hooked into the generate-sources phase of the maven lifecycle.