maven的war plugin插件里有兩個參數(shù)warSourceExcludes和packagingExcludes寞射,從clean package后的效果來說扫夜,他們都能起到打war包時不包含指定文件夾或者指定文件的作用。
但是他們實現(xiàn)的方式不一樣衫嵌。按照plugin中對這兩個參數(shù)的說明:
warSourceExcludes: The comma separated list of tokens to exclude when copying the content of the warSourceDirectory.
packagingExcludes: The comma separated list of tokens to exclude from the WAR before packaging.
With packagingExcludes, the tokens are completely excluded from the final war file. With warSourceExcludes, the tokens are just ignored when copying the war directory into the war file. As a result, if the tokens are present in the webappDirectory for example, they will not be ignored when using warSourceExcludes but will be when usingpackagingExcludes.
warSourceExcludes是在拷貝文件到war文件夾時忽略掉指定文件或者文件夾(但是如果war命令前沒有clean指令浸锨,而war文件夾下已經(jīng)包含了指定文件或者文件夾時百侧,最后生成的war包里還是會包含這些文件或文件夾,哪怕沒有拷貝它們到war文件夾).
packagingExcludes是在生成war包時不包含指定文件或文件夾到war文件中谴供,不論它們是否存在于war文件夾下块茁。
因此慎重起見,更傾向于使用packagingExcludes參數(shù)桂肌。