如何更改 Javadoc 的包以查找源文件?

How do I change the package for Javadoc to find source files?

我有一个 Mavenized 项目,我正在使用 Eclipse(但我也有这个问题 运行从 cmd 中使用它)和 Java 1.6.0_45,并且我正在尝试 运行 命令:

mvn package

这是我的项目: Project Layout

我的项目名称是cycle-server,我的Main.java在src/main/java下的一个测试包中。

cycle-server
--> src/main/java
    --> test
        --> Main.java
--> src/main/resources
--> src/test/java
--> src/test/resources
--> Referenced Libraries
--> JRE System Library [JavaSE-1.6]
--> doc
--> src
    --> main
        --> assembly
            --> assembly.xml
    --> test
--> target
--> pom.xml

当我运行上面的命令时:我收到这个错误:

Loading source files for package main.java.test...
Constructing Javadoc information...
1 error
1 warning
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] MavenReportException: Error while creating archive:
Exit code: 1 - javadoc: warning - No source files for package main.java.test
javadoc: error - No public or protected classes found to document.

Command line was: "C:\Program Files (x86)\Java\jdk1.6.0_45\jre\..\bin\javadoc.exe" @options @packages

Refer to the generated Javadoc files in 'C:\Users\Thy\eclipse\workspace\cycle-server\target\apidocs' dir.

我已将我的问题确定为 Javadoc 正在查找的包:main.java.test。如果只是测试,我相信我能够成功构建。有没有办法修复 Eclipse 和命令行的 Javadoc 位置路径?

我试过更改包名称,还更改了项目中的源文件夹。我想让我的文件夹保持原样。

作业需要 Javadoc,我不想跳过 Javadoc 生成。

编辑:这是我的pom.xml。我删除了一些依赖项,因为它们是公司特定的。

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>COMPANY PARENT POM</groupId>
    <artifactId>COMPANY MAVEN PARENT POM</artifactId>
    <version>2.1</version>
  </parent>
  <groupId>test</groupId>
  <artifactId>cycle-server</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>cycle-server</name>
  <packaging>jar</packaging>
  <dependencies>
        <dependency>
            <groupId>commons-cli</groupId>
            <artifactId>commons-cli</artifactId>
            <version>1.3.1</version>
        </dependency>
    </dependencies>
    <repositories>
        <!-- Tell Maven where to find the parent POM -->
        <repository>
            <releases>
                <enabled>true</enabled>
                <updatePolicy>daily</updatePolicy>
                <checksumPolicy>ignore</checksumPolicy>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <id>COMPANY PARENT POM</id>
            <name>COMPANY PARENT POM REPO</name>
            <url>REPO URL</url>
        </repository>
    </repositories>
    <build>
        <sourceDirectory>src</sourceDirectory>
        <plugins>
            <plugin>
                <groupId>com.google.code.sortpom</groupId>
                <artifactId>maven-sortpom-plugin</artifactId>
                <version>2.2.1</version>
                <executions>
                    <execution>
                        <phase>verify</phase>
                        <goals>
                            <goal>sort</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <lineSeparator>\n</lineSeparator>
                    <keepBlankLines>true</keepBlankLines>
                    <sortDependencies>scope,artifactId</sortDependencies>
                    <nrOfIndentSpace>-1</nrOfIndentSpace>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.5.5</version>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <descriptors>
                        <descriptor>src/main/assembly/assembly.xml</descriptor>
                    </descriptors>
                    <archive>
                        <manifest>
                            <mainClass>test.Main</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>snapshot</id>
            <activation>
                <property>
                    <name>maven.perform.snapshot</name>
                    <value>true</value>
                </property>
            </activation>
        </profile>
    </profiles>
</project>  

<sourceDirectory> 是错误的。应该是

<sourceDirectory>src/main/java</sourceDirectory>

或根本不指定,因为这是默认值。这就是它抱怨 "package main.java.test" 的原因,因为那不是真正的包裹。