[MPMD-335] - Aggregate mode doesn't use additional repositories
diff --git a/src/it/MPMD-335-aggregate-classpath-repositories/invoker.properties b/src/it/MPMD-335-aggregate-classpath-repositories/invoker.properties
new file mode 100644
index 0000000..71033d7
--- /dev/null
+++ b/src/it/MPMD-335-aggregate-classpath-repositories/invoker.properties
@@ -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 = verify
diff --git a/src/it/MPMD-335-aggregate-classpath-repositories/mpmd335-module1/pom.xml b/src/it/MPMD-335-aggregate-classpath-repositories/mpmd335-module1/pom.xml
new file mode 100644
index 0000000..f71a315
--- /dev/null
+++ b/src/it/MPMD-335-aggregate-classpath-repositories/mpmd335-module1/pom.xml
@@ -0,0 +1,40 @@
+<?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>
+    <parent>
+        <groupId>org.apache.maven.plugins.pmd.it</groupId>
+        <artifactId>mpmd335-parent</artifactId>
+        <version>1.0.0-SNAPSHOT</version>
+    </parent>
+    <artifactId>mpmd335-module1</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.maven.plugins.pmd.it</groupId>
+            <artifactId>mpmd335-dependency1</artifactId>
+            <version>1.0.0-SNAPSHOT</version>
+            <type>pom</type>
+        </dependency>
+    </dependencies>
+</project>
+
diff --git a/src/it/MPMD-335-aggregate-classpath-repositories/mpmd335-module1/src/main/java/org/example/Foo.java b/src/it/MPMD-335-aggregate-classpath-repositories/mpmd335-module1/src/main/java/org/example/Foo.java
new file mode 100644
index 0000000..fd3cfbf
--- /dev/null
+++ b/src/it/MPMD-335-aggregate-classpath-repositories/mpmd335-module1/src/main/java/org/example/Foo.java
@@ -0,0 +1,26 @@
+package org.example;
+
+/*
+ * 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 Foo
+{
+
+}
diff --git a/src/it/MPMD-335-aggregate-classpath-repositories/pom.xml b/src/it/MPMD-335-aggregate-classpath-repositories/pom.xml
new file mode 100644
index 0000000..a5533b5
--- /dev/null
+++ b/src/it/MPMD-335-aggregate-classpath-repositories/pom.xml
@@ -0,0 +1,63 @@
+<?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.plugins.pmd.it</groupId>
+    <artifactId>mpmd335-parent</artifactId>
+    <version>1.0.0-SNAPSHOT</version>
+    <packaging>pom</packaging>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+
+    <modules>
+        <module>mpmd335-module1</module>
+    </modules>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-pmd-plugin</artifactId>
+                <version>@project.version@</version>
+                <configuration>
+                    <aggregate>true</aggregate>
+                </configuration>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>check</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+    <repositories>
+        <repository>
+            <id>corp1</id>
+            <url>file://${user.dir}/private-repo</url>
+        </repository>
+    </repositories>
+</project>
diff --git a/src/it/MPMD-335-aggregate-classpath-repositories/private-repo/org/apache/maven/plugins/pmd/it/mpmd335-dependency1/1.0.0-SNAPSHOT/mpmd335-dependency1-1.0.0-SNAPSHOT.pom b/src/it/MPMD-335-aggregate-classpath-repositories/private-repo/org/apache/maven/plugins/pmd/it/mpmd335-dependency1/1.0.0-SNAPSHOT/mpmd335-dependency1-1.0.0-SNAPSHOT.pom
new file mode 100644
index 0000000..ea3473c
--- /dev/null
+++ b/src/it/MPMD-335-aggregate-classpath-repositories/private-repo/org/apache/maven/plugins/pmd/it/mpmd335-dependency1/1.0.0-SNAPSHOT/mpmd335-dependency1-1.0.0-SNAPSHOT.pom
@@ -0,0 +1,28 @@
+<?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.plugins.pmd.it</groupId>
+    <artifactId>mpmd335-dependency1</artifactId>
+    <version>1.0.0-SNAPSHOT</version>
+    <packaging>pom</packaging>
+</project>
diff --git a/src/it/MPMD-335-aggregate-classpath-repositories/verify.groovy b/src/it/MPMD-335-aggregate-classpath-repositories/verify.groovy
new file mode 100644
index 0000000..4274014
--- /dev/null
+++ b/src/it/MPMD-335-aggregate-classpath-repositories/verify.groovy
@@ -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.
+ */
+
+File buildLog = new File( basedir, 'build.log' )
+assert buildLog.exists()
+assert !buildLog.text.contains( 'pmd failed: org.apache.maven.reporting.MavenReportException' )
+assert !buildLog.text.contains( 'org.eclipse.aether.resolution.DependencyResolutionException' )
+assert !buildLog.text.contains( 'Could not find artifact org.apache.maven.plugins.pmd.it:mpmd335-dependency1:pom:1.0.0-SNAPSHOT' )
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 72f923a..362a603 100644
--- a/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java
+++ b/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java
@@ -552,6 +552,8 @@
                 {
                     ProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest(
                             session.getProjectBuildingRequest() );
+                    // use any additional configured repo as well
+                    buildingRequest.getRemoteRepositories().addAll( localProject.getRemoteArtifactRepositories() );
 
                     Iterable<ArtifactResult> resolvedDependencies = dependencyResolver.resolveDependencies(
                             buildingRequest, localProject.getDependencies(), null, filter );