Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"No public or protected classes found to document" error from path with accents

My Maven Java 8 project is inside a path which contains accents: C:\Développements\myproject.

When I use maven-javadoc-plugin (event with last 2.10.4 version) I have this error when I try to generate the javadoc of my project (from IntelliJ IDEA 2016.2.4):

[ERROR] javadoc: warning - No source files for package com.mycompany.myproject
[ERROR] javadoc: error - No public or protected classes found to document.

This is strange because I have documented classes in this project.

like image 781
Anthony O. Avatar asked Mar 10 '23 22:03

Anthony O.


1 Answers

This error can also occur if you have no public methods in your test classes, which is exactly what can happen because Sonar lint rule S5786 says JUnits should have default package visibility, for readability. Fortunately, you can use the -package javadoc option, to fix this. If you put this in your parent pom:

 <properties>
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  <java.version>1.8</java.version>
  <maven.compiler.version>3.8.1</maven.compiler.version>
  <junit.version>5.7.0</junit.version>
 </properties>
...
<build>
  <pluginManagement>
   <plugins>
    <plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-compiler-plugin</artifactId>
     <version>${maven.compiler.version}</version>
     <configuration>
      <source>${java.version}</source>
      <target>${java.version}</target>
     </configuration>
    </plugin>
    <plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-surefire-plugin</artifactId>
     <version>3.0.0-M4</version>
    </plugin>
    <plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-site-plugin</artifactId>
     <version>3.9.1</version>
    </plugin>
    <plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-project-info-reports-plugin</artifactId>
     <version>3.1.1</version>
    </plugin>
    <plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-javadoc-plugin</artifactId>
     <version>3.2.0</version>
     <configuration>
      <source>8</source>
      <additionalOptions>-package</additionalOptions>
     </configuration>
    </plugin>
   </plugins>
  </pluginManagement>
 </build>
 <reporting>
  <plugins>
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-javadoc-plugin</artifactId>
   </plugin>
  </plugins>
 </reporting>
 <distributionManagement>
  <site>
   <id>yourid</id>
   <url>file:///var/www/html/maven</url>
  </site>
 </distributionManagement>

then

mvn site-deploy

will give you your default maven site along with the javadoc. Included everything relevant for a Java 8 project.

like image 157
karl Avatar answered Apr 23 '23 23:04

karl