Thy Dai Thy Dai - 1 year ago 121
Java Question

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

I have a Mavenized project and I'm using Eclipse (but I'm also having this issue running it from cmd) with Java 1.6.0_45, and I am trying to run the command:

mvn package

Here is my project:
Project Layout

My project name is cycle-server, and my is within a test package under src/main/java.

--> src/main/java
--> test
--> 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

When I run the above command: I receive this error:

Loading source files for package
Constructing Javadoc information...
1 error
1 warning
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] MavenReportException: Error while creating archive:
Exit code: 1 - javadoc: warning - No source files for package
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.

I have pinpointed my problem to the package that Javadoc is looking in: If it was just test, I believe I would be able to successfully build. Is there anyway to fix this Javadoc location path for both Eclipse and command line?

I have tried changing the package name, and also changing the source folders within the project. I would like to keep my folders the way they are.

A Javadoc is REQUIRED for the assignment, and I would not like to skip the Javadoc generation.

EDIT: Here is my pom.xml. I have removed a few dependencies because they are company specific.

<project xmlns="" xmlns:xsi="" xsi:schemaLocation="">
<groupId>COMPANY PARENT POM</groupId>
<artifactId>COMPANY MAVEN PARENT POM</artifactId>
<!-- Tell Maven where to find the parent POM -->
<url>REPO URL</url>

Answer Source

The <sourceDirectory> is wrong. It should be either


or not specified at all, as this is the default. This is why it is complaining about "package", because that's not a real package.