You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ad...@apache.org on 2016/10/01 10:09:20 UTC
svn commit: r1762994 - in /maven/plugins/trunk/maven-pmd-plugin/src:
it/MPMD-206-sourceDirectories-js/ it/MPMD-206-sourceDirectories-js/src/
it/MPMD-206-sourceDirectories-js/src/main/
it/MPMD-206-sourceDirectories-js/src/main/javascript/ main/java/org/...
Author: adangel
Date: Sat Oct 1 10:09:19 2016
New Revision: 1762994
URL: http://svn.apache.org/viewvc?rev=1762994&view=rev
Log:
[MPMD-212] Add documentation and IT for MPMD-206
Added:
maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-206-sourceDirectories-js/
maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-206-sourceDirectories-js/invoker.properties
maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-206-sourceDirectories-js/pom.xml
maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-206-sourceDirectories-js/src/
maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-206-sourceDirectories-js/src/main/
maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-206-sourceDirectories-js/src/main/javascript/
maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-206-sourceDirectories-js/src/main/javascript/PmdJsCheck.js
maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-206-sourceDirectories-js/verify.groovy
Modified:
maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/AbstractPmdReport.java
maven/plugins/trunk/maven-pmd-plugin/src/site/apt/examples/javascriptReport.apt.vm
maven/plugins/trunk/maven-pmd-plugin/src/site/apt/examples/jspReport.apt.vm
Added: maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-206-sourceDirectories-js/invoker.properties
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-206-sourceDirectories-js/invoker.properties?rev=1762994&view=auto
==============================================================================
--- maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-206-sourceDirectories-js/invoker.properties (added)
+++ maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-206-sourceDirectories-js/invoker.properties Sat Oct 1 10:09:19 2016
@@ -0,0 +1,18 @@
+# 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 = clean verify
Added: maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-206-sourceDirectories-js/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-206-sourceDirectories-js/pom.xml?rev=1762994&view=auto
==============================================================================
--- maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-206-sourceDirectories-js/pom.xml (added)
+++ maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-206-sourceDirectories-js/pom.xml Sat Oct 1 10:09:19 2016
@@ -0,0 +1,69 @@
+<?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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.plugin.pmd.its</groupId>
+ <artifactId>MPMD-206-pmd-sourceDirectories-js</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
+ <description>
+ Execute PMD for checking javascript.
+ </description>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-pmd-plugin</artifactId>
+ <version>@project.version@</version>
+ <configuration>
+ <language>javascript</language>
+ <rulesets>
+ <ruleset>ecmascript-basic</ruleset>
+ <ruleset>ecmascript-braces</ruleset>
+ <ruleset>ecmascript-unnecessary</ruleset>
+ </rulesets>
+ <includes>
+ <include>**/*.js</include>
+ </includes>
+ <compileSourceRoots>
+ <compileSourceRoot>src/main/javascript</compileSourceRoot>
+ </compileSourceRoots>
+ <printFailingErrors>true</printFailingErrors>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>verify</phase>
+ <goals>
+ <goal>pmd</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added: maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-206-sourceDirectories-js/src/main/javascript/PmdJsCheck.js
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-206-sourceDirectories-js/src/main/javascript/PmdJsCheck.js?rev=1762994&view=auto
==============================================================================
--- maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-206-sourceDirectories-js/src/main/javascript/PmdJsCheck.js (added)
+++ maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-206-sourceDirectories-js/src/main/javascript/PmdJsCheck.js Sat Oct 1 10:09:19 2016
@@ -0,0 +1,25 @@
+/*
+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.
+*/
+
+(function() {
+
+ var i = 1; // this semicolon should have been a comma
+ j = 2; // that's why "j" is now a global variable
+
+})();
\ No newline at end of file
Added: maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-206-sourceDirectories-js/verify.groovy
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-206-sourceDirectories-js/verify.groovy?rev=1762994&view=auto
==============================================================================
--- maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-206-sourceDirectories-js/verify.groovy (added)
+++ maven/plugins/trunk/maven-pmd-plugin/src/it/MPMD-206-sourceDirectories-js/verify.groovy Sat Oct 1 10:09:19 2016
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+
+File buildLog = new File( basedir, 'build.log' )
+assert buildLog.exists()
+
+File pmd = new File( basedir, 'target/pmd.xml' )
+assert pmd.exists()
+assert pmd.getText().contains("GlobalVariable")
Modified: maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/AbstractPmdReport.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/AbstractPmdReport.java?rev=1762994&r1=1762993&r2=1762994&view=diff
==============================================================================
--- maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/AbstractPmdReport.java (original)
+++ maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/AbstractPmdReport.java Sat Oct 1 10:09:19 2016
@@ -126,13 +126,17 @@ public abstract class AbstractPmdReport
private List<String> includes;
/**
- * The directories containing the sources to be compiled.
+ * Specifies the location of the source directories to be used for PMD.
+ * Defaults to <code>project.compileSourceRoots</code>.
+ * @since 3.5
*/
@Parameter( defaultValue = "${project.compileSourceRoots}" )
private List<String> compileSourceRoots;
/**
- * The directories containing the test-sources to be compiled.
+ * The directories containing the test-sources to be used for PMD.
+ * Defaults to <code>project.testCompileSourceRoots</code>
+ * @since 3.5
*/
@Parameter( defaultValue = "${project.testCompileSourceRoots}" )
private List<String> testSourceRoots;
@@ -306,6 +310,10 @@ public abstract class AbstractPmdReport
List<PmdFileInfo> directories = new ArrayList<>();
+ if ( null == compileSourceRoots )
+ {
+ compileSourceRoots = project.getCompileSourceRoots();
+ }
if ( compileSourceRoots != null )
{
for ( String root : compileSourceRoots )
@@ -317,7 +325,11 @@ public abstract class AbstractPmdReport
directories.add( new PmdFileInfo( project, sroot, sourceXref ) );
}
}
+ }
+ if ( null == testSourceRoots )
+ {
+ testSourceRoots = project.getTestCompileSourceRoots();
}
if ( includeTests )
{
Modified: maven/plugins/trunk/maven-pmd-plugin/src/site/apt/examples/javascriptReport.apt.vm
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/site/apt/examples/javascriptReport.apt.vm?rev=1762994&r1=1762993&r2=1762994&view=diff
==============================================================================
--- maven/plugins/trunk/maven-pmd-plugin/src/site/apt/examples/javascriptReport.apt.vm (original)
+++ maven/plugins/trunk/maven-pmd-plugin/src/site/apt/examples/javascriptReport.apt.vm Sat Oct 1 10:09:19 2016
@@ -33,36 +33,12 @@ Analyzing JavaScript Code
The example assumes that the JavaScript source code is stored in the subdirectory <<<src/main/javascript>>> and
enables three built-in rulesets (<basic>, <braces>, <unnecessary>).
- Note that you have to make sure that the build-helper-maven-plugin is executed, so that the additional source
- directory is actually added. To generate the site report, you can include e.g. the <generate-sources> phase:
-
- <<<mvn generate-sources site>>>
+ Note that you have to make sure that you configure <<<compileSourceRoots>>> and <<<includes>>>, so that
+ PMD finds the JavaScript files.
+-----+
<project>
...
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <version>1.7</version>
- <configuration>
- <sources>
- <source>${basedir}/src/main/javascript</source>
- </sources>
- </configuration>
- <executions>
- <execution>
- <goals>
- <goal>add-source</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
<reporting>
<plugins>
<plugin>
@@ -79,6 +55,9 @@ Analyzing JavaScript Code
<includes>
<include>**/*.js</include>
</includes>
+ <compileSourceRoots>
+ <compileSourceRoot>${basedir}/src/main/javascript</compileSourceRoot>
+ </compileSourceRoots>
</configuration>
</plugin>
</plugins>
Modified: maven/plugins/trunk/maven-pmd-plugin/src/site/apt/examples/jspReport.apt.vm
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/site/apt/examples/jspReport.apt.vm?rev=1762994&r1=1762993&r2=1762994&view=diff
==============================================================================
--- maven/plugins/trunk/maven-pmd-plugin/src/site/apt/examples/jspReport.apt.vm (original)
+++ maven/plugins/trunk/maven-pmd-plugin/src/site/apt/examples/jspReport.apt.vm Sat Oct 1 10:09:19 2016
@@ -33,36 +33,12 @@ Analyzing JSP Code
The example assumes that the JSP source code is stored in various subdirectories under the source directory
<<<src/main/webapp>>> and enables the built-in JSP ruleset (<basic>).
- Note that you have to make sure that the build-helper-maven-plugin is executed, so that the additional source
- directory is actually added. To generate the site report, you can include e.g. the <generate-sources> phase:
-
- <<<mvn generate-sources site>>>
+ Note that you have to make sure that you configure <<<compileSourceRoots>>> and <<<includes>>>, so that
+ PMD finds the JSP files.
+-----+
<project>
...
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <version>1.7</version>
- <configuration>
- <sources>
- <source>${basedir}/src/main/webapp</source>
- </sources>
- </configuration>
- <executions>
- <execution>
- <goals>
- <goal>add-source</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
<reporting>
<plugins>
<plugin>
@@ -77,6 +53,9 @@ Analyzing JSP Code
<includes>
<include>**/*.jsp</include>
</includes>
+ <compileSourceRoots>
+ <compileSourceRoot>${basedir}/src/main/webapp</compileSourceRoot>
+ </compileSourceRoots>
</configuration>
</plugin>
</plugins>