using retrotranslator with maven-antrun-plugin


respicitur

veni, vidi, non vici

I failed to using Retrotranslator Maven Plugin for back-porting my Java 7 compiled classes to previous JDK(1.3) compliant classes. It has been stayed at 1.0-alpha-4 for a long time. I don’t think it’s dead but it’s so obvious that Codehaus guys or project members are busy.

velle est posse

Here is how I succeeded using description about Ant task at here.
There are two things we have to prepare inside the Maven project.

  • Old JDK Libraries
  • Retrotranslator Binary Files
/pom.xml
/src/
/retrotranslator/Retrotranslator-1.2.9-bin/
/jdk/1.3.1_28/jre/lib

Now we can retrotranslate like this.

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-antrun-plugin</artifactId>
  <executions>
    <execution>
      <id>retrotranslate</id>
      <phase>process-classes</phase>
      <goals>
        <goal>run</goal>
      </goals>
      <configuration>
        <target>
          <taskdef name="retrotranslator"
                   classname="net.sf.retrotranslator.transformer.RetrotranslatorTask"
                   classpathref="maven.plugin.classpath"/>
          <retrotranslator srcdir="${project.build.outputDirectory}"
                           destdir="${project.build.outputDirectory}"
                           target="1.3" smart="true" stripannot="true"
                           stripsign="true" verify="true" failonwarning="true"
                           embed="some.renamed.retrotranslator">
            <classpath>
              <fileset dir="${basedir}/jdk/1.3.1_28/jre/lib" includes="**/*.jar"/>
              <fileset dir="${basedir}/retrotranslator/Retrotranslator-1.2.9-bin">
                <include name="retrotranslator-runtime13-1.2.9.jar" />
                <include name="backport-util-concurrent-java12-3.1.jar" />
              </fileset>
            </classpath>
          </retrotranslator>
        </target>
      </configuration>
    </execution>
  </executions>
  <dependencies>
    <dependency>
      <groupId>net.sf.retrotranslator</groupId>
      <artifactId>retrotranslator-transformer</artifactId>
      <version>1.2.9</version>
    </dependency>
  </dependencies>
</plugin>

ex scientia vera

I wrote a simple project for testing retrotranslator.

$ svn co http://jinahya.googlecode.com/svn/trunk/\
com.googlecode.jinahya.test/retrotranslator-antrun-test
$ cd retrotranslator-antrun-test
$ mvn -Ptarget13 clean test;mvn -Ptarget14 clean test
<retrotranslator srcdir="${project.build.outputDirectory}"
                 destdir="${project.build.outputDirectory}"
                 target="1.3"
                 smart="true" stripannot="true" stripsign="true" verify="true"
                 failonwarning="true">
 <classpath>
   <fileset dir="${basedir}/lib/j2sdk1.3.1_28/jre/lib">
     <include name="rt.jar"/>
   </fileset>
   <fileset dir="${basedir}/lib/Retrotranslator-1.2.9-bin">
     <include name="retrotranslator-runtime13-1.2.9.jar"/>
     <include name="backport-util-concurrent-java12-3.1.jar"/>
   </fileset>
 </classpath>
</retrotranslator>
<retrotranslator srcdir="${project.build.outputDirectory}"
                 destdir="${project.build.outputDirectory}"
                 target="1.4"
                 smart="true" stripannot="true" stripsign="true" verify="true"
                 failonwarning="true">
  <classpath>
    <fileset dir="${basedir}/lib/j2sdk1.4.2_19/jre/lib">
      <include name="rt.jar"/>
      <include name="jce.jar"/>
      <include name="jsse.jar"/>
    </fileset>
    <fileset dir="${basedir}/lib/Retrotranslator-1.2.9-bin">
      <include name="retrotranslator-runtime-1.2.9.jar"/>
      <include name="backport-util-concurrent-3.1.jar"/>
    </fileset>
  </classpath>
</retrotranslator>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s