I'm trying to use the site target for maven to generate javadoc, but I'm getting inconsistent results. I've created a stripped down sample project to test with, and when I execute the site target along with a build target (eg, mvn package site , or mvn compile site ) it works fine. But if I execute with just the site target (ie, mvn site ) I get the error:
Exit code: 1 - error: module not found: foo.bar
I've checked the generated options files, and when a build target is included the --module-path argument includes my target/classes path, but with just the site target that path isn't included.
Does anyone know how the javadoc plugin configures those arguments and how I can get it to work both ways?
Here's my test pom.xml file:
<modelVersion>4.0.0</modelVersion>
<groupId>foo.bar</groupId>
<artifactId>MyProgram</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>MyProgram</name>
<description>
This is a sample program.
</description>
<inceptionYear>2020</inceptionYear>
<properties>
<java.source>11</java.source>
<java.target>11</java.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<clean.plugin.version>3.1.0</clean.plugin.version>
<compiler.plugin.version>3.8.0</compiler.plugin.version>
<dependency.plugin.version>3.1.2</dependency.plugin.version>
<install.plugin.version>3.0.0-M1</install.plugin.version>
<jar.plugin.version>3.2.0</jar.plugin.version>
<javadoc.plugin.version>3.2.0</javadoc.plugin.version>
<resources.plugin.version>3.1.0</resources.plugin.version>
<surefire.plugin.version>3.0.0-M3</surefire.plugin.version>
<versions.plugin.version>2.7</versions.plugin.version>
<jakarta.version>2.3.2</jakarta.version>
<project.site.root.path>${CATALINA_HOME}/webapps/projects</project.site.root.path>
</properties>
<distributionManagement>
<site>
<id>foo.bar</id>
<url>file:${project.site.root.path}/${project.artifactId}</url>
</site>
</distributionManagement>
<dependencies>
<!-- https://mvnrepository.com/artifact/jakarta.xml.bind/jakarta.xml.bind-api -->
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>${jakarta.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.7.0-M1</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.platform/junit-platform-commons -->
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-commons</artifactId>
<version>1.7.0-M1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-dependency-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>${dependency.plugin.version}</version>
</plugin>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-resources-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>${resources.plugin.version}</version>
</plugin>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-site-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.9.0</version>
<configuration>
<locales>en</locales>
<generateSiteMap>true</generateSiteMap>
</configuration>
</plugin>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-javadoc-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${javadoc.plugin.version}</version>
<configuration>
<source>${java.source}</source>
<show>protected</show>
<nohelp>true</nohelp>
<detectLinks>false</detectLinks>
<detectOfflineLinks>false</detectOfflineLinks>
<detectJavaApiLink>true</detectJavaApiLink>
<failOnWarnings>true</failOnWarnings>
<additionalparam>${javadoc.opts}</additionalparam>
<sourcepath>${project.basedir}/src/main/java</sourcepath>
<subpackages>${javadoc.package}</subpackages>
<additionalJOption>-Xdoclint:all</additionalJOption>
<links>
<link>https://javadoc.io/doc/jakarta.xml.bind/jakarta.xml.bind-api/${jakarta.version}/</link>
</links>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-clean-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>${clean.plugin.version}</version>
</plugin>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-jar-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${jar.plugin.version}</version>
</plugin>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-install-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>${install.plugin.version}</version>
</plugin>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-surefire-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.plugin.version}</version>
</plugin>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-checkstyle-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<configLocation>google_checks.xml</configLocation>
<encoding>${project.build.sourceEncoding}</encoding>
<consoleOutput>true</consoleOutput>
<failsOnError>false</failsOnError>
<failsOnViolation>true</failsOnViolation>
<linkXref>false</linkXref>
</configuration>
</plugin>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-compiler-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${compiler.plugin.version}</version>
<configuration>
<source>${java.source}</source>
<target>${java.target}</target>
<showWarnings>true</showWarnings>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-project-info-reports-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-javadoc-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<reportSets>
<reportSet>
<reports>
<report>javadoc</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<!-- https://mvnrepository.com/artifact/org.codehaus.mojo/versions-maven-plugin -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>${versions.plugin.version}</version>
<reportSets>
<reportSet>
<reports>
<report>dependency-updates-report</report>
<report>plugin-updates-report</report>
<report>property-updates-report</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
To make matters even more confusing, I have another project that behaves exactly the opposite way: mvn site works correctly, but mvn package site creates the error:
Exit code: 2 - javadoc: error - No source files for package org.larrick.commons
Any insights on this would be greatly appreciated.
BTW: I'm using JDK 11 and Maven 3.6.3.
This appears to be an issue with the Javadoc plugin. Without the build step there's no artifact defined for the project, so the target/classes path (or the target.jar file) isn't added to the --module-path argument for Javadoc.
I'm reaching out to the Maven plugin team to identify a fix.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.