retrolambda
retrolambda copied to clipboard
maven shade intergration
Is it possible to integrate with shade maven plugin ?
like transformer class?
I'm using Retrolambda and Shade plugins together in https://github.com/orfjackal/jumi without any problems. First the Retrolambda plugin backports the bytecode and then the Shade plugin does its thing.
Why would you want to integrate them?
The Shade plugin's transformer API is probably too limited for Retrolambda.
I use shade plugin to make a jar with all-reasonably-required-dependencies. Some of them are java8. After checking with javap packed class files - those classes belong to actual project are converted to java7 (target bytecode level) while some dependencies are in java8.
Maybe I configured it in a wrong way - i tried to do in the same way as you did in https://github.com/orfjackal/jumi/blob/master/parent/pom.xml - could you please provide more concrete example ?
<plugin>
<groupId>net.orfjackal.retrolambda</groupId>
<artifactId>retrolambda-maven-plugin</artifactId>
<version>2.0.2</version>
<executions>
<execution>
<goals>
<goal>process-main</goal>
<goal>process-test</goal>
</goals>
</execution>
</executions>
<configuration>
<target>1.7</target>
<java8home>${env.JAVA_HOME8}</java8home>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>...</include>
</includes>
</artifactSet>
</configuration>
</execution>
</executions>
</plugin>
OK. The Retrolambda plugin doesn't backport the dependencies. As a workaround you should backport each Java 8 dependency individually and publish it as a Java 7 compatible jar file.
The actual workaround is run custom shell script that runs java -jar retrolambda.jar - I suppose it would be better to backport dependencies in plugin too.
This might be solvable by implementing issue #44, after which Retrolambda could be used to process the JAR file which the Shade plugin generates.
However, it would be best to do the backporting inside the dependency project, so that all of the project's tests would be run against the backported classes. Otherwise there is some possibility that the project uses features which Retrolambda doesn't backport.