This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-pmd-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new c2812fd  Combine the includeTests aux classpath ITs, assert in 
empty-rulesets
c2812fd is described below

commit c2812fd9b3134baeb57fdd978201913d78e02b36
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Wed Nov 4 20:35:32 2026 +0000

    Combine the includeTests aux classpath ITs, assert in empty-rulesets
    
    MPMD-317 and MPMD-318 differ only by includeTests, so one project runs both 
and
    verify.groovy checks each invocation's aux classpath line in order. With an 
empty
    rulesets element no rule is applied; the default ruleset is not used.
---
 .../invoker.properties                             |  7 ++-
 .../module-a/pom.xml                               |  4 +-
 .../module-a/src/main/java/module/a/ModuleA.java   |  0
 .../src/test/java/module/a/ModuleATest.java        |  0
 .../pom.xml                                        | 21 +++++++-
 src/it/MPMD-317-318-auxclasspath/verify.groovy     | 62 ++++++++++++++++++++++
 .../module-a/pom.xml                               | 47 ----------------
 src/it/MPMD-317-auxclasspath-provided/pom.xml      | 60 ---------------------
 .../MPMD-317-auxclasspath-provided/verify.groovy   | 41 --------------
 .../invoker.properties                             | 20 -------
 .../module-a/src/main/java/module/a/ModuleA.java   | 24 ---------
 .../verify.groovy                                  | 44 ---------------
 src/it/empty-rulesets/verify.groovy                |  8 ++-
 13 files changed, 96 insertions(+), 242 deletions(-)

diff --git a/src/it/MPMD-317-auxclasspath-provided/invoker.properties 
b/src/it/MPMD-317-318-auxclasspath/invoker.properties
similarity index 74%
rename from src/it/MPMD-317-auxclasspath-provided/invoker.properties
rename to src/it/MPMD-317-318-auxclasspath/invoker.properties
index 40c3f6f..73ad713 100644
--- a/src/it/MPMD-317-auxclasspath-provided/invoker.properties
+++ b/src/it/MPMD-317-318-auxclasspath/invoker.properties
@@ -15,6 +15,11 @@
 # specific language governing permissions and limitations
 # under the License.
 
-invoker.goals = clean verify
+# 1 and 2: includeTests is off; 3 and 4: the includeTests profile adds the 
test classes and test dependencies
+invoker.goals.1 = clean verify
 invoker.goals.2 = clean verify -Daggregate=true
+invoker.goals.3 = clean verify
+invoker.profiles.3 = includeTests
+invoker.goals.4 = clean verify -Daggregate=true
+invoker.profiles.4 = includeTests
 invoker.debug = true
diff --git a/src/it/MPMD-318-auxclasspath-includeTests/module-a/pom.xml 
b/src/it/MPMD-317-318-auxclasspath/module-a/pom.xml
similarity index 92%
rename from src/it/MPMD-318-auxclasspath-includeTests/module-a/pom.xml
rename to src/it/MPMD-317-318-auxclasspath/module-a/pom.xml
index 88acf01..bb7c98c 100644
--- a/src/it/MPMD-318-auxclasspath-includeTests/module-a/pom.xml
+++ b/src/it/MPMD-317-318-auxclasspath/module-a/pom.xml
@@ -24,11 +24,11 @@ under the License.
 
   <parent>
     <groupId>org.apache.maven.plugins.pmd.it</groupId>
-    <artifactId>MPMD-318-auxclasspath-includeTests</artifactId>
+    <artifactId>MPMD-317-318-auxclasspath</artifactId>
     <version>1.0-SNAPSHOT</version>
   </parent>
 
-  <artifactId>MPMD-318-auxclasspath-includeTests-module-a</artifactId>
+  <artifactId>MPMD-317-318-auxclasspath-module-a</artifactId>
 
   <dependencies>
     <dependency>
diff --git 
a/src/it/MPMD-317-auxclasspath-provided/module-a/src/main/java/module/a/ModuleA.java
 b/src/it/MPMD-317-318-auxclasspath/module-a/src/main/java/module/a/ModuleA.java
similarity index 100%
rename from 
src/it/MPMD-317-auxclasspath-provided/module-a/src/main/java/module/a/ModuleA.java
rename to 
src/it/MPMD-317-318-auxclasspath/module-a/src/main/java/module/a/ModuleA.java
diff --git 
a/src/it/MPMD-318-auxclasspath-includeTests/module-a/src/test/java/module/a/ModuleATest.java
 
b/src/it/MPMD-317-318-auxclasspath/module-a/src/test/java/module/a/ModuleATest.java
similarity index 100%
rename from 
src/it/MPMD-318-auxclasspath-includeTests/module-a/src/test/java/module/a/ModuleATest.java
rename to 
src/it/MPMD-317-318-auxclasspath/module-a/src/test/java/module/a/ModuleATest.java
diff --git a/src/it/MPMD-318-auxclasspath-includeTests/pom.xml 
b/src/it/MPMD-317-318-auxclasspath/pom.xml
similarity index 77%
rename from src/it/MPMD-318-auxclasspath-includeTests/pom.xml
rename to src/it/MPMD-317-318-auxclasspath/pom.xml
index f10c3ff..b966a33 100644
--- a/src/it/MPMD-318-auxclasspath-includeTests/pom.xml
+++ b/src/it/MPMD-317-318-auxclasspath/pom.xml
@@ -23,7 +23,7 @@ under the License.
   <modelVersion>4.0.0</modelVersion>
 
   <groupId>org.apache.maven.plugins.pmd.it</groupId>
-  <artifactId>MPMD-318-auxclasspath-includeTests</artifactId>
+  <artifactId>MPMD-317-318-auxclasspath</artifactId>
   <version>1.0-SNAPSHOT</version>
   <packaging>pom</packaging>
 
@@ -46,7 +46,6 @@ under the License.
         <configuration>
           <linkXRef>false</linkXRef>
           <typeResolution>true</typeResolution>
-          <includeTests>true</includeTests>
         </configuration>
         <executions>
           <execution>
@@ -58,4 +57,22 @@ under the License.
       </plugin>
     </plugins>
   </build>
+
+  <profiles>
+    <profile>
+      <id>includeTests</id>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>@project.groupId@</groupId>
+            <artifactId>@project.artifactId@</artifactId>
+            <version>@project.version@</version>
+            <configuration>
+              <includeTests>true</includeTests>
+            </configuration>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+  </profiles>
 </project>
diff --git a/src/it/MPMD-317-318-auxclasspath/verify.groovy 
b/src/it/MPMD-317-318-auxclasspath/verify.groovy
new file mode 100644
index 0000000..76bee03
--- /dev/null
+++ b/src/it/MPMD-317-318-auxclasspath/verify.groovy
@@ -0,0 +1,62 @@
+/*
+ * 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()
+
+// build.log holds all four invocations, in order
+def auxclasspathLines = []
+for ( String line : buildLog.readLines() ) {
+    if ( line.contains( 'aux classpath:' ) ) {
+      // convert windows path names
+      auxclasspathLines << line.replaceAll( '\\\\', '/' )
+    }
+}
+
+assert 4 == auxclasspathLines.size()
+def aux = auxclasspathLines[0]
+def auxAggregated = auxclasspathLines[1]
+def auxIncludeTests = auxclasspathLines[2]
+def auxAggregatedIncludeTests = auxclasspathLines[3]
+
+assert aux.contains( '[DEBUG] Using aux classpath:' )
+assert auxAggregated.contains( '[DEBUG] Using aggregated aux classpath:' )
+assert auxIncludeTests.contains( '[DEBUG] Using aux classpath:' )
+assert auxAggregatedIncludeTests.contains( '[DEBUG] Using aggregated aux 
classpath:' )
+
+for ( String line : auxclasspathLines ) {
+    assert line.contains( 'module-a/target/classes' )
+    // compile
+    assert line.contains( 
'org/apache/commons/commons-lang3/3.18.0/commons-lang3-3.18.0.jar' )
+    // provided
+    assert line.contains( 
'javax/servlet/javax.servlet-api/4.0.1/javax.servlet-api-4.0.1.jar' )
+}
+
+// includeTests is off
+for ( String line : [ aux, auxAggregated ] ) {
+    assert !line.contains( 'module-a/target/test-classes' )
+    assert !line.contains( 
'commons-io/commons-io/2.14.0/commons-io-2.14.0.jar' )
+}
+
+// includeTests is on
+for ( String line : [ auxIncludeTests, auxAggregatedIncludeTests ] ) {
+    assert line.contains( 'module-a/target/test-classes' )
+    // test
+    assert line.contains( 'commons-io/commons-io/2.14.0/commons-io-2.14.0.jar' 
)
+}
diff --git a/src/it/MPMD-317-auxclasspath-provided/module-a/pom.xml 
b/src/it/MPMD-317-auxclasspath-provided/module-a/pom.xml
deleted file mode 100644
index 5a7d2b6..0000000
--- a/src/it/MPMD-317-auxclasspath-provided/module-a/pom.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<?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.18.0</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/pom.xml 
b/src/it/MPMD-317-auxclasspath-provided/pom.xml
deleted file mode 100644
index 401bcad..0000000
--- a/src/it/MPMD-317-auxclasspath-provided/pom.xml
+++ /dev/null
@@ -1,60 +0,0 @@
-<?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
deleted file mode 100644
index 8bf5f79..0000000
--- a/src/it/MPMD-317-auxclasspath-provided/verify.groovy
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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( '[DEBUG] Using aux classpath:' )
-assert 1 == auxclasspathLog.count( '[DEBUG] Using aggregated aux classpath:' )
-
-assert 2 == auxclasspathLog.count( 'module-a/target/classes' )
-
-// compile
-assert 2 == auxclasspathLog.count( 
'org/apache/commons/commons-lang3/3.18.0/commons-lang3-3.18.0.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/invoker.properties 
b/src/it/MPMD-318-auxclasspath-includeTests/invoker.properties
deleted file mode 100644
index 40c3f6f..0000000
--- a/src/it/MPMD-318-auxclasspath-includeTests/invoker.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-# 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.debug = true
diff --git 
a/src/it/MPMD-318-auxclasspath-includeTests/module-a/src/main/java/module/a/ModuleA.java
 
b/src/it/MPMD-318-auxclasspath-includeTests/module-a/src/main/java/module/a/ModuleA.java
deleted file mode 100644
index a407af5..0000000
--- 
a/src/it/MPMD-318-auxclasspath-includeTests/module-a/src/main/java/module/a/ModuleA.java
+++ /dev/null
@@ -1,24 +0,0 @@
-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-318-auxclasspath-includeTests/verify.groovy 
b/src/it/MPMD-318-auxclasspath-includeTests/verify.groovy
deleted file mode 100644
index d5a794e..0000000
--- a/src/it/MPMD-318-auxclasspath-includeTests/verify.groovy
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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( '[DEBUG] Using aux classpath:' )
-assert 1 == auxclasspathLog.count( '[DEBUG] Using aggregated aux classpath:' )
-
-assert 2 == auxclasspathLog.count( 'module-a/target/test-classes' )
-assert 2 == auxclasspathLog.count( 'module-a/target/classes' )
-
-// compile
-assert 2 == auxclasspathLog.count( 
'org/apache/commons/commons-lang3/3.18.0/commons-lang3-3.18.0.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.14.0/commons-io-2.14.0.jar' )
diff --git a/src/it/empty-rulesets/verify.groovy 
b/src/it/empty-rulesets/verify.groovy
index 1cd85d4..aecbec8 100644
--- a/src/it/empty-rulesets/verify.groovy
+++ b/src/it/empty-rulesets/verify.groovy
@@ -19,4 +19,10 @@
  */
 
 File buildLog = new File( basedir, 'build.log' )
-assert buildLog.exists()
\ No newline at end of file
+assert buildLog.exists()
+
+// <rulesets/> configures no rule at all: Foo.java has an unused constructor 
parameter, which the default ruleset reports
+File pmdXml = new File( basedir, 'target/pmd.xml' )
+assert pmdXml.exists()
+assert pmdXml.getText( 'UTF-8' ).contains( '</pmd>' )
+assert !pmdXml.getText( 'UTF-8' ).contains( '<violation' )

Reply via email to