Dev/maven/plugin/styx

From CubeiaWiki

Jump to: navigation, search

Protocol Generator Plugin

The protocol generator plugin is used for generating source code from a protocol.xml file, as specified by the StyxProtocol?. The plugin currently takes the following parameters:

protocol_file
The name of the protocol file.
language
The language to generate, available values are: 'java', 'c' and 'flash'.
package_name
The package to put the generated files in
output_dir (DEPRECATED since 1.7-SNAPSHOT)
Where to put the generated code. This will be deprecated in future versions.
output_base_dir
Base directory for the generated code. Default is target/jruby-protocol-plugin/generated-sources. The generated source will be generated to <output_base_dir>/<language>/<langugage specific package structure>.
generate_visitors
Should be set to true. This will be deprecated in future versions.
fail_on_bad_packet_order
defaults to false, if true fail the build if the XML protocol specification declares packets out of order that will generate compile errors in C++

Example usage (pom snippet):

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.5</source>
          <target>1.5</target>
        </configuration>
      </plugin>
      
      <plugin>
        <groupId>com.cubeia</groupId>
        <artifactId>protocol-generator-plugin</artifactId>
        <version>1.7-SNAPSHOT</version>
        <configuration>
          <protocol_file>src/main/resources/firebase-protocol.xml</protocol_file>
          <language>java</language>
          <package_name>com.cubeia.firebase.io.protocol</package_name>
          <generate_visitors>true</generate_visitors>
          <fail_on_bad_packet_order>true</fail_on_bad_packet_order>
        </configuration>
        <executions>
          <execution>
            <phase>generate-sources</phase>
            <goals>
              <goal>generate</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
 
  <pluginRepositories>
    <pluginRepository>
      <id>cubeia-plugin-repo</id>
      <url>https://secure.cubeia.com/repo/maventest</url>
      <releases>
        <enabled>true</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </pluginRepository>
  </pluginRepositories> 

  <dependencies>
    <dependency>
      <groupId>com.cubeia.firebase</groupId>
      <artifactId>styx</artifactId>
      <version>1.5</version>
    </dependency>
  </dependencies>
  ...
</project>

Note that the pluginRepository is needed! Also, the Styx dependency is essential.

Personal tools