Parsing jars

what is the best way to parse a jar for a version? say Chisel2- and i wanted the 2.3.5 and have it dynamically available to the script. and when the version changes i don’t want to have to change a file manually.

Where did the jar come from?

If you’re only doing it for this one jar and know that it’s always going to be “Chisel2-..jar”, you could use split or a regex to pull it apart. There are lots of Groovy/Java resources for that.

They are minecraft mods. tho the jars aren’t the same for each mod. some are -1.7.10-.<.revision>.jar others are ---.jar I want to use them in zip names like <

What do you want to do with the jars? Just package them into a zip?

task makeZip(type: Zip) {
   include "**/*.jar"

I want to be able to use the names of the jars as a dynamic value for the zips name

OK, I would take a look at Groovy’s regex and matching groups in particular:

Another way would be to check the Jar’s manifest file for a version number. Get a manifest from opening the jar file with this: Jars aren’t required to have a version attribute in them, so that may not work all the time.

Sterling Thank you for your help. will test it now.