[MPMD-258] PMD output multiplies with every module in multi module projects
diff --git a/src/it/MPMD-258-multiple-executions/invoker.properties b/src/it/MPMD-258-multiple-executions/invoker.properties
new file mode 100644
index 0000000..02b72c7
--- /dev/null
+++ b/src/it/MPMD-258-multiple-executions/invoker.properties
@@ -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 = clean compile pmd:pmd
+invoker.maven.version = 3.1.0+
diff --git a/src/it/MPMD-258-multiple-executions/mod1/pom.xml b/src/it/MPMD-258-multiple-executions/mod1/pom.xml
new file mode 100644
index 0000000..5f389e8
--- /dev/null
+++ b/src/it/MPMD-258-multiple-executions/mod1/pom.xml
@@ -0,0 +1,32 @@
+<?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.its</groupId>
+    <artifactId>MPMD-258-multiple-executions</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>MPMD-258-multiple-executions-mod1</artifactId>
+
+</project>
diff --git a/src/it/MPMD-258-multiple-executions/mod1/src/main/java/hello/Test.java b/src/it/MPMD-258-multiple-executions/mod1/src/main/java/hello/Test.java
new file mode 100644
index 0000000..6cbe739
--- /dev/null
+++ b/src/it/MPMD-258-multiple-executions/mod1/src/main/java/hello/Test.java
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+package hello;
+
+public class Test {
+    String foo;
+
+    public Test() {
+        for (; true;) {
+            System.out.println(this.foo);
+        }
+    }
+}
diff --git a/src/it/MPMD-258-multiple-executions/mod2/pom.xml b/src/it/MPMD-258-multiple-executions/mod2/pom.xml
new file mode 100644
index 0000000..613ef7e
--- /dev/null
+++ b/src/it/MPMD-258-multiple-executions/mod2/pom.xml
@@ -0,0 +1,32 @@
+<?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.its</groupId>
+    <artifactId>MPMD-258-multiple-executions</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>MPMD-258-multiple-executions-mod2</artifactId>
+
+</project>
diff --git a/src/it/MPMD-258-multiple-executions/mod2/src/main/java/hello/Test.java b/src/it/MPMD-258-multiple-executions/mod2/src/main/java/hello/Test.java
new file mode 100644
index 0000000..6cbe739
--- /dev/null
+++ b/src/it/MPMD-258-multiple-executions/mod2/src/main/java/hello/Test.java
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+package hello;
+
+public class Test {
+    String foo;
+
+    public Test() {
+        for (; true;) {
+            System.out.println(this.foo);
+        }
+    }
+}
diff --git a/src/it/MPMD-258-multiple-executions/pom.xml b/src/it/MPMD-258-multiple-executions/pom.xml
new file mode 100644
index 0000000..f29a9c6
--- /dev/null
+++ b/src/it/MPMD-258-multiple-executions/pom.xml
@@ -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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.plugins.pmd.its</groupId>
+  <artifactId>MPMD-258-multiple-executions</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>pom</packaging>
+
+  <description>
+    multi module build, pmd logs are output multiple times
+  </description>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>@project.groupId@</groupId>
+        <artifactId>@project.artifactId@</artifactId>
+        <version>@project.version@</version>
+<!--         <groupId>org.apache.maven.plugins</groupId> -->
+<!--         <artifactId>maven-pmd-plugin</artifactId> -->
+<!--         <version>3.9.0</version> -->
+        <configuration>
+            <analysisCache>true</analysisCache>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+  <modules>
+    <module>mod1</module>
+    <module>mod2</module>
+  </modules>
+</project>
diff --git a/src/it/MPMD-258-multiple-executions/verify.groovy b/src/it/MPMD-258-multiple-executions/verify.groovy
new file mode 100644
index 0000000..01fddfa
--- /dev/null
+++ b/src/it/MPMD-258-multiple-executions/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()
+
+// we have 2 modules and for each module this should be output once
+assert 2 == buildLog.text.count( "Analysis cache updated" )
diff --git a/src/main/java/org/apache/maven/plugins/pmd/AbstractPmdReport.java b/src/main/java/org/apache/maven/plugins/pmd/AbstractPmdReport.java
index af11911..53a6da2 100644
--- a/src/main/java/org/apache/maven/plugins/pmd/AbstractPmdReport.java
+++ b/src/main/java/org/apache/maven/plugins/pmd/AbstractPmdReport.java
@@ -29,6 +29,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
+import java.util.logging.Handler;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.SimpleFormatter;
@@ -553,6 +554,21 @@
 
         Logger logger = Logger.getLogger( "net.sourceforge.pmd" );
 
+        boolean slf4jBridgeAlreadyAdded = false;
+        for ( Handler handler : logger.getHandlers() )
+        {
+            if ( handler instanceof SLF4JBridgeHandler )
+            {
+                slf4jBridgeAlreadyAdded = true;
+                break;
+            }
+        }
+
+        if ( slf4jBridgeAlreadyAdded )
+        {
+            return;
+        }
+
         SLF4JBridgeHandler handler = new SLF4JBridgeHandler();
         SimpleFormatter formatter = new SimpleFormatter();
         handler.setFormatter( formatter );