简单的javaant构建问题
我对Ant完全陌生,我只有一个简单的问题。我用一个输入文件运行ant:简单的javaant构建问题,java,xml,ant,build,Java,Xml,Ant,Build,我对Ant完全陌生,我只有一个简单的问题。我用一个输入文件运行ant:ant-Dargs=“input.txt”run,但它说它找不到input.txt(没有这样的文件或目录)。我有build.xml文件和input.txt在同一个目录中,在src和bin上方。这是我的build.xml文件,我遗漏了什么吗 <project name="Project" default="compile" basedir="."> <description> A build
ant-Dargs=“input.txt”run
,但它说它找不到input.txt
(没有这样的文件或目录)。我有build.xml
文件和input.txt
在同一个目录中,在src
和bin
上方。这是我的build.xml
文件,我遗漏了什么吗
<project name="Project" default="compile" basedir=".">
<description>
A build file for a project
</description>
<!-- global properties for this build file -->
<property name="source.dir" location="src"/>
<property name="build.dir" location="bin"/>
<property name="doc.dir" location="doc"/>
<property name="main.class" value="proj.ProjMain"/>
<!-- set up some directories used by this project -->
<target name="init" description="setup project directories">
<mkdir dir="${build.dir}"/>
<mkdir dir="${doc.dir}"/>
</target>
<!-- Compile the java code in ${src.dir} into ${build.dir} -->
<target name="compile" depends="init" description="compile java sources">
<javac srcdir="${source.dir}" destdir="${build.dir}"/>
</target>
<!-- execute the program with the fully qualified name in ${build.dir} -->
<target name="run" description="run the project">
<java dir="${build.dir}" classname="${main.class}" fork="yes">
<arg line="${args}"/>
</java>
</target>
<!-- Delete the build & doc directories and Emacs backup (*~) files -->
<target name="clean" description="tidy up the workspace">
<delete dir="${build.dir}"/>
<delete dir="${doc.dir}"/>
<delete>
<fileset defaultexcludes="no" dir="${source.dir}" includes="**/*~"/>
</delete>
</target>
<!-- Generate javadocs for current project into ${doc.dir} -->
<target name="doc" depends="init" description="generate documentation">
<javadoc sourcepath="${source.dir}" destdir="${doc.dir}"/>
</target>
</project>
项目的生成文件
命令ant-Dargs=“input.txt”run将运行以下目标:
<!-- execute the program with the fully qualified name in ${build.dir} -->
<target name="run" description="run the project">
<java dir="${build.dir}" classname="${main.class}" fork="yes">
<arg line="${args}"/>
</java>
</target>
命令ant-Dargs=“input.txt”run将运行以下目标:
<!-- execute the program with the fully qualified name in ${build.dir} -->
<target name="run" description="run the project">
<java dir="${build.dir}" classname="${main.class}" fork="yes">
<arg line="${args}"/>
</java>
</target>
项目标记中的basedir
参数指示未指定绝对路径时生成文件引用的目录。因此,您的input.txt
应该与您的basedir
相对,或者您应该提到您的input.txt
的绝对路径
在您的例子中,basedir指的是构建文件所在的目录。因此,如果input.txt与生成文件位于同一目录中,它应该可以正常工作项目标记中的basedir
参数指示未指定绝对路径时生成文件引用的目录。因此,您的input.txt
应该与您的basedir
相对,或者您应该提到您的input.txt
的绝对路径
在您的例子中,basedir指的是构建文件所在的目录。因此,如果input.txt与构建文件位于同一目录中,它应该可以正常工作input.txt位于哪个目录?input.txt位于哪个目录?是proj.ProjMain
在抱怨,而不是ant。是proj.ProjMain
在抱怨,而不是ant。