Author: rfscholte Date: Thu Apr 24 19:29:37 2014 New Revision: 1589845 URL: http://svn.apache.org/r1589845 Log: MCHECKSTYLE-225: headerLocation no longer sets checkstyle.header.file also verify pluginManagement for dependencies. mark plugin and mojoExecution as readonly
Added: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/ (with props) maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/build-tools/ (with props) maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/build-tools/pom.xml maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/build-tools/src/ (with props) maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/build-tools/src/main/ (with props) maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/build-tools/src/main/resources/ (with props) maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/build-tools/src/main/resources/test/ (with props) maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/build-tools/src/main/resources/test/custom-header.txt maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/core/ (with props) maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/core/pom.xml maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/invoker.properties maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/pom.xml maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/verify.groovy Modified: maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/AbstractCheckstyleReport.java maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleViolationCheckMojo.java Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/ ------------------------------------------------------------------------------ --- bugtraq:logregex (added) +++ bugtraq:logregex Thu Apr 24 19:29:37 2014 @@ -0,0 +1 @@ +MCHECKSTYLE-\d+ Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/ ------------------------------------------------------------------------------ bugtraq:url = http://jira.codehaus.org/browse/%BUGID% Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/build-tools/ ------------------------------------------------------------------------------ --- bugtraq:logregex (added) +++ bugtraq:logregex Thu Apr 24 19:29:37 2014 @@ -0,0 +1 @@ +MCHECKSTYLE-\d+ Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/build-tools/ ------------------------------------------------------------------------------ bugtraq:url = http://jira.codehaus.org/browse/%BUGID% Added: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/build-tools/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/build-tools/pom.xml?rev=1589845&view=auto ============================================================================== --- maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/build-tools/pom.xml (added) +++ maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/build-tools/pom.xml Thu Apr 24 19:29:37 2014 @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you under the Apache License, Version 2.0 (the + ~ "License"); you may not use this file except in compliance + ~ with the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, + ~ software distributed under the License is distributed on an + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ~ KIND, either express or implied. See the License for the + ~ specific language governing permissions and limitations + ~ under the License. + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.maven.plugins.checkstyle</groupId> + <artifactId>mcheckstyle-225-build-tools</artifactId> + <version>1.0-SNAPSHOT</version> +</project> Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/build-tools/src/ ------------------------------------------------------------------------------ --- bugtraq:logregex (added) +++ bugtraq:logregex Thu Apr 24 19:29:37 2014 @@ -0,0 +1 @@ +MCHECKSTYLE-\d+ Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/build-tools/src/ ------------------------------------------------------------------------------ bugtraq:url = http://jira.codehaus.org/browse/%BUGID% Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/build-tools/src/main/ ------------------------------------------------------------------------------ --- bugtraq:logregex (added) +++ bugtraq:logregex Thu Apr 24 19:29:37 2014 @@ -0,0 +1 @@ +MCHECKSTYLE-\d+ Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/build-tools/src/main/ ------------------------------------------------------------------------------ bugtraq:url = http://jira.codehaus.org/browse/%BUGID% Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/build-tools/src/main/resources/ ------------------------------------------------------------------------------ --- bugtraq:logregex (added) +++ bugtraq:logregex Thu Apr 24 19:29:37 2014 @@ -0,0 +1 @@ +MCHECKSTYLE-\d+ Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/build-tools/src/main/resources/ ------------------------------------------------------------------------------ bugtraq:url = http://jira.codehaus.org/browse/%BUGID% Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/build-tools/src/main/resources/test/ ------------------------------------------------------------------------------ --- bugtraq:logregex (added) +++ bugtraq:logregex Thu Apr 24 19:29:37 2014 @@ -0,0 +1 @@ +MCHECKSTYLE-\d+ Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/build-tools/src/main/resources/test/ ------------------------------------------------------------------------------ bugtraq:url = http://jira.codehaus.org/browse/%BUGID% Added: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/build-tools/src/main/resources/test/custom-header.txt URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/build-tools/src/main/resources/test/custom-header.txt?rev=1589845&view=auto ============================================================================== --- maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/build-tools/src/main/resources/test/custom-header.txt (added) +++ maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/build-tools/src/main/resources/test/custom-header.txt Thu Apr 24 19:29:37 2014 @@ -0,0 +1 @@ +This is a custom header file. \ No newline at end of file Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/core/ ------------------------------------------------------------------------------ --- bugtraq:logregex (added) +++ bugtraq:logregex Thu Apr 24 19:29:37 2014 @@ -0,0 +1 @@ +MCHECKSTYLE-\d+ Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/core/ ------------------------------------------------------------------------------ bugtraq:url = http://jira.codehaus.org/browse/%BUGID% Added: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/core/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/core/pom.xml?rev=1589845&view=auto ============================================================================== --- maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/core/pom.xml (added) +++ maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/core/pom.xml Thu Apr 24 19:29:37 2014 @@ -0,0 +1,57 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you under the Apache License, Version 2.0 (the + ~ "License"); you may not use this file except in compliance + ~ with the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, + ~ software distributed under the License is distributed on an + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ~ KIND, either express or implied. See the License for the + ~ specific language governing permissions and limitations + ~ under the License. + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.maven.plugins.checkstyle</groupId> + <artifactId>mcheckstyle-225</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + <artifactId>mcheckstyle-225-core</artifactId> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-checkstyle-plugin</artifactId> + <version>@pom.version@</version> + <executions> + <execution> + <id>check</id> + <goals> + <goal>check</goal> + </goals> + </execution> + </executions> + <configuration> + <headerLocation>test/custom-header.txt</headerLocation> + </configuration> + </plugin> + </plugins> + </build> +</project> Added: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/invoker.properties URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/invoker.properties?rev=1589845&view=auto ============================================================================== --- maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/invoker.properties (added) +++ maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/invoker.properties Thu Apr 24 19:29:37 2014 @@ -0,0 +1,19 @@ +# 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. + +invoker.goals = verify +invoker.debug = true \ No newline at end of file Added: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/pom.xml?rev=1589845&view=auto ============================================================================== --- maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/pom.xml (added) +++ maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/pom.xml Thu Apr 24 19:29:37 2014 @@ -0,0 +1,46 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- ~ Licensed to the Apache Software Foundation (ASF) under one ~ or more + contributor license agreements. See the NOTICE file ~ distributed with this + work for additional information ~ regarding copyright ownership. The ASF + licenses this file ~ to you under the Apache License, Version 2.0 (the ~ + "License"); you may not use this file except in compliance ~ with the License. + You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ ~ Unless required by applicable law or agreed to in writing, ~ software + distributed under the License is distributed on an ~ "AS IS" BASIS, WITHOUT + WARRANTIES OR CONDITIONS OF ANY ~ KIND, either express or implied. See the + License for the ~ specific language governing permissions and limitations + ~ under the License. --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.maven.plugins.checkstyle</groupId> + <artifactId>mcheckstyle-225</artifactId> + <version>1.0-SNAPSHOT</version> + <packaging>pom</packaging> + + <build> + <pluginManagement> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-checkstyle-plugin</artifactId> + <version>@pom.version@</version> + <dependencies> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>mcheckstyle-225-build-tools</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + </plugin> + </plugins> + </pluginManagement> + </build> + + <modules> + <module>build-tools</module> + <module>core</module> + </modules> +</project> Added: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/verify.groovy URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/verify.groovy?rev=1589845&view=auto ============================================================================== --- maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/verify.groovy (added) +++ maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-pluginManagement/verify.groovy Thu Apr 24 19:29:37 2014 @@ -0,0 +1,22 @@ + +/* + * 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. + */ +def buildLog = new File( basedir, 'build.log' ) + +assert buildLog.text.contains( "The resource 'test/custom-header.txt' was found" ) Modified: maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/AbstractCheckstyleReport.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/AbstractCheckstyleReport.java?rev=1589845&r1=1589844&r2=1589845&view=diff ============================================================================== --- maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/AbstractCheckstyleReport.java (original) +++ maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/AbstractCheckstyleReport.java Thu Apr 24 19:29:37 2014 @@ -29,6 +29,7 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.List; import java.util.Locale; +import java.util.Map; import java.util.ResourceBundle; import org.apache.maven.artifact.Artifact; @@ -38,6 +39,7 @@ import org.apache.maven.model.Dependency import org.apache.maven.model.Plugin; import org.apache.maven.model.ReportPlugin; import org.apache.maven.model.Resource; +import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.checkstyle.rss.CheckstyleRssGenerator; import org.apache.maven.plugin.checkstyle.rss.CheckstyleRssGeneratorRequest; import org.apache.maven.plugin.descriptor.PluginDescriptor; @@ -379,9 +381,13 @@ public abstract class AbstractCheckstyle /** * The Plugin Descriptor */ - @Parameter( defaultValue= "${plugin}" ) + @Parameter( defaultValue= "${plugin}", readonly = true ) private PluginDescriptor plugin; + // remove when requiring Maven 3.x, just use #plugin + @Parameter( defaultValue= "${mojoExecution}", readonly = true ) + private MojoExecution mojoExecution; + /** * Link the violation line numbers to the source xref. Will link * automatically if Maven JXR plugin is being used. @@ -522,12 +528,32 @@ public abstract class AbstractCheckstyle protected abstract CheckstyleExecutorRequest createRequest() throws MavenReportException; + @SuppressWarnings( "unchecked" ) private List<Artifact> collectArtifacts( String hint ) { + if ( plugin == null || plugin.getGroupId() == null ) + { + // Maven 2.x workaround + plugin = mojoExecution.getMojoDescriptor().getPluginDescriptor(); + } + List<Artifact> artifacts = new ArrayList<Artifact>(); - Plugin checkstylePlugin = - (Plugin) project.getBuild().getPluginsAsMap().get( plugin.getGroupId() + ":" + plugin.getArtifactId() ); + if ( project.getBuild().getPluginManagement() != null ) + { + artifacts.addAll( getCheckstylePluginDependenciesAsArtifacts( project.getBuild().getPluginManagement().getPluginsAsMap(), hint ) ); + } + + artifacts.addAll( getCheckstylePluginDependenciesAsArtifacts( project.getBuild().getPluginsAsMap(), hint ) ); + + return artifacts; + } + + private List<Artifact> getCheckstylePluginDependenciesAsArtifacts( Map<String, Plugin> plugins, String hint ) + { + List<Artifact> artifacts = new ArrayList<Artifact>(); + + Plugin checkstylePlugin = plugins.get( plugin.getGroupId() + ":" + plugin.getArtifactId() ); if ( checkstylePlugin != null ) { for ( Dependency dep : checkstylePlugin.getDependencies() ) @@ -537,10 +563,9 @@ public abstract class AbstractCheckstyle artifacts.add( (Artifact) plugin.getArtifactMap().get( depKey ) ); } } - return artifacts; } - + /** * Creates and returns the report generation listener. * Modified: maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleViolationCheckMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleViolationCheckMojo.java?rev=1589845&r1=1589844&r2=1589845&view=diff ============================================================================== --- maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleViolationCheckMojo.java (original) +++ maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleViolationCheckMojo.java Thu Apr 24 19:29:37 2014 @@ -19,10 +19,17 @@ package org.apache.maven.plugin.checksty * under the License. */ -import com.puppycrawl.tools.checkstyle.DefaultLogger; -import com.puppycrawl.tools.checkstyle.XMLLogger; -import com.puppycrawl.tools.checkstyle.api.AuditListener; -import com.puppycrawl.tools.checkstyle.api.CheckstyleException; +import java.io.BufferedReader; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.io.Reader; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; import org.apache.maven.artifact.Artifact; import org.apache.maven.model.Dependency; @@ -47,16 +54,10 @@ import org.codehaus.plexus.util.xml.pull import org.codehaus.plexus.util.xml.pull.XmlPullParser; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; -import java.io.BufferedReader; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.io.Reader; -import java.util.ArrayList; -import java.util.List; +import com.puppycrawl.tools.checkstyle.DefaultLogger; +import com.puppycrawl.tools.checkstyle.XMLLogger; +import com.puppycrawl.tools.checkstyle.api.AuditListener; +import com.puppycrawl.tools.checkstyle.api.CheckstyleException; /** * Performs Checkstyle analysis and outputs violations or a count of violations @@ -311,11 +312,11 @@ public class CheckstyleViolationCheckMoj /** * The Plugin Descriptor */ - @Parameter( defaultValue= "${plugin}" ) + @Parameter( defaultValue= "${plugin}", readonly = true ) private PluginDescriptor plugin; // remove when requiring Maven 3.x, just use #plugin - @Parameter( defaultValue= "${mojoExecution}" ) + @Parameter( defaultValue= "${mojoExecution}", readonly = true ) private MojoExecution mojoExecution; /** @@ -699,6 +700,7 @@ public class CheckstyleViolationCheckMoj return listener; } + @SuppressWarnings( "unchecked" ) private List<Artifact> collectArtifacts( String hint ) { if ( plugin == null || plugin.getGroupId() == null ) @@ -709,19 +711,31 @@ public class CheckstyleViolationCheckMoj List<Artifact> artifacts = new ArrayList<Artifact>(); - Plugin checkstylePlugin = - (Plugin) project.getBuild().getPluginsAsMap().get( plugin.getGroupId() + ":" + plugin.getArtifactId() ); + if ( project.getBuild().getPluginManagement() != null ) + { + artifacts.addAll( getCheckstylePluginDependenciesAsArtifacts( project.getBuild().getPluginManagement().getPluginsAsMap(), hint ) ); + } + + artifacts.addAll( getCheckstylePluginDependenciesAsArtifacts( project.getBuild().getPluginsAsMap(), hint ) ); + + return artifacts; + } + + private List<Artifact> getCheckstylePluginDependenciesAsArtifacts( Map<String, Plugin> plugins, String hint ) + { + List<Artifact> artifacts = new ArrayList<Artifact>(); + + Plugin checkstylePlugin = plugins.get( plugin.getGroupId() + ":" + plugin.getArtifactId() ); if ( checkstylePlugin != null ) { for ( Dependency dep : checkstylePlugin.getDependencies() ) { - // @todo if we can filter on hints, it should be done here... + // @todo if we can filter on hints, it should be done here... String depKey = dep.getGroupId() + ":" + dep.getArtifactId(); artifacts.add( (Artifact) plugin.getArtifactMap().get( depKey ) ); } } - return artifacts; } - + }