11

I am experiencing the same problem described in maven-site plugins 3.3 java.lang.ClassNotFoundException: org.apache.maven.doxia.siterenderer.DocumentContent

I'm trying to set the versions for maven-site-plugin (to 3.7.1) and maven-project-info-reports-plugin-version (to 3.0.0) as described in one of the answers. I'm using Eclipse, so I look in the "Effective POM" tab for the pom file I'm working on, and can see that the versions for those plugins are 3.7.1 and 3.0.0, as I specified.

However, when I run mvn help:effective-pom, the output shows maven-site-plugin twice - one with a version of 3.7.1, as I want, and the other with a version of 3.3. When I run mvn site, the output shows that it is using maven-site-plugin 3.3.

So my question is, where is that reference to maven-site-plugin version 3.3 coming from, and how can I force it to use 3.7.1? I'm already specifying it in the pom file, but it still uses version 3.3.

Here's my definition for the maven-site-plugin:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-site-plugin</artifactId>
        <version>3.7.1</version>
    </plugin>

By the way, this is a parent pom file, but it is the only reference that I have to maven-site-plugin in it or any of the child pom files.

I'm using maven version 3.2.1.

mbreck
  • 121
  • 1
  • 4
  • Check your dependency tree. – Dave Newton Jun 29 '18 at 13:42
  • Thanks for the tip about the maven dependency tree. I haven't used that before, and it looks like it should tell me which dependency is pulling in the unexpected version of maven-site-plugin. Unfortunately, I'm struggling to get the information I need from it. – mbreck Jun 29 '18 at 18:33
  • 1
    Do you have any tips on how to use the mvn dependency:tree option? I'm currently using "mvn dependency:tree -Dverbose -DoutputType=graphml", but the output file doesn't mention maven-site-plugin at all. – mbreck Jun 29 '18 at 18:44
  • It's a complete transitive dependency tree-grep the output? – Dave Newton Jun 29 '18 at 19:05
  • I am grepping the output, but I don't seem to be getting a complete tree. If I were, then I should see maven-site-plugin somewhere. I've changed my grep statement to look for another jar that does appear in the output file, and it gives me the output that I expect. But when I change to grep for maven-site-plugin, I find nothing. I thought I must be doing something wrong, that I'm not getting a complete tree, and was hoping for advice on what's wrong with me maven dependency:tree command. – mbreck Jun 29 '18 at 19:11
  • I think the problem has to do with the project structure. We're using a parent pom file, with several dependent poms, and then a build pom. mvn dependency:tree doesn't seem to show me the entire dependency tree, I believe because of that structure. Defining the maven-site-plugin version to use in both the parent pom and the build pom, instead of only in the parent pom, might help me solve my underlying problem. – mbreck Jun 29 '18 at 19:49
  • I have faced the same issue. I used 3.7 but it is picking 3.3. I tried to run the command mvn -e site to see in which child modules 3.3 version plugin is picked up and getting failed. Whichever module it is picking 3.3 I have added the same plugin in that child module and it worked !!!. Also, for me one of the child modules is outside the parent root directory,there also i have added the same. Hope this will resolve your issue. Good Luck ! – Mallik Arjun Apr 11 '19 at 11:01

1 Answers1

10

Maven does not always use maven-site-plugin version 3.3.

In fact the plugin version being used during site lifecycle is specified in Apache Maven project itself, in maven-core/src/main/resources/META-INF/plexus/components.xml:

<default-phases>
  <site>
    org.apache.maven.plugins:maven-site-plugin:3.3:site
  </site>
  <site-deploy>
    org.apache.maven.plugins:maven-site-plugin:3.3:deploy
  </site-deploy>
</default-phases>

Before maven 3.1.0

version 3.2

Since maven 3.1.0

version 3.3

See this commit for more info.

Since maven 4.0.0

version 3.9.1

Following MNG-7263, the plugin version is specified in SiteLifecycleProvider.java:

phases.put( "site", new LifecyclePhase( "org.apache.maven.plugins:maven-site-plugin:3.9.1:site" ) );
phases.put( "site-deploy", new LifecyclePhase( "org.apache.maven.plugins:maven-site-plugin:3.9.1:deploy" ) );

Issue fix

To override the maven-site-plugin version add it to the build section of the POM file and maven-project-info-reports-plugin to reporting. Here is a full working example:

<?xml version="1.0" encoding="UTF-8"?>
<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>

  <groupId>com.mycompany</groupId>
  <artifactId>mavenproject</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>
  <url>http://www.your.site.com/</url>

  <properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-site-plugin</artifactId>
        <version>3.7.1</version>
      </plugin>
    </plugins>
  </build>

  <reporting>
    <plugins>
      <plugin>
        <artifactId>maven-project-info-reports-plugin</artifactId>
        <version>3.0.0</version>
      </plugin>
    </plugins>
  </reporting>

</project>

Then generate a project site:

$ mvn site 

[INFO] Scanning for projects...
[INFO] 
[INFO] ---------------------< com.mycompany:mavenproject >---------------------
[INFO] Building mavenproject 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-site-plugin:3.7.1:site (default-site) @ mavenproject ---
[INFO] configuring report plugin org.apache.maven.plugins:maven-project-info-reports-plugin:3.0.0
[INFO] 15 reports detected for maven-project-info-reports-plugin:3.0.0: ci-management, dependencies, dependency-info, dependency-management, distribution-management, index, issue-management, licenses, mailing-lists, modules, plugin-management, plugins, scm, summary, team
...
Boris
  • 22,667
  • 16
  • 50
  • 71
  • Alas this advice doesn't work with the maven-release-plugin. Bug raised here: https://issues.apache.org/jira/browse/MRELEASE-1052 – Graham Leggett Jul 23 '20 at 14:11
  • 2
    Your advice wasn't enough, I needed to add an execution also : ` maven-site-plugin 3.9.1 attach-descriptor attach-descriptor ` – Dave Moten Jan 19 '22 at 06:04