This plugin allows you to utilize all the new language features of Java while targeting an older version's bytecode.
To integrate into your project:
- Install the plugin locally
- Add the plugin to your project
- Update the scope of any dependency that is future-versioned to
<scope>provided</scope>
- Update the scope of any dependency that is future-versioned to
- Run
compile
on your project to generate the modified classes in the%PROJECT%/target/classes
directory - Run any phase you like, such as
test
(They should now see the modified classes)
git clone https://github.com/Col-E/Class-Version-Patcher.git
cd Maven-Class-Patcher
mvn install
<build>
<plugins>
<plugin>
<groupId>software.coley</groupId>
<artifactId>class-version-patcher-maven</artifactId>
<version>2.1.0</version>
<configuration>
<!-- Target Java 8, can swap for other version such as 11 -->
<targetVersion>8</targetVersion>
<artifacts>
<!-- The parameters are the group + artifact identifiers of any dependency separated by a colon ":"
You can include any number of values here.
-->
<param>group_id:artifact_id</param>
<param>org.jgroups:jgroups</param>
</artifacts>
</configuration>
<!-- Required to run -->
<executions>
<execution>
<goals>
<goal>patch-compiled</goal>
<goal>patch-dependencies</goal>
<goal>patch-postprocess</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
NOTE: The gradle plugin is not yet developed, however you can add the
core
module of this project as a dependency to your buildscript. From there, you can invokesoftware.coley.versionpatcher.VersionPatcher
as you see fit.
Please open an issue with an example of how to replicate your problem.
For example:
- Providing a class file
- Listing a maven dependency
- Listing an open source project