[
https://issues.apache.org/jira/browse/MCHECKSTYLE-432?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17713284#comment-17713284
]
Michael Osipov commented on MCHECKSTYLE-432:
--------------------------------------------
Tested your sample project, thank you. Discovered a bug in MSITE which I will
fix, though it does not affect this issue.
I think that your fix addresses only a symptom, not the cause. Look at this
screenshot:
!screenshot-1.png!
All mojos of the plugin are marked as thread safe, yet this parameter is
modified in flight. Therefore, the value is broken/modified. This is wrong. A
proper fix would rewrite the code in such a way {{configLocation}} is *never*
touched. Why is this visible now? Same mojo instance is used multiple times for
multiple locales.
Here is a better patch:
{noformat}
D:\Entwicklung\Projekte\maven-checkstyle-plugin [doxia-2.0.0 ≡ +0 ~4 -0 !]> git
diff -U0
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 d11ac18..d6aa3de 100644
---
a/src/main/java/org/apache/maven/plugins/checkstyle/AbstractCheckstyleReport.java
+++
b/src/main/java/org/apache/maven/plugins/checkstyle/AbstractCheckstyleReport.java
@@ -483,0 +484 @@ public abstract class AbstractCheckstyleReport
+ String effectiveConfigLocation = configLocation;
@@ -506 +507 @@ public abstract class AbstractCheckstyleReport
- configLocation = rulesFiles.getAbsolutePath();
+ effectiveConfigLocation = rulesFiles.getAbsolutePath();
@@ -514 +515,2 @@ public abstract class AbstractCheckstyleReport
- .setOmitIgnoredModules( omitIgnoredModules );
+ .setOmitIgnoredModules( omitIgnoredModules )
+ .setConfigLocation( effectiveConfigLocation );
@@ -519 +521 @@ public abstract class AbstractCheckstyleReport
- generateMainReport( results, bundle );
+ generateMainReport( results, bundle, effectiveConfigLocation );
@@ -672 +674 @@ public abstract class AbstractCheckstyleReport
- private void generateMainReport( CheckstyleResults results, ResourceBundle
bundle )
+ private void generateMainReport( CheckstyleResults results, ResourceBundle
bundle, String configLocation )
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 f74b58e..28e1577 100644
---
a/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleAggregateReport.java
+++
b/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleAggregateReport.java
@@ -58 +58 @@ public class CheckstyleAggregateReport
- .setTestSourceDirectories( getTestSourceDirectories()
).setConfigLocation( configLocation )
+ .setTestSourceDirectories( getTestSourceDirectories() )
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 d7af430..517878c 100644
--- a/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleReport.java
+++ b/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleReport.java
@@ -62 +62 @@ public class CheckstyleReport
- .setTestSourceDirectories( getTestSourceDirectories()
).setConfigLocation( configLocation )
+ .setTestSourceDirectories( getTestSourceDirectories() )
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 d2bb6d0..b3e8cc4 100644
---
a/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleViolationCheckMojo.java
+++
b/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleViolationCheckMojo.java
@@ -496,0 +497 @@ public class CheckstyleViolationCheckMojo
+ String effectiveConfigLocation = configLocation;
@@ -520 +521 @@ public class CheckstyleViolationCheckMojo
- configLocation = rulesFiles.getAbsolutePath();
+ effectiveConfigLocation = rulesFiles.getAbsolutePath();
@@ -538 +539 @@ public class CheckstyleViolationCheckMojo
- .setTestSourceDirectories( getTestSourceDirectories()
).setConfigLocation( configLocation )
+ .setTestSourceDirectories( getTestSourceDirectories()
).setConfigLocation( effectiveConfigLocation )
{noformat}
Let know what you think!
> Inline configuration does not work when creating site reports with multiple
> locales
> -----------------------------------------------------------------------------------
>
> Key: MCHECKSTYLE-432
> URL: https://issues.apache.org/jira/browse/MCHECKSTYLE-432
> Project: Maven Checkstyle Plugin
> Issue Type: Bug
> Affects Versions: 3.2.1
> Reporter: Peter Lamby
> Priority: Minor
> Attachments: screenshot-1.png
>
>
> The AbstractCheckstyleReport is called multiple times when generating a Site
> with more than one locale.
> Due to how we handle the check for inlineConfigurations the following
> Exception is thrown even tough the configuration is corrrect
> {noformat}
> [ERROR] Failed to execute goal
> org.apache.maven.plugins:maven-site-plugin:4.0.0-M6:site (default-site) on
> project so-dirty: Error generating maven-checkstyle-plugin:3.2.1:checkstyle
> report: If you use inline configuration for rules, don't specify a
> configLocation -> [Help 1]
> org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute
> goal org.apache.maven.plugins:maven-site-plugin:4.0.0-M6:site (default-site)
> on project so-dirty: Error generating
> maven-checkstyle-plugin:3.2.1:checkstyle report
> at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2
> (MojoExecutor.java:375)
> at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute
> (MojoExecutor.java:351)
> at org.apache.maven.lifecycle.internal.MojoExecutor.execute
> (MojoExecutor.java:215)
> at org.apache.maven.lifecycle.internal.MojoExecutor.execute
> (MojoExecutor.java:171)
> at org.apache.maven.lifecycle.internal.MojoExecutor.execute
> (MojoExecutor.java:163)
> at
> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject
> (LifecycleModuleBuilder.java:117)
> at
> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject
> (LifecycleModuleBuilder.java:81)
> at
> org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build
> (SingleThreadedBuilder.java:56)
> at org.apache.maven.lifecycle.internal.LifecycleStarter.execute
> (LifecycleStarter.java:128)
> at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:298)
> at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
> at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
> at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
> at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
> at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
> at jdk.internal.reflect.DirectMethodHandleAccessor.invoke
> (DirectMethodHandleAccessor.java:104)
> at java.lang.reflect.Method.invoke (Method.java:578)
> at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced
> (Launcher.java:282)
> at org.codehaus.plexus.classworlds.launcher.Launcher.launch
> (Launcher.java:225)
> at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode
> (Launcher.java:406)
> at org.codehaus.plexus.classworlds.launcher.Launcher.main
> (Launcher.java:347)
> Caused by: org.apache.maven.plugin.MojoExecutionException: Error generating
> maven-checkstyle-plugin:3.2.1:checkstyle report
> at org.apache.maven.plugins.site.render.SiteMojo.execute
> (SiteMojo.java:128)
> at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo
> (DefaultBuildPluginManager.java:137)
> at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2
> (MojoExecutor.java:370)
> at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute
> (MojoExecutor.java:351)
> at org.apache.maven.lifecycle.internal.MojoExecutor.execute
> (MojoExecutor.java:215)
> at org.apache.maven.lifecycle.internal.MojoExecutor.execute
> (MojoExecutor.java:171)
> at org.apache.maven.lifecycle.internal.MojoExecutor.execute
> (MojoExecutor.java:163)
> at
> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject
> (LifecycleModuleBuilder.java:117)
> at
> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject
> (LifecycleModuleBuilder.java:81)
> at
> org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build
> (SingleThreadedBuilder.java:56)
> at org.apache.maven.lifecycle.internal.LifecycleStarter.execute
> (LifecycleStarter.java:128)
> at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:298)
> at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
> at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
> at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
> at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
> at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
> at jdk.internal.reflect.DirectMethodHandleAccessor.invoke
> (DirectMethodHandleAccessor.java:104)
> at java.lang.reflect.Method.invoke (Method.java:578)
> at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced
> (Launcher.java:282)
> at org.codehaus.plexus.classworlds.launcher.Launcher.launch
> (Launcher.java:225)
> at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode
> (Launcher.java:406)
> at org.codehaus.plexus.classworlds.launcher.Launcher.main
> (Launcher.java:347)
> Caused by: org.apache.maven.reporting.MavenReportException: If you use inline
> configuration for rules, don't specify a configLocation
> at
> org.apache.maven.plugins.checkstyle.AbstractCheckstyleReport.executeReport
> (AbstractCheckstyleReport.java:500)
> at org.apache.maven.reporting.AbstractMavenReport.generate
> (AbstractMavenReport.java:289)
> at
> org.apache.maven.plugins.site.render.ReportDocumentRenderer.renderDocument
> (ReportDocumentRenderer.java:200)
> at org.apache.maven.doxia.siterenderer.DefaultSiteRenderer.render
> (DefaultSiteRenderer.java:299)
> at org.apache.maven.plugins.site.render.SiteMojo.renderLocale
> (SiteMojo.java:167)
> at org.apache.maven.plugins.site.render.SiteMojo.execute
> (SiteMojo.java:123)
> at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo
> (DefaultBuildPluginManager.java:137)
> at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2
> (MojoExecutor.java:370)
> at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute
> (MojoExecutor.java:351)
> at org.apache.maven.lifecycle.internal.MojoExecutor.execute
> (MojoExecutor.java:215)
> at org.apache.maven.lifecycle.internal.MojoExecutor.execute
> (MojoExecutor.java:171)
> at org.apache.maven.lifecycle.internal.MojoExecutor.execute
> (MojoExecutor.java:163)
> at
> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject
> (LifecycleModuleBuilder.java:117)
> at
> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject
> (LifecycleModuleBuilder.java:81)
> at
> org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build
> (SingleThreadedBuilder.java:56)
> at org.apache.maven.lifecycle.internal.LifecycleStarter.execute
> (LifecycleStarter.java:128)
> at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:298)
> at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
> at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
> at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
> at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
> at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
> at jdk.internal.reflect.DirectMethodHandleAccessor.invoke
> (DirectMethodHandleAccessor.java:104)
> at java.lang.reflect.Method.invoke (Method.java:578)
> at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced
> (Launcher.java:282)
> at org.codehaus.plexus.classworlds.launcher.Launcher.launch
> (Launcher.java:225)
> at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode
> (Launcher.java:406)
> at org.codehaus.plexus.classworlds.launcher.Launcher.main
> (Launcher.java:347){noformat}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)