我正在尝试运行一些基本的ant脚本,同时面对以下错误:
D:\{user...}\build.xml:31: Javadoc failed: java.io.IOException: Cannot run program "javadoc.exe": CreateProcess error=2, The system cannot find the file specified
我已经尝试过搜索解决方案并找到了以下解决方案: CreateProcess error=2 running javadoc from Ant
这是我的build.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project name="Ant-Test" default="main" basedir=".">
<!-- Sets variables which can later be used. -->
<!-- The value of a property is accessed via ${} -->
<property name="src.dir" location="src" />
<property name="build.dir" location="bin" />
<property name="dist.dir" location="dist" />
<property name="docs.dir" location="docs" />
<!-- Deletes the existing build, docs and dist directory-->
<target name="clean">
<delete dir="${build.dir}" />
<delete dir="${docs.dir}" />
<delete dir="${dist.dir}" />
</target>
<!-- Creates the build, docs and dist directory-->
<target name="makedir">
<mkdir dir="${build.dir}" />
<mkdir dir="${docs.dir}" />
<mkdir dir="${dist.dir}" />
</target>
<!-- Compiles the java code (including the usage of library for JUnit -->
<target name="compile" depends="clean, makedir">
<javac srcdir="${src.dir}" destdir="${build.dir}"></javac>
</target>
<!-- Creates Javadoc -->
<target name="docs" depends="compile">
<javadoc packagenames="com.ant.vogellaTut.*" sourcepath="${src.dir}" destdir="${docs.dir}">
<!-- Define which files / directory should get included, we include all -->
<fileset dir="${src.dir}">
<include name="**" />
</fileset>
</javadoc>
</target>
<!--Creates the deployable jar file -->
<target name="jar" depends="compile">
<jar destfile="${dist.dir}\antTraining.jar" basedir="${build.dir}">
<manifest>
<attribute name="Main-Class" value="com.ant.vogellaTut.test.Test" />
</manifest>
</jar>
</target>
<target name="main" depends="compile, jar, docs">
<description>Main target</description>
</target>
</project>
答案 0 :(得分:0)
错误告诉你的是它无法找到&#34; javadoc.exe&#34;在路径中。
尝试从ant脚本中输出路径系统变量,您可以使用以下内容:
<span class="note important"></span>
并验证javadoc.exe的路径是否列在其中。