Class-Version-Patcher
Class-Version-Patcher copied to clipboard
For when you are stuck in Java 8 but want to use new language features and dependencies
Class Version Patcher
This plugin allows you to utilize all the new language features of Java while targeting an older version's bytecode.
Usage - Maven
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
compileon your project to generate the modified classes in the%PROJECT%/target/classesdirectory - Run any phase you like, such as
test(They should now see the modified classes)
Installing the plugin locally
git clone https://github.com/Col-E/Class-Version-Patcher.git
cd Maven-Class-Patcher
mvn install
Using the plugin in your pom.xml
<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>
Usage - Gradle
NOTE: The gradle plugin is not yet developed, however you can add the
coremodule of this project as a dependency to your buildscript. From there, you can invokesoftware.coley.versionpatcher.VersionPatcheras you see fit.
This doesn't properly downgrade Java X's "xyz-feature" to Java Y's version!
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