Exclude directory inside jar file?

Hello,

I have the following situation:

I've got some java source files, and one of the files is called, say, Foo.java. I've also added a few jar files using "jar or directories" in the project structure (it was created as a jar directory in IJ 10, but the project is now in IJ 11.1).

Inside one of these jars, there happens to be Foo.class, which is the same one as the one from Foo.java. However, this jar contains much more than only Foo.class, it also contains classes for which I don't have .java sources, so I really need to depend on this jar.

When debugging, and I put a breakpoint somewhere in Foo.java, then the breakpoint indeed breaks. However as soon as I press e.g. F8 (continue to next line), the Foo.java file gets replaces by the Foo.class file, and all it shows is the function name and the debugging position is marked on it. This is useless. I just was in the .java file, when stepping to next line why does IntelliJ prefer to continue in this useless Foo.class file instead of the Foo.java file that it knows it exists because it just broke at the breakpoint there?

Using "Attach sources" in this Foo.class and marking Foo.java as it, also fails (somehow after I did this, IntelliJ didn't find a single import in my whole project anymore, everything was marked as error).

Manually opening the jar file with a zip tool and deleting the files related to classes of which I have java files, actually fixes this!!! But that's a bit annoying to have to modify the jar file that way.

Is it possible somehow to let IntelliJ know, if there's both a .java and a .class version of the same class, that you give preference to the .java version and it may ignore the one in the jar?

Is it possible to do the same as you do with "Exclude directories" in the project settings, but with the directories inside of a jar instead?

Or some other way to fix the problem which is more convenient than the manually deleting it from the jar file?

Thanks!

0

Please sign in to leave a comment.