[英]Java - How to create JavaDocs in Apache Ivy
I know how to create javadocs
for my source file in Apache Ant Build . 我知道如何在Apache Ant Build中为源文件创建
javadocs
。
<target name="doc" description="generate documentation">
<delete dir="${doc.dir}"/>
<mkdir dir="${doc.dir}"/>
<javadoc sourcepath="${source.dir}" destdir="${doc.dir}"/>
</target>
But I don't know how to create them in Apache Ivy . 但是我不知道如何在Apache Ivy中创建它们。
Could some one show me a sample example ? 有人可以给我看一个示例例子吗?
Apache Ivy is a dependency management library for use with (not a replacement for) Apache Ant. Apache Ivy是一个与Apache Ant一起使用(而不是替代)的依赖管理库。 Therefore, you will use the same
<javadoc>
task as always. 因此,您将像往常一样使用相同的
<javadoc>
任务。
Apache Ivy is a dependency manager that works with Ant (a build manager). Apache Ivy是与Ant(构建管理器)一起使用的依赖项管理器。 Apache Ivy is usually (or possible always?) used with Ant to handle builds.
Apache Ivy通常(或可能总是?)与Ant一起使用来处理构建。 Since javadoc creation is a build task not a dependency task, it wouldn't make sense to generate javadocs using Ivy.
由于javadoc的创建是一个构建任务而不是一个依赖项任务,因此使用Ivy生成javadoc毫无意义。
It looks like you're going around in a circle here. 看来您在这里转了一圈。 Ivy works with Ant.
常春藤与蚂蚁一起工作。 You still have a
build.xml
file that you use for your builds. 您仍然具有用于构建的
build.xml
文件。 The ivy.xml
file simply contains a list of the third-party jars your project needs in order to build. ivy.xml
文件仅包含项目要构建的第三方jar的列表。 Thus, the direct answer to your question would be: 因此,您的问题的直接答案将是:
Put the following in your build.xml
: 将以下内容放入您的
build.xml
:
<target name="doc" description="generate documentation">
<delete dir="${doc.dir}"/>
<mkdir dir="${doc.dir}"/>
<javadoc sourcepath="${source.dir}" destdir="${doc.dir}"/>
</target>
When you use Ivy, you still use Ant. 当您使用Ivy时,仍会使用Ant。 And, you still have a
build.xml
file. 并且,您仍然有一个
build.xml
文件。 And, you still write compose your build with various Ant tasks. 并且,您仍然使用各种Ant任务编写组成您的构建。
Download this project . 下载此项目 。 It's a simple build that contains three class files and a
build.xml
file. 这是一个简单的构建,其中包含三个类文件和一个
build.xml
文件。 You will notice there's a jar directory with the following two jars: 您会注意到有一个包含以下两个jar的jar目录:
If you look at lines 36 to 40 of the build.xml
file, the project is creating a compile classpath like this: 如果您查看
build.xml
文件的第36至40行,则该项目正在创建一个编译类路径,如下所示:
<path id="java">
<fileset file="jar/spring.jar"/>
<fileset file="jar/commons-logging-1.1.1.jar"/>
</path>
So, when he compiles, he does this: 因此,当他编译时,他这样做:
<javac destdir="bin">
<src path="${src}"/>
<classpath refid="java"/>
</javac>
Now, let's look at how this may change with Ivy. 现在,让我们看一下常春藤的情况。 In Ivy, I create a
ivy.xml
file that contains a description of what jars I need. 在Ivy中,我创建一个
ivy.xml
文件,其中包含我需要的jar的描述。 However, I only have to specify classes I use directly. 但是,我只需要指定直接使用的类即可。 In this case, I only need the
spring.jar
. 在这种情况下,我只需要
spring.jar
。 Here's my ivy.xml
: 这是我的
ivy.xml
:
<ivy-module version="1.0>
<info organisation="com.seantheflexguy"
name="ContextExample"
revision="1.0"/>
<configurations>
<conf="default" visibility="public"/>
<conf="compile" visibility="public"/>
</configurations>
<dependencies>
<dependency org="org.springframework" name="spring"
rev="2.0.4" conf="compile->default"/>
</dependencies>
</ivy-module>
Now, instead, of using the jars in the jar
directory, I'll have Ivy construct the classpath: 现在,代替使用
jar
目录中的jar
,我将让Ivy构造类路径:
<ivy:resolve/>
<ivy:cachepath pathid="java"/>
<javac destdir="bin">
<src path="${src}"/>
<classpath refid="java"/>
</javac>
Notice instead of using the <path>
task to create a classpath, I use two Ant tasks that Ivy uses. 请注意,我使用了Ivy使用的两个Ant任务,而不是使用
<path>
任务创建类路径。 The <ivy:resolve/>
looks at my ivy.xml
and resolves my dependencies on the jars I request. <ivy:resolve/>
查看我的ivy.xml
并解析我对我请求的jar的依赖关系。 These jars will be downloaded into my $HOME/.ivy2/cache
directory. 这些罐子将下载到我的
$HOME/.ivy2/cache
目录中。
The <ivy:cachepath>
task creates a classpath I'm calling the classpath java
because that's what it was previously called. <ivy:cachepath>
任务创建一个我称为类路径java
的类路径,因为以前是这样的。
With those two Ivy tasks, I've created a classpath that I can use with the <javac>
task. 通过这两个Ivy任务,我创建了一个可用于
<javac>
任务的类路径。 In fact, I'm not even bothering to change the <javac>
task. 实际上,我什至不愿意更改
<javac>
任务。
So, in Ivy: 因此,在常春藤中:
build.xml
. build.xml
。 It's how I define the various build tasks I need to do. build.xml
file. build.xml
文件中定义了我需要的更多Ant任务。 ivy.xml
file simply defines my jar dependencies. ivy.xml
文件只是定义了我的jar依赖项。 When I implement Ivy in this project, I can delete the jar
directory. jar
目录。 Does this help you understand how Ivy works? 这是否有助于您了解常春藤的工作原理?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.