Monkey patch uncompilable lib w/ Maven?

I use Maven as a main project/build tool and it works well from the command line. I want IntelliJ to be able to build a project.

I depend on a library Foo-1.0, which requires JDK 1.7 for compilation. I use JDK 1.8 locally and I can not compile it (I know it sounds crazy, but such is life). I want to Monkey patch a class a two there. I can change my Maven project, just to make IntelliJ happy and I can not seem to find a way.

Here is how it works from the command line:

During generate-resources in Foo-Patched module I download pre-compiled class files Foo-1.0.jar and unpack to target/classes directory. I declare Foo-1.0 as a provided dependency and compile my monkey patched classes from the source and overwrite class files of the original library. Then when I pack a jar I get the result I want. To make a source jar I separately download source jar for Foo-1.0 and overwrite it with my monkey patched classes.

Result? IntelliJ can not compile files that depend on Foo-1.0 in my project as it does not have source files for Foo-1.0 added. If I try to add Foo-1.0 source files as a generated-sources, then IntelliJ tries to compile them and fails cause of wrong JDK I have locally.

It looks like the thing I want is to use classes "compiled" from Maven from IntelliJ without having source code for these classes added. Not sure how to do that within one project with several modules.

 

0

Please sign in to leave a comment.