This is an automated email from the ASF dual-hosted git repository. michaelo pushed a commit to branch doxia-2.0.0 in repository https://gitbox.apache.org/repos/asf/maven-checkstyle-plugin.git
commit 19b62c58466c3d82bf5051253dcefbb1a428f78c Author: Michael Osipov <micha...@apache.org> AuthorDate: Sat Dec 3 00:59:34 2022 +0100 Prepare for Doxia 2.0.0 --- pom.xml | 49 ++---- .../MCHECKSTYLE-357-with-header-override/pom.xml | 3 - .../verify.groovy | 3 - src/it/MCHECKSTYLE-357/pom.xml | 3 - src/it/MCHECKSTYLE-357/verify.groovy | 3 - src/it/MCHECKSTYLE-70-multi-sourcefolder/pom.xml | 170 ++++++++++----------- src/it/check-pass/pom.xml | 2 +- src/it/checkstyle-goal/pom.xml | 3 - src/it/checkstyle-goal/verify.groovy | 15 +- src/it/checkstyle-report/pom.xml | 3 - src/it/checkstyle-report/verify.groovy | 16 +- .../checkstyle/AbstractCheckstyleReport.java | 79 ++-------- .../checkstyle/CheckstyleAggregateReport.java | 18 --- .../maven/plugins/checkstyle/CheckstyleReport.java | 7 - .../checkstyle/CheckstyleReportGenerator.java | 37 +---- .../maven/plugins/checkstyle/ReportResource.java | 76 --------- .../checkstyle/rss/CheckstyleRssGenerator.java | 34 ----- .../rss/CheckstyleRssGeneratorRequest.java | 90 ----------- .../rss/DefaultCheckstyleRssGenerator.java | 83 ---------- .../plugins/checkstyle/rss/VelocityTemplate.java | 137 ----------------- .../maven/plugins/checkstyle/checkstyle-rss.vm | 74 --------- .../apache/maven/plugins/checkstyle/images/rss.png | Bin 360 -> 0 bytes .../checkstyle/AbstractCheckstyleTestCase.java | 48 +++--- .../plugins/checkstyle/CheckstyleReportTest.java | 18 +-- .../plugins/checkstyle/ReportResourceTest.java | 63 -------- .../checkstyle/stubs/CheckstyleProjectStub.java | 26 ++++ .../checkstyle/stubs/MinMavenProjectStub.java | 23 +-- .../checkstyle/stubs/ModuleMavenProjectStub.java | 29 ++-- .../checkstyle/stubs/MultiMavenProjectStub.java | 19 +-- .../plugin-configs/custom-plugin-config.xml | 2 - .../dep-resolution-exception-plugin-config.xml | 2 - .../plugin-configs/fail-on-error-plugin-config.xml | 1 - .../resources/plugin-configs/min-plugin-config.xml | 2 - .../plugin-configs/multi-plugin-config.xml | 1 - .../plugin-configs/no-files-plugin-config.xml | 2 - .../plugin-configs/no-rules-plugin-config.xml | 2 - .../plugin-configs/no-severity-plugin-config.xml | 2 - .../plugin-configs/no-source-plugin-config.xml | 1 - .../test-source-directory-plugin-config.xml | 2 - .../plugin-configs/useFile-plugin-config.xml | 2 - 40 files changed, 201 insertions(+), 949 deletions(-) diff --git a/pom.xml b/pom.xml index 332b87b..1fca218 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ under the License. </parent> <artifactId>maven-checkstyle-plugin</artifactId> - <version>3.2.3-SNAPSHOT</version> + <version>4.0.0-M1-SNAPSHOT</version> <packaging>maven-plugin</packaging> <name>Apache Maven Checkstyle Plugin</name> @@ -67,10 +67,10 @@ under the License. <aetherVersion>1.0.0.v20140518</aetherVersion> <mavenVersion>3.2.5</mavenVersion> <checkstyleVersion>9.3</checkstyleVersion> - <doxiaVersion>1.11.1</doxiaVersion> - <doxiaSitetoolsVersion>1.11.1</doxiaSitetoolsVersion> - <sitePluginVersion>3.12.1</sitePluginVersion> - <jxrPluginVersion>3.3.0</jxrPluginVersion> + <doxiaVersion>2.0.0-M6</doxiaVersion> + <doxiaSitetoolsVersion>2.0.0-M10</doxiaSitetoolsVersion> + <sitePluginVersion>4.0.0-M8</sitePluginVersion> + <jxrPluginVersion>4.0.0-M1-SNAPSHOT</jxrPluginVersion> <project.build.outputTimestamp>2023-04-18T14:54:00Z</project.build.outputTimestamp> </properties> @@ -122,12 +122,12 @@ under the License. <dependency> <groupId>org.apache.maven.reporting</groupId> <artifactId>maven-reporting-api</artifactId> - <version>3.1.1</version> + <version>4.0.0-M6</version> </dependency> <dependency> <groupId>org.apache.maven.reporting</groupId> <artifactId>maven-reporting-impl</artifactId> - <version>3.2.0</version> + <version>4.0.0-M8</version> </dependency> <!-- doxia --> @@ -166,28 +166,8 @@ under the License. <dependency> <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-utils</artifactId> - <version>3.4.2</version> - </dependency> - <dependency> - <groupId>org.codehaus.plexus</groupId> - <artifactId>plexus-velocity</artifactId> - <version>1.2</version> - <exclusions> - <exclusion> - <groupId>org.codehaus.plexus</groupId> - <artifactId>plexus-container-default</artifactId> - </exclusion> - <exclusion> - <groupId>org.codehaus.plexus</groupId> - <artifactId>plexus-component-api</artifactId> - </exclusion> - <exclusion> - <groupId>velocity</groupId> - <artifactId>velocity</artifactId> - </exclusion> - </exclusions> + <version>3.5.1</version> </dependency> - <!-- checkstyle --> <dependency> <groupId>com.puppycrawl.tools</groupId> @@ -195,13 +175,6 @@ under the License. <version>${checkstyleVersion}</version> </dependency> - <!-- misc --> - <dependency> - <groupId>org.apache.velocity</groupId> - <artifactId>velocity</artifactId> - <version>1.7</version> - </dependency> - <!-- test --> <dependency> <groupId>org.codehaus.plexus</groupId> @@ -260,7 +233,7 @@ under the License. <dependency> <groupId>org.apache.maven.wagon</groupId> <artifactId>wagon-http-lightweight</artifactId> - <version>3.5.1</version> + <version>3.5.3</version> <scope>test</scope> </dependency> <dependency> @@ -297,7 +270,7 @@ under the License. <plugin> <!-- check with parent pom upgrade --> <artifactId>maven-checkstyle-plugin</artifactId> - <version>3.1.1</version> + <version>3.2.1</version> <dependencies> <dependency> <groupId>com.puppycrawl.tools</groupId> @@ -307,7 +280,7 @@ under the License. <dependency> <groupId>org.apache.maven.shared</groupId> <artifactId>maven-shared-resources</artifactId> - <version>4</version> + <version>5</version> </dependency> </dependencies> </plugin> diff --git a/src/it/MCHECKSTYLE-357-with-header-override/pom.xml b/src/it/MCHECKSTYLE-357-with-header-override/pom.xml index 9a11d16..b05481e 100644 --- a/src/it/MCHECKSTYLE-357-with-header-override/pom.xml +++ b/src/it/MCHECKSTYLE-357-with-header-override/pom.xml @@ -187,9 +187,6 @@ <plugins> <plugin> <artifactId>maven-checkstyle-plugin</artifactId> - <configuration> - <enableRSS>true</enableRSS> - </configuration> <reportSets> <reportSet> <reports> diff --git a/src/it/MCHECKSTYLE-357-with-header-override/verify.groovy b/src/it/MCHECKSTYLE-357-with-header-override/verify.groovy index 946bc91..b7dc255 100644 --- a/src/it/MCHECKSTYLE-357-with-header-override/verify.groovy +++ b/src/it/MCHECKSTYLE-357-with-header-override/verify.groovy @@ -24,7 +24,4 @@ assert new File(basedir, 'target/checkstyle-checker.xml').exists(); assert new File(basedir, 'target/checkstyle-result.xml').exists(); assert new File(basedir, 'target/checkstyle-rules.xml').exists(); -File rssFile = new File( basedir, 'target/site/checkstyle.rss' ); -assert rssFile.exists(); - return true; diff --git a/src/it/MCHECKSTYLE-357/pom.xml b/src/it/MCHECKSTYLE-357/pom.xml index 3e809bf..907599c 100644 --- a/src/it/MCHECKSTYLE-357/pom.xml +++ b/src/it/MCHECKSTYLE-357/pom.xml @@ -172,9 +172,6 @@ <plugins> <plugin> <artifactId>maven-checkstyle-plugin</artifactId> - <configuration> - <enableRSS>true</enableRSS> - </configuration> <reportSets> <reportSet> <reports> diff --git a/src/it/MCHECKSTYLE-357/verify.groovy b/src/it/MCHECKSTYLE-357/verify.groovy index 946bc91..b7dc255 100644 --- a/src/it/MCHECKSTYLE-357/verify.groovy +++ b/src/it/MCHECKSTYLE-357/verify.groovy @@ -24,7 +24,4 @@ assert new File(basedir, 'target/checkstyle-checker.xml').exists(); assert new File(basedir, 'target/checkstyle-result.xml').exists(); assert new File(basedir, 'target/checkstyle-rules.xml').exists(); -File rssFile = new File( basedir, 'target/site/checkstyle.rss' ); -assert rssFile.exists(); - return true; diff --git a/src/it/MCHECKSTYLE-70-multi-sourcefolder/pom.xml b/src/it/MCHECKSTYLE-70-multi-sourcefolder/pom.xml index f142b5b..9ec15d2 100644 --- a/src/it/MCHECKSTYLE-70-multi-sourcefolder/pom.xml +++ b/src/it/MCHECKSTYLE-70-multi-sourcefolder/pom.xml @@ -1,85 +1,85 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ~ Licensed to the Apache Software Foundation (ASF) under one - ~ or more contributor license agreements. See the NOTICE file - ~ distributed with this work for additional information - ~ regarding copyright ownership. The ASF licenses this file - ~ to you under the Apache License, Version 2.0 (the - ~ "License"); you may not use this file except in compliance - ~ with the License. You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, - ~ software distributed under the License is distributed on an - ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - ~ KIND, either express or implied. See the License for the - ~ specific language governing permissions and limitations - ~ under the License. - --> - -<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>org.apache.maven.plugins.checkstyle</groupId> - <artifactId>multi-sourcefolder</artifactId> - <version>1.0-SNAPSHOT</version> - - <url>https://issues.apache.org/jira/browse/MCHECKSTYLE-70</url> - - <properties> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - </properties> - - <build> - <plugins> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>build-helper-maven-plugin</artifactId> - <version>1.7</version> - <executions> - <execution> - <id>main-source</id> - <goals> - <goal>add-source</goal> - </goals> - <configuration> - <sources> - <source>src/additional/java</source> - </sources> - </configuration> - </execution> - <execution> - <id>test-source</id> - <goals> - <goal>add-test-source</goal> - </goals> - <configuration> - <sources> - <source>src/test-additional/java</source> - </sources> - </configuration> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-checkstyle-plugin</artifactId> - <version>@project.version@</version> - <executions> - <execution> - <id>check</id> - <goals> - <goal>check</goal> - </goals> - <configuration> - <includeTestSourceDirectory>true</includeTestSourceDirectory> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> -</project> +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you under the Apache License, Version 2.0 (the + ~ "License"); you may not use this file except in compliance + ~ with the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, + ~ software distributed under the License is distributed on an + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ~ KIND, either express or implied. See the License for the + ~ specific language governing permissions and limitations + ~ under the License. + --> + +<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>org.apache.maven.plugins.checkstyle</groupId> + <artifactId>multi-sourcefolder</artifactId> + <version>1.0-SNAPSHOT</version> + + <url>https://issues.apache.org/jira/browse/MCHECKSTYLE-70</url> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <build> + <plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <version>3.3.0</version> + <executions> + <execution> + <id>main-source</id> + <goals> + <goal>add-source</goal> + </goals> + <configuration> + <sources> + <source>src/additional/java</source> + </sources> + </configuration> + </execution> + <execution> + <id>test-source</id> + <goals> + <goal>add-test-source</goal> + </goals> + <configuration> + <sources> + <source>src/test-additional/java</source> + </sources> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-checkstyle-plugin</artifactId> + <version>@project.version@</version> + <executions> + <execution> + <id>check</id> + <goals> + <goal>check</goal> + </goals> + <configuration> + <includeTestSourceDirectory>true</includeTestSourceDirectory> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> diff --git a/src/it/check-pass/pom.xml b/src/it/check-pass/pom.xml index 532139c..91162e7 100644 --- a/src/it/check-pass/pom.xml +++ b/src/it/check-pass/pom.xml @@ -40,7 +40,7 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> - <version>3.1</version> + <version>3.11.0</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> diff --git a/src/it/checkstyle-goal/pom.xml b/src/it/checkstyle-goal/pom.xml index 373425c..58b699c 100644 --- a/src/it/checkstyle-goal/pom.xml +++ b/src/it/checkstyle-goal/pom.xml @@ -41,9 +41,6 @@ <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <version>@project.version@</version> - <configuration> - <enableRSS>true</enableRSS> - </configuration> </plugin> </plugins> </build> diff --git a/src/it/checkstyle-goal/verify.groovy b/src/it/checkstyle-goal/verify.groovy index a5605ef..9cdc38c 100644 --- a/src/it/checkstyle-goal/verify.groovy +++ b/src/it/checkstyle-goal/verify.groovy @@ -24,20 +24,7 @@ assert new File( basedir, 'target/checkstyle-checker.xml' ).exists(); assert new File( basedir, 'target/checkstyle-header.txt' ).exists(); assert new File( basedir, 'target/checkstyle-result.xml' ).exists(); -File rssFile = new File( basedir, 'target/site/checkstyle.rss' ); -assert rssFile.exists(); - -def rss = new XmlParser().parse( rssFile ); - -def channel = rss.channel[0] - -assert channel.title.text() == 'check-pass - Checkstyle report' - -def item = channel.item[0] -assert item != null -assert item.title.text().startsWith('File: 1,') - def html = new File( basedir, 'target/site/checkstyle.html' ).text; assert html.contains( '<meta charset="UTF-8" />' ); -return true; \ No newline at end of file +return true; diff --git a/src/it/checkstyle-report/pom.xml b/src/it/checkstyle-report/pom.xml index 9755cab..19b8793 100644 --- a/src/it/checkstyle-report/pom.xml +++ b/src/it/checkstyle-report/pom.xml @@ -56,9 +56,6 @@ <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <version>@project.version@</version> - <configuration> - <enableRSS>true</enableRSS> - </configuration> <reportSets> <reportSet> <reports> diff --git a/src/it/checkstyle-report/verify.groovy b/src/it/checkstyle-report/verify.groovy index eda75a7..7ff2754 100644 --- a/src/it/checkstyle-report/verify.groovy +++ b/src/it/checkstyle-report/verify.groovy @@ -26,18 +26,4 @@ assert new File(basedir, 'target/checkstyle-checker.xml').exists(); assert new File(basedir, 'target/checkstyle-header.txt').exists(); assert new File(basedir, 'target/checkstyle-result.xml').exists(); -File rssFile = new File( basedir, 'target/site/checkstyle.rss' ); -assert rssFile.exists(); - -def rss = new XmlParser().parse( rssFile ); - -def channel = rss.channel[0] - -assert channel.title.text() == 'check-pass - Checkstyle report' - -def item = channel.item[0] -assert item != null -assert item.title.text().startsWith('File: 1,') - - -return true; \ No newline at end of file +return true; diff --git a/src/main/java/org/apache/maven/plugins/checkstyle/AbstractCheckstyleReport.java b/src/main/java/org/apache/maven/plugins/checkstyle/AbstractCheckstyleReport.java index f6e4d66..d6aa3de 100644 --- a/src/main/java/org/apache/maven/plugins/checkstyle/AbstractCheckstyleReport.java +++ b/src/main/java/org/apache/maven/plugins/checkstyle/AbstractCheckstyleReport.java @@ -26,7 +26,6 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.util.ArrayList; -import java.util.Calendar; import java.util.List; import java.util.Locale; import java.util.Map; @@ -47,8 +46,7 @@ import org.apache.maven.plugins.checkstyle.exec.CheckstyleExecutor; import org.apache.maven.plugins.checkstyle.exec.CheckstyleExecutorException; import org.apache.maven.plugins.checkstyle.exec.CheckstyleExecutorRequest; import org.apache.maven.plugins.checkstyle.exec.CheckstyleResults; -import org.apache.maven.plugins.checkstyle.rss.CheckstyleRssGenerator; -import org.apache.maven.plugins.checkstyle.rss.CheckstyleRssGeneratorRequest; +import org.apache.maven.project.MavenProject; import org.apache.maven.reporting.AbstractMavenReport; import org.apache.maven.reporting.MavenReportException; import org.codehaus.plexus.configuration.PlexusConfiguration; @@ -71,8 +69,6 @@ import com.puppycrawl.tools.checkstyle.api.CheckstyleException; public abstract class AbstractCheckstyleReport extends AbstractMavenReport { - public static final String PLUGIN_RESOURCES = "org/apache/maven/plugins/checkstyle"; - protected static final String JAVA_FILES = "**\\/*.java"; private static final String DEFAULT_CONFIG_LOCATION = "sun_checks.xml"; @@ -346,15 +342,6 @@ public abstract class AbstractCheckstyleReport @Parameter( property = "checkstyle.enable.files.summary", defaultValue = "true" ) private boolean enableFilesSummary; - /** - * Specifies if the RSS should be enabled or not. - * - * @deprecated This feature will be removed in a future version. - */ - @Parameter( property = "checkstyle.enable.rss", defaultValue = "false" ) - @Deprecated - private boolean enableRSS; - /** * The Plugin Descriptor */ @@ -448,15 +435,6 @@ public abstract class AbstractCheckstyleReport @Component protected ResourceManager locator; - /** - * CheckstyleRssGenerator. - * - * @since 2.4 - */ - @Component( role = CheckstyleRssGenerator.class, hint = "default" ) - @Deprecated - protected CheckstyleRssGenerator checkstyleRssGenerator; - /** * @since 2.5 */ @@ -477,6 +455,16 @@ public abstract class AbstractCheckstyleReport return getBundle( locale ).getString( "report.checkstyle.description" ); } + protected MavenProject getProject() + { + return project; + } + + protected List<MavenProject> getReactorProjects() + { + return reactorProjects; + } + /** {@inheritDoc} */ public void executeReport( Locale locale ) throws MavenReportException @@ -530,15 +518,7 @@ public abstract class AbstractCheckstyleReport CheckstyleResults results = checkstyleExecutor.executeCheckstyle( request ); ResourceBundle bundle = getBundle( locale ); - generateReportStatics(); generateMainReport( results, bundle, effectiveConfigLocation ); - if ( enableRSS ) - { - CheckstyleRssGeneratorRequest checkstyleRssGeneratorRequest = - new CheckstyleRssGeneratorRequest( this.project, this.getCopyright(), outputDirectory, getLog() ); - checkstyleRssGenerator.generateRSS( results, checkstyleRssGeneratorRequest ); - } - } catch ( CheckstyleException e ) { @@ -691,42 +671,6 @@ public abstract class AbstractCheckstyleReport return consoleListener; } - private void generateReportStatics() - throws MavenReportException - { - ReportResource rresource = new ReportResource( PLUGIN_RESOURCES, outputDirectory ); - try - { - rresource.copy( "images/rss.png" ); - } - catch ( IOException e ) - { - throw new MavenReportException( "Unable to copy static resources.", e ); - } - } - - - private String getCopyright() - { - String copyright; - int currentYear = Calendar.getInstance().get( Calendar.YEAR ); - if ( StringUtils.isNotEmpty( project.getInceptionYear() ) - && !String.valueOf( currentYear ).equals( project.getInceptionYear() ) ) - { - copyright = project.getInceptionYear() + " - " + currentYear; - } - else - { - copyright = String.valueOf( currentYear ); - } - - if ( ( project.getOrganization() != null ) && StringUtils.isNotEmpty( project.getOrganization().getName() ) ) - { - copyright = copyright + " " + project.getOrganization().getName(); - } - return copyright; - } - private void generateMainReport( CheckstyleResults results, ResourceBundle bundle, String configLocation ) { CheckstyleReportGenerator generator = @@ -736,7 +680,6 @@ public abstract class AbstractCheckstyleReport generator.setEnableRulesSummary( enableRulesSummary ); generator.setEnableSeveritySummary( enableSeveritySummary ); generator.setEnableFilesSummary( enableFilesSummary ); - generator.setEnableRSS( enableRSS ); generator.setCheckstyleConfig( results.getConfiguration() ); if ( linkXRef ) { diff --git a/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleAggregateReport.java b/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleAggregateReport.java index 6d9b381..28e1577 100644 --- a/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleAggregateReport.java +++ b/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleAggregateReport.java @@ -20,14 +20,10 @@ package org.apache.maven.plugins.checkstyle; */ import org.apache.maven.plugins.annotations.Mojo; -import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.plugins.checkstyle.exec.CheckstyleExecutorRequest; -import org.apache.maven.project.MavenProject; import org.apache.maven.reporting.MavenReportException; -import java.util.List; - /** * A reporting task that performs Checkstyle analysis and generates an aggregate * HTML report on the violations that Checkstyle finds in a multi-module reactor @@ -40,20 +36,6 @@ import java.util.List; public class CheckstyleAggregateReport extends AbstractCheckstyleReport { - /** - * The projects in the reactor for aggregation report. - * - * @since 2.8 - */ - @Parameter( property = "reactorProjects", readonly = true ) - private List<MavenProject> reactorProjects; - - /** {@inheritDoc} */ - protected MavenProject getProject() - { - return project; - } - /** * {@inheritDoc} */ diff --git a/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleReport.java b/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleReport.java index c742421..517878c 100644 --- a/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleReport.java +++ b/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleReport.java @@ -26,7 +26,6 @@ import org.apache.maven.model.Resource; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.plugins.checkstyle.exec.CheckstyleExecutorRequest; -import org.apache.maven.project.MavenProject; import org.apache.maven.reporting.MavenReportException; /** @@ -43,12 +42,6 @@ public class CheckstyleReport extends AbstractCheckstyleReport { - /** {@inheritDoc} */ - protected MavenProject getProject() - { - return project; - } - /** * {@inheritDoc} */ diff --git a/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleReportGenerator.java b/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleReportGenerator.java index af163b2..0e73aae 100644 --- a/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleReportGenerator.java +++ b/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleReportGenerator.java @@ -65,9 +65,6 @@ public class CheckstyleReportGenerator private boolean enableFilesSummary; - @Deprecated - private boolean enableRSS; - private final SiteTool siteTool; private String xrefLocation; @@ -98,7 +95,6 @@ public class CheckstyleReportGenerator this.enableRulesSummary = true; this.enableSeveritySummary = true; this.enableFilesSummary = true; - this.enableRSS = false; this.iconTool = new IconTool( sink, bundle ); } @@ -190,19 +186,6 @@ public class CheckstyleReportGenerator sink.text( String.format( bundle.getString( "report.checkstyle.ruleset" ), ruleset ) ); sink.text( "." ); - if ( enableRSS ) - { - sink.nonBreakingSpace(); - sink.link( "checkstyle.rss" ); - sink.figure(); - sink.figureCaption(); - sink.text( "rss feed" ); - sink.figureCaption_(); - sink.figureGraphics( "images/rss.png" ); - sink.figure_(); - sink.link_(); - } - sink.paragraph_(); sink.section1_(); } @@ -263,7 +246,7 @@ public class CheckstyleReportGenerator sink.sectionTitle1_(); sink.table(); - sink.tableRows( null, false ); + sink.tableRows(); sink.tableRow(); sink.tableHeaderCell(); @@ -480,7 +463,7 @@ public class CheckstyleReportGenerator sink.sectionTitle1_(); sink.table(); - sink.tableRows( null, false ); + sink.tableRows(); sink.tableRow(); sink.tableHeaderCell(); @@ -529,7 +512,7 @@ public class CheckstyleReportGenerator sink.sectionTitle1_(); sink.table(); - sink.tableRows( null, false ); + sink.tableRows(); sink.tableRow(); sink.tableHeaderCell(); @@ -618,7 +601,7 @@ public class CheckstyleReportGenerator sink.sectionTitle_( Sink.SECTION_LEVEL_2 ); sink.table(); - sink.tableRows( null, false ); + sink.tableRows(); sink.tableRow(); sink.tableHeaderCell(); @@ -773,18 +756,6 @@ public class CheckstyleReportGenerator this.enableFilesSummary = enableFilesSummary; } - @Deprecated - public boolean isEnableRSS() - { - return enableRSS; - } - - @Deprecated - public void setEnableRSS( boolean enableRSS ) - { - this.enableRSS = enableRSS; - } - public String getXrefLocation() { return xrefLocation; diff --git a/src/main/java/org/apache/maven/plugins/checkstyle/ReportResource.java b/src/main/java/org/apache/maven/plugins/checkstyle/ReportResource.java deleted file mode 100644 index 0188c80..0000000 --- a/src/main/java/org/apache/maven/plugins/checkstyle/ReportResource.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.apache.maven.plugins.checkstyle; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.codehaus.plexus.util.FileUtils; - -import java.io.File; -import java.io.IOException; -import java.net.URL; - -/** - * Generic Report Resource management. - * - * @author <a href="mailto:joa...@erdfelt.net">Joakim Erdfelt</a> - * - */ -public class ReportResource -{ - private String resourcePathBase; - - private File outputDirectory; - - public ReportResource( String resourcePathBase, File outputDirectory ) - { - this.resourcePathBase = resourcePathBase; - this.outputDirectory = outputDirectory; - } - - public void copy( String resourceName ) throws IOException - { - File resource = new File( outputDirectory, resourceName ); - if ( !resource.exists() ) - { - URL url = - Thread.currentThread().getContextClassLoader().getResource( resourcePathBase + "/" + resourceName ); - FileUtils.copyURLToFile( url, resource ); - } - } - - public File getOutputDirectory() - { - return outputDirectory; - } - - public void setOutputDirectory( File outputDirectory ) - { - this.outputDirectory = outputDirectory; - } - - public String getResourcePathBase() - { - return resourcePathBase; - } - - public void setResourcePathBase( String resourcePathBase ) - { - this.resourcePathBase = resourcePathBase; - } -} diff --git a/src/main/java/org/apache/maven/plugins/checkstyle/rss/CheckstyleRssGenerator.java b/src/main/java/org/apache/maven/plugins/checkstyle/rss/CheckstyleRssGenerator.java deleted file mode 100644 index c90adc4..0000000 --- a/src/main/java/org/apache/maven/plugins/checkstyle/rss/CheckstyleRssGenerator.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.apache.maven.plugins.checkstyle.rss; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.plugins.checkstyle.exec.CheckstyleResults; -import org.apache.maven.reporting.MavenReportException; - -/** - * @author Olivier Lamy - * @since 2.4 - */ -@Deprecated -public interface CheckstyleRssGenerator -{ - void generateRSS( CheckstyleResults results, CheckstyleRssGeneratorRequest checkstyleRssGeneratorRequest ) - throws MavenReportException; -} diff --git a/src/main/java/org/apache/maven/plugins/checkstyle/rss/CheckstyleRssGeneratorRequest.java b/src/main/java/org/apache/maven/plugins/checkstyle/rss/CheckstyleRssGeneratorRequest.java deleted file mode 100644 index 8813217..0000000 --- a/src/main/java/org/apache/maven/plugins/checkstyle/rss/CheckstyleRssGeneratorRequest.java +++ /dev/null @@ -1,90 +0,0 @@ -package org.apache.maven.plugins.checkstyle.rss; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.File; - -import org.apache.maven.plugin.logging.Log; -import org.apache.maven.project.MavenProject; - -/** - * @author Olivier Lamy - * @since 2.4 - */ -@Deprecated -public class CheckstyleRssGeneratorRequest -{ - private MavenProject mavenProject; - - private String copyright; - - private File outputDirectory; - - private Log log; - - public CheckstyleRssGeneratorRequest( MavenProject mavenProject, String copyright, File outputDirectory, Log log ) - { - this.mavenProject = mavenProject; - this.copyright = copyright; - this.outputDirectory = outputDirectory; - this.log = log; - } - - public MavenProject getMavenProject() - { - return mavenProject; - } - - public void setMavenProject( MavenProject mavenProject ) - { - this.mavenProject = mavenProject; - } - - public String getCopyright() - { - return copyright; - } - - public void setCopyright( String copyright ) - { - this.copyright = copyright; - } - - public File getOutputDirectory() - { - return outputDirectory; - } - - public void setOutputDirectory( File outputDirectory ) - { - this.outputDirectory = outputDirectory; - } - - public Log getLog() - { - return log; - } - - public void setLog( Log log ) - { - this.log = log; - } - -} diff --git a/src/main/java/org/apache/maven/plugins/checkstyle/rss/DefaultCheckstyleRssGenerator.java b/src/main/java/org/apache/maven/plugins/checkstyle/rss/DefaultCheckstyleRssGenerator.java deleted file mode 100644 index c8d03dd..0000000 --- a/src/main/java/org/apache/maven/plugins/checkstyle/rss/DefaultCheckstyleRssGenerator.java +++ /dev/null @@ -1,83 +0,0 @@ -package org.apache.maven.plugins.checkstyle.rss; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.IOException; - -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugins.checkstyle.CheckstyleReport; -import org.apache.maven.plugins.checkstyle.exec.CheckstyleResults; -import org.apache.maven.reporting.MavenReportException; -import org.apache.velocity.VelocityContext; -import org.apache.velocity.context.Context; -import org.apache.velocity.exception.ResourceNotFoundException; -import org.apache.velocity.exception.VelocityException; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; -import org.codehaus.plexus.util.StringUtils; -import org.codehaus.plexus.velocity.VelocityComponent; - -import com.puppycrawl.tools.checkstyle.api.SeverityLevel; - -/** - * @author Olivier Lamy - * @since 2.4 - */ -@Component( role = CheckstyleRssGenerator.class, hint = "default" ) -@Deprecated -public class DefaultCheckstyleRssGenerator - implements CheckstyleRssGenerator -{ - @Requirement - private VelocityComponent velocityComponent; - - @Override - public void generateRSS( CheckstyleResults results, CheckstyleRssGeneratorRequest checkstyleRssGeneratorRequest ) - throws MavenReportException - { - - VelocityTemplate vtemplate = new VelocityTemplate( velocityComponent, CheckstyleReport.PLUGIN_RESOURCES ); - vtemplate.setLog( checkstyleRssGeneratorRequest.getLog() ); - - Context context = new VelocityContext(); - context.put( "results", results ); - context.put( "project", checkstyleRssGeneratorRequest.getMavenProject() ); - context.put( "copyright", checkstyleRssGeneratorRequest.getCopyright() ); - context.put( "levelInfo", SeverityLevel.INFO ); - context.put( "levelWarning", SeverityLevel.WARNING ); - context.put( "levelError", SeverityLevel.ERROR ); - context.put( "stringutils", new StringUtils() ); - - try - { - vtemplate.generate( checkstyleRssGeneratorRequest.getOutputDirectory().getPath() + "/checkstyle.rss", - "checkstyle-rss.vm", context ); - } - catch ( ResourceNotFoundException e ) - { - throw new MavenReportException( "Unable to find checkstyle-rss.vm resource.", e ); - } - catch ( MojoExecutionException | IOException | VelocityException e ) - { - throw new MavenReportException( "Unable to generate checkstyle.rss.", e ); - } - } - -} diff --git a/src/main/java/org/apache/maven/plugins/checkstyle/rss/VelocityTemplate.java b/src/main/java/org/apache/maven/plugins/checkstyle/rss/VelocityTemplate.java deleted file mode 100644 index 0919bd2..0000000 --- a/src/main/java/org/apache/maven/plugins/checkstyle/rss/VelocityTemplate.java +++ /dev/null @@ -1,137 +0,0 @@ -package org.apache.maven.plugins.checkstyle.rss; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.logging.Log; -import org.apache.maven.plugin.logging.SystemStreamLog; -import org.apache.velocity.context.Context; -import org.apache.velocity.exception.ResourceNotFoundException; -import org.apache.velocity.exception.VelocityException; -import org.codehaus.plexus.velocity.VelocityComponent; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.Writer; -import java.nio.charset.StandardCharsets; - -/** - * <p> - * A component to work with Velocity templates from within plugins. - * <p> - * You will need to reference the velocity component as a parameter - * in your plugin. Like this: - * <pre> - * /** - * * Velocity Component - * * @component - * */ - * private VelocityComponent velocity; - * </pre> - * - * @author <a href="mailto:joa...@erdfelt.net">Joakim Erdfelt</a> - * - */ -@Deprecated -public class VelocityTemplate -{ - private String templateDirectory; - - private Log log; - - private VelocityComponent velocity; - - public VelocityTemplate( VelocityComponent velocityComponent, String templateBaseDirectory ) - { - this.velocity = velocityComponent; - this.templateDirectory = templateBaseDirectory; - } - - public String getTemplateDirectory() - { - return templateDirectory; - } - - public VelocityComponent getVelocity() - { - return velocity; - } - - /** - * Using a specified Velocity Template and provided context, create the outputFilename. - * - * @param outputFilename the file to be generated. - * @param template the velocity template to use - * @param context the velocity context map - * @throws VelocityException if the template was not found or any other Velocity exception - * @throws MojoExecutionException if merging the velocity template failed - * @throws IOException if there was an error writing to the output file - */ - public void generate( String outputFilename, String template, Context context ) - throws VelocityException, MojoExecutionException, IOException - { - - File outputFile = new File( outputFilename ); - if ( !outputFile.getParentFile().exists() ) - { - outputFile.getParentFile().mkdirs(); - } - - try ( Writer writer = new OutputStreamWriter( new FileOutputStream( outputFile ), StandardCharsets.UTF_8 ) ) - { - getVelocity().getEngine().mergeTemplate( templateDirectory + "/" + template, context, writer ); - } - catch ( ResourceNotFoundException e ) - { - throw new ResourceNotFoundException( "Template not found: " + templateDirectory + "/" + template, e ); - } - catch ( RuntimeException e ) - { - throw new MojoExecutionException( e.getMessage(), e ); - } - } - - public void setTemplateDirectory( String templateDirectory ) - { - this.templateDirectory = templateDirectory; - } - - public void setVelocity( VelocityComponent velocity ) - { - this.velocity = velocity; - } - - public Log getLog() - { - if ( this.log == null ) - { - this.log = new SystemStreamLog(); - } - return log; - } - - public void setLog( Log log ) - { - this.log = log; - } - -} diff --git a/src/main/resources/org/apache/maven/plugins/checkstyle/checkstyle-rss.vm b/src/main/resources/org/apache/maven/plugins/checkstyle/checkstyle-rss.vm deleted file mode 100644 index 77c908d..0000000 --- a/src/main/resources/org/apache/maven/plugins/checkstyle/checkstyle-rss.vm +++ /dev/null @@ -1,74 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---> -<rss version="0.91"> - <channel> - <title>${project.name} - Checkstyle report</title> - <link>${project.url}</link> - <description>${project.name} - Checkstyle report</description> - <language>en-us</language> - <copyright>©${copyright}</copyright> - <item> - <title>File: $results.getFileCount(), - Errors: $results.getSeverityCount($levelError), - Warnings: $results.getSeverityCount($levelWarning), - Infos: $results.getSeverityCount($levelInfo) - </title> - #set ( $reportlink = "${project.url}/checkstyle.html" ) - <link>$reportlink</link> - <description> - <p>Click <a href="$reportlink">here</a> for the full Checkstyle report.</p> - - <table summary="Files" boder="1"> - <thead> - <tr> - <th>Files</th> - <th style="width:30px;"><abbr title="Info">I</abbr></th> - <th style="width:30px;"><abbr title="Warning">W</abbr></th> - <th style="width:30px;"><abbr title="Error">E</abbr></th> - </tr> - </thead> - <tbody> - #foreach( $key in $results.files.keySet() ) - #set ( $filename = $key.toString() ) - #set ( $anchor = $stringutils.replace( $filename, '\\', '/' ) ) - #set ( $anchor = $stringutils.replace( $anchor, '/', '.' ) ) - <tr> - <td> - <a href="${reportlink}#$anchor">$filename</a> - </td> - <td> - $results.getSeverityCount(${key}, $levelInfo) - </td> - <td> - $results.getSeverityCount(${key}, $levelWarning) - </td> - <td> - $results.getSeverityCount(${key}, $levelError) - </td> - </tr> - #end - </tbody> - </table> - - </description> - </item> - </channel> -</rss> - diff --git a/src/main/resources/org/apache/maven/plugins/checkstyle/images/rss.png b/src/main/resources/org/apache/maven/plugins/checkstyle/images/rss.png deleted file mode 100644 index f0796ac..0000000 Binary files a/src/main/resources/org/apache/maven/plugins/checkstyle/images/rss.png and /dev/null differ diff --git a/src/test/java/org/apache/maven/plugins/checkstyle/AbstractCheckstyleTestCase.java b/src/test/java/org/apache/maven/plugins/checkstyle/AbstractCheckstyleTestCase.java index 0d925d3..9fea641 100644 --- a/src/test/java/org/apache/maven/plugins/checkstyle/AbstractCheckstyleTestCase.java +++ b/src/test/java/org/apache/maven/plugins/checkstyle/AbstractCheckstyleTestCase.java @@ -22,9 +22,14 @@ package org.apache.maven.plugins.checkstyle; import java.io.File; import java.io.IOException; import java.nio.file.Files; -import java.util.Locale; +import java.util.Collections; +import java.util.List; +import org.apache.maven.model.Plugin; import org.apache.maven.plugin.LegacySupport; +import org.apache.maven.plugin.MojoExecution; +import org.apache.maven.plugin.descriptor.MojoDescriptor; +import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.plugin.testing.AbstractMojoTestCase; import org.apache.maven.plugin.testing.ArtifactStubFactory; import org.apache.maven.plugin.testing.stubs.MavenProjectStub; @@ -42,8 +47,6 @@ import org.eclipse.aether.repository.LocalRepository; public abstract class AbstractCheckstyleTestCase extends AbstractMojoTestCase { - private Locale oldLocale; - private ArtifactStubFactory artifactStubFactory; /** @@ -58,23 +61,10 @@ public abstract class AbstractCheckstyleTestCase // required for mojo lookups to work super.setUp(); - oldLocale = Locale.getDefault(); - Locale.setDefault( Locale.ENGLISH ); - artifactStubFactory = new DependencyArtifactStubFactory( getTestFile( "target" ), true, false ); artifactStubFactory.getWorkingDir().mkdirs(); } - @Override - protected void tearDown() - throws Exception - { - super.tearDown(); - - Locale.setDefault( oldLocale ); - oldLocale = null; - } - /** * Get the current Maven project * @@ -134,8 +124,14 @@ public abstract class AbstractCheckstyleTestCase (DefaultRepositorySystemSession) legacySupport.getRepositorySession(); repoSession.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory().newInstance( repoSession, new LocalRepository( artifactStubFactory.getWorkingDir() ) ) ); + List<MavenProject> reactorProjects = mojo.getReactorProjects() != null ? mojo.getReactorProjects() : Collections.emptyList(); + + setVariableValueToObject( mojo, "mojoExecution", getMockMojoExecution() ); setVariableValueToObject( mojo, "session", legacySupport.getSession() ); - setVariableValueToObject( mojo, "remoteRepositories", mojo.getProject().getRemoteArtifactRepositories() ); + setVariableValueToObject( mojo, "repoSession", legacySupport.getRepositorySession() ); + setVariableValueToObject( mojo, "reactorProjects", reactorProjects ); + setVariableValueToObject( mojo, "remoteProjectRepositories", mojo.getProject().getRemoteProjectRepositories() ); + setVariableValueToObject( mojo, "siteDirectory", new File( mojo.getProject().getBasedir(), "src/site" ) ); return mojo; } @@ -165,4 +161,22 @@ public abstract class AbstractCheckstyleTestCase return new String( Files.readAllBytes( checkstyleTestDir.toPath().resolve( fileName ) ) ); } + private MojoExecution getMockMojoExecution() { + MojoDescriptor md = new MojoDescriptor(); + md.setGoal(getGoal()); + + MojoExecution me = new MojoExecution(md); + + PluginDescriptor pd = new PluginDescriptor(); + Plugin p = new Plugin(); + p.setGroupId("org.apache.maven.plugins"); + p.setArtifactId("maven-checkstyle-plugin"); + pd.setPlugin(p); + md.setPluginDescriptor(pd); + + return me; + } + + protected abstract String getGoal(); + } diff --git a/src/test/java/org/apache/maven/plugins/checkstyle/CheckstyleReportTest.java b/src/test/java/org/apache/maven/plugins/checkstyle/CheckstyleReportTest.java index b6575c8..bb4a6c6 100644 --- a/src/test/java/org/apache/maven/plugins/checkstyle/CheckstyleReportTest.java +++ b/src/test/java/org/apache/maven/plugins/checkstyle/CheckstyleReportTest.java @@ -24,10 +24,10 @@ import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; -import java.util.Locale; import java.util.ResourceBundle; import org.apache.maven.artifact.DependencyResolutionRequiredException; +import org.apache.maven.doxia.tools.SiteTool; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.codehaus.plexus.util.FileUtils; @@ -148,7 +148,7 @@ public class CheckstyleReportTest { File pluginXmlFile = new File( getBasedir(), "src/test/resources/plugin-configs/" + pluginXml ); ResourceBundle bundle = - ResourceBundle.getBundle( "checkstyle-report", Locale.getDefault(), this.getClassLoader() ); + ResourceBundle.getBundle( "checkstyle-report", SiteTool.DEFAULT_LOCALE, this.getClassLoader() ); CheckstyleReport mojo = createReportMojo( "checkstyle", pluginXmlFile ); @@ -172,13 +172,6 @@ public class CheckstyleReportTest File outputDir = mojo.getReportOutputDirectory(); - Boolean rss = (Boolean) getVariableValueFromObject( mojo, "enableRSS" ); - if (rss) - { - File rssFile = new File( outputDir, "checkstyle.rss" ); - assertTrue( "Test rss file exists", rssFile.exists() ); - } - File useFile = (File) getVariableValueFromObject( mojo, "useFile" ); if ( useFile != null ) { @@ -224,6 +217,11 @@ public class CheckstyleReportTest private static String getHtmlHeader( String s ) { - return ">" + s + "</h2>"; + return ">" + s + "</h1>"; + } + + @Override + protected String getGoal() { + return "checkstyle"; } } diff --git a/src/test/java/org/apache/maven/plugins/checkstyle/ReportResourceTest.java b/src/test/java/org/apache/maven/plugins/checkstyle/ReportResourceTest.java deleted file mode 100644 index 1c31ca1..0000000 --- a/src/test/java/org/apache/maven/plugins/checkstyle/ReportResourceTest.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.apache.maven.plugins.checkstyle; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import junit.framework.TestCase; - -import org.codehaus.plexus.PlexusTestCase; - -import java.io.File; - -/** - * @author Edwin Punzalan - * - */ -public class ReportResourceTest - extends TestCase -{ - private File outputDir = new File( PlexusTestCase.getBasedir(), "target/unit-test/ReportResource" ); - - public void testConstructor() - { - ReportResource reportResource = new ReportResource( "reportbase", outputDir ); - assertEquals( "Test resourcePathBase", "reportbase", reportResource.getResourcePathBase() ); - assertEquals( "Test outputDirectory", outputDir, reportResource.getOutputDirectory() ); - } - - public void testSetters() - { - ReportResource reportResource = new ReportResource( null, null ); - reportResource.setResourcePathBase( "reportbase" ); - reportResource.setOutputDirectory( outputDir ); - - assertEquals( "Test resourcePathBase", "reportbase", reportResource.getResourcePathBase() ); - assertEquals( "Test outputDirectory", outputDir, reportResource.getOutputDirectory() ); - } - - public void testCopy() - throws Exception - { - ReportResource reportResource = new ReportResource( "META-INF/plexus", outputDir ); - reportResource.copy( "components.xml" ); - - File copiedFile = new File( outputDir, "components.xml" ); - assertTrue( "Test copied file exists", copiedFile.exists() ); - } -} diff --git a/src/test/java/org/apache/maven/plugins/checkstyle/stubs/CheckstyleProjectStub.java b/src/test/java/org/apache/maven/plugins/checkstyle/stubs/CheckstyleProjectStub.java index 528a00f..8d8e71f 100644 --- a/src/test/java/org/apache/maven/plugins/checkstyle/stubs/CheckstyleProjectStub.java +++ b/src/test/java/org/apache/maven/plugins/checkstyle/stubs/CheckstyleProjectStub.java @@ -19,18 +19,38 @@ package org.apache.maven.plugins.checkstyle.stubs; * under the License. */ +import java.io.File; import java.util.Collections; import java.util.List; +import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; import org.apache.maven.artifact.repository.MavenArtifactRepository; import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; import org.apache.maven.plugin.testing.stubs.MavenProjectStub; +import org.eclipse.aether.repository.RemoteRepository; public abstract class CheckstyleProjectStub extends MavenProjectStub { + /** + * @return the POM file name + */ + protected abstract String getPOM(); + + @Override + public File getBasedir() + { + return new File( super.getBasedir() + "/src/test/resources/plugin-configs/" ); + } + + @Override + public File getFile() + { + return new File( getBasedir(), getPOM() ); + } + @Override public List<ArtifactRepository> getRemoteArtifactRepositories() { @@ -39,4 +59,10 @@ public abstract class CheckstyleProjectStub return Collections.singletonList( repository ); } + + @Override + public List<RemoteRepository> getRemoteProjectRepositories() + { + return RepositoryUtils.toRepos( getRemoteArtifactRepositories() ); + } } diff --git a/src/test/java/org/apache/maven/plugins/checkstyle/stubs/MinMavenProjectStub.java b/src/test/java/org/apache/maven/plugins/checkstyle/stubs/MinMavenProjectStub.java index ab83801..80b08a9 100644 --- a/src/test/java/org/apache/maven/plugins/checkstyle/stubs/MinMavenProjectStub.java +++ b/src/test/java/org/apache/maven/plugins/checkstyle/stubs/MinMavenProjectStub.java @@ -49,30 +49,24 @@ public class MinMavenProjectStub throws DependencyResolutionRequiredException { List<String> list = new ArrayList<>( getCompileClasspathElements() ); - list.add( PlexusTestCase.getBasedir() + "/target/test-classes" ); + list.add( getBasedir() + "/target/test-classes" ); return list; } /** {@inheritDoc} */ public List<String> getCompileSourceRoots() { - return Collections.singletonList( PlexusTestCase.getBasedir() + "/target/classes" ); + return Collections.singletonList( getBasedir() + "/target/classes" ); } /** {@inheritDoc} */ public List<String> getTestCompileSourceRoots() { List<String> list = new ArrayList<>( getCompileSourceRoots() ); - list.add( PlexusTestCase.getBasedir() + "/target/test-classes" ); + list.add( getBasedir() + "/target/test-classes" ); return list; } - /** {@inheritDoc} */ - public File getBasedir() - { - return new File( PlexusTestCase.getBasedir() ); - } - /** {@inheritDoc} */ public List<ReportPlugin> getReportPlugins() { @@ -104,16 +98,13 @@ public class MinMavenProjectStub { Build build = new Build(); - build.setDirectory( PlexusTestCase.getBasedir() + "/target/test-harness/checkstyle/min" ); + build.setDirectory( getBasedir() + "/target/test-harness/checkstyle/min" ); return build; } - /** {@inheritDoc} */ - public File getFile() - { - File file = new File( getBasedir(), "pom.xml" ); - - return file; + @Override + protected String getPOM() { + return "min-plugin-config.xml"; } } diff --git a/src/test/java/org/apache/maven/plugins/checkstyle/stubs/ModuleMavenProjectStub.java b/src/test/java/org/apache/maven/plugins/checkstyle/stubs/ModuleMavenProjectStub.java index 5c92929..63606d4 100644 --- a/src/test/java/org/apache/maven/plugins/checkstyle/stubs/ModuleMavenProjectStub.java +++ b/src/test/java/org/apache/maven/plugins/checkstyle/stubs/ModuleMavenProjectStub.java @@ -23,7 +23,6 @@ import org.apache.maven.model.Build; import org.apache.maven.model.Organization; import org.apache.maven.model.ReportPlugin; import org.apache.maven.artifact.DependencyResolutionRequiredException; -import org.codehaus.plexus.PlexusTestCase; import java.util.ArrayList; import java.util.List; @@ -50,30 +49,24 @@ public class ModuleMavenProjectStub throws DependencyResolutionRequiredException { List<String> list = new ArrayList<>( getCompileClasspathElements() ); - list.add( PlexusTestCase.getBasedir() + "/target/test-classes" ); + list.add( getBasedir() + "/target/test-classes" ); return list; } /** {@inheritDoc} */ public List<String> getCompileSourceRoots() { - return Collections.singletonList( PlexusTestCase.getBasedir() + "/target/classes" ); + return Collections.singletonList( getBasedir() + "/target/classes" ); } /** {@inheritDoc} */ public List<String> getTestCompileSourceRoots() { List<String> list = new ArrayList<>( getCompileSourceRoots() ); - list.add( PlexusTestCase.getBasedir() + "/target/test-classes" ); + list.add( getBasedir() + "/target/test-classes" ); return list; } - /** {@inheritDoc} */ - public File getBasedir() - { - return new File( PlexusTestCase.getBasedir() ); - } - /** {@inheritDoc} */ public List<ReportPlugin> getReportPlugins() { @@ -105,18 +98,16 @@ public class ModuleMavenProjectStub { Build build = new Build(); - build.setDirectory( PlexusTestCase.getBasedir() + "/target/test-harness/checkstyle/multi" ); - build.setSourceDirectory( PlexusTestCase.getBasedir() + "/src/test/test-sources" ); - build.setTestSourceDirectory( PlexusTestCase.getBasedir() + "/src/test/java" ); + build.setDirectory( getBasedir() + "/target/test-harness/checkstyle/multi" ); + build.setSourceDirectory( getBasedir() + "/src/test/test-sources" ); + build.setTestSourceDirectory( getBasedir() + "/src/test/java" ); return build; } - /** {@inheritDoc} */ - public File getFile() - { - File file = new File( getBasedir(), "pom.xml" ); - - return file; + @Override + protected String getPOM() { + return "multi-plugin-config.xml"; } + } diff --git a/src/test/java/org/apache/maven/plugins/checkstyle/stubs/MultiMavenProjectStub.java b/src/test/java/org/apache/maven/plugins/checkstyle/stubs/MultiMavenProjectStub.java index b39d9e0..1c60c44 100644 --- a/src/test/java/org/apache/maven/plugins/checkstyle/stubs/MultiMavenProjectStub.java +++ b/src/test/java/org/apache/maven/plugins/checkstyle/stubs/MultiMavenProjectStub.java @@ -19,7 +19,6 @@ package org.apache.maven.plugins.checkstyle.stubs; * under the License. */ -import java.io.File; import java.util.Collections; import java.util.List; @@ -74,12 +73,6 @@ public class MultiMavenProjectStub return Collections.emptyList(); } - /** {@inheritDoc} */ - public File getBasedir() - { - return new File( PlexusTestCase.getBasedir() ); - } - /** {@inheritDoc} */ public List<ReportPlugin> getReportPlugins() { @@ -111,16 +104,14 @@ public class MultiMavenProjectStub { Build build = new Build(); - build.setDirectory( PlexusTestCase.getBasedir() + "/target/test-harness/checkstyle/multi" ); + build.setDirectory( getBasedir() + "/target/test-harness/checkstyle/multi" ); return build; } - /** {@inheritDoc} */ - public File getFile() - { - File file = new File( getBasedir(), "pom.xml" ); - - return file; + @Override + protected String getPOM() { + return "multi-plugin-config.xml"; } + } diff --git a/src/test/resources/plugin-configs/custom-plugin-config.xml b/src/test/resources/plugin-configs/custom-plugin-config.xml index 43bd679..4d3703b 100644 --- a/src/test/resources/plugin-configs/custom-plugin-config.xml +++ b/src/test/resources/plugin-configs/custom-plugin-config.xml @@ -28,11 +28,9 @@ under the License. <artifactId>maven-checkstyle-plugin</artifactId> <configuration> <outputDirectory>${basedir}/target/test-harness/checkstyle/custom</outputDirectory> - <localRepository>${localRepository}</localRepository> <enableRulesSummary>true</enableRulesSummary> <enableSeveritySummary>true</enableSeveritySummary> <enableFilesSummary>true</enableFilesSummary> - <enableRSS>true</enableRSS> <includes>**/*.java</includes> <configLocation>google_checks.xml</configLocation> <headerLocation>LICENSE.txt</headerLocation> diff --git a/src/test/resources/plugin-configs/dep-resolution-exception-plugin-config.xml b/src/test/resources/plugin-configs/dep-resolution-exception-plugin-config.xml index e9aa739..aba1d2e 100644 --- a/src/test/resources/plugin-configs/dep-resolution-exception-plugin-config.xml +++ b/src/test/resources/plugin-configs/dep-resolution-exception-plugin-config.xml @@ -24,11 +24,9 @@ under the License. <artifactId>maven-checkstyle-plugin</artifactId> <configuration> <outputDirectory>${basedir}/target/test-harness/checkstyle/dep-resolution</outputDirectory> - <localRepository>${localRepository}</localRepository> <enableRulesSummary>true</enableRulesSummary> <enableSeveritySummary>true</enableSeveritySummary> <enableFilesSummary>true</enableFilesSummary> - <enableRSS>true</enableRSS> <includes>**/*.java</includes> <configLocation>sun_checks.xml</configLocation> <headerLocation>${basedir}/src/test/test-sources/LICENSE.txt</headerLocation> diff --git a/src/test/resources/plugin-configs/fail-on-error-plugin-config.xml b/src/test/resources/plugin-configs/fail-on-error-plugin-config.xml index 4090e09..a3bae69 100644 --- a/src/test/resources/plugin-configs/fail-on-error-plugin-config.xml +++ b/src/test/resources/plugin-configs/fail-on-error-plugin-config.xml @@ -27,7 +27,6 @@ under the License. <enableRulesSummary>true</enableRulesSummary> <enableSeveritySummary>true</enableSeveritySummary> <enableFilesSummary>true</enableFilesSummary> - <enableRSS>true</enableRSS> <includes>**/*.java</includes> <configLocation>sun_checks.xml</configLocation> <headerLocation>${basedir}/src/test/test-sources/LICENSE.txt</headerLocation> diff --git a/src/test/resources/plugin-configs/min-plugin-config.xml b/src/test/resources/plugin-configs/min-plugin-config.xml index 5ce4ca1..b897fff 100644 --- a/src/test/resources/plugin-configs/min-plugin-config.xml +++ b/src/test/resources/plugin-configs/min-plugin-config.xml @@ -28,11 +28,9 @@ under the License. <artifactId>maven-checkstyle-plugin</artifactId> <configuration> <outputDirectory>${basedir}/target/test-harness/checkstyle/min</outputDirectory> - <localRepository>${localRepository}</localRepository> <enableRulesSummary>true</enableRulesSummary> <enableSeveritySummary>true</enableSeveritySummary> <enableFilesSummary>true</enableFilesSummary> - <enableRSS>true</enableRSS> <includes>**/*.java</includes> <configLocation>sun_checks.xml</configLocation> <headerLocation>${basedir}/src/test/test-sources/LICENSE.txt</headerLocation> diff --git a/src/test/resources/plugin-configs/multi-plugin-config.xml b/src/test/resources/plugin-configs/multi-plugin-config.xml index 9bb0c05..e1b9d9c 100644 --- a/src/test/resources/plugin-configs/multi-plugin-config.xml +++ b/src/test/resources/plugin-configs/multi-plugin-config.xml @@ -27,7 +27,6 @@ under the License. <enableRulesSummary>true</enableRulesSummary> <enableSeveritySummary>true</enableSeveritySummary> <enableFilesSummary>true</enableFilesSummary> - <enableRSS>true</enableRSS> <includes>**/*.java</includes> <configLocation>sun_checks.xml</configLocation> <headerLocation>${basedir}/src/test/test-sources/LICENSE.txt</headerLocation> diff --git a/src/test/resources/plugin-configs/no-files-plugin-config.xml b/src/test/resources/plugin-configs/no-files-plugin-config.xml index ce32b86..d09c3a9 100644 --- a/src/test/resources/plugin-configs/no-files-plugin-config.xml +++ b/src/test/resources/plugin-configs/no-files-plugin-config.xml @@ -28,11 +28,9 @@ under the License. <artifactId>maven-checkstyle-plugin</artifactId> <configuration> <outputDirectory>${basedir}/target/test-harness/checkstyle/no-files</outputDirectory> - <localRepository>${localRepository}</localRepository> <enableRulesSummary>true</enableRulesSummary> <enableSeveritySummary>true</enableSeveritySummary> <enableFilesSummary>false</enableFilesSummary> - <enableRSS>true</enableRSS> <includes>**/*.java</includes> <configLocation>sun_checks.xml</configLocation> <headerLocation>${basedir}/src/test/test-sources/LICENSE.txt</headerLocation> diff --git a/src/test/resources/plugin-configs/no-rules-plugin-config.xml b/src/test/resources/plugin-configs/no-rules-plugin-config.xml index 899bc84..60b4cd8 100644 --- a/src/test/resources/plugin-configs/no-rules-plugin-config.xml +++ b/src/test/resources/plugin-configs/no-rules-plugin-config.xml @@ -28,11 +28,9 @@ under the License. <artifactId>maven-checkstyle-plugin</artifactId> <configuration> <outputDirectory>${basedir}/target/test-harness/checkstyle/no-rules</outputDirectory> - <localRepository>${localRepository}</localRepository> <enableRulesSummary>false</enableRulesSummary> <enableSeveritySummary>true</enableSeveritySummary> <enableFilesSummary>true</enableFilesSummary> - <enableRSS>true</enableRSS> <includes>**/*.java</includes> <configLocation>sun_checks.xml</configLocation> <headerLocation>${basedir}/src/test/test-sources/LICENSE.txt</headerLocation> diff --git a/src/test/resources/plugin-configs/no-severity-plugin-config.xml b/src/test/resources/plugin-configs/no-severity-plugin-config.xml index 416c9fc..f65b18a 100644 --- a/src/test/resources/plugin-configs/no-severity-plugin-config.xml +++ b/src/test/resources/plugin-configs/no-severity-plugin-config.xml @@ -28,11 +28,9 @@ under the License. <artifactId>maven-checkstyle-plugin</artifactId> <configuration> <outputDirectory>${basedir}/target/test-harness/checkstyle/no-severity</outputDirectory> - <localRepository>${localRepository}</localRepository> <enableRulesSummary>true</enableRulesSummary> <enableSeveritySummary>false</enableSeveritySummary> <enableFilesSummary>true</enableFilesSummary> - <enableRSS>true</enableRSS> <includes>**/*.java</includes> <configLocation>sun_checks.xml</configLocation> <headerLocation>${basedir}/src/test/test-sources/LICENSE.txt</headerLocation> diff --git a/src/test/resources/plugin-configs/no-source-plugin-config.xml b/src/test/resources/plugin-configs/no-source-plugin-config.xml index fab7251..0ca6522 100644 --- a/src/test/resources/plugin-configs/no-source-plugin-config.xml +++ b/src/test/resources/plugin-configs/no-source-plugin-config.xml @@ -31,7 +31,6 @@ under the License. <enableRulesSummary>true</enableRulesSummary> <enableSeveritySummary>true</enableSeveritySummary> <enableFilesSummary>true</enableFilesSummary> - <enableRSS>true</enableRSS> <includes>**/*.java</includes> <configLocation>sun_checks.xml</configLocation> <headerLocation>${basedir}/src/test/test-sources/LICENSE.txt</headerLocation> diff --git a/src/test/resources/plugin-configs/test-source-directory-plugin-config.xml b/src/test/resources/plugin-configs/test-source-directory-plugin-config.xml index 4678fa4..79cf03a 100644 --- a/src/test/resources/plugin-configs/test-source-directory-plugin-config.xml +++ b/src/test/resources/plugin-configs/test-source-directory-plugin-config.xml @@ -28,11 +28,9 @@ under the License. <artifactId>maven-checkstyle-plugin</artifactId> <configuration> <outputDirectory>${basedir}/target/test-harness/checkstyle/no-source</outputDirectory> - <localRepository>${localRepository}</localRepository> <enableRulesSummary>true</enableRulesSummary> <enableSeveritySummary>true</enableSeveritySummary> <enableFilesSummary>true</enableFilesSummary> - <enableRSS>true</enableRSS> <includes>**/*.java</includes> <configLocation>sun_checks.xml</configLocation> <headerLocation>${basedir}/src/test/test-sources/LICENSE.txt</headerLocation> diff --git a/src/test/resources/plugin-configs/useFile-plugin-config.xml b/src/test/resources/plugin-configs/useFile-plugin-config.xml index 89e78b4..acb5ba3 100644 --- a/src/test/resources/plugin-configs/useFile-plugin-config.xml +++ b/src/test/resources/plugin-configs/useFile-plugin-config.xml @@ -28,11 +28,9 @@ under the License. <artifactId>maven-checkstyle-plugin</artifactId> <configuration> <outputDirectory>${basedir}/target/test-harness/checkstyle/useFile</outputDirectory> - <localRepository>${localRepository}</localRepository> <enableRulesSummary>true</enableRulesSummary> <enableSeveritySummary>true</enableSeveritySummary> <enableFilesSummary>true</enableFilesSummary> - <enableRSS>true</enableRSS> <includes>**/*.java</includes> <configLocation>sun_checks.xml</configLocation> <headerLocation>${basedir}/src/test/test-sources/LICENSE.txt</headerLocation>