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 2024/08/16 17:37:18 UTC
(maven-checkstyle-plugin) 01/02: [MCHECKSTYLE-445] Upgrade to Doxia 2.0.0 Milestone Stack
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 a03c6bdaddf83eef9a1ce48434e51a6d3a78b348
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Sat Dec 3 00:59:34 2022 +0100
[MCHECKSTYLE-445] Upgrade to Doxia 2.0.0 Milestone Stack
This closes #114
---
pom.xml | 12 +++---
src/it/MCHECKSTYLE-222-resources/verify.groovy | 2 +-
src/it/MCHECKSTYLE-222-testResources/verify.groovy | 2 +-
src/it/MCHECKSTYLE-338/verify.groovy | 4 +-
.../MCHECKSTYLE-412/src/main/java/org/MyClass.java | 26 ------------
.../verify.groovy | 8 ++--
src/it/MCHECKSTYLE-99/verify.groovy | 8 ++--
src/it/checkstyle-goal/verify.groovy | 2 +-
.../checkstyle/AbstractCheckstyleReport.java | 9 ++++
.../checkstyle/CheckstyleAggregateReport.java | 17 --------
.../maven/plugins/checkstyle/CheckstyleReport.java | 7 ----
.../checkstyle/AbstractCheckstyleTestCase.java | 49 +++++++++++++++-------
.../plugins/checkstyle/CheckstyleReportTest.java | 20 +++++----
.../checkstyle/stubs/CheckstyleProjectStub.java | 23 ++++++++++
.../checkstyle/stubs/MinMavenProjectStub.java | 17 ++++----
.../checkstyle/stubs/ModuleMavenProjectStub.java | 21 ++++------
.../checkstyle/stubs/MultiMavenProjectStub.java | 11 ++---
.../plugin-configs/custom-plugin-config.xml | 1 -
.../dep-resolution-exception-plugin-config.xml | 1 -
.../resources/plugin-configs/min-plugin-config.xml | 1 -
.../plugin-configs/no-files-plugin-config.xml | 1 -
.../plugin-configs/no-rules-plugin-config.xml | 1 -
.../plugin-configs/no-severity-plugin-config.xml | 1 -
.../test-source-directory-plugin-config.xml | 1 -
.../plugin-configs/useFile-plugin-config.xml | 1 -
25 files changed, 116 insertions(+), 130 deletions(-)
diff --git a/pom.xml b/pom.xml
index 3d0abfb..d346ad3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -78,10 +78,10 @@ under the License.
<resolverVersion>1.4.1</resolverVersion>
<checkstyleVersion>9.3</checkstyleVersion>
<slf4jVersion>1.7.36</slf4jVersion>
- <doxiaVersion>1.11.1</doxiaVersion>
- <doxiaSitetoolsVersion>1.11.1</doxiaSitetoolsVersion>
- <sitePluginVersion>3.12.1</sitePluginVersion>
- <jxrPluginVersion>3.3.0</jxrPluginVersion>
+ <doxiaVersion>2.0.0-M12</doxiaVersion>
+ <doxiaSitetoolsVersion>2.0.0-M19</doxiaSitetoolsVersion>
+ <sitePluginVersion>4.0.0-M16</sitePluginVersion>
+ <jxrPluginVersion>3.4.0</jxrPluginVersion>
<project.build.outputTimestamp>2024-06-02T14:45:45Z</project.build.outputTimestamp>
</properties>
@@ -132,12 +132,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-M12</version>
</dependency>
<dependency>
<groupId>org.apache.maven.reporting</groupId>
<artifactId>maven-reporting-impl</artifactId>
- <version>3.2.0</version>
+ <version>4.0.0-M15</version>
</dependency>
<!-- doxia -->
diff --git a/src/it/MCHECKSTYLE-222-resources/verify.groovy b/src/it/MCHECKSTYLE-222-resources/verify.groovy
index db588b9..0d9ff04 100644
--- a/src/it/MCHECKSTYLE-222-resources/verify.groovy
+++ b/src/it/MCHECKSTYLE-222-resources/verify.groovy
@@ -17,6 +17,6 @@
* under the License.
*/
-assert new File(basedir, 'target/site/checkstyle.html').exists();
+assert new File(basedir, 'target/reports/checkstyle.html').exists();
return true;
diff --git a/src/it/MCHECKSTYLE-222-testResources/verify.groovy b/src/it/MCHECKSTYLE-222-testResources/verify.groovy
index db588b9..0d9ff04 100644
--- a/src/it/MCHECKSTYLE-222-testResources/verify.groovy
+++ b/src/it/MCHECKSTYLE-222-testResources/verify.groovy
@@ -17,6 +17,6 @@
* under the License.
*/
-assert new File(basedir, 'target/site/checkstyle.html').exists();
+assert new File(basedir, 'target/reports/checkstyle.html').exists();
return true;
diff --git a/src/it/MCHECKSTYLE-338/verify.groovy b/src/it/MCHECKSTYLE-338/verify.groovy
index 71b05da..6c606b9 100644
--- a/src/it/MCHECKSTYLE-338/verify.groovy
+++ b/src/it/MCHECKSTYLE-338/verify.groovy
@@ -25,7 +25,7 @@ assert buildLog.text.contains( 'EmptyLogging: EmptyLoggingCheck on file TestFals
assert !buildLog.text.contains( 'EmptyLogging: EmptyLoggingCheck on file TestTrue.java' )
// verify that the "checkstyle" goal does the same
-site = new File( basedir, 'omitignoredmodules-false/target/site/checkstyle.html' )
+site = new File( basedir, 'omitignoredmodules-false/target/reports/checkstyle.html' )
assert site.text.contains( 'EmptyLoggingCheck on file TestFalse.java' )
-site = new File( basedir, 'omitignoredmodules-true/target/site/checkstyle.html' )
+site = new File( basedir, 'omitignoredmodules-true/target/reports/checkstyle.html' )
assert !site.text.contains( 'EmptyLoggingCheck on file TestTrue.java' )
diff --git a/src/it/MCHECKSTYLE-412/src/main/java/org/MyClass.java b/src/it/MCHECKSTYLE-412/src/main/java/org/MyClass.java
deleted file mode 100644
index 1645c13..0000000
--- a/src/it/MCHECKSTYLE-412/src/main/java/org/MyClass.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package org;
-
-/*
- * 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.
- */
-
-/**
- * My class.
- */
-public class MyClass {
-}
diff --git a/src/it/MCHECKSTYLE-99-custom-xref-test-location/verify.groovy b/src/it/MCHECKSTYLE-99-custom-xref-test-location/verify.groovy
index c0e8435..e15f882 100644
--- a/src/it/MCHECKSTYLE-99-custom-xref-test-location/verify.groovy
+++ b/src/it/MCHECKSTYLE-99-custom-xref-test-location/verify.groovy
@@ -18,9 +18,9 @@
* under the License.
*/
-site = new File( basedir, 'target/site/checkstyle.html' )
-assert site.exists();
-assert site.text.contains( '<a href="./xref/com/example/App.html#L26">' )
-assert site.text.contains( '<a href="./custom-xref-test-location/com/example/AppTest.html#L32">' )
+report = new File( basedir, 'target/reports/checkstyle.html' )
+assert report.exists();
+assert report.text.contains( '<a href="./xref/com/example/App.html#L26">' )
+assert report.text.contains( '<a href="./custom-xref-test-location/com/example/AppTest.html#L32">' )
return true;
diff --git a/src/it/MCHECKSTYLE-99/verify.groovy b/src/it/MCHECKSTYLE-99/verify.groovy
index 1567552..fc04c77 100644
--- a/src/it/MCHECKSTYLE-99/verify.groovy
+++ b/src/it/MCHECKSTYLE-99/verify.groovy
@@ -18,9 +18,9 @@
* under the License.
*/
-site = new File( basedir, 'target/site/checkstyle.html' )
-assert site.exists();
-assert site.text.contains( '<a href="./xref/com/example/App.html#L26">' )
-assert site.text.contains( '<a href="./xref-test/com/example/AppTest.html#L32">' )
+report = new File( basedir, 'target/reports/checkstyle.html' )
+assert report.exists();
+assert report.text.contains( '<a href="./xref/com/example/App.html#L26">' )
+assert report.text.contains( '<a href="./xref-test/com/example/AppTest.html#L32">' )
return true;
diff --git a/src/it/checkstyle-goal/verify.groovy b/src/it/checkstyle-goal/verify.groovy
index 9cdc38c..22a61c4 100644
--- a/src/it/checkstyle-goal/verify.groovy
+++ b/src/it/checkstyle-goal/verify.groovy
@@ -24,7 +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();
-def html = new File( basedir, 'target/site/checkstyle.html' ).text;
+def html = new File( basedir, 'target/reports/checkstyle.html' ).text;
assert html.contains( '<meta charset="UTF-8" />' );
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 e86b6d9..23593ef 100644
--- a/src/main/java/org/apache/maven/plugins/checkstyle/AbstractCheckstyleReport.java
+++ b/src/main/java/org/apache/maven/plugins/checkstyle/AbstractCheckstyleReport.java
@@ -50,6 +50,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.project.MavenProject;
import org.apache.maven.reporting.AbstractMavenReport;
import org.apache.maven.reporting.MavenReportException;
import org.codehaus.plexus.configuration.PlexusConfiguration;
@@ -474,6 +475,14 @@ public abstract class AbstractCheckstyleReport extends AbstractMavenReport {
return i18n.getString("checkstyle-report", locale, "report.checkstyle." + key);
}
+ protected MavenProject getProject() {
+ return project;
+ }
+
+ protected List<MavenProject> getReactorProjects() {
+ return reactorProjects;
+ }
+
/** {@inheritDoc} */
public void executeReport(Locale locale) throws MavenReportException {
checkDeprecatedParameterUsage(sourceDirectory, "sourceDirectory", "sourceDirectories");
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 0419d28..232e248 100644
--- a/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleAggregateReport.java
+++ b/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleAggregateReport.java
@@ -18,13 +18,9 @@
*/
package org.apache.maven.plugins.checkstyle;
-import java.util.List;
-
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;
/**
@@ -40,19 +36,6 @@ import org.apache.maven.reporting.MavenReportException;
requiresDependencyResolution = ResolutionScope.COMPILE,
threadSafe = true)
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 15f16e0..ed575f4 100644
--- a/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleReport.java
+++ b/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleReport.java
@@ -25,7 +25,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;
/**
@@ -39,12 +38,6 @@ import org.apache.maven.reporting.MavenReportException;
*/
@Mojo(name = "checkstyle", requiresDependencyResolution = ResolutionScope.COMPILE, threadSafe = true)
public class CheckstyleReport extends AbstractCheckstyleReport {
-
- /** {@inheritDoc} */
- protected MavenProject getProject() {
- return project;
- }
-
/**
* {@inheritDoc}
*/
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 9db52c9..7aaa6fd 100644
--- a/src/test/java/org/apache/maven/plugins/checkstyle/AbstractCheckstyleTestCase.java
+++ b/src/test/java/org/apache/maven/plugins/checkstyle/AbstractCheckstyleTestCase.java
@@ -21,9 +21,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;
@@ -39,8 +44,6 @@ import org.eclipse.aether.repository.LocalRepository;
* Abstract class to test reports generation.
*/
public abstract class AbstractCheckstyleTestCase extends AbstractMojoTestCase {
- private Locale oldLocale;
-
private ArtifactStubFactory artifactStubFactory;
/**
@@ -53,21 +56,10 @@ public abstract class AbstractCheckstyleTestCase extends AbstractMojoTestCase {
// 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
*
@@ -121,8 +113,17 @@ public abstract class AbstractCheckstyleTestCase extends AbstractMojoTestCase {
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;
}
@@ -148,4 +149,22 @@ public abstract class AbstractCheckstyleTestCase extends AbstractMojoTestCase {
protected String readFile(File checkstyleTestDir, String fileName) throws IOException {
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 1326330..038839b 100644
--- a/src/test/java/org/apache/maven/plugins/checkstyle/CheckstyleReportTest.java
+++ b/src/test/java/org/apache/maven/plugins/checkstyle/CheckstyleReportTest.java
@@ -22,10 +22,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;
@@ -35,11 +35,8 @@ import org.codehaus.plexus.util.FileUtils;
*/
public class CheckstyleReportTest extends AbstractCheckstyleTestCase {
public void testNoSource() throws Exception {
- // clean up after earlier runs
- File report = new File("target/test-harness/checkstyle/no-source/checkstyle.html");
- report.delete();
- File generatedReport = generateReport("checkstyle", "no-source-plugin-config.xml");
- assertFalse(report + " exists", generatedReport.exists());
+ File generatedReport = generateReport(getGoal(), "no-source-plugin-config.xml");
+ assertFalse(FileUtils.fileExists(generatedReport.getAbsolutePath()));
}
public void testMinConfiguration() throws Exception {
@@ -117,9 +114,9 @@ public class CheckstyleReportTest extends AbstractCheckstyleTestCase {
private void generateReport(String pluginXml) throws Exception {
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);
+ CheckstyleReport mojo = createReportMojo(getGoal(), pluginXmlFile);
PluginDescriptor descriptorStub = new PluginDescriptor();
descriptorStub.setGroupId("org.apache.maven.plugins");
@@ -173,6 +170,11 @@ public class CheckstyleReportTest extends AbstractCheckstyleTestCase {
}
private static String getHtmlHeader(String s) {
- return ">" + s + "</h3>";
+ return ">" + s + "</h2>";
+ }
+
+ @Override
+ protected String getGoal() {
+ return "checkstyle";
}
}
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 82e3d04..f85404b 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
@@ -18,16 +18,34 @@
*/
package org.apache.maven.plugins.checkstyle.stubs;
+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() {
ArtifactRepository repository = new MavenArtifactRepository(
@@ -39,4 +57,9 @@ public abstract class CheckstyleProjectStub extends MavenProjectStub {
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 a9bb6ca..1dcaa0c 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
@@ -18,7 +18,6 @@
*/
package org.apache.maven.plugins.checkstyle.stubs;
-import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -41,19 +40,19 @@ public class MinMavenProjectStub extends CheckstyleProjectStub {
/** {@inheritDoc} */
public List<String> getTestClasspathElements() throws DependencyResolutionRequiredException {
List<String> list = new ArrayList<>(getCompileClasspathElements());
- list.add("target/test-classes");
+ list.add(getBasedir() + "/target/test-classes");
return list;
}
/** {@inheritDoc} */
public List<String> getCompileSourceRoots() {
- return Collections.singletonList("target/classes");
+ return Collections.singletonList(getBasedir() + "/target/classes");
}
/** {@inheritDoc} */
public List<String> getTestCompileSourceRoots() {
List<String> list = new ArrayList<>(getCompileSourceRoots());
- list.add("target/test-classes");
+ list.add(getBasedir() + "/target/test-classes");
return list;
}
@@ -84,15 +83,13 @@ public class MinMavenProjectStub extends CheckstyleProjectStub {
public Build getBuild() {
Build build = new Build();
- build.setDirectory("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 4279abf..4bc3136 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
@@ -18,7 +18,6 @@
*/
package org.apache.maven.plugins.checkstyle.stubs;
-import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -42,19 +41,19 @@ public class ModuleMavenProjectStub extends CheckstyleProjectStub {
/** {@inheritDoc} */
public List<String> getTestClasspathElements() throws DependencyResolutionRequiredException {
List<String> list = new ArrayList<>(getCompileClasspathElements());
- list.add("target/test-classes");
+ list.add(getBasedir() + "/target/test-classes");
return list;
}
/** {@inheritDoc} */
public List<String> getCompileSourceRoots() {
- return Collections.singletonList("target/classes");
+ return Collections.singletonList(getBasedir() + "/target/classes");
}
/** {@inheritDoc} */
public List<String> getTestCompileSourceRoots() {
List<String> list = new ArrayList<>(getCompileSourceRoots());
- list.add("target/test-classes");
+ list.add(getBasedir() + "/target/test-classes");
return list;
}
@@ -85,17 +84,15 @@ public class ModuleMavenProjectStub extends CheckstyleProjectStub {
public Build getBuild() {
Build build = new Build();
- build.setDirectory("target/test-harness/checkstyle/multi");
- build.setSourceDirectory("src/test/test-sources");
- build.setTestSourceDirectory("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 a0c5f94..20790ee 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
@@ -18,7 +18,6 @@
*/
package org.apache.maven.plugins.checkstyle.stubs;
-import java.io.File;
import java.util.Collections;
import java.util.List;
@@ -89,15 +88,13 @@ public class MultiMavenProjectStub extends CheckstyleProjectStub {
public Build getBuild() {
Build build = new Build();
- build.setDirectory("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 830a928..4d3703b 100644
--- a/src/test/resources/plugin-configs/custom-plugin-config.xml
+++ b/src/test/resources/plugin-configs/custom-plugin-config.xml
@@ -28,7 +28,6 @@ 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>
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 7d1c8cb..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,7 +24,6 @@ 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>
diff --git a/src/test/resources/plugin-configs/min-plugin-config.xml b/src/test/resources/plugin-configs/min-plugin-config.xml
index 1cb1e8e..b897fff 100644
--- a/src/test/resources/plugin-configs/min-plugin-config.xml
+++ b/src/test/resources/plugin-configs/min-plugin-config.xml
@@ -28,7 +28,6 @@ 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>
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 49061c7..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,7 +28,6 @@ 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>
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 a3795ed..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,7 +28,6 @@ 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>
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 fb785b1..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,7 +28,6 @@ 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>
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 9ca9d03..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,7 +28,6 @@ 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>
diff --git a/src/test/resources/plugin-configs/useFile-plugin-config.xml b/src/test/resources/plugin-configs/useFile-plugin-config.xml
index f78464d..acb5ba3 100644
--- a/src/test/resources/plugin-configs/useFile-plugin-config.xml
+++ b/src/test/resources/plugin-configs/useFile-plugin-config.xml
@@ -28,7 +28,6 @@ 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>