问题描述
得到以下 build.xml 字符串:
Got a following build.xml string:
<jar destfile="${lib.dir}/rpt.jar" basedir="${classes.src}" excludes="**/*.java" />
我是 Ant 的新手,我不明白 excludes 字符串是如何工作的.哪些文件受到影响?所有java源文件?
I am new to Ant and i don't understand how excludes string works. What files are affected? All java source files?
谢谢.
推荐答案
先说一下
<jar destfile="${lib.dir}/rpt.jar" basedir="${classes.src}" excludes="**/*.java" />
此目标用于将您的文件打包到 jar 存档中
this target is used to package your files inside a jar archive
destfile : 指定目标文件的名称和位置,将创建的存档
destfile : specifies the name and location of the destination file, the archive that would be created
basedir :指定需要打包的文件的基目录.请注意,将包含所有文件和子文件夹
basedir : specifies the base directory of the files that needed to be packaged. note that all files and subfolders would be included
excludes : 这用于从 basedir 中排除您在包 (jar) 中不需要的文件
excludes : this is used to exclude files from basedir that you dont need inside your package (jar)
现在回答你的问题
上述语句的作用是将 classes.src 中的所有文件打包到 $(lib.dir)/rpt.jar 中,但将排除在 basedir 的任何子文件夹中或内部找到的任何 .java 文件.
what the above statement would do is that it will package all the files inside classes.src to $(lib.dir)/rpt.jar but will exclude any .java files found at or inside any sub folder of basedir.
这个 exclude="*/.java" 通常用于从将使用、分发、导出等的 jar 中排除源代码
EDIT :This exclude="*/.java" is generally done to exclude source code form the jar which would be used, distributed,exported etc
这篇关于蚂蚁<jar>任务:使用排除参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!