我正在搜索并搜索它,但没有任何结果。
我终于问你一个问题:如何使用ant为我的java项目创建类路径文件?注意我不希望classpath编译源代码,我只想创建文件。
主要思想是我只想在GIT上存储我的Java项目的框架,其中包含:
并且在ant的帮助下,我想从中创建一个eclipse项目。
在build.xml
文件中,我有一个任务将创建.project
文件,另一个任务是将一些外部jar从远程位置复制到我的/lib
文件夹中。之后,我想创建一个引用这些外部库的.classpath
文件。
到目前为止,我仅成功在.classpath文件中逐行列出了所有库:
<property name="line.separator" value="/n" />
<target name="createClasspath">
<path id="class.path">
<!-- include all jars in the lib directory and all sub-directories -->
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
</fileset>
</path>
<pathconvert pathsep="${line.separator}" property="jars" refid="class.path">
<!-- Add this if you want the path stripped -->
<mapper>
<flattenmapper />
</mapper>
</pathconvert>
<echo file=".classpath">${jars}</echo>
</target>
Output .classpath
...
log4j-1.2.17.jar
jradius-client-2.0.0.jar
...
所需的输出.classpath
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="lib" path="lib/log4j-1.2.17.jar"/>
<classpathentry kind="lib" path="lib/jradius-client-2.0.0.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
如何使用经典结构轻松创建.classpath
文件?