gpt4 book ai didi

java - apache ant - 没有指定源文件和包

转载 作者:行者123 更新时间:2023-12-04 13:55:33 26 4
gpt4 key购买 nike

我试图通过本教程学习 apache ant Apache Ant - tutorial

但是在我创建了一步一步的构建文件并运行它之后,它抛出:

compile:
[javac] /home/nazar_art/workspace/de.vogella.build.ant.first/src/test/build.xml:27: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
jar:
[jar] Building MANIFEST-only jar: /home/nazar_art/workspace/de.vogella.build.ant.first/src/test/dist/de.vogella.build.test.ant.jar
docs:

BUILD FAILED
/home/nazar_art/workspace/de.vogella.build.ant.first/src/test/build.xml:34: No source files and no packages have been specified.

我不明白为什么会这样?
我使用 Ubuntu 12.04 操作系统和 Eclipse Indigo。

build.xml:
<?xml version="1.0"?>
<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="src" 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}\de.vogella.build.test.ant.jar" basedir="${build.dir}">
<manifest>
<attribute name="Main-Class" value="test.Main" />
</manifest>
</jar>
</target>

<target name="main" depends="compile, jar, docs">
<description>Main target</description>
</target>

</project>

代码部分:
package math;

public class MyMath {
public int multi(int number1, int number2) {
return number1 * number2;
}
}

package test;

import math.MyMath;

public class Main {
public static void main(String[] args) {
MyMath math = new MyMath();
System.out.println("Result is: " + math.multi(5, 10));
}
}
  • 如何解决这个烦恼?
  • 最佳答案

    在您的 ANT build.xml 中,<docs>目标正在尝试为“src”包生成文档。尝试使用正确的包名称,例如 <javadoc packagenames="src" sourcepath="..."> 中的“math”喜欢 packagenames="math,test" .您可以阅读 ANT documentation其中有 javadoc 的例子任务使用。

    关于java - apache ant - 没有指定源文件和包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18123777/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com