Сбой задачи Javadoc в сборке Ant - PullRequest
1 голос
/ 29 мая 2019

Я получаю сообщение об ошибке от Ant при попытке запустить задачу Javadoc ant.

"СТРОИТЬ НЕУДАЧИ /data/data/com.termux/files/home/LearnJava/Observer/build.xml:39: Не указаны ни исходные файлы, ни пакеты, ни модули. "

Файлы сборки находятся по адресу:

https://github.com/Fernal73/LearnJava/blob/master/Observer/build.properties

version=1.0.0
main.class=com.javacodegeeks.patterns.observerpattern.TestObserver
main.class1=com.javacodegeeks.patterns.observerpattern.Test
cs.properties=../checkstyle.properties
gformat.properties=../gformat.properties
ant.build.javac.source=1.7
ant.build.javac.target=1.7
packages=com.javacodegeeks.patterns.observerpatern.*

и https://github.com/Fernal73/LearnJava/blob/master/Observer/build.xml

<?xml version="1.0"?>
<project name="Observer" default="main"
  basedir=".">
  <property file = "build.properties"/>
  <property file = "${cs.properties}"/>
  <property file = "${gformat.properties}"/>
    <!-- Sets variables which can later be used. -->
    <!-- The value of a property is accessed via ${} -->
    <property name="src.dir" location="." />
    <property name="build.dir" location="." />
    <property name="dist.dir" location="dist" />
    <property name="docs.dir" location="docs" />
    <taskdef resource="${cs.taskdef.resource}"
      classpath="../${cs.jar}"/>
    <!-- Deletes the existing build, docs and dist directory-->
    <target name="clean">
        <delete>
            <fileset dir="." includes="**/*.class"/>
    </delete>       
        <delete dir="${docs.dir}" />
        <delete dir="${dist.dir}" />
    </target>
    <!-- Creates the  build, docs and dist directory-->
    <target name="makedir">
        <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,gformat,checkstyle">
        <javac includeantruntime="false" srcdir="${src.dir}" destdir="${build.dir}">
<compilerarg value="-Xlint:-options"/>
        </javac>
    </target>
    <!-- Creates Javadoc -->
    <target name="docs" depends="compile">
      <javadoc  packagenames="${packages}" additionalparam="-Xdoclint:none" 
        sourcepath="${src.dir}" 
        destdir="${docs.dir}">
            <!-- Define which files / directory should get included, we include all -->
             <fileset dir="${src.dir}">
                <include name="*.java" />
             </fileset>
        </javadoc>
      </target>
      <target name="manifest">
        <tstamp/>
      <manifest file="manifest.mf">
  <attribute name="Built-By" value="${user.name}"/>
<section name="common">
    <attribute name="Specification-Title" value="${ant.project.name}"/>
    <attribute name="Specification-Version" value="${version}"/>
    <attribute name="Specification-Vendor" value=""/>
    <attribute name="Implementation-Title" value=""/>
    <attribute name="Implementation-Version" value="${build} ${TODAY}"/>
    <attribute name="Implementation-Vendor" value=""/>
  </section>
  <attribute name="Main-Class" value="${main.class}" />
</manifest>
</target>
    <!--Creates the deployable jar file  -->
    <target name="jar" depends="compile,manifest">
      <jar destfile="${dist.dir}\${ant.project.name}.jar" basedir="${build.dir}" includes="**/*.class"
        manifest="manifest.mf">
</jar>
</target>
<target name="run" >
<description>Run target</description>
<java classname="${main.class}">
 <classpath>
   <pathelement location="${dist.dir}\${ant.project.name}.jar"/>
<pathelement path="${java.class.path}"/>
</classpath>
</java>
</target>
<target name="gformat">
  <exec executable="find" dir="${basedir}"
    failonerror="true" outputproperty="sources"> 
            <arg line=" . -type f -name '*.java'"/>  
          </exec>
          <echo message="About to format ...: ${sources}"/>
          <java classname="${gformat.main.class}">
            <arg line=" -i ${sources}"/>
 <classpath>
   <pathelement location="../${gformat.jar}"/>
<pathelement path="${java.class.path}"/>
</classpath>
</java>
    </target>
<target name="checkstyle">
  <first id="checkstylefile">
    <fileset dir=".." includes="${cs.config}"/>
  </first>
  <checkstyle config="${toString:checkstylefile}"
    classpath="../${cs.jar}"
    failOnViolation="false" properties="${cs.properties}">
  <fileset dir="${src.dir}" includes="**/*.java"/>
  <formatter type="plain"/>
  <formatter type="plain" toFile="${cs.output}"/>
</checkstyle>
</target>
<target name="main" depends="compile, jar, docs">
        <description>Main target</description>
    </target>
</project>

соответственно.

Мои другие проекты в хранилище имеют аналогичные конфигурации.

Они работают как положено.

Я что-то упускаю из виду?

Я упустил что-то очевидное. Дополнительный 't' в пакетах свойств. Очевидно, мне понадобятся два набора глаз для этого или нового набора, несколько часов спустя!

СЕЙЧАС, как мне это закрыть?

1 Ответ

2 голосов
/ 29 мая 2019

Я думаю, что проблема в следующей части:

<fileset dir="${src.dir}">
    <include name="*.java" />
</fileset>

В Ant "*.java" означает все файлы с именами, соответствующими * .java. Это не поиск в подкаталогах. Чтобы включить все подкаталоги, вы должны указать:

<fileset dir="${src.dir}">
    <include name="**/*.java" />
</fileset>

Но так как вы уже указали атрибут sourcePath, мне интересно, не можете ли вы просто удалить элемент fileset, так как ant добавит ** / *. Java по умолчанию.

...