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

时间:2016-06-07 14:24:16

标签: java eclipse maven javadoc

我有一个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>  

1 个答案:

答案 0 :(得分:3)

<sourceDirectory>错了。它应该是

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

或根本没有指定,因为这是默认值。这就是为什么它抱怨"package main.java.test",因为那不是一个真正的包。