[MPMD-317] NoClassDefFoundError for provided classes
diff --git a/src/it/MPMD-317-auxclasspath-provided/invoker.properties b/src/it/MPMD-317-auxclasspath-provided/invoker.properties
new file mode 100644
index 0000000..85a3ada
--- /dev/null
+++ b/src/it/MPMD-317-auxclasspath-provided/invoker.properties
@@ -0,0 +1,21 @@
+# 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
+invoker.goals.2 = clean verify -Daggregate=true
+invoker.maven.version = 3+
+invoker.debug = true
diff --git a/src/it/MPMD-317-auxclasspath-provided/module-a/pom.xml b/src/it/MPMD-317-auxclasspath-provided/module-a/pom.xml
new file mode 100644
index 0000000..f53700f
--- /dev/null
+++ b/src/it/MPMD-317-auxclasspath-provided/module-a/pom.xml
@@ -0,0 +1,47 @@
+<?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>
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven.plugins.pmd.it</groupId>
+ <artifactId>MPMD-317-auxclasspath-provided</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>MPMD-317-auxclasspath-provided-module-a</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ <version>3.8.1</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ <version>4.0.1</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/src/it/MPMD-317-auxclasspath-provided/module-a/src/main/java/module/a/ModuleA.java b/src/it/MPMD-317-auxclasspath-provided/module-a/src/main/java/module/a/ModuleA.java
new file mode 100644
index 0000000..a407af5
--- /dev/null
+++ b/src/it/MPMD-317-auxclasspath-provided/module-a/src/main/java/module/a/ModuleA.java
@@ -0,0 +1,24 @@
+package module.a;
+
+/*
+ * 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.
+ */
+
+public class ModuleA
+{
+}
\ No newline at end of file
diff --git a/src/it/MPMD-317-auxclasspath-provided/pom.xml b/src/it/MPMD-317-auxclasspath-provided/pom.xml
new file mode 100644
index 0000000..401bcad
--- /dev/null
+++ b/src/it/MPMD-317-auxclasspath-provided/pom.xml
@@ -0,0 +1,60 @@
+<?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>
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.plugins.pmd.it</groupId>
+ <artifactId>MPMD-317-auxclasspath-provided</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <maven.compiler.source>1.8</maven.compiler.source>
+ <maven.compiler.target>1.8</maven.compiler.target>
+ </properties>
+
+ <modules>
+ <module>module-a</module>
+ </modules>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>@project.groupId@</groupId>
+ <artifactId>@project.artifactId@</artifactId>
+ <version>@project.version@</version>
+ <configuration>
+ <linkXRef>false</linkXRef>
+ <typeResolution>true</typeResolution>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/src/it/MPMD-317-auxclasspath-provided/verify.groovy b/src/it/MPMD-317-auxclasspath-provided/verify.groovy
new file mode 100644
index 0000000..9096b9b
--- /dev/null
+++ b/src/it/MPMD-317-auxclasspath-provided/verify.groovy
@@ -0,0 +1,41 @@
+/*
+ * 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()
+
+def auxclasspathLog = ''
+for ( String line : buildLog.readLines() ) {
+ if ( line.contains( 'aux classpath:' ) ) {
+ auxclasspathLog += line + '\n';
+ }
+}
+
+// convert windows path names
+auxclasspathLog = auxclasspathLog.replaceAll('\\\\', '/')
+
+assert 1 == auxclasspathLog.count( 'Using aux classpath:' )
+assert 1 == auxclasspathLog.count( 'Using aggregated aux classpath:' )
+
+assert 2 == auxclasspathLog.count( 'module-a/target/classes' )
+
+// compile
+assert 2 == auxclasspathLog.count( 'org/apache/commons/commons-lang3/3.8.1/commons-lang3-3.8.1.jar' )
+// provided
+assert 2 == auxclasspathLog.count( 'javax/servlet/javax.servlet-api/4.0.1/javax.servlet-api-4.0.1.jar' )
diff --git a/src/it/MPMD-318-auxclasspath-includeTests/module-a/pom.xml b/src/it/MPMD-318-auxclasspath-includeTests/module-a/pom.xml
index 0374658..0250bdb 100644
--- a/src/it/MPMD-318-auxclasspath-includeTests/module-a/pom.xml
+++ b/src/it/MPMD-318-auxclasspath-includeTests/module-a/pom.xml
@@ -38,6 +38,12 @@
<scope>compile</scope>
</dependency>
<dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ <version>4.0.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
diff --git a/src/it/MPMD-318-auxclasspath-includeTests/verify.groovy b/src/it/MPMD-318-auxclasspath-includeTests/verify.groovy
index b24bd87..4190e39 100644
--- a/src/it/MPMD-318-auxclasspath-includeTests/verify.groovy
+++ b/src/it/MPMD-318-auxclasspath-includeTests/verify.groovy
@@ -38,5 +38,7 @@
// compile
assert 2 == auxclasspathLog.count( 'org/apache/commons/commons-lang3/3.8.1/commons-lang3-3.8.1.jar' )
+// provided
+assert 2 == auxclasspathLog.count( 'javax/servlet/javax.servlet-api/4.0.1/javax.servlet-api-4.0.1.jar' )
// test
assert 2 == auxclasspathLog.count( 'commons-io/commons-io/2.6/commons-io-2.6.jar' )
diff --git a/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java b/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java
index cccbcd4..71f0257 100644
--- a/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java
+++ b/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java
@@ -561,8 +561,8 @@
}
TransformableFilter filter = new AndFilter( Arrays.asList(
new ExclusionsFilter( exclusionPatterns ),
- includeTests ? ScopeFilter.including( "compile", "test" )
- : ScopeFilter.including( "compile" )
+ includeTests ? ScopeFilter.including( "compile", "provided", "test" )
+ : ScopeFilter.including( "compile", "provided" )
) );
for ( MavenProject localProject : reactorProjects )