Home Help Center

Maven slice2java plugin

pkbhavanipkbhavani Member Praveen BhavaniOrganization: Saracen EnergyProject: Global Energy Trading
anybody have maven2 plugin written for slice2java

-Praveen

Comments

  • urbanqurbanq Member Mathew UrbanOrganization: University of Science & Technology CracowProject: Ice Sale service - using ice technology as server
    Maven slice2java plugin

    1. I've downloaded ice jars from zeroc.com :
    we need only: ant-ice-3.4.2.jar, Ice-3.4.2.jar.

    2. Add jars to my local maven repository:
    mvn install:install-file -Dfile=ant-ice-3.4.2.jar -DgroupId=com.zeroc -DartifactId=ant-ice -Dversion=3.4.2 -Dpackaging=jar
    mvn install:install-file -Dfile=Ice-3.4.2.jar -DgroupId=com.zeroc -DartifactId=ice -Dversion=3.4.2 -Dpackaging=jar -Dsources=Ice-3.4.2.jar
    

    3. Create pom.xml using ant-run plugin to run slice2java:
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <groupId>my.project.groupId</groupId>
      <artifactId>my.project.artifactId</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      <name>my.project.name</name>
    
      <properties>
        <ice.include.path>/usr/share/Ice-3.4.2/slice/Ice</ice.include.path>
      </properties>
    
      <dependencies>
        <dependency>
          <groupId>com.zeroc</groupId>
          <artifactId>ice</artifactId>
          <version>3.4.2</version>
        </dependency>
      </dependencies>
    
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.7</version>
            <executions>
              <execution>
                <phase>generate-sources</phase>
                <configuration>
                  <target name="slice2java">
                    <taskdef name="slice2java" classname="Slice2JavaTask" classpathref="maven.plugin.classpath" />
                    <slice2java outputdir="src/generated/java">
                      <fileset dir="src/main/resources" includes="fileSystem.ice sale.ice" />
                      <includepath>
                        <pathelement path="${ice.include.path}" />
                      </includepath>
                    </slice2java>
                  </target>
                </configuration>
                <goals>
                  <goal>run</goal>
                </goals>
              </execution>
            </executions>
            <dependencies>
              <dependency>
                <groupId>com.zeroc</groupId>
                <artifactId>ant-ice</artifactId>
                <version>3.4.2</version>
              </dependency>
            </dependencies>
          </plugin>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <version>1.7</version>
            <executions>
              <execution>
                <id>add-source</id>
                <phase>generate-sources</phase>
                <goals>
                  <goal>add-source</goal>
                </goals>
                <configuration>
                  <sources>
                    <source>src/generated/java</source>
                  </sources>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </project>
    

    * I added "ice.include.path" property because I'm using #include <BuiltinSequences.ice> in my *.ice definitions
    ** build-helper-maven-plugin add generated sources to compile process

    Hope it will help you!
Sign In or Register to comment.