I followed The Java Archive Tool but couldn't find how to exclude folders.
For example, I have the files under working copy directory:
workingcopy
--src
--.svn
-- com
--.svn
--WebContent
I would like to compile and create jar only from the classes under src
excluding all folders starting with .svn directory. I want to run it from cmd
like jar -cf test.jar
etc..
How can I do it?
This can be done with a command:
jar cf test.jar `find . -not -path "*/.svn/*" -not -type d`
The problem with jar
is that if directory is passed it will be added recursively with all content. So our goal is to pass only files and only those of them which doesn't have '.svn' substring in the path. For this purpose find
command is used with 2 conditions:
-not -path "*/.svn*"
filters out all svn files-not -type d
filters out all directoriesThis will exclude empty directories from the jar though.
This could be a practical workaround for your problem: it will not exclude the subversion directory (directories) but include only class files (assuming, you don't put class files under version control):
jar -cf test.jar *.class
Further enhancement: separate code from class files. You don't want to check in class files (build artefacts) anyway:
workingcopy
--src
--.svn
-- com // only *.java files in here and below
--.svn
--WebContent
--bin
--com // only *.class files in here and below
There is a concept called Export in SVN. if you use that you will get the structure without the .svn repository. It is slightly different from the Check-Out.
After this you must be able to do a regular jar command from that directory instead of the repository folder.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With