我想用ant建立一個「uberjar」,並且該項目有一個配置目錄和幾個屬性文件。如何將包含屬性文件的目錄添加到Ant build.xml中?
如何將配置目錄添加到build.xml?
下面是它是如何引用的例子:
static private String CONFIG_DIR = "config/";
static public String CONFIG_FILE = "proj.properties";
File configFile = new File(CONFIG_DIR, CONFIG_FILE);
有config目錄多個屬性文件。通常我只會把它添加到類路徑:
java -classpath bin:lib/*:config some.project.Example
這裏是我的build.xml的目標,這是不完全正確:
<target name="uberjar" depends="compile">
<jar jarfile="${babelnet.jar}">
<fileset dir="${bin.dir}">
<include name="**/*.class"/>
</fileset>
<zipgroupfileset dir="lib" includes="*.jar"/>
</jar>
<copy todir="config">
<fileset dir="config">
<include name="**/*.properties"/>
</fileset>
</copy>
</target>
你應該考慮加載文件,從classpath ressources:http://stackoverflow.com/questions/3294196/load-resource-from -where-class-class – oers 2012-08-17 14:47:01
如果可能,我寧願不修改代碼 - 這是我正在評估的外部項目。 – espeed 2012-08-17 14:51:37
@espeed:你是否試圖將屬性文件添加到jar中的config目錄中? – 2012-08-17 15:21:55