<properties> <maven.compiler.source>11</maven.compiler.source> <maven.compiler.target>11</maven.compiler.target> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> </properties> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-site-plugin</artifactId> <version>4.0.0-M13</version> <configuration> <locales>en</locales> </configuration> </plugin> </plugins> </build> <reporting> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-project-info-reports-plugin</artifactId> <version>3.6.2</version> <reportSets> <reportSet> <reports> <report>index</report> <report>summary</report> <report>dependencies</report> <report>dependency-info</report> <report>dependency-management</report> <report>plugin-management</report> <report>plugins</report> <report>team</report> <report>scm</report> <report>issue-management</report> <report>licenses</report> </reports> </reportSet> </reportSets> </plugin> </plugins> </reporting>To generate the site:
$ mvn clean siteBy default, the resulting site will be in "target/site/" folder:
$ ls -1 target/site/
index.html project-info.html dependencies.html plugins.html css/ images/ ...
$ sudo mkdir /srv/ftp/maven-sites $ sudo chmod -R 775 /srv/ftp/maven-sites/ $ sudo chown -R mtitek:ftp /srv/ftp/maven-sites/You should replace mtitek with your actual user name.
<servers> <server> <id>ftpServer</id> <username>admin1</username> <password>{encrypted_password}</password> </server> </servers>Modify the "pom.xml" file of your project to include the "site" configuration:
<distributionManagement> <site> <id>ftpServer</id> <url>ftp://admin1@localhost/srv/ftp/maven-sites/mtitek-svn-test-a</url> </site> </distributionManagement>Modify the "pom.xml" file to include the "wagon-ftp" extension:
<build> <extensions> <extension> <groupId>org.apache.maven.wagon</groupId> <artifactId>wagon-ftp</artifactId> <version>3.5.3</version> </extension> </extensions> </build>Generating and deploying the Site:
$ mvn clean site-deployHTTP server: Creating a soft link to the site folder:
$ sudo ln -s /srv/ftp/maven-sites /var/www/html/maven-sitesYou can use the browser to access the generated site: http://localhost/maven-sites/your-project-name/
<reporting> <plugins> <!-- maven-project-info-reports-plugin --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <version>3.6.3</version> <configuration> <doclint>none</doclint> <failOnError>false</failOnError> <quiet>true</quiet> <source>${maven.compiler.source}</source> <additionalJOptions> <additionalJOption>-Xdoclint:none</additionalJOption> </additionalJOptions> </configuration> <reportSets> <reportSet> <reports> <report>javadoc</report> <report>test-javadoc</report> </reports> </reportSet> </reportSets> </plugin> </plugins> </reporting>To generate the reports:
$ mvn clean siteBy default, the resulting javadoc will be in the folders "target/site/apidocs/" and "target/site/testapidocs/":
$ ls -1 target/site/apidocs/
index.html allclasses-index.html allpackages-index.html overview-tree.html ...
$ ls -1 target/site/testapidocs/
index.html allclasses-index.html allpackages-index.html ...Reports: JavaDoc - Unit Test - Code Quality:
<reporting> <plugins> <!-- maven-project-info-reports-plugin --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-report-plugin</artifactId> <version>3.2.5</version> <reportSets> <reportSet> <reports> <report>report</report> <report>failsafe-report</report> </reports> </reportSet> </reportSets> </plugin> </plugins> </reporting>Note: This plugin also generates integration test reports if you're using the Failsafe plugin.
$ mvn clean test siteBy default, the resulting unit test reports will be in:
<build> <plugins> <!-- maven-site-plugin --> <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>0.8.11</version> <executions> <execution> <id>jacoco-prepare-agent</id> <goals> <goal>prepare-agent</goal> </goals> </execution> <execution> <id>jacoco-prepare-agent-integration</id> <goals> <goal>prepare-agent-integration</goal> </goals> </execution> <execution> <id>jacoco-report</id> <phase>test</phase> <goals> <goal>report</goal> </goals> </execution> <execution> <id>jacoco-integration-report</id> <phase>post-integration-test</phase> <goals> <goal>report-integration</goal> </goals> </execution> <execution> <id>jacoco-check</id> <goals> <goal>check</goal> </goals> <configuration> <rules> <rule> <element>BUNDLE</element> <limits> <limit> <counter>INSTRUCTION</counter> <value>COVEREDRATIO</value> <minimum>0.80</minimum> </limit> </limits> </rule> </rules> </configuration> </execution> </executions> </plugin> </plugins> </build> <reporting> <plugins> <!-- maven-project-info-reports-plugin --> <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>0.8.11</version> <reportSets> <reportSet> <reports> <report>report</report> </reports> </reportSet> </reportSets> </plugin> </plugins> </reporting>To generate the reports:
$ mvn clean test siteBy default, the resulting code coverage reports will be in the folder "target/site/jacoco/":
$ ls -1 target/site/jacoco/
index.html jacoco.xml jacoco.csv jacoco-resources/ ...Tip: You can set coverage thresholds to fail the build if coverage is too low, as shown in the configuration above (80% minimum).
<reporting> <plugins> <!-- maven-project-info-reports-plugin --> <plugin> <groupId>com.github.spotbugs</groupId> <artifactId>spotbugs-maven-plugin</artifactId> <version>4.8.3.1</version> <configuration> <effort>Max</effort> <threshold>Low</threshold> <xmlOutput>true</xmlOutput> <spotbugsXmlOutputDirectory>${project.build.directory}/spotbugs</spotbugsXmlOutputDirectory> <excludeFilterFile>spotbugs-exclude.xml</excludeFilterFile> </configuration> </plugin> </plugins> </reporting>Optional: Create a spotbugs-exclude.xml file in your project root to exclude certain bug patterns:
<?xml version="1.0" encoding="UTF-8"?> <FindBugsFilter> <Match> <Bug pattern="DM_EXIT"/> </Match> <Match> <Class name="~.*\.Test.*"/> </Match> </FindBugsFilter>To generate the reports:
$ mvn clean compile siteBy default, the resulting bug report will be in "target/site/spotbugs.html" file.