Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does maven-site-plugin always use version 3.3?

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.

like image 433
mbreck Avatar asked Jun 29 '18 13:06

mbreck


People also ask

How do I find my Maven plugin version?

The display-plugin-updates goal will check all the plugins and reports used in your project and display a list of those plugins with newer versions available, first staying with the same Maven version prerequisite, then additional options if you update the Maven version prerequisite.

What is site generation in Maven?

The Site Plugin is used to generate a site for the project. The generated site also includes the project's reports that were configured in the POM. Please read the migration guide if you want to upgrade from a previous version.

What are default plugins in Maven?

This project consists of a POM that lock down plugins versions that are referenced by Maven in default lifecycle bindings and super-POM, and classical plugins.


1 Answers

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
...
like image 138
Boris Avatar answered Oct 23 '22 07:10

Boris