Sunday, March 27, 2011

Clearing WAR , EAR JAR files for .svn folders and library jars

Big archieve sizes can be annoying. There can be some useless files within a war or jar file.

1. If you uploaded your library files to application server than you do not need to pack them everytime you create application archieve file.

2. There can be subversion folders which do not have a function in runtime.

I wrote a basic windows batch file. it uses 7-zip.


cd %TEMP%
rem "C:\Program Files\7-Zip\7z.exe" d %1 *.jar -r -tzip
"C:\Program Files\7-Zip\7z.exe" d %1 .svn -r -tzip
rem "C:\Program Files\7-Zip\7z.exe" d %1 WEB-INF\lib -tzip

paste this code to file.

first line is the for the temp files.

if you want to clear all jar files within your archieve , and you know what you are doing , delete rem part of line 2 , otherwise you can delete delete line 2.

3rd line deletes all .svn folders within your archieve file. if you donot want to do this , delete line 3.

if you want to delete web-inf/lib , delete rem part of 4th line. (warning be sure you uploaded all necessary jar files to your application server's lib folder) , otherwise you can delete delete line 4!!!

on windows , right-click to your arcive file -> open with -> choose default program -> (you can uncheck "always use the selected..." checkbox if you donot wanto to change your default program) -> browse.

once you open your archieve file with this script , windows adds it to open-with menu with the right-click.

use with caution and test before deploying to production.

No comments: