COMMUNITY

[JVM] How to add custom resources into output jar

Is there a compiler flag for adding static resources into the output jar?

In other words, I want to add a custom entry such as META-INF/my_file.txt to the list returned by the command: jar tf bin/Main.jar

(for those who need a workaround: jar is just a zip file so it is possible to add files to it manually via zip/unzip)

Okay, --resource META-INF/my_file.txt almost did it. Except it becomes META-x45INF/my_file.txt in the jar. Apparently that’s because the dash is being escaped:

Is there a reason why the dash has to be escaped?

I guess it’s because dash is used to detect escaped sequences (-xNN)

Can we have something like --jar-resources resources which will copy everything under the resources folder into the jar without name mangling?

Okay, I made a maven plugin which makes maven call the haxe compiler to produce the required bytecodes. (Normally maven calls the java compiler)

In that case I am able to make use of the entire maven build tool, including resource bundling mentioned in the OP. So I would say the problem is solved for now.

2 Likes