You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2014/04/12 11:53:40 UTC
svn commit: r1586844 - in /maven/plugins/trunk/maven-checkstyle-plugin: ./
src/it/MCHECKSTYLE-225-LICENSE.txt/
src/it/MCHECKSTYLE-225-LICENSE.txt/build-tools/
src/it/MCHECKSTYLE-225-LICENSE.txt/build-tools/src/
src/it/MCHECKSTYLE-225-LICENSE.txt/build-...
Author: rfscholte
Date: Sat Apr 12 09:53:39 2014
New Revision: 1586844
URL: http://svn.apache.org/r1586844
Log:
[MCHECKSTYLE-225] headerLocation no longer sets checkstyle.header.file
Added:
maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/ (with props)
maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/build-tools/ (with props)
maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/build-tools/pom.xml
maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/build-tools/src/ (with props)
maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/build-tools/src/main/ (with props)
maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/build-tools/src/main/resources/ (with props)
maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/build-tools/src/main/resources/LICENSE.txt
maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/core/ (with props)
maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/core/pom.xml
maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/invoker.properties
maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/pom.xml
maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/verify.groovy
maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-customHeader/
- copied from r1585828, maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225/
Removed:
maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225/
Modified:
maven/plugins/trunk/maven-checkstyle-plugin/pom.xml
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/CheckstyleExecutorRequest.java
maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleViolationCheckMojo.java
maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/DefaultCheckstyleExecutor.java
maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/CheckstyleReportTest.java
Modified: maven/plugins/trunk/maven-checkstyle-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/pom.xml?rev=1586844&r1=1586843&r2=1586844&view=diff
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-checkstyle-plugin/pom.xml Sat Apr 12 09:53:39 2014
@@ -94,6 +94,11 @@ under the License.
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-descriptor</artifactId>
+ <version>${mavenVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
<version>${mavenVersion}</version>
</dependency>
@@ -260,7 +265,8 @@ under the License.
These are license header templates.
-->
<exclude>src/main/resources/config/maven-header.txt</exclude>
- <exclude>src/it/MCHECKSTYLE-225/build-tools/src/main/resources/test/custom-header.txt</exclude>
+ <exclude>src/it/MCHECKSTYLE-225-customHeader/build-tools/src/main/resources/test/custom-header.txt</exclude>
+ <exclude>src/it/MCHECKSTYLE-225-LICENSE.txt/build-tools/src/main/resources/LICENSE.txt</exclude>
<!--
File from the Checkstyle distribution - do not add our own license header.
-->
Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/
------------------------------------------------------------------------------
--- bugtraq:logregex (added)
+++ bugtraq:logregex Sat Apr 12 09:53:39 2014
@@ -0,0 +1 @@
+MCHECKSTYLE-\d+
Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/
------------------------------------------------------------------------------
bugtraq:url = http://jira.codehaus.org/browse/%BUGID%
Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/build-tools/
------------------------------------------------------------------------------
--- bugtraq:logregex (added)
+++ bugtraq:logregex Sat Apr 12 09:53:39 2014
@@ -0,0 +1 @@
+MCHECKSTYLE-\d+
Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/build-tools/
------------------------------------------------------------------------------
bugtraq:url = http://jira.codehaus.org/browse/%BUGID%
Added: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/build-tools/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/build-tools/pom.xml?rev=1586844&view=auto
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/build-tools/pom.xml (added)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/build-tools/pom.xml Sat Apr 12 09:53:39 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-LICENSE.txt/build-tools/src/
------------------------------------------------------------------------------
--- bugtraq:logregex (added)
+++ bugtraq:logregex Sat Apr 12 09:53:39 2014
@@ -0,0 +1 @@
+MCHECKSTYLE-\d+
Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/build-tools/src/
------------------------------------------------------------------------------
bugtraq:url = http://jira.codehaus.org/browse/%BUGID%
Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/build-tools/src/main/
------------------------------------------------------------------------------
--- bugtraq:logregex (added)
+++ bugtraq:logregex Sat Apr 12 09:53:39 2014
@@ -0,0 +1 @@
+MCHECKSTYLE-\d+
Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/build-tools/src/main/
------------------------------------------------------------------------------
bugtraq:url = http://jira.codehaus.org/browse/%BUGID%
Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/build-tools/src/main/resources/
------------------------------------------------------------------------------
--- bugtraq:logregex (added)
+++ bugtraq:logregex Sat Apr 12 09:53:39 2014
@@ -0,0 +1 @@
+MCHECKSTYLE-\d+
Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/build-tools/src/main/resources/
------------------------------------------------------------------------------
bugtraq:url = http://jira.codehaus.org/browse/%BUGID%
Added: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/build-tools/src/main/resources/LICENSE.txt
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/build-tools/src/main/resources/LICENSE.txt?rev=1586844&view=auto
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/build-tools/src/main/resources/LICENSE.txt (added)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/build-tools/src/main/resources/LICENSE.txt Sat Apr 12 09:53:39 2014
@@ -0,0 +1 @@
+MCHECKSTYLE-225 CUSTOM LICENSE
\ No newline at end of file
Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/core/
------------------------------------------------------------------------------
--- bugtraq:logregex (added)
+++ bugtraq:logregex Sat Apr 12 09:53:39 2014
@@ -0,0 +1 @@
+MCHECKSTYLE-\d+
Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/core/
------------------------------------------------------------------------------
bugtraq:url = http://jira.codehaus.org/browse/%BUGID%
Added: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/core/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/core/pom.xml?rev=1586844&view=auto
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/core/pom.xml (added)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/core/pom.xml Sat Apr 12 09:53:39 2014
@@ -0,0 +1,58 @@
+<?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-core</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
+ <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>
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>mcheckstyle-225-build-tools</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>check</id>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/invoker.properties
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/invoker.properties?rev=1586844&view=auto
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/invoker.properties (added)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/invoker.properties Sat Apr 12 09:53:39 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-LICENSE.txt/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/pom.xml?rev=1586844&view=auto
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/pom.xml (added)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/pom.xml Sat Apr 12 09:53:39 2014
@@ -0,0 +1,35 @@
+<?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>
+
+ <modules>
+ <module>build-tools</module>
+ <module>core</module>
+ </modules>
+</project>
Added: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/verify.groovy
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/verify.groovy?rev=1586844&view=auto
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/verify.groovy (added)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-225-LICENSE.txt/verify.groovy Sat Apr 12 09:53:39 2014
@@ -0,0 +1,24 @@
+
+/*
+ * 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 'LICENSE.txt' was found" )
+
+def checkstyleHeader = new File( basedir, 'core/target/checkstyle-header.txt')
+assert checkstyleHeader.text == "MCHECKSTYLE-225 CUSTOM LICENSE"
\ No newline at end of file
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=1586844&r1=1586843&r2=1586844&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 Sat Apr 12 09:53:39 2014
@@ -19,16 +19,28 @@ 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.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.List;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import org.apache.maven.artifact.Artifact;
import org.apache.maven.doxia.siterenderer.Renderer;
import org.apache.maven.doxia.tools.SiteTool;
+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.checkstyle.rss.CheckstyleRssGenerator;
import org.apache.maven.plugin.checkstyle.rss.CheckstyleRssGeneratorRequest;
+import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
@@ -39,16 +51,10 @@ import org.codehaus.plexus.resource.load
import org.codehaus.plexus.util.PathTool;
import org.codehaus.plexus.util.StringUtils;
-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.util.Calendar;
-import java.util.List;
-import java.util.Locale;
-import java.util.ResourceBundle;
+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;
/**
* Base abstract class for Checkstyle reports.
@@ -366,8 +372,15 @@ public abstract class AbstractCheckstyle
/**
* The Maven Project Object.
*/
- @Component
+ @Parameter( defaultValue = "${project}" )
protected MavenProject project;
+
+
+ /**
+ * The Plugin Descriptor
+ */
+ @Parameter( defaultValue= "${plugin}" )
+ private PluginDescriptor plugin;
/**
* Link the violation line numbers to the source xref. Will link
@@ -469,7 +482,8 @@ public abstract class AbstractCheckstyle
try
{
- CheckstyleExecutorRequest request = createRequest();
+ CheckstyleExecutorRequest request = createRequest().setLicenseArtifacts( collectArtifacts( "license" ) )
+ .setConfigurationArtifacts( collectArtifacts( "configuration" ) );
CheckstyleResults results = checkstyleExecutor.executeCheckstyle( request );
@@ -508,6 +522,25 @@ public abstract class AbstractCheckstyle
protected abstract CheckstyleExecutorRequest createRequest()
throws MavenReportException;
+ private List<Artifact> collectArtifacts( String hint )
+ {
+ List<Artifact> artifacts = new ArrayList<Artifact>();
+
+ Plugin checkstylePlugin =
+ (Plugin) project.getBuild().getPluginsAsMap().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...
+ String depKey = dep.getGroupId() + ":" + dep.getArtifactId();
+ artifacts.add( (Artifact) plugin.getArtifactMap().get( depKey ) );
+ }
+ }
+
+ return artifacts;
+ }
+
/**
* Creates and returns the report generation listener.
*
@@ -689,4 +722,6 @@ public abstract class AbstractCheckstyle
super.setReportOutputDirectory( reportOutputDirectory );
this.outputDirectory = reportOutputDirectory;
}
+
+
}
Modified: maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleExecutorRequest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleExecutorRequest.java?rev=1586844&r1=1586843&r2=1586844&view=diff
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleExecutorRequest.java (original)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleExecutorRequest.java Sat Apr 12 09:53:39 2014
@@ -23,6 +23,7 @@ import java.io.ByteArrayOutputStream;
import java.io.File;
import java.util.List;
+import org.apache.maven.artifact.Artifact;
import org.apache.maven.model.Resource;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.project.MavenProject;
@@ -113,8 +114,18 @@ public class CheckstyleExecutorRequest
* @since 2.8
*/
private List<MavenProject> reactorProjects;
+
+ /**
+ * @since 2.12.1
+ */
+ private List<Artifact> licenseArtifacts;
/**
+ * @since 2.12.1
+ */
+ private List<Artifact> configurationArtifacts;
+
+ /**
* Constructor.
*/
public CheckstyleExecutorRequest( )
@@ -434,6 +445,50 @@ public class CheckstyleExecutorRequest
return this;
}
+ /**
+ * Returns a list of license artifacts, which may contain the license.
+ *
+ * @return the license artifacts
+ */
+ public List<Artifact> getLicenseArtifacts()
+ {
+ return licenseArtifacts;
+ }
+
+ /**
+ * Sets a list of license artifacts, which may contain the license.
+ *
+ * @param licenseArtifacts
+ * @return This object.
+ */
+ public CheckstyleExecutorRequest setLicenseArtifacts( List<Artifact> licenseArtifacts )
+ {
+ this.licenseArtifacts = licenseArtifacts;
+ return this;
+ }
+
+ /**
+ * Returns a list of artifacts, which may contain the checkstyle configuration.
+ *
+ * @return the license artifacts
+ */
+ public List<Artifact> getConfigurationArtifacts()
+ {
+ return configurationArtifacts;
+ }
+
+ /**
+ * Sets a list of artifacts, which may contain the checkstyle configuration.
+ *
+ * @param configArtifacts
+ * @return This object.
+ */
+ public CheckstyleExecutorRequest setConfigurationArtifacts( List<Artifact> configArtifacts )
+ {
+ this.configurationArtifacts = configArtifacts;
+ return this;
+ }
+
public boolean isIncludeResources()
{
return includeResources;
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=1586844&r1=1586843&r2=1586844&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 Sat Apr 12 09:53:39 2014
@@ -23,10 +23,15 @@ import com.puppycrawl.tools.checkstyle.D
import com.puppycrawl.tools.checkstyle.XMLLogger;
import com.puppycrawl.tools.checkstyle.api.AuditListener;
import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.model.Dependency;
+import org.apache.maven.model.Plugin;
import org.apache.maven.model.Resource;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
@@ -49,6 +54,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.Reader;
+import java.util.ArrayList;
import java.util.List;
/**
@@ -298,8 +304,14 @@ public class CheckstyleViolationCheckMoj
/**
* The Maven Project Object.
*/
- @Component
+ @Parameter ( defaultValue = "${project}" )
protected MavenProject project;
+
+ /**
+ * The Plugin Descriptor
+ */
+ @Parameter( defaultValue= "${plugin}" )
+ private PluginDescriptor plugin;
/**
* If <code>null</code>, the Checkstyle plugin will display violations on stdout.
@@ -468,7 +480,8 @@ public class CheckstyleViolationCheckMoj
.setResources( resources )
.setStringOutputStream( stringOutputStream ).setSuppressionsLocation( suppressionsLocation )
.setTestSourceDirectory( testSourceDirectory ).setConfigLocation( configLocation )
- .setPropertyExpansion( propertyExpansion ).setHeaderLocation( headerLocation )
+ .setConfigurationArtifacts( collectArtifacts( "config" ) ).setPropertyExpansion( propertyExpansion )
+ .setHeaderLocation( headerLocation ).setLicenseArtifacts( collectArtifacts( "license" ) )
.setCacheFile( cacheFile ).setSuppressionsFileExpression( suppressionsFileExpression )
.setEncoding( encoding ).setPropertiesLocation( propertiesLocation );
checkstyleExecutor.executeCheckstyle( request );
@@ -680,5 +693,24 @@ public class CheckstyleViolationCheckMoj
return listener;
}
+
+ private List<Artifact> collectArtifacts( String hint )
+ {
+ List<Artifact> artifacts = new ArrayList<Artifact>();
+
+ Plugin checkstylePlugin =
+ (Plugin) project.getBuild().getPluginsAsMap().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...
+ String depKey = dep.getGroupId() + ":" + dep.getArtifactId();
+ artifacts.add( (Artifact) plugin.getArtifactMap().get( depKey ) );
+ }
+ }
+
+ return artifacts;
+ }
}
Modified: maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/DefaultCheckstyleExecutor.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/DefaultCheckstyleExecutor.java?rev=1586844&r1=1586843&r2=1586844&view=diff
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/DefaultCheckstyleExecutor.java (original)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/DefaultCheckstyleExecutor.java Sat Apr 12 09:53:39 2014
@@ -33,6 +33,7 @@ import java.util.List;
import java.util.Properties;
import org.apache.commons.io.IOUtils;
+import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DependencyResolutionRequiredException;
import org.apache.maven.model.Resource;
import org.apache.maven.project.MavenProject;
@@ -92,9 +93,12 @@ public class DefaultCheckstyleExecutor
MavenProject project = request.getProject();
- configureResourceLocator( locator, request );
+ configureResourceLocator( locator, request, null );
- configureResourceLocator( licenseLocator, request );
+ configureResourceLocator( licenseLocator, request, request.getLicenseArtifacts() );
+
+ // Config is less critical than License, locator can still be used.
+ // configureResourceLocator( configurationLocator, request, request.getConfigurationArtifacts() );
File[] files;
try
@@ -699,7 +703,8 @@ public class DefaultCheckstyleExecutor
* @param request executor request data.
*/
private void configureResourceLocator( final ResourceManager resourceManager,
- final CheckstyleExecutorRequest request )
+ final CheckstyleExecutorRequest request,
+ final List<Artifact> additionalArtifacts )
{
final MavenProject project = request.getProject();
resourceManager.setOutputDirectory( new File( project.getBuild().getDirectory() ) );
@@ -715,7 +720,22 @@ public class DefaultCheckstyleExecutor
resourceManager.addSearchPath( FileResourceLoader.ID, dir.getAbsolutePath() );
parent = parent.getParent();
}
-
resourceManager.addSearchPath( "url", "" );
+
+ // MCHECKSTYLE-225: load licenses from additional artifacts, not from classpath
+ if ( additionalArtifacts != null )
+ {
+ for ( Artifact licenseArtifact : additionalArtifacts )
+ {
+ try
+ {
+ resourceManager.addSearchPath( "jar", "jar:" + licenseArtifact.getFile().toURI().toURL() );
+ }
+ catch ( MalformedURLException e )
+ {
+ // noop
+ }
+ }
+ }
}
}
Modified: maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/CheckstyleReportTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/CheckstyleReportTest.java?rev=1586844&r1=1586843&r2=1586844&view=diff
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/CheckstyleReportTest.java (original)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/CheckstyleReportTest.java Sat Apr 12 09:53:39 2014
@@ -26,10 +26,12 @@ 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;
@@ -167,6 +169,11 @@ public class CheckstyleReportTest
CheckstyleReport mojo = (CheckstyleReport) lookupMojo( "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();