简体   繁体   中英

Maven site plugin fails when running on jenkins

I am running maven application "DemoApp" that generates checkstyle static code analysis reports. It works correctly when I run it on eclipse, but when I build it on jenkins it gives the below error

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-site plugin:3.3:site (default-site) on project DemoApp: Execution default-site of goal org.apache.maven.plugins:maven-site-plugin:3.3:site failed: A required class was missing while executing org.apache.maven.plugins:maven-site-plugin:3

and The following exception :

java.lang.NoClassDefFoundError: org/apache/maven/doxia/siterenderer/DocumentContent 
Caused by: java.lang.ClassNotFoundException: org.apache.maven.doxia.siterenderer.DocumentContent

I added the following plugins in pom.xml

    <build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>3.0.0</version>
                <executions>
                    <execution>
                        <id>validate</id>
                        <phase>validate</phase>
                        <configuration>
                            <configLocation>src/main/resources/google_checks.xml</configLocation>
                            <encoding>UTF-8</encoding>
                            <consoleOutput>true</consoleOutput>
                            <failsOnError>false</failsOnError>
                            <linkXRef>false</linkXRef>
                        </configuration>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

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

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-project-info-reports-plugin</artifactId>
                <version>3.0.0</version>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

<reporting>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-checkstyle-plugin</artifactId>
            <version>3.0.0</version>
            <reportSets>
                <reportSet>
                    <reports>
                        <report>checkstyle</report>
                    </reports>
                </reportSet>
            </reportSets>
        </plugin>
    </plugins>
</reporting>

I can't tell whether this solves your current issue but generally: Declarations within <pluginManagement> do not actually set anything in the build process but are intended as a centralized place for declarations common to (sub-)projects:

[...] this only configures plugins that are actually referenced within the plugins element in the children or in the current POM.

See the different versions in the error message: maven-site-plugin:3.3 and in the declaration: <version>3.7.1 .

To add such a plugin declaration to the build process you have to declare/reference it additionaly in:

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

The same applies to the maven-checkstyle-plugin :

If you want to report to the console or fail the build, you must add an execution of checkstyle::check to the <build> element and configure any options that you need.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM