kgs
kgs

Reputation: 1884

How to exclude certain files while creating war file using jar command?

I am using command jar cvf MyWarFile.war <list all files and dir to be part of war file with space in between> to create a war file in linux. I don't want to specify each and every file/dir in the command rather I just want to use * (to create war file out of files in current dir) . What should I do to exclude certain file/dir while trying add all the files (using *) in the directory to the war file that i am creating.

I am looking for something like

jar cvf MyWarFile.war * <how to exclude certain file/dir>

Upvotes: 1

Views: 3346

Answers (1)

Fahad Siddiqui
Fahad Siddiqui

Reputation: 1849

You can use wildcard ! and parenthesis to create your war file. Anything written inside parenthesis will be excluded

jar cvf MyWarFile.war !(file1)

If you want to exclude multiple files from jar file/folder selection you can use |.

jar cvf MyWarFile.war !(file1|folder1)

Upvotes: 1

Related Questions