You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2022/08/13 20:23:37 UTC
[maven-checkstyle-plugin] 01/01: [MCHECKSTYLE-417] Upgrade Maven Reporting API to 3.1.1/Maven Reporting Impl to 3.2.0
This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a commit to branch MCHECKSTYLE-417
in repository https://gitbox.apache.org/repos/asf/maven-checkstyle-plugin.git
commit 27cd2a205d882e12db860792c1ff44764fe92e37
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Sat Aug 13 20:49:01 2022 +0200
[MCHECKSTYLE-417] Upgrade Maven Reporting API to 3.1.1/Maven Reporting Impl to 3.2.0
---
pom.xml | 92 ++++++++---
src/it/MCHECKSTYLE-137/pom.xml | 4 -
src/it/MCHECKSTYLE-193/pom.xml | 8 +-
.../checkstyle/AbstractCheckstyleReport.java | 35 ++---
.../checkstyle/CheckstyleAggregateReport.java | 2 +-
.../maven/plugins/checkstyle/CheckstyleReport.java | 8 +-
.../checkstyle/CheckstyleViolationCheckMojo.java | 24 +--
.../checkstyle/AbstractCheckstyleTestCase.java | 168 +++++++++++++++++++++
.../plugins/checkstyle/CheckstyleReportTest.java | 142 +++++------------
.../CheckstyleViolationCheckMojoTest.java | 31 ++--
.../checkstyle/DependencyArtifactStubFactory.java | 69 +++++++++
.../checkstyle/stubs/CheckstyleProjectStub.java | 42 ++++++
.../checkstyle/stubs/MinMavenProjectStub.java | 2 +-
.../checkstyle/stubs/ModuleMavenProjectStub.java | 2 +-
.../checkstyle/stubs/MultiMavenProjectStub.java | 2 +-
.../plugin-configs/check-plugin-config.xml | 2 +-
.../plugin-configs/check-plugin-plain-output.xml | 2 +-
.../plugin-configs/custom-plugin-config.xml | 7 +-
.../dep-resolution-exception-plugin-config.xml | 3 +-
.../plugin-configs/fail-on-error-plugin-config.xml | 2 +-
.../plugin-configs/min-plugin-config.xml | 7 +-
.../plugin-configs/multi-plugin-config.xml | 2 +-
.../plugin-configs/no-files-plugin-config.xml | 7 +-
.../plugin-configs/no-rules-plugin-config.xml | 7 +-
.../plugin-configs/no-severity-plugin-config.xml | 7 +-
.../plugin-configs/no-source-plugin-config.xml | 6 +-
.../test-source-directory-plugin-config.xml | 7 +-
.../plugin-configs/useFile-plugin-config.xml | 7 +-
28 files changed, 487 insertions(+), 210 deletions(-)
diff --git a/pom.xml b/pom.xml
index 3cf27b5..f44d5f0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,4 +1,4 @@
-<?xml version='1.0' encoding='UTF-8'?>
+<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
@@ -64,11 +64,13 @@ under the License.
<properties>
<javaVersion>8</javaVersion>
+ <aetherVersion>1.0.0.v20140518</aetherVersion>
<mavenVersion>3.2.5</mavenVersion>
<checkstyleVersion>9.3</checkstyleVersion>
<doxiaVersion>1.11.1</doxiaVersion>
- <sitePluginVersion>3.9.1</sitePluginVersion>
- <surefire.version>2.22.2</surefire.version>
+ <doxiaSitetoolsVersion>1.11.1</doxiaSitetoolsVersion>
+ <sitePluginVersion>3.12.1</sitePluginVersion>
+ <surefire.version>3.0.0-M7</surefire.version>
<project.build.outputTimestamp>2021-01-23T22:30:12Z</project.build.outputTimestamp>
</properties>
@@ -113,35 +115,33 @@ under the License.
</dependency>
<!-- shared -->
+ <dependency>
+ <groupId>org.apache.maven.reporting</groupId>
+ <artifactId>maven-reporting-api</artifactId>
+ <version>3.1.1</version>
+ </dependency>
<dependency>
<groupId>org.apache.maven.reporting</groupId>
<artifactId>maven-reporting-impl</artifactId>
- <version>3.1.0</version>
- <exclusions>
- <exclusion>
- <groupId>org.apache.maven.doxia</groupId>
- <artifactId>*</artifactId>
- </exclusion>
- </exclusions>
+ <version>3.2.0</version>
</dependency>
<!-- doxia -->
<dependency>
<groupId>org.apache.maven.doxia</groupId>
- <artifactId>doxia-site-renderer</artifactId>
+ <artifactId>doxia-sink-api</artifactId>
<version>${doxiaVersion}</version>
- <exclusions>
- <exclusion>
- <artifactId>plexus-container-default</artifactId>
- <groupId>org.codehaus.plexus</groupId>
- </exclusion>
- </exclusions>
</dependency>
<dependency>
<groupId>org.apache.maven.doxia</groupId>
- <artifactId>doxia-integration-tools</artifactId>
+ <artifactId>doxia-core</artifactId>
<version>${doxiaVersion}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.maven.doxia</groupId>
+ <artifactId>doxia-integration-tools</artifactId>
+ <version>${doxiaSitetoolsVersion}</version>
+ </dependency>
<!-- plexus -->
<dependency>
@@ -164,11 +164,6 @@ under the License.
<artifactId>plexus-utils</artifactId>
<version>3.4.2</version>
</dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-interpolation</artifactId>
- <version>1.26</version>
- </dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-velocity</artifactId>
@@ -204,17 +199,65 @@ under the License.
</dependency>
<!-- test -->
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-container-default</artifactId>
+ <version>2.1.1</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <version>1.7.36</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.apache.maven.plugin-testing</groupId>
<artifactId>maven-plugin-testing-harness</artifactId>
<version>3.3.0</version>
<scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-container-default</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.aether</groupId>
+ <artifactId>aether-api</artifactId>
+ <version>${aetherVersion}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.aether</groupId>
+ <artifactId>aether-impl</artifactId>
+ <version>${aetherVersion}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.aether</groupId>
+ <artifactId>aether-connector-basic</artifactId>
+ <version>${aetherVersion}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.aether</groupId>
+ <artifactId>aether-transport-wagon</artifactId>
+ <version>${aetherVersion}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-http-lightweight</artifactId>
+ <version>3.5.1</version>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
@@ -359,6 +402,7 @@ under the License.
<build>
<plugins>
<plugin>
+ <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<configuration>
<goals>
@@ -403,7 +447,7 @@ under the License.
</plugins>
</reporting>
</profile>
-
+
<profile>
<id>jdk9</id>
<activation>
diff --git a/src/it/MCHECKSTYLE-137/pom.xml b/src/it/MCHECKSTYLE-137/pom.xml
index 7050b4d..f7e470c 100644
--- a/src/it/MCHECKSTYLE-137/pom.xml
+++ b/src/it/MCHECKSTYLE-137/pom.xml
@@ -38,16 +38,12 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>@pom.version@</version>
- <configuration>
- <encoding>UTF-8</encoding>
- </configuration>
<executions>
<execution>
<id>validate</id>
<phase>validate</phase>
<configuration>
<configLocation>checkstyle.xml</configLocation>
- <encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
<linkXRef>false</linkXRef>
diff --git a/src/it/MCHECKSTYLE-193/pom.xml b/src/it/MCHECKSTYLE-193/pom.xml
index 0b93fbb..a91343e 100644
--- a/src/it/MCHECKSTYLE-193/pom.xml
+++ b/src/it/MCHECKSTYLE-193/pom.xml
@@ -39,11 +39,9 @@
<artifactId>maven-checkstyle-plugin</artifactId>
<version>@pom.version@</version>
<configuration>
- <encoding>UTF-8</encoding>
- <configLocation>checkstyle.xml</configLocation>
- <encoding>UTF-8</encoding>
- <consoleOutput>true</consoleOutput>
- <failsOnError>true</failsOnError>
+ <configLocation>checkstyle.xml</configLocation>
+ <consoleOutput>true</consoleOutput>
+ <failsOnError>true</failsOnError>
</configuration>
<executions>
<execution>
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 f6df100..dd40895 100644
--- a/src/main/java/org/apache/maven/plugins/checkstyle/AbstractCheckstyleReport.java
+++ b/src/main/java/org/apache/maven/plugins/checkstyle/AbstractCheckstyleReport.java
@@ -33,7 +33,7 @@ import java.util.Map;
import java.util.ResourceBundle;
import org.apache.maven.artifact.Artifact;
-import org.apache.maven.doxia.tools.SiteTool;
+import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.PluginManagement;
@@ -77,6 +77,9 @@ public abstract class AbstractCheckstyleReport
private static final String DEFAULT_CONFIG_LOCATION = "sun_checks.xml";
+ @Parameter( defaultValue = "${session}", readonly = true, required = true )
+ private MavenSession session;
+
/**
* Specifies the cache file used to speed up Checkstyle on successive runs.
*/
@@ -113,16 +116,6 @@ public abstract class AbstractCheckstyleReport
@Parameter( property = "checkstyle.consoleOutput", defaultValue = "false" )
protected boolean consoleOutput;
- /**
- * The file encoding to use when reading the source files. If the property <code>project.build.sourceEncoding</code>
- * is not set, the platform default encoding is used. <strong>Note:</strong> This parameter always overrides the
- * property <code>charset</code> from Checkstyle's <code>TreeWalker</code> module.
- *
- * @since 2.2
- */
- @Parameter( property = "encoding", defaultValue = "${project.build.sourceEncoding}" )
- protected String encoding;
-
/**
* Specifies if the build should fail upon a violation.
*/
@@ -251,7 +244,7 @@ public abstract class AbstractCheckstyleReport
/**
* Specifies the location of the source directory to be used for Checkstyle.
- *
+ *
* @deprecated instead use {@link #sourceDirectories}. For version 3.0.0, this parameter is only defined to break
* the build if you use it!
*/
@@ -267,7 +260,7 @@ public abstract class AbstractCheckstyleReport
// Compatibility with all Maven 3: default of 'project.compileSourceRoots' is done manually because of MNG-5440
@Parameter
private List<String> sourceDirectories;
-
+
/**
* Specifies the location of the test source directory to be used for Checkstyle.
*
@@ -278,7 +271,7 @@ public abstract class AbstractCheckstyleReport
@Parameter
@Deprecated
private File testSourceDirectory;
-
+
/**
* Specifies the location of the test source directories to be used for Checkstyle.
* Default value is <code>${project.testCompileSourceRoots}</code>.
@@ -359,14 +352,6 @@ public abstract class AbstractCheckstyleReport
@Parameter( property = "checkstyle.enable.rss", defaultValue = "true" )
private boolean enableRSS;
- /**
- * SiteTool.
- *
- * @since 2.2
- */
- @Component( role = SiteTool.class )
- protected SiteTool siteTool;
-
/**
* The Plugin Descriptor
*/
@@ -397,7 +382,7 @@ public abstract class AbstractCheckstyleReport
/**
* When using custom treeWalkers, specify their names here so the checks
* inside the treeWalker end up the the rule-summary.
- *
+ *
* @since 2.11
*/
@Parameter
@@ -406,7 +391,7 @@ public abstract class AbstractCheckstyleReport
/**
* Specifies whether modules with a configured severity of <code>ignore</code> should be omitted during Checkstyle
* invocation.
- *
+ *
* @since 3.0.0
*/
@Parameter( defaultValue = "false" )
@@ -602,7 +587,7 @@ public abstract class AbstractCheckstyleReport
private List<Artifact> getCheckstylePluginDependenciesAsArtifacts( Map<String, Plugin> plugins, String hint )
{
List<Artifact> artifacts = new ArrayList<>();
-
+
Plugin checkstylePlugin = plugins.get( plugin.getGroupId() + ":" + plugin.getArtifactId() );
if ( checkstylePlugin != null )
{
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 d2981d7..dee6f64 100644
--- a/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleAggregateReport.java
+++ b/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleAggregateReport.java
@@ -76,7 +76,7 @@ public class CheckstyleAggregateReport
.setTestSourceDirectories( getTestSourceDirectories() ).setConfigLocation( configLocation )
.setPropertyExpansion( propertyExpansion ).setHeaderLocation( headerLocation )
.setCacheFile( cacheFile ).setSuppressionsFileExpression( suppressionsFileExpression )
- .setEncoding( encoding ).setPropertiesLocation( propertiesLocation );
+ .setEncoding( getInputEncoding() ).setPropertiesLocation( propertiesLocation );
return request;
}
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 faf0a16..0d3af2d 100644
--- a/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleReport.java
+++ b/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleReport.java
@@ -69,7 +69,7 @@ public class CheckstyleReport
.setTestSourceDirectories( getTestSourceDirectories() ).setConfigLocation( configLocation )
.setPropertyExpansion( propertyExpansion ).setHeaderLocation( headerLocation )
.setCacheFile( cacheFile ).setSuppressionsFileExpression( suppressionsFileExpression )
- .setEncoding( encoding ).setPropertiesLocation( propertiesLocation );
+ .setEncoding( getInputEncoding() ).setPropertiesLocation( propertiesLocation );
return request;
}
@@ -86,7 +86,7 @@ public class CheckstyleReport
{
return false;
}
-
+
// TODO: would be good to scan the files here
for ( File sourceDirectory : getSourceDirectories() )
{
@@ -95,7 +95,7 @@ public class CheckstyleReport
return true;
}
}
-
+
if ( includeTestSourceDirectory )
{
for ( File testSourceDirectory : getTestSourceDirectories() )
@@ -106,7 +106,7 @@ public class CheckstyleReport
}
}
}
-
+
return ( ( includeResources && hasResources( resources ) )
|| ( includeTestResources && hasResources( testResources ) )
);
diff --git a/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleViolationCheckMojo.java b/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleViolationCheckMojo.java
index f3e645c..43c07a1 100644
--- a/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleViolationCheckMojo.java
+++ b/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleViolationCheckMojo.java
@@ -172,7 +172,7 @@ public class CheckstyleViolationCheckMojo
*/
@Parameter( defaultValue = "${project.resources}", readonly = true )
protected List<Resource> resources;
-
+
/**
* Specifies the location of the test resources to be used for Checkstyle.
*
@@ -292,7 +292,7 @@ public class CheckstyleViolationCheckMojo
* @since 2.2
*/
@Parameter( property = "encoding", defaultValue = "${project.build.sourceEncoding}" )
- private String encoding;
+ private String inputEncoding;
/**
* @since 2.5
@@ -311,7 +311,7 @@ public class CheckstyleViolationCheckMojo
*/
@Parameter ( defaultValue = "${project}", readonly = true, required = true )
protected MavenProject project;
-
+
/**
* The Plugin Descriptor
*/
@@ -392,7 +392,7 @@ public class CheckstyleViolationCheckMojo
/**
* Specifies the location of the source directory to be used for Checkstyle.
- *
+ *
* @deprecated instead use {@link #sourceDirectories}. For version 3.0.0, this parameter is only defined to break
* the build if you use it!
*/
@@ -451,7 +451,7 @@ public class CheckstyleViolationCheckMojo
private PlexusConfiguration checkstyleRules;
/**
- * Dump file for inlined Checkstyle rules.
+ * Dump file for inlined Checkstyle rules.
*/
@Parameter( property = "checkstyle.output.rules.file",
defaultValue = "${project.build.directory}/checkstyle-rules.xml" )
@@ -469,7 +469,7 @@ public class CheckstyleViolationCheckMojo
/**
* Specifies whether modules with a configured severity of <code>ignore</code> should be omitted during Checkstyle
* invocation.
- *
+ *
* @since 3.0.0
*/
@Parameter( defaultValue = "false" )
@@ -540,7 +540,7 @@ public class CheckstyleViolationCheckMojo
.setPropertyExpansion( propertyExpansion )
.setHeaderLocation( headerLocation ).setLicenseArtifacts( collectArtifacts( "license" ) )
.setCacheFile( cacheFile ).setSuppressionsFileExpression( suppressionsFileExpression )
- .setEncoding( encoding ).setPropertiesLocation( propertiesLocation )
+ .setEncoding( inputEncoding ).setPropertiesLocation( propertiesLocation )
.setOmitIgnoredModules( omitIgnoredModules );
checkstyleExecutor.executeCheckstyle( request );
@@ -876,7 +876,7 @@ public class CheckstyleViolationCheckMojo
return listener;
}
-
+
private List<Artifact> collectArtifacts( String hint )
{
List<Artifact> artifacts = new ArrayList<>();
@@ -895,7 +895,7 @@ public class CheckstyleViolationCheckMojo
private List<Artifact> getCheckstylePluginDependenciesAsArtifacts( Map<String, Plugin> plugins, String hint )
{
List<Artifact> artifacts = new ArrayList<>();
-
+
Plugin checkstylePlugin = plugins.get( plugin.getGroupId() + ":" + plugin.getArtifactId() );
if ( checkstylePlugin != null )
{
@@ -908,7 +908,7 @@ public class CheckstyleViolationCheckMojo
}
return artifacts;
}
-
+
private List<File> getSourceDirectories()
{
if ( sourceDirectories == null )
@@ -922,7 +922,7 @@ public class CheckstyleViolationCheckMojo
}
return sourceDirs;
}
-
+
private List<File> getTestSourceDirectories()
{
if ( testSourceDirectories == null )
@@ -936,5 +936,5 @@ public class CheckstyleViolationCheckMojo
}
return testSourceDirs;
}
-
+
}
diff --git a/src/test/java/org/apache/maven/plugins/checkstyle/AbstractCheckstyleTestCase.java b/src/test/java/org/apache/maven/plugins/checkstyle/AbstractCheckstyleTestCase.java
new file mode 100644
index 0000000..0d925d3
--- /dev/null
+++ b/src/test/java/org/apache/maven/plugins/checkstyle/AbstractCheckstyleTestCase.java
@@ -0,0 +1,168 @@
+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 java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.util.Locale;
+
+import org.apache.maven.plugin.LegacySupport;
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.apache.maven.plugin.testing.ArtifactStubFactory;
+import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
+import org.apache.maven.project.DefaultProjectBuildingRequest;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.ProjectBuilder;
+import org.apache.maven.project.ProjectBuildingRequest;
+import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory;
+import org.eclipse.aether.DefaultRepositorySystemSession;
+import org.eclipse.aether.repository.LocalRepository;
+
+/**
+ * Abstract class to test reports generation.
+ */
+public abstract class AbstractCheckstyleTestCase
+ extends AbstractMojoTestCase
+{
+ private Locale oldLocale;
+
+ private ArtifactStubFactory artifactStubFactory;
+
+ /**
+ * The current project to be test.
+ */
+ private MavenProject testMavenProject;
+
+ @Override
+ protected void setUp()
+ throws Exception
+ {
+ // 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
+ *
+ * @return the maven project
+ */
+ protected MavenProject getTestMavenProject()
+ {
+ return testMavenProject;
+ }
+
+ /**
+ * Get the generated report as file in the test maven project.
+ *
+ * @param name the name of the report.
+ * @return the generated report as file
+ * @throws IOException if the return file doesnt exist
+ */
+ protected File getGeneratedReport( String name )
+ throws IOException
+ {
+ String outputDirectory = getBasedir() + "/target/test/test-harness/" + getTestMavenProject().getArtifactId();
+
+ File report = new File( outputDirectory, name );
+ if ( !report.exists() )
+ {
+ throw new IOException( "File not found. Attempted: " + report );
+ }
+
+ return report;
+ }
+
+ /**
+ * Generate the report and return the generated file
+ *
+ * @param goal the mojo goal.
+ * @param pluginXml the name of the xml file in "src/test/resources/plugin-configs/".
+ * @return the generated HTML file
+ * @throws Exception if any
+ */
+ protected File generateReport( String goal, String pluginXml )
+ throws Exception
+ {
+ File pluginXmlFile = new File( getBasedir(), "src/test/resources/plugin-configs/" + pluginXml );
+ CheckstyleReport mojo = createReportMojo( goal, pluginXmlFile );
+ return generateReport( mojo, pluginXmlFile );
+ }
+
+ protected CheckstyleReport createReportMojo( String goal, File pluginXmlFile )
+ throws Exception
+ {
+ CheckstyleReport mojo = (CheckstyleReport) lookupMojo( goal, pluginXmlFile );
+ assertNotNull( "Mojo not found.", mojo );
+
+ LegacySupport legacySupport = lookup( LegacySupport.class );
+ legacySupport.setSession( newMavenSession( new MavenProjectStub() ) );
+ DefaultRepositorySystemSession repoSession =
+ (DefaultRepositorySystemSession) legacySupport.getRepositorySession();
+ repoSession.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory().newInstance( repoSession, new LocalRepository( artifactStubFactory.getWorkingDir() ) ) );
+
+ setVariableValueToObject( mojo, "session", legacySupport.getSession() );
+ setVariableValueToObject( mojo, "remoteRepositories", mojo.getProject().getRemoteArtifactRepositories() );
+ return mojo;
+ }
+
+ protected File generateReport( CheckstyleReport mojo, File pluginXmlFile )
+ throws Exception
+ {
+ mojo.execute();
+
+ ProjectBuilder builder = lookup( ProjectBuilder.class );
+
+ ProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest();
+ buildingRequest.setRepositorySession( lookup( LegacySupport.class ).getRepositorySession() );
+
+ testMavenProject = builder.build( pluginXmlFile, buildingRequest ).getProject();
+
+ File outputDir = mojo.getReportOutputDirectory();
+ String filename = mojo.getOutputName() + ".html";
+
+ return new File( outputDir, filename );
+ }
+
+ /**
+ * Read the contents of the specified file object into a string
+ */
+ protected String readFile( File checkstyleTestDir, String fileName ) throws IOException
+ {
+ return new String( Files.readAllBytes( checkstyleTestDir.toPath().resolve( fileName ) ) );
+ }
+
+}
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 81ec866..b6575c8 100644
--- a/src/test/java/org/apache/maven/plugins/checkstyle/CheckstyleReportTest.java
+++ b/src/test/java/org/apache/maven/plugins/checkstyle/CheckstyleReportTest.java
@@ -19,70 +19,30 @@ package org.apache.maven.plugins.checkstyle;
* under the License.
*/
+
+import java.io.BufferedReader;
import java.io.File;
+import java.io.FileReader;
import java.io.IOException;
-import java.io.Writer;
import java.util.Locale;
import java.util.ResourceBundle;
-
-
import org.apache.maven.artifact.DependencyResolutionRequiredException;
-import org.apache.maven.doxia.site.decoration.DecorationModel;
-import org.apache.maven.doxia.siterenderer.RendererException;
-import org.apache.maven.doxia.siterenderer.SiteRenderingContext;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
-import org.apache.maven.plugin.testing.AbstractMojoTestCase;
-import org.apache.maven.reporting.MavenReport;
import org.codehaus.plexus.util.FileUtils;
-import org.codehaus.plexus.util.IOUtil;
-import org.codehaus.plexus.util.WriterFactory;
/**
* @author Edwin Punzalan
*
*/
public class CheckstyleReportTest
- extends AbstractMojoTestCase
+ extends AbstractCheckstyleTestCase
{
- private Locale oldLocale;
-
- /** {@inheritDoc} */
- protected void setUp()
- throws Exception
- {
- super.setUp();
-
- oldLocale = Locale.getDefault();
- Locale.setDefault( Locale.ENGLISH );
- }
-
- /** {@inheritDoc} */
- protected void tearDown()
- throws Exception
- {
- super.tearDown();
-
- Locale.setDefault( oldLocale );
- oldLocale = null;
- }
-
public void testNoSource()
throws Exception
{
- File pluginXmlFile = new File( getBasedir(), "src/test/plugin-configs/no-source-plugin-config.xml" );
-
- CheckstyleReport mojo = (CheckstyleReport) lookupMojo( "checkstyle", pluginXmlFile );
- assertNotNull( "Mojo found.", mojo );
- mojo.execute();
-
- File outputFile = (File) getVariableValueFromObject( mojo, "outputFile" );
-
- renderer( mojo, outputFile );
-
- assertTrue( outputFile.getAbsolutePath() + " not generated!", outputFile.exists() );
-
- assertTrue( outputFile.getAbsolutePath() + " is empty!", outputFile.length() <= 0 );
+ File generatedReport = generateReport( "checkstyle", "no-source-plugin-config.xml" );
+ assertFalse( FileUtils.fileExists( generatedReport.getAbsolutePath() ) );
}
public void testMinConfiguration()
@@ -159,23 +119,46 @@ public class CheckstyleReportTest
generateReport( "test-source-directory-plugin-config.xml" );
}
- private File generateReport( String pluginXml )
+ /**
+ * Read the contents of the specified file object into a string
+ *
+ * @param file the file to be read
+ * @return a String object that contains the contents of the file
+ * @throws java.io.IOException
+ */
+ private String readFile( File file )
+ throws IOException
+ {
+ String strTmp;
+ StringBuilder str = new StringBuilder( (int) file.length() );
+ try ( BufferedReader in = new BufferedReader( new FileReader( file ) ) )
+ {
+ while ( ( strTmp = in.readLine() ) != null )
+ {
+ str.append( ' ' );
+ str.append( strTmp );
+ }
+ }
+
+ return str.toString();
+ }
+
+ private void generateReport( String pluginXml )
throws Exception
{
- File pluginXmlFile = new File( getBasedir(), "src/test/plugin-configs/" + pluginXml );
+ File pluginXmlFile = new File( getBasedir(), "src/test/resources/plugin-configs/" + pluginXml );
ResourceBundle bundle =
ResourceBundle.getBundle( "checkstyle-report", Locale.getDefault(), this.getClassLoader() );
- CheckstyleReport mojo = (CheckstyleReport) lookupMojo( "checkstyle", pluginXmlFile );
+ CheckstyleReport mojo = createReportMojo( "checkstyle", pluginXmlFile );
- assertNotNull( "Mojo found.", mojo );
-
PluginDescriptor descriptorStub = new PluginDescriptor();
descriptorStub.setGroupId( "org.apache.maven.plugins" );
descriptorStub.setArtifactId( "maven-checkstyle-plugin" );
setVariableValueToObject( mojo, "plugin", descriptorStub );
- mojo.execute();
+ File generatedReport = generateReport( mojo, pluginXmlFile );
+ assertTrue( FileUtils.fileExists( generatedReport.getAbsolutePath() ) );
File outputFile = (File) getVariableValueFromObject( mojo, "outputFile" );
assertNotNull( "Test output file", outputFile );
@@ -187,8 +170,7 @@ public class CheckstyleReportTest
assertTrue( "Test cache file exists", new File( cacheFile ).exists() );
}
- MavenReport reportMojo = mojo;
- File outputDir = reportMojo.getReportOutputDirectory();
+ File outputDir = mojo.getReportOutputDirectory();
Boolean rss = (Boolean) getVariableValueFromObject( mojo, "enableRSS" );
if (rss)
@@ -203,19 +185,10 @@ public class CheckstyleReportTest
assertTrue( "Test useFile exists", useFile.exists() );
}
- String filename = reportMojo.getOutputName() + ".html";
- File outputHtml = new File( outputDir, filename );
-
- renderer( mojo, outputHtml );
-
- assertTrue( outputHtml.getAbsolutePath() + " not generated!", outputHtml.exists() );
-
- assertTrue( outputHtml.getAbsolutePath() + " is empty!", outputHtml.length() > 0 );
-
- String htmlString = FileUtils.fileRead( outputHtml );
+ String str = readFile( generatedReport );
boolean searchHeaderFound =
- htmlString.contains( getHtmlHeader( bundle.getString( "report.checkstyle.rules" ) ) );
+ str.contains( getHtmlHeader( bundle.getString( "report.checkstyle.rules" ) ) );
Boolean rules = (Boolean) getVariableValueFromObject( mojo, "enableRulesSummary" );
if (rules)
{
@@ -226,7 +199,7 @@ public class CheckstyleReportTest
assertFalse( "Test for Rules Summary", searchHeaderFound );
}
- searchHeaderFound = htmlString.contains( getHtmlHeader( bundle.getString( "report.checkstyle.summary" ) ) );
+ searchHeaderFound = str.contains( getHtmlHeader( bundle.getString( "report.checkstyle.summary" ) ) );
Boolean severity = (Boolean) getVariableValueFromObject( mojo, "enableSeveritySummary" );
if (severity)
{
@@ -237,7 +210,7 @@ public class CheckstyleReportTest
assertFalse( "Test for Severity Summary", searchHeaderFound );
}
- searchHeaderFound = htmlString.contains( getHtmlHeader( bundle.getString( "report.checkstyle.files" ) ) );
+ searchHeaderFound = str.contains( getHtmlHeader( bundle.getString( "report.checkstyle.files" ) ) );
Boolean files = (Boolean) getVariableValueFromObject( mojo, "enableFilesSummary" );
if (files)
{
@@ -247,45 +220,10 @@ public class CheckstyleReportTest
{
assertFalse( "Test for Files Summary", searchHeaderFound );
}
-
- return outputHtml;
}
private static String getHtmlHeader( String s )
{
return ">" + s + "</h2>";
}
-
- /**
- * Renderer the sink from the report mojo.
- *
- * @param mojo not null
- * @param outputHtml not null
- * @throws RendererException if any
- * @throws IOException if any
- */
- private void renderer( CheckstyleReport mojo, File outputHtml )
- throws RendererException, Exception
- {
- Writer writer = null;
- SiteRenderingContext context = new SiteRenderingContext();
- context.setDecoration( new DecorationModel() );
- context.setTemplateName( "org/apache/maven/doxia/siterenderer/resources/default-site.vm" );
- context.setLocale( Locale.ENGLISH );
-
- try
- {
- outputHtml.getParentFile().mkdirs();
- writer = WriterFactory.newXmlWriter( outputHtml );
-
- mojo.execute();
-
- writer.close();
- writer = null;
- }
- finally
- {
- IOUtil.close( writer );
- }
- }
}
diff --git a/src/test/java/org/apache/maven/plugins/checkstyle/CheckstyleViolationCheckMojoTest.java b/src/test/java/org/apache/maven/plugins/checkstyle/CheckstyleViolationCheckMojoTest.java
index af9ba83..ee1f2c9 100644
--- a/src/test/java/org/apache/maven/plugins/checkstyle/CheckstyleViolationCheckMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/checkstyle/CheckstyleViolationCheckMojoTest.java
@@ -37,22 +37,19 @@ import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
public class CheckstyleViolationCheckMojoTest
extends AbstractMojoTestCase
{
-
-
-
public void testDefaultConfig()
throws Exception
{
- File pluginXmlFile = new File( getBasedir(), "src/test/plugin-configs/check-plugin-config.xml" );
+ File pluginXmlFile = new File( getBasedir(), "src/test/resources/plugin-configs/check-plugin-config.xml" );
CheckstyleViolationCheckMojo mojo = (CheckstyleViolationCheckMojo) lookupMojo( "check", pluginXmlFile );
-
+
mojoSetup( mojo );
-
+
assertNotNull( "Mojo found.", mojo );
-
+
assertNotNull( "project null.", mojo.project );
-
+
try
{
mojo.execute();
@@ -68,14 +65,14 @@ public class CheckstyleViolationCheckMojoTest
public void testInvalidFormatWithSkipExec()
throws Exception
{
- File pluginXmlFile = new File( getBasedir(), "src/test/plugin-configs/check-plugin-config.xml" );
+ File pluginXmlFile = new File( getBasedir(), "src/test/resources/plugin-configs/check-plugin-config.xml" );
Mojo mojo = lookupMojo( "check", pluginXmlFile );
assertNotNull( "Mojo found.", mojo );
mojoSetup( mojo );
-
+
setVariableValueToObject( mojo, "outputFileFormat", "plain" );
try
@@ -93,14 +90,14 @@ public class CheckstyleViolationCheckMojoTest
public void testNoOutputFile()
throws Exception
{
- File pluginXmlFile = new File( getBasedir(), "src/test/plugin-configs/check-plugin-config.xml" );
+ File pluginXmlFile = new File( getBasedir(), "src/test/resources/plugin-configs/check-plugin-config.xml" );
Mojo mojo = lookupMojo( "check", pluginXmlFile );
assertNotNull( "Mojo found.", mojo );
mojoSetup( mojo );
-
+
setVariableValueToObject( mojo, "outputFile", new File( "target/NoSuchFile.xml" ) );
mojo.execute();
@@ -109,7 +106,7 @@ public class CheckstyleViolationCheckMojoTest
private void doTestPlainOutputFile( boolean failsOnError )
throws Exception
{
- File pluginXmlFile = new File( getBasedir(), "src/test/plugin-configs/check-plugin-plain-output.xml" );
+ File pluginXmlFile = new File( getBasedir(), "src/test/resources/plugin-configs/check-plugin-plain-output.xml" );
Mojo mojo = lookupMojo( "check", pluginXmlFile );
@@ -149,19 +146,19 @@ public class CheckstyleViolationCheckMojoTest
public void testNoFail()
throws Exception
{
- File pluginXmlFile = new File( getBasedir(), "src/test/plugin-configs/check-plugin-config.xml" );
+ File pluginXmlFile = new File( getBasedir(), "src/test/resources/plugin-configs/check-plugin-config.xml" );
Mojo mojo = lookupMojo( "check", pluginXmlFile );
assertNotNull( "Mojo found.", mojo );
mojoSetup( mojo );
-
+
setVariableValueToObject( mojo, "failOnViolation", Boolean.FALSE );
mojo.execute();
}
-
+
protected void mojoSetup( Mojo mojo )
throws Exception
{
@@ -193,7 +190,7 @@ public class CheckstyleViolationCheckMojoTest
setVariableValueToObject( mojo, "configLocation", "sun_checks.xml" );
setVariableValueToObject( mojo, "cacheFile", getBasedir() + "/target/classes/checkstyle-cachefile" );
setVariableValueToObject( mojo, "sourceDirectories", Arrays.asList( getBasedir() + "/src/test/plugin-configs/src" ));// new File( getBasedir() + "/target" ) );
- setVariableValueToObject( mojo, "encoding", "UTF-8" );
+ setVariableValueToObject( mojo, "inputEncoding", "UTF-8" );
setVariableValueToObject( mojo, "skipExec", Boolean.TRUE );
}
diff --git a/src/test/java/org/apache/maven/plugins/checkstyle/DependencyArtifactStubFactory.java b/src/test/java/org/apache/maven/plugins/checkstyle/DependencyArtifactStubFactory.java
new file mode 100644
index 0000000..5a15a42
--- /dev/null
+++ b/src/test/java/org/apache/maven/plugins/checkstyle/DependencyArtifactStubFactory.java
@@ -0,0 +1,69 @@
+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 java.io.File;
+import java.io.IOException;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.ArtifactUtils;
+import org.apache.maven.artifact.versioning.VersionRange;
+import org.apache.maven.plugin.testing.ArtifactStubFactory;
+
+public class DependencyArtifactStubFactory
+ extends ArtifactStubFactory
+{
+ private boolean flattenedPath = true;
+
+ public DependencyArtifactStubFactory( File theWorkingDir, boolean theCreateFiles, boolean flattenedPath )
+ {
+ this( theWorkingDir, theCreateFiles );
+ this.flattenedPath = flattenedPath;
+ }
+
+ public DependencyArtifactStubFactory( File theWorkingDir, boolean theCreateFiles )
+ {
+ super( theWorkingDir, theCreateFiles );
+ }
+
+ @Override
+ public Artifact createArtifact( String groupId, String artifactId, VersionRange versionRange, String scope,
+ String type, String classifier, boolean optional )
+ throws IOException
+ {
+ File workingDir = getWorkingDir();
+
+ if ( !flattenedPath )
+ {
+ // don't use flatten directories, won't happen at runtime
+ String path = groupId.replace( '.', '/' ) + '/' +
+ artifactId + '/' +
+ ArtifactUtils.toSnapshotVersion( versionRange.getRecommendedVersion().toString() );
+ setWorkingDir( new File( workingDir, path ) );
+ }
+
+ Artifact artifact =
+ super.createArtifact( groupId, artifactId, versionRange, scope, type, classifier, optional );
+
+ setWorkingDir( workingDir );
+
+ return artifact;
+ }
+}
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
new file mode 100644
index 0000000..528a00f
--- /dev/null
+++ b/src/test/java/org/apache/maven/plugins/checkstyle/stubs/CheckstyleProjectStub.java
@@ -0,0 +1,42 @@
+package org.apache.maven.plugins.checkstyle.stubs;
+
+/*
+ * 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.util.Collections;
+import java.util.List;
+
+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;
+
+public abstract class CheckstyleProjectStub
+ extends MavenProjectStub
+{
+ @Override
+ public List<ArtifactRepository> getRemoteArtifactRepositories()
+ {
+ ArtifactRepository repository = new MavenArtifactRepository( "central", "https://repo1.maven.org/maven2",
+ new DefaultRepositoryLayout(), new ArtifactRepositoryPolicy(), new ArtifactRepositoryPolicy() );
+
+ return Collections.singletonList( repository );
+ }
+}
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 795b835..ab83801 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
@@ -35,7 +35,7 @@ import java.io.File;
*
*/
public class MinMavenProjectStub
- extends org.apache.maven.plugin.testing.stubs.MavenProjectStub
+ extends CheckstyleProjectStub
{
/** {@inheritDoc} */
public List<String> getCompileClasspathElements()
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 71debc5..5c92929 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
@@ -35,7 +35,7 @@ import java.io.File;
*
*/
public class ModuleMavenProjectStub
- extends org.apache.maven.plugin.testing.stubs.MavenProjectStub
+ extends CheckstyleProjectStub
{
/** {@inheritDoc} */
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 5c415a7..b39d9e0 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
@@ -34,7 +34,7 @@ import org.codehaus.plexus.PlexusTestCase;
*
*/
public class MultiMavenProjectStub
- extends org.apache.maven.plugin.testing.stubs.MavenProjectStub
+ extends CheckstyleProjectStub
{
public MultiMavenProjectStub()
diff --git a/src/test/plugin-configs/check-plugin-config.xml b/src/test/resources/plugin-configs/check-plugin-config.xml
similarity index 99%
rename from src/test/plugin-configs/check-plugin-config.xml
rename to src/test/resources/plugin-configs/check-plugin-config.xml
index a2c5d09..754c8e4 100644
--- a/src/test/plugin-configs/check-plugin-config.xml
+++ b/src/test/resources/plugin-configs/check-plugin-config.xml
@@ -30,4 +30,4 @@ under the License.
</plugin>
</plugins>
</build>
-</project>
\ No newline at end of file
+</project>
diff --git a/src/test/plugin-configs/check-plugin-plain-output.xml b/src/test/resources/plugin-configs/check-plugin-plain-output.xml
similarity index 97%
rename from src/test/plugin-configs/check-plugin-plain-output.xml
rename to src/test/resources/plugin-configs/check-plugin-plain-output.xml
index 4d5e29c..0fb56a7 100644
--- a/src/test/plugin-configs/check-plugin-plain-output.xml
+++ b/src/test/resources/plugin-configs/check-plugin-plain-output.xml
@@ -33,7 +33,7 @@ under the License.
</sourceDirectories>
<project implementation="org.apache.maven.plugins.checkstyle.stubs.MinMavenProjectStub"/>
<consoleOutput>false</consoleOutput>
- <encoding>UTF-8</encoding>
+ <inputEncoding>UTF-8</inputEncoding>
</configuration>
</plugin>
</plugins>
diff --git a/src/test/plugin-configs/custom-plugin-config.xml b/src/test/resources/plugin-configs/custom-plugin-config.xml
similarity index 90%
rename from src/test/plugin-configs/custom-plugin-config.xml
rename to src/test/resources/plugin-configs/custom-plugin-config.xml
index 309762e..43bd679 100644
--- a/src/test/plugin-configs/custom-plugin-config.xml
+++ b/src/test/resources/plugin-configs/custom-plugin-config.xml
@@ -18,12 +18,17 @@ under the License.
-->
<project>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>test</groupId>
+ <artifactId>test</artifactId>
+ <version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<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>
@@ -44,7 +49,7 @@ under the License.
<!-- value not really important, just point to an existing dir -->
<xrefLocation>${basedir}/target/test-harness/checkstyle/custom</xrefLocation>
<xrefTestLocation>${basedir}/target/test-harness/checkstyle/custom</xrefTestLocation>
- <encoding>UTF-8</encoding>
+ <inputEncoding>UTF-8</inputEncoding>
</configuration>
</plugin>
</plugins>
diff --git a/src/test/plugin-configs/dep-resolution-exception-plugin-config.xml b/src/test/resources/plugin-configs/dep-resolution-exception-plugin-config.xml
similarity index 95%
rename from src/test/plugin-configs/dep-resolution-exception-plugin-config.xml
rename to src/test/resources/plugin-configs/dep-resolution-exception-plugin-config.xml
index d2c0218..e9aa739 100644
--- a/src/test/plugin-configs/dep-resolution-exception-plugin-config.xml
+++ b/src/test/resources/plugin-configs/dep-resolution-exception-plugin-config.xml
@@ -24,6 +24,7 @@ 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>
@@ -43,7 +44,7 @@ under the License.
<linkXRef>true</linkXRef>
<xrefLocation>${basedir}/target/site/xref</xrefLocation>
<xrefTestLocation>${basedir}/target/site/xref-test</xrefTestLocation>
- <encoding>UTF-8</encoding>
+ <inputEncoding>UTF-8</inputEncoding>
</configuration>
</plugin>
</plugins>
diff --git a/src/test/plugin-configs/fail-on-error-plugin-config.xml b/src/test/resources/plugin-configs/fail-on-error-plugin-config.xml
similarity index 97%
rename from src/test/plugin-configs/fail-on-error-plugin-config.xml
rename to src/test/resources/plugin-configs/fail-on-error-plugin-config.xml
index 06853a1..4090e09 100644
--- a/src/test/plugin-configs/fail-on-error-plugin-config.xml
+++ b/src/test/resources/plugin-configs/fail-on-error-plugin-config.xml
@@ -43,7 +43,7 @@ under the License.
<linkXRef>true</linkXRef>
<xrefLocation>${basedir}/target/site/xref</xrefLocation>
<xrefTestLocation>${basedir}/target/site/xref-test</xrefTestLocation>
- <encoding>UTF-8</encoding>
+ <inputEncoding>UTF-8</inputEncoding>
</configuration>
</plugin>
</plugins>
diff --git a/src/test/plugin-configs/min-plugin-config.xml b/src/test/resources/plugin-configs/min-plugin-config.xml
similarity index 90%
rename from src/test/plugin-configs/min-plugin-config.xml
rename to src/test/resources/plugin-configs/min-plugin-config.xml
index a151bdb..5ce4ca1 100644
--- a/src/test/plugin-configs/min-plugin-config.xml
+++ b/src/test/resources/plugin-configs/min-plugin-config.xml
@@ -18,12 +18,17 @@ under the License.
-->
<project>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>test</groupId>
+ <artifactId>test</artifactId>
+ <version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<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>
@@ -43,7 +48,7 @@ under the License.
<linkXRef>true</linkXRef>
<xrefLocation>${basedir}/target/site/xref</xrefLocation>
<xrefTestLocation>${basedir}/target/site/xref-test</xrefTestLocation>
- <encoding>UTF-8</encoding>
+ <inputEncoding>UTF-8</inputEncoding>
</configuration>
</plugin>
</plugins>
diff --git a/src/test/plugin-configs/multi-plugin-config.xml b/src/test/resources/plugin-configs/multi-plugin-config.xml
similarity index 97%
rename from src/test/plugin-configs/multi-plugin-config.xml
rename to src/test/resources/plugin-configs/multi-plugin-config.xml
index 4f3d4f2..9bb0c05 100644
--- a/src/test/plugin-configs/multi-plugin-config.xml
+++ b/src/test/resources/plugin-configs/multi-plugin-config.xml
@@ -43,7 +43,7 @@ under the License.
<linkXRef>true</linkXRef>
<xrefLocation>${basedir}/target/site/xref</xrefLocation>
<xrefTestLocation>${basedir}/target/site/xref-test</xrefTestLocation>
- <encoding>UTF-8</encoding>
+ <inputEncoding>UTF-8</inputEncoding>
</configuration>
</plugin>
</plugins>
diff --git a/src/test/plugin-configs/no-files-plugin-config.xml b/src/test/resources/plugin-configs/no-files-plugin-config.xml
similarity index 90%
rename from src/test/plugin-configs/no-files-plugin-config.xml
rename to src/test/resources/plugin-configs/no-files-plugin-config.xml
index ad5e125..ce32b86 100644
--- a/src/test/plugin-configs/no-files-plugin-config.xml
+++ b/src/test/resources/plugin-configs/no-files-plugin-config.xml
@@ -18,12 +18,17 @@ under the License.
-->
<project>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>test</groupId>
+ <artifactId>test</artifactId>
+ <version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<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>
@@ -43,7 +48,7 @@ under the License.
<linkXRef>true</linkXRef>
<xrefLocation>${basedir}/target/site/xref</xrefLocation>
<xrefTestLocation>${basedir}/target/site/xref-test</xrefTestLocation>
- <encoding>UTF-8</encoding>
+ <inputEncoding>UTF-8</inputEncoding>
</configuration>
</plugin>
</plugins>
diff --git a/src/test/plugin-configs/no-rules-plugin-config.xml b/src/test/resources/plugin-configs/no-rules-plugin-config.xml
similarity index 90%
rename from src/test/plugin-configs/no-rules-plugin-config.xml
rename to src/test/resources/plugin-configs/no-rules-plugin-config.xml
index b189c75..899bc84 100644
--- a/src/test/plugin-configs/no-rules-plugin-config.xml
+++ b/src/test/resources/plugin-configs/no-rules-plugin-config.xml
@@ -18,12 +18,17 @@ under the License.
-->
<project>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>test</groupId>
+ <artifactId>test</artifactId>
+ <version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<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>
@@ -43,7 +48,7 @@ under the License.
<linkXRef>true</linkXRef>
<xrefLocation>${basedir}/target/site/xref</xrefLocation>
<xrefTestLocation>${basedir}/target/site/xref-test</xrefTestLocation>
- <encoding>UTF-8</encoding>
+ <inputEncoding>UTF-8</inputEncoding>
</configuration>
</plugin>
</plugins>
diff --git a/src/test/plugin-configs/no-severity-plugin-config.xml b/src/test/resources/plugin-configs/no-severity-plugin-config.xml
similarity index 90%
rename from src/test/plugin-configs/no-severity-plugin-config.xml
rename to src/test/resources/plugin-configs/no-severity-plugin-config.xml
index 91d5fae..416c9fc 100644
--- a/src/test/plugin-configs/no-severity-plugin-config.xml
+++ b/src/test/resources/plugin-configs/no-severity-plugin-config.xml
@@ -18,12 +18,17 @@ under the License.
-->
<project>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>test</groupId>
+ <artifactId>test</artifactId>
+ <version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<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>
@@ -43,7 +48,7 @@ under the License.
<linkXRef>true</linkXRef>
<xrefLocation>${basedir}/target/site/xref</xrefLocation>
<xrefTestLocation>${basedir}/target/site/xref-test</xrefTestLocation>
- <encoding>UTF-8</encoding>
+ <inputEncoding>UTF-8</inputEncoding>
</configuration>
</plugin>
</plugins>
diff --git a/src/test/plugin-configs/no-source-plugin-config.xml b/src/test/resources/plugin-configs/no-source-plugin-config.xml
similarity index 92%
rename from src/test/plugin-configs/no-source-plugin-config.xml
rename to src/test/resources/plugin-configs/no-source-plugin-config.xml
index 37a110e..fab7251 100644
--- a/src/test/plugin-configs/no-source-plugin-config.xml
+++ b/src/test/resources/plugin-configs/no-source-plugin-config.xml
@@ -18,6 +18,10 @@ under the License.
-->
<project>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>test</groupId>
+ <artifactId>test</artifactId>
+ <version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
@@ -43,7 +47,7 @@ under the License.
<linkXRef>true</linkXRef>
<xrefLocation>${basedir}/target/site/xref</xrefLocation>
<xrefTestLocation>${basedir}/target/site/xref-test</xrefTestLocation>
- <encoding>UTF-8</encoding>
+ <inputEncoding>UTF-8</inputEncoding>
</configuration>
</plugin>
</plugins>
diff --git a/src/test/plugin-configs/test-source-directory-plugin-config.xml b/src/test/resources/plugin-configs/test-source-directory-plugin-config.xml
similarity index 90%
rename from src/test/plugin-configs/test-source-directory-plugin-config.xml
rename to src/test/resources/plugin-configs/test-source-directory-plugin-config.xml
index 2f6defe..4678fa4 100644
--- a/src/test/plugin-configs/test-source-directory-plugin-config.xml
+++ b/src/test/resources/plugin-configs/test-source-directory-plugin-config.xml
@@ -18,12 +18,17 @@ under the License.
-->
<project>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>test</groupId>
+ <artifactId>test</artifactId>
+ <version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<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>
@@ -46,7 +51,7 @@ under the License.
<linkXRef>true</linkXRef>
<xrefLocation>${basedir}/target/site/xref</xrefLocation>
<xrefTestLocation>${basedir}/target/site/xref-test</xrefTestLocation>
- <encoding>UTF-8</encoding>
+ <inputEncoding>UTF-8</inputEncoding>
</configuration>
</plugin>
</plugins>
diff --git a/src/test/plugin-configs/useFile-plugin-config.xml b/src/test/resources/plugin-configs/useFile-plugin-config.xml
similarity index 90%
rename from src/test/plugin-configs/useFile-plugin-config.xml
rename to src/test/resources/plugin-configs/useFile-plugin-config.xml
index b488964..89e78b4 100644
--- a/src/test/plugin-configs/useFile-plugin-config.xml
+++ b/src/test/resources/plugin-configs/useFile-plugin-config.xml
@@ -18,12 +18,17 @@ under the License.
-->
<project>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>test</groupId>
+ <artifactId>test</artifactId>
+ <version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<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>
@@ -44,7 +49,7 @@ under the License.
<xrefLocation>${basedir}/target/site/xref</xrefLocation>
<xrefTestLocation>${basedir}/target/site/xref-test</xrefTestLocation>
<useFile>${basedir}/target/test-harness/checkstyle/useFile/checkstyle-output.txt</useFile>
- <encoding>UTF-8</encoding>
+ <inputEncoding>UTF-8</inputEncoding>
</configuration>
</plugin>
</plugins>