2009-09-30 29 views
5

Tôi muốn tạo một Javadoc từ một tệp xây dựng kiến, nhưng tôi không thấy nó ở đâu. Trong tệp build.xml tôi có:Làm thế nào để tạo ra javadoc với kiến, cho một dự án hiện có?

<description> 
    A sample build file for this project 
    </description> 

    <property name="source.dir" location="src"/> 
    <property name="build.dir" location="bin"/> 
    <property name="doc.dir" location="doc"/> 
    <property name="main.class" value="proj1.Proj1"/> 

    <target name="init" description="setup project directories"> 
    <mkdir dir="${build.dir}"/> 
    <mkdir dir="${doc.dir}"/> 
    </target> 

    <target name="compile" depends="init" description="compile java sources"> 
    <javac srcdir="${source.dir}" destdir="${build.dir}"/> 
    </target> 

    <target name="run" description="run the project"> 
    <java dir="${build.dir}" classname="${main.class}" fork="yes"> 
     <arg line="${args}"/> 
    </java> 
    </target> 

    <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> 

Javadoc nằm ở đâu? Nó là một tập tin ẩn hoặc một cái gì đó được đặt trong thư mục đó?

Trả lời

14

Bạn có một mục tiêu doc được xác định tạo javadoc trong ${doc.dir} được đặt thành doc.

<!-- Generate javadocs for current project into ${doc.dir} --> 
    <target name="doc" depends="init" description="generate documentation"> 
    <javadoc sourcepath="${source.dir}" destdir="${doc.dir}"/> 
    </target> 

Vì vậy, để tạo ra các javadoc chỉ cần chạy:

$ ant doc 

Và bạn sẽ tìm thấy nó trong thư mục doc phụ.

0

Nếu bạn đang sử dụng Eclipse, và các tập tin nguồn của bạn là dưới $ {source.dir}/main, công trình này:

<target name="doc" depends="init" description="generate documentation"> 
<delete dir="${doc.dir}" /> 
<mkdir dir="${doc.dir}" /> 
    <javadoc destdir="${doc.dir}"> 
     <fileset dir="${source.dir}/main" /> 
    </javadoc> 
</target> 
+0

BTW, nó tốt hơn để đưa '' trong phần 'clean' ... –

Các vấn đề liên quan