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
commit eb1c2116c0bf81bc12264aaa034ad710ea232448 Author: Sylwester Lachiewicz <[email protected]> AuthorDate: Wed Nov 4 19:59:14 2026 +0000 Move 15 option-level ITs to unit tests The C# CPD test needs pmd-cs on the test classpath, so it is added in test scope. --- pom.xml | 6 + .../invoker.properties | 18 -- src/it/MPMD-163-duplicated-violations/pom.xml | 51 ------ .../src/main/java/com/mycompany/app/App.java | 26 --- .../src/main/java/com/mycompany/app/Foo.java | 27 --- .../MPMD-163-duplicated-violations/verify.groovy | 32 ---- .../invoker.properties | 18 -- src/it/MPMD-165-invalid-reporting-encoding/pom.xml | 48 ------ .../src/main/java/test/MyClass.java | 30 ---- .../verify.groovy | 26 --- src/it/MPMD-181-benchmark/invoker.properties | 18 -- src/it/MPMD-181-benchmark/pom.xml | 50 ------ .../src/main/java/com/mycompany/app/Hello.java | 28 ---- src/it/MPMD-181-benchmark/verify.groovy | 24 --- src/it/MPMD-181-no-benchmark/invoker.properties | 18 -- src/it/MPMD-181-no-benchmark/pom.xml | 46 ------ .../src/main/java/com/mycompany/app/Hello.java | 28 ---- src/it/MPMD-181-no-benchmark/verify.groovy | 24 --- .../MPMD-187-skip-pmd-and-cpd/invoker.properties | 18 -- src/it/MPMD-187-skip-pmd-and-cpd/pom.xml | 55 ------- .../src/main/java/App.java | 23 --- src/it/MPMD-187-skip-pmd-and-cpd/verify.groovy | 27 --- src/it/MPMD-205-pmd-js-check/invoker.properties | 19 --- src/it/MPMD-205-pmd-js-check/pom.xml | 82 ---------- .../src/main/javascript/PmdJsCheck.js | 25 --- src/it/MPMD-205-pmd-js-check/verify.groovy | 23 --- .../invoker.properties | 18 -- src/it/MPMD-206-sourceDirectories-js/pom.xml | 69 -------- .../src/main/javascript/PmdJsCheck.js | 25 --- src/it/MPMD-206-sourceDirectories-js/verify.groovy | 25 --- .../invoker.properties | 19 --- src/it/MPMD-219-pmd-processing-error/pom.xml | 57 ------- .../src/main/java/BrokenFile.java | 26 --- src/it/MPMD-219-pmd-processing-error/verify.groovy | 24 --- .../config/pmd-exclude.properties | 18 -- .../invoker.properties | 18 -- src/it/MPMD-243-excludeFromFailureFile/pom.xml | 70 -------- .../src/main/java/com/example/A.java | 28 ---- .../com/example/ClassWithLotsOfStaticImports.java | 34 ---- .../MPMD-243-excludeFromFailureFile/verify.groovy | 32 ---- .../MPMD-268-deprecated-rules/invoker.properties | 19 --- src/it/MPMD-268-deprecated-rules/pom.xml | 60 ------- .../src/main/java/sample/Sample.java | 24 --- src/it/MPMD-268-deprecated-rules/verify.groovy | 22 --- .../MPMD-289-format-html-check/invoker.properties | 18 -- src/it/MPMD-289-format-html-check/pom.xml | 72 -------- .../src/main/java/com/mycompany/app/App.java | 25 --- src/it/MPMD-289-format-html-check/verify.groovy | 34 ---- src/it/MPMD-290-cpd-for-csharp/invoker.properties | 19 --- src/it/MPMD-290-cpd-for-csharp/verify.groovy | 40 ----- .../invoker.properties | 24 --- src/it/MPMD-296-rulesetsTargetDirectory/pom.xml | 82 ---------- .../src/main/java/test/MyClass.java | 31 ---- .../MPMD-296-rulesetsTargetDirectory/verify.groovy | 34 ---- src/it/mpmd-80-included/pom.xml | 56 ------- src/it/mpmd-80-included/verify.groovy | 27 --- src/it/mpmd-80-not-included/pom.xml | 52 ------ src/it/mpmd-80-not-included/verify.groovy | 27 --- .../apache/maven/plugins/pmd/CpdReportTest.java | 78 +++++++++ .../plugins/pmd/CpdViolationCheckMojoTest.java | 4 + .../apache/maven/plugins/pmd/PmdReportTest.java | 181 +++++++++++++++++++++ .../pmd/PmdViolationCheckMojoOnLinuxTest.java | 89 ++++++++++ .../cpd-cs-plugin-config.xml} | 56 +++---- .../unit/default-configuration}/cs/Sample1.cs | 0 .../unit/default-configuration}/cs/Sample2.cs | 0 ...md-report-default-rulesets-target-directory.xml | 65 ++++++++ .../default-configuration/pmd-report-js/pmd.xml} | 21 +-- .../rulesets/deprecated-rule.xml} | 0 68 files changed, 457 insertions(+), 1956 deletions(-) diff --git a/pom.xml b/pom.xml index fbe8708..25562b7 100644 --- a/pom.xml +++ b/pom.xml @@ -214,6 +214,12 @@ under the License. <version>${pmdVersion}</version> <scope>runtime</scope> </dependency> + <dependency> + <groupId>net.sourceforge.pmd</groupId> + <artifactId>pmd-cs</artifactId> + <version>${pmdVersion}</version> + <scope>test</scope> + </dependency> <dependency> <groupId>org.slf4j</groupId> diff --git a/src/it/MPMD-163-duplicated-violations/invoker.properties b/src/it/MPMD-163-duplicated-violations/invoker.properties deleted file mode 100644 index cac6eaa..0000000 --- a/src/it/MPMD-163-duplicated-violations/invoker.properties +++ /dev/null @@ -1,18 +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 pmd:check \ No newline at end of file diff --git a/src/it/MPMD-163-duplicated-violations/pom.xml b/src/it/MPMD-163-duplicated-violations/pom.xml deleted file mode 100644 index 3665433..0000000 --- a/src/it/MPMD-163-duplicated-violations/pom.xml +++ /dev/null @@ -1,51 +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 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/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>org.apache.maven.plugins.pmd.it</groupId> - <artifactId>MPMD-163-duplicated-violations</artifactId> - <version>1.0-SNAPSHOT</version> - <name>my-app</name> - - <properties> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - </properties> - - <build> - <pluginManagement> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-pmd-plugin</artifactId> - <version>@project.version@</version> - <configuration> - <verbose>true</verbose> - <printFailingErrors>true</printFailingErrors> - <failurePriority>0</failurePriority> - <skipPmdError>false</skipPmdError> - </configuration> - </plugin> - </plugins> - </pluginManagement> - </build> -</project> diff --git a/src/it/MPMD-163-duplicated-violations/src/main/java/com/mycompany/app/App.java b/src/it/MPMD-163-duplicated-violations/src/main/java/com/mycompany/app/App.java deleted file mode 100644 index 8b32bce..0000000 --- a/src/it/MPMD-163-duplicated-violations/src/main/java/com/mycompany/app/App.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.mycompany.app; - -/* - * 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 App -{ - - -} diff --git a/src/it/MPMD-163-duplicated-violations/src/main/java/com/mycompany/app/Foo.java b/src/it/MPMD-163-duplicated-violations/src/main/java/com/mycompany/app/Foo.java deleted file mode 100644 index 45be021..0000000 --- a/src/it/MPMD-163-duplicated-violations/src/main/java/com/mycompany/app/Foo.java +++ /dev/null @@ -1,27 +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. - */ - -import java.util.ArrayList; -public class Foo -{ - private Foo(final ArrayList<String> foo) - { - } - -} diff --git a/src/it/MPMD-163-duplicated-violations/verify.groovy b/src/it/MPMD-163-duplicated-violations/verify.groovy deleted file mode 100644 index 84a2060..0000000 --- a/src/it/MPMD-163-duplicated-violations/verify.groovy +++ /dev/null @@ -1,32 +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. - */ - -import groovy.xml.XmlSlurper - -File buildLog = new File( basedir, 'build.log' ) -assert buildLog.exists() - -File pmdXml = new File( basedir, "target/pmd.xml" ) -assert pmdXml.exists() - -def pmd = new XmlSlurper().parse( pmdXml ) -def version = pmd.@version - -assert buildLog.getText().contains('[WARNING] PMD ' + version + ' has issued 1 warning. For more details see:') -assert buildLog.getText().contains("[WARNING] PMD Warning: Foo:23 Rule:UnusedFormalParameter Priority:3 Avoid unused constructor parameters such as 'foo'..") diff --git a/src/it/MPMD-165-invalid-reporting-encoding/invoker.properties b/src/it/MPMD-165-invalid-reporting-encoding/invoker.properties deleted file mode 100644 index 37c0dc1..0000000 --- a/src/it/MPMD-165-invalid-reporting-encoding/invoker.properties +++ /dev/null @@ -1,18 +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 pmd:pmd diff --git a/src/it/MPMD-165-invalid-reporting-encoding/pom.xml b/src/it/MPMD-165-invalid-reporting-encoding/pom.xml deleted file mode 100644 index 4ae8b84..0000000 --- a/src/it/MPMD-165-invalid-reporting-encoding/pom.xml +++ /dev/null @@ -1,48 +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-165-invalid-reporting-encoding</artifactId> - <version>1.0-SNAPSHOT</version> - - <properties> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <project.reporting.outputEncoding>UTF-16</project.reporting.outputEncoding> - </properties> - - <dependencies> - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>@project.groupId@</groupId> - <artifactId>@project.artifactId@</artifactId> - <version>@project.version@</version> - <configuration> - </configuration> - </plugin> - </plugins> - </build> -</project> diff --git a/src/it/MPMD-165-invalid-reporting-encoding/src/main/java/test/MyClass.java b/src/it/MPMD-165-invalid-reporting-encoding/src/main/java/test/MyClass.java deleted file mode 100644 index 6c4c05c..0000000 --- a/src/it/MPMD-165-invalid-reporting-encoding/src/main/java/test/MyClass.java +++ /dev/null @@ -1,30 +0,0 @@ -package test; - -/* - * 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 MyClass -{ - - public static void main( String[] args ) - { - return; // This is a UnnecessaryReturn violation - } - -} diff --git a/src/it/MPMD-165-invalid-reporting-encoding/verify.groovy b/src/it/MPMD-165-invalid-reporting-encoding/verify.groovy deleted file mode 100644 index 94cc1d6..0000000 --- a/src/it/MPMD-165-invalid-reporting-encoding/verify.groovy +++ /dev/null @@ -1,26 +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 pmdHtml = new File( basedir, "target/reports/pmd.html" ); -assert pmdHtml.exists() - -// Groovy's getText() automatically detects the correct encoding, so that UTF-16 works out of the box -// see also http://groovy.codehaus.org/api/groovy/util/CharsetToolkit.html -def html = pmdHtml.text; -assert html.contains( '<meta charset="UTF-16" />' ); diff --git a/src/it/MPMD-181-benchmark/invoker.properties b/src/it/MPMD-181-benchmark/invoker.properties deleted file mode 100644 index 268725a..0000000 --- a/src/it/MPMD-181-benchmark/invoker.properties +++ /dev/null @@ -1,18 +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 pmd:pmd diff --git a/src/it/MPMD-181-benchmark/pom.xml b/src/it/MPMD-181-benchmark/pom.xml deleted file mode 100644 index 51d8cdc..0000000 --- a/src/it/MPMD-181-benchmark/pom.xml +++ /dev/null @@ -1,50 +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 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-181-benchmark</artifactId> - <version>1.0-SNAPSHOT</version> - - <description> - Verify that a benchmark file is produced. - </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> - <benchmark>true</benchmark> - <benchmarkOutputFilename>${project.build.directory}/my-own-pmd-benchmark.txt</benchmarkOutputFilename> - </configuration> - </plugin> - </plugins> - </build> -</project> diff --git a/src/it/MPMD-181-benchmark/src/main/java/com/mycompany/app/Hello.java b/src/it/MPMD-181-benchmark/src/main/java/com/mycompany/app/Hello.java deleted file mode 100644 index f7f504d..0000000 --- a/src/it/MPMD-181-benchmark/src/main/java/com/mycompany/app/Hello.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.mycompany.app; - -/* - * 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 Hello -{ - public static void main( String[] args ) - { - System.out.println( args[0] ); - } -} diff --git a/src/it/MPMD-181-benchmark/verify.groovy b/src/it/MPMD-181-benchmark/verify.groovy deleted file mode 100644 index 5a4327b..0000000 --- a/src/it/MPMD-181-benchmark/verify.groovy +++ /dev/null @@ -1,24 +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 defaultBenchmarkFile = new File( basedir, 'target/pmd-benchmark.txt' ) -assert !defaultBenchmarkFile.exists() - -File customBenchmarkFile = new File( basedir, 'target/my-own-pmd-benchmark.txt' ) -assert customBenchmarkFile.exists() diff --git a/src/it/MPMD-181-no-benchmark/invoker.properties b/src/it/MPMD-181-no-benchmark/invoker.properties deleted file mode 100644 index 268725a..0000000 --- a/src/it/MPMD-181-no-benchmark/invoker.properties +++ /dev/null @@ -1,18 +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 pmd:pmd diff --git a/src/it/MPMD-181-no-benchmark/pom.xml b/src/it/MPMD-181-no-benchmark/pom.xml deleted file mode 100644 index c875442..0000000 --- a/src/it/MPMD-181-no-benchmark/pom.xml +++ /dev/null @@ -1,46 +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 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-181-no-benchmark</artifactId> - <version>1.0-SNAPSHOT</version> - - <description> - Verify that no benchmark file is produced. - </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> - </plugin> - </plugins> - </build> -</project> diff --git a/src/it/MPMD-181-no-benchmark/src/main/java/com/mycompany/app/Hello.java b/src/it/MPMD-181-no-benchmark/src/main/java/com/mycompany/app/Hello.java deleted file mode 100644 index f7f504d..0000000 --- a/src/it/MPMD-181-no-benchmark/src/main/java/com/mycompany/app/Hello.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.mycompany.app; - -/* - * 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 Hello -{ - public static void main( String[] args ) - { - System.out.println( args[0] ); - } -} diff --git a/src/it/MPMD-181-no-benchmark/verify.groovy b/src/it/MPMD-181-no-benchmark/verify.groovy deleted file mode 100644 index 13a1cd0..0000000 --- a/src/it/MPMD-181-no-benchmark/verify.groovy +++ /dev/null @@ -1,24 +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 defaultBenchmarkFile = new File( basedir, 'target/pmd-benchmark.txt' ) -assert !defaultBenchmarkFile.exists() - -File customBenchmarkFile = new File( basedir, 'target/my-own-pmd-benchmark.txt' ) -assert !customBenchmarkFile.exists() diff --git a/src/it/MPMD-187-skip-pmd-and-cpd/invoker.properties b/src/it/MPMD-187-skip-pmd-and-cpd/invoker.properties deleted file mode 100644 index cdef1c3..0000000 --- a/src/it/MPMD-187-skip-pmd-and-cpd/invoker.properties +++ /dev/null @@ -1,18 +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 -Dpmd.skip=true -Dcpd.skip=true diff --git a/src/it/MPMD-187-skip-pmd-and-cpd/pom.xml b/src/it/MPMD-187-skip-pmd-and-cpd/pom.xml deleted file mode 100644 index 55ff9ed..0000000 --- a/src/it/MPMD-187-skip-pmd-and-cpd/pom.xml +++ /dev/null @@ -1,55 +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 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-187-skip-pmd-and-cpd</artifactId> - <version>1.0-SNAPSHOT</version> - - <description> - Verify that pmd.skip really skips pmd plugin - </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> - <executions> - <execution> - <phase>verify</phase> - <goals> - <goal>pmd</goal> - <goal>cpd</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> -</project> diff --git a/src/it/MPMD-187-skip-pmd-and-cpd/src/main/java/App.java b/src/it/MPMD-187-skip-pmd-and-cpd/src/main/java/App.java deleted file mode 100644 index ce723a3..0000000 --- a/src/it/MPMD-187-skip-pmd-and-cpd/src/main/java/App.java +++ /dev/null @@ -1,23 +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. - */ - -public class App -{ - -} diff --git a/src/it/MPMD-187-skip-pmd-and-cpd/verify.groovy b/src/it/MPMD-187-skip-pmd-and-cpd/verify.groovy deleted file mode 100644 index 4af16b7..0000000 --- a/src/it/MPMD-187-skip-pmd-and-cpd/verify.groovy +++ /dev/null @@ -1,27 +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() - -File pmdXml = new File( basedir, "target/pmd.xml" ) -assert !pmdXml.exists() - -File cpdXml = new File( basedir, "target/cpd.xml" ) -assert !cpdXml.exists() diff --git a/src/it/MPMD-205-pmd-js-check/invoker.properties b/src/it/MPMD-205-pmd-js-check/invoker.properties deleted file mode 100644 index 472318a..0000000 --- a/src/it/MPMD-205-pmd-js-check/invoker.properties +++ /dev/null @@ -1,19 +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.buildResult = failure diff --git a/src/it/MPMD-205-pmd-js-check/pom.xml b/src/it/MPMD-205-pmd-js-check/pom.xml deleted file mode 100644 index eb544f9..0000000 --- a/src/it/MPMD-205-pmd-js-check/pom.xml +++ /dev/null @@ -1,82 +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 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-205-pmd-js-check</artifactId> - <version>1.0-SNAPSHOT</version> - - <description> - Verify that check fails the build if language is javascript - </description> - - <properties> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - </properties> - - <build> - <plugins> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>build-helper-maven-plugin</artifactId> - <version>3.3.0</version> - <executions> - <execution> - <id>add-javascript-source</id> - <goals><goal>add-source</goal></goals> - <configuration> - <sources> - <source>src/main/javascript</source> - </sources> - </configuration> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-pmd-plugin</artifactId> - <version>@project.version@</version> - <configuration> - <language>javascript</language> - <rulesets> - <ruleset>/category/ecmascript/bestpractices.xml</ruleset> - <ruleset>/category/ecmascript/codestyle.xml</ruleset> - <ruleset>/category/ecmascript/errorprone.xml</ruleset> - </rulesets> - <includes> - <include>**/*.js</include> - </includes> - <printFailingErrors>true</printFailingErrors> - </configuration> - <executions> - <execution> - <phase>verify</phase> - <goals> - <goal>check</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> -</project> diff --git a/src/it/MPMD-205-pmd-js-check/src/main/javascript/PmdJsCheck.js b/src/it/MPMD-205-pmd-js-check/src/main/javascript/PmdJsCheck.js deleted file mode 100644 index 11707b4..0000000 --- a/src/it/MPMD-205-pmd-js-check/src/main/javascript/PmdJsCheck.js +++ /dev/null @@ -1,25 +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. -*/ - -(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 diff --git a/src/it/MPMD-205-pmd-js-check/verify.groovy b/src/it/MPMD-205-pmd-js-check/verify.groovy deleted file mode 100644 index f5fba04..0000000 --- a/src/it/MPMD-205-pmd-js-check/verify.groovy +++ /dev/null @@ -1,23 +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() - -assert buildLog.getText().contains("[WARNING] PMD Failure: PmdJsCheck.js:23 Rule:GlobalVariable Priority:1 Avoid using global variables."); diff --git a/src/it/MPMD-206-sourceDirectories-js/invoker.properties b/src/it/MPMD-206-sourceDirectories-js/invoker.properties deleted file mode 100644 index a5ed592..0000000 --- a/src/it/MPMD-206-sourceDirectories-js/invoker.properties +++ /dev/null @@ -1,18 +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 diff --git a/src/it/MPMD-206-sourceDirectories-js/pom.xml b/src/it/MPMD-206-sourceDirectories-js/pom.xml deleted file mode 100644 index 4819272..0000000 --- a/src/it/MPMD-206-sourceDirectories-js/pom.xml +++ /dev/null @@ -1,69 +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 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-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>/category/ecmascript/bestpractices.xml</ruleset> - <ruleset>/category/ecmascript/codestyle.xml</ruleset> - <ruleset>/category/ecmascript/errorprone.xml</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> diff --git a/src/it/MPMD-206-sourceDirectories-js/src/main/javascript/PmdJsCheck.js b/src/it/MPMD-206-sourceDirectories-js/src/main/javascript/PmdJsCheck.js deleted file mode 100644 index 11707b4..0000000 --- a/src/it/MPMD-206-sourceDirectories-js/src/main/javascript/PmdJsCheck.js +++ /dev/null @@ -1,25 +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. -*/ - -(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 diff --git a/src/it/MPMD-206-sourceDirectories-js/verify.groovy b/src/it/MPMD-206-sourceDirectories-js/verify.groovy deleted file mode 100644 index b451716..0000000 --- a/src/it/MPMD-206-sourceDirectories-js/verify.groovy +++ /dev/null @@ -1,25 +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() - -File pmd = new File( basedir, 'target/pmd.xml' ) -assert pmd.exists() -assert pmd.getText().contains("GlobalVariable") diff --git a/src/it/MPMD-219-pmd-processing-error/invoker.properties b/src/it/MPMD-219-pmd-processing-error/invoker.properties deleted file mode 100644 index fa9bee7..0000000 --- a/src/it/MPMD-219-pmd-processing-error/invoker.properties +++ /dev/null @@ -1,19 +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 pmd:check -invoker.buildResult = failure diff --git a/src/it/MPMD-219-pmd-processing-error/pom.xml b/src/it/MPMD-219-pmd-processing-error/pom.xml deleted file mode 100644 index 8f85f7e..0000000 --- a/src/it/MPMD-219-pmd-processing-error/pom.xml +++ /dev/null @@ -1,57 +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-219-pmd-processing-error</artifactId> - <version>1.0-SNAPSHOT</version> - - <properties> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - </properties> - - <dependencies> - </dependencies> - - - <build> - <plugins> - <plugin> - <groupId>@project.groupId@</groupId> - <artifactId>@project.artifactId@</artifactId> - <version>@project.version@</version> - <configuration> - <skipPmdError>false</skipPmdError> - </configuration> - <executions> - <execution> - <phase>test-compile</phase> - <goals> - <goal>check</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> -</project> diff --git a/src/it/MPMD-219-pmd-processing-error/src/main/java/BrokenFile.java b/src/it/MPMD-219-pmd-processing-error/src/main/java/BrokenFile.java deleted file mode 100644 index 1c5335a..0000000 --- a/src/it/MPMD-219-pmd-processing-error/src/main/java/BrokenFile.java +++ /dev/null @@ -1,26 +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. - */ - -public class BrokenFile -{ - - // This file has a parse error, so PMD will fail to parse it - broken!! - -} diff --git a/src/it/MPMD-219-pmd-processing-error/verify.groovy b/src/it/MPMD-219-pmd-processing-error/verify.groovy deleted file mode 100644 index ea9d802..0000000 --- a/src/it/MPMD-219-pmd-processing-error/verify.groovy +++ /dev/null @@ -1,24 +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() -assert buildLog.text.contains( "PMD processing errors" ) -assert buildLog.text.contains( "ParseException: Parse exception in file" ) -assert buildLog.text.contains( "BrokenFile.java" ) diff --git a/src/it/MPMD-243-excludeFromFailureFile/config/pmd-exclude.properties b/src/it/MPMD-243-excludeFromFailureFile/config/pmd-exclude.properties deleted file mode 100644 index c1cf9f0..0000000 --- a/src/it/MPMD-243-excludeFromFailureFile/config/pmd-exclude.properties +++ /dev/null @@ -1,18 +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. - -com.example.ClassWithLotsOfStaticImports=TooManyStaticImports diff --git a/src/it/MPMD-243-excludeFromFailureFile/invoker.properties b/src/it/MPMD-243-excludeFromFailureFile/invoker.properties deleted file mode 100644 index 4b2a684..0000000 --- a/src/it/MPMD-243-excludeFromFailureFile/invoker.properties +++ /dev/null @@ -1,18 +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 pmd:check diff --git a/src/it/MPMD-243-excludeFromFailureFile/pom.xml b/src/it/MPMD-243-excludeFromFailureFile/pom.xml deleted file mode 100644 index 86e4f0f..0000000 --- a/src/it/MPMD-243-excludeFromFailureFile/pom.xml +++ /dev/null @@ -1,70 +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 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-243-excludeFromFailureFile</artifactId> - <version>1.0-SNAPSHOT</version> - <packaging>jar</packaging> - - <description> - Test that the option excludeFromFailureFile is actually honored - </description> - - <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> - - <build> - <plugins> - <plugin> - <groupId>@project.groupId@</groupId> - <artifactId>@project.artifactId@</artifactId> - <version>@project.version@</version> - <configuration> - <verbose>true</verbose> - <skipPmdError>false</skipPmdError> - <failOnViolation>true</failOnViolation> -<!-- <printFailingErrors>true</printFailingErrors> --> - <rulesets> - <ruleset>${basedir}/config/ruleset.xml</ruleset> - </rulesets> - </configuration> - <executions> - <execution> - <id>default-cli</id> - <goals> - <goal>check</goal> - </goals> - <configuration> - <excludeFromFailureFile>${basedir}/config/pmd-exclude.properties</excludeFromFailureFile> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> - -</project> diff --git a/src/it/MPMD-243-excludeFromFailureFile/src/main/java/com/example/A.java b/src/it/MPMD-243-excludeFromFailureFile/src/main/java/com/example/A.java deleted file mode 100644 index 7386d42..0000000 --- a/src/it/MPMD-243-excludeFromFailureFile/src/main/java/com/example/A.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.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 A { - public static final int A = 1; - public static final int B = 1; - public static final int C = 1; - public static final int D = 1; - public static final int E = 1; -} diff --git a/src/it/MPMD-243-excludeFromFailureFile/src/main/java/com/example/ClassWithLotsOfStaticImports.java b/src/it/MPMD-243-excludeFromFailureFile/src/main/java/com/example/ClassWithLotsOfStaticImports.java deleted file mode 100644 index f3d3969..0000000 --- a/src/it/MPMD-243-excludeFromFailureFile/src/main/java/com/example/ClassWithLotsOfStaticImports.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.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. - */ - -import static com.example.A.A; -import static com.example.A.B; -import static com.example.A.C; -import static com.example.A.D; -import static com.example.A.E; // Too much ! - -public class ClassWithLotsOfStaticImports -{ - public static void main( String[] args ) - { - System.out.println( A + B + C + D + E ); - } -} diff --git a/src/it/MPMD-243-excludeFromFailureFile/verify.groovy b/src/it/MPMD-243-excludeFromFailureFile/verify.groovy deleted file mode 100644 index 1fc0480..0000000 --- a/src/it/MPMD-243-excludeFromFailureFile/verify.groovy +++ /dev/null @@ -1,32 +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. - */ - -import groovy.xml.XmlSlurper - -File buildLog = new File( basedir, 'build.log' ) -assert buildLog.exists() - -File pmdXml = new File( basedir, "target/pmd.xml" ) -assert pmdXml.exists() - -def pmd = new XmlSlurper().parse( pmdXml ) -def version = pmd.@version - -assert buildLog.text.contains( "[WARNING] PMD Warning: com.example.ClassWithLotsOfStaticImports" ) -assert buildLog.text.contains( "[WARNING] PMD " + version + " has issued 1 warning. For more details see:" ) diff --git a/src/it/MPMD-268-deprecated-rules/invoker.properties b/src/it/MPMD-268-deprecated-rules/invoker.properties deleted file mode 100644 index 8e1679b..0000000 --- a/src/it/MPMD-268-deprecated-rules/invoker.properties +++ /dev/null @@ -1,19 +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.debug = false diff --git a/src/it/MPMD-268-deprecated-rules/pom.xml b/src/it/MPMD-268-deprecated-rules/pom.xml deleted file mode 100644 index 1653a46..0000000 --- a/src/it/MPMD-268-deprecated-rules/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 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-268-deprecated-rules</artifactId> - <version>1.0-SNAPSHOT</version> - <packaging>jar</packaging> - - <description> - Verify PMD logs deprecated rules - </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> - <configuration> - <rulesets> - <ruleset>ruleset.xml</ruleset> - </rulesets> - </configuration> - <executions> - <execution> - <phase>verify</phase> - <goals> - <goal>check</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> -</project> diff --git a/src/it/MPMD-268-deprecated-rules/src/main/java/sample/Sample.java b/src/it/MPMD-268-deprecated-rules/src/main/java/sample/Sample.java deleted file mode 100644 index af4c55b..0000000 --- a/src/it/MPMD-268-deprecated-rules/src/main/java/sample/Sample.java +++ /dev/null @@ -1,24 +0,0 @@ -package sample; - -/* - * 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 Sample -{ -} \ No newline at end of file diff --git a/src/it/MPMD-268-deprecated-rules/verify.groovy b/src/it/MPMD-268-deprecated-rules/verify.groovy deleted file mode 100644 index 48f60ec..0000000 --- a/src/it/MPMD-268-deprecated-rules/verify.groovy +++ /dev/null @@ -1,22 +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() -assert buildLog.text.count( "Use Rule name category/java/codestyle.xml/ControlStatementBraces instead of the deprecated Rule name" ) == 1 diff --git a/src/it/MPMD-289-format-html-check/invoker.properties b/src/it/MPMD-289-format-html-check/invoker.properties deleted file mode 100644 index a5ed592..0000000 --- a/src/it/MPMD-289-format-html-check/invoker.properties +++ /dev/null @@ -1,18 +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 diff --git a/src/it/MPMD-289-format-html-check/pom.xml b/src/it/MPMD-289-format-html-check/pom.xml deleted file mode 100644 index b7233d1..0000000 --- a/src/it/MPMD-289-format-html-check/pom.xml +++ /dev/null @@ -1,72 +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 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-289-format-html-check</artifactId> - <version>1.0-SNAPSHOT</version> - - <description> - Then report format is html, xml format should still be created so that the check goal still works. - </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> - <skipPmdError>false</skipPmdError> - <skip>false</skip> - <failOnViolation>true</failOnViolation> - <failurePriority>4</failurePriority> - <minimumTokens>100</minimumTokens> - <skipEmptyReport>false</skipEmptyReport> - <format>html</format> - <excludes> - <exclude>**/*Bean.java</exclude> - <exclude>**/generated/*.java</exclude> - </excludes> - <excludeRoots> - <excludeRoot>target/generated-sources/stubs</excludeRoot> - </excludeRoots> - <rulesets/> - </configuration> - <executions> - <execution> - <goals> - <goal>check</goal> - <goal>cpd-check</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - -</project> diff --git a/src/it/MPMD-289-format-html-check/src/main/java/com/mycompany/app/App.java b/src/it/MPMD-289-format-html-check/src/main/java/com/mycompany/app/App.java deleted file mode 100644 index 8e4972d..0000000 --- a/src/it/MPMD-289-format-html-check/src/main/java/com/mycompany/app/App.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.mycompany.app; - -/* - * 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 App -{ - -} diff --git a/src/it/MPMD-289-format-html-check/verify.groovy b/src/it/MPMD-289-format-html-check/verify.groovy deleted file mode 100644 index aa62e28..0000000 --- a/src/it/MPMD-289-format-html-check/verify.groovy +++ /dev/null @@ -1,34 +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() - -File pmdXml = new File( basedir, 'target/pmd.xml' ) -assert pmdXml.exists() - -File pmdHtmlReport = new File ( basedir, 'target/reports/pmd.html' ) -assert pmdHtmlReport.exists() - -File cpdXml = new File( basedir, 'target/cpd.xml' ) -assert cpdXml.exists() - -File cpdHtmlReport = new File ( basedir, 'target/reports/cpd.html' ) -assert cpdHtmlReport.exists() diff --git a/src/it/MPMD-290-cpd-for-csharp/invoker.properties b/src/it/MPMD-290-cpd-for-csharp/invoker.properties deleted file mode 100644 index 472318a..0000000 --- a/src/it/MPMD-290-cpd-for-csharp/invoker.properties +++ /dev/null @@ -1,19 +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.buildResult = failure diff --git a/src/it/MPMD-290-cpd-for-csharp/verify.groovy b/src/it/MPMD-290-cpd-for-csharp/verify.groovy deleted file mode 100644 index e4d1257..0000000 --- a/src/it/MPMD-290-cpd-for-csharp/verify.groovy +++ /dev/null @@ -1,40 +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. - */ - -import groovy.xml.XmlSlurper - -File buildLog = new File( basedir, 'build.log' ) -assert buildLog.exists() - -File cpdXml = new File( basedir, 'target/cpd.xml' ) -assert cpdXml.exists() - -def cpd = new XmlSlurper().parse( cpdXml ) -def pmdVersion = cpd.@pmdVersion - -assert buildLog.text.contains( "[WARNING] CPD Failure: Found 7 lines of duplicated code at locations" ) -assert buildLog.text.contains( "CPD " + pmdVersion + " has found 1 duplication. For more details see:" ) - -// no duplication for the license header - if this is reported, then CPD uses the wrong language/tokenizer -assert !cpdXml.text.contains( '<duplication lines="20" tokens="148">' ) -assert !cpdXml.text.contains( 'line="1"' ) - -// the only valid duplication -assert cpdXml.text.contains( '<duplication lines="7" tokens="26">' ) -assert cpdXml.text.contains( 'line="20"' ) diff --git a/src/it/MPMD-296-rulesetsTargetDirectory/invoker.properties b/src/it/MPMD-296-rulesetsTargetDirectory/invoker.properties deleted file mode 100644 index 3f2b089..0000000 --- a/src/it/MPMD-296-rulesetsTargetDirectory/invoker.properties +++ /dev/null @@ -1,24 +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.1 = clean verify -invoker.profiles.1 = -# no clean for the next executions, otherwise we can't verify -invoker.goals.2 = verify -invoker.profiles.2 = customTargetOld -invoker.goals.3 = verify -invoker.profiles.3 = customTarget diff --git a/src/it/MPMD-296-rulesetsTargetDirectory/pom.xml b/src/it/MPMD-296-rulesetsTargetDirectory/pom.xml deleted file mode 100644 index a8299c2..0000000 --- a/src/it/MPMD-296-rulesetsTargetDirectory/pom.xml +++ /dev/null @@ -1,82 +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 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/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>org.apache.maven.plugins.pmd.it</groupId> - <artifactId>MPMD-296-rulesetsTargetDirectory</artifactId> - <version>1.0.0-SNAPSHOT</version> - - <description>Verifies that the resolved and extracted rulesets are in the correct target directory</description> - - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-pmd-plugin</artifactId> - <version>@project.version@</version> - <configuration> - <failOnViolation>false</failOnViolation> - </configuration> - <executions> - <execution> - <id>pmd-check</id> - <goals> - <goal>check</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - - <profiles> - <profile> - <id>customTargetOld</id> - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-pmd-plugin</artifactId> - <configuration> - <rulesetsTargetDirectory>${project.build.directory}</rulesetsTargetDirectory> - </configuration> - </plugin> - </plugins> - </build> - </profile> - <profile> - <id>customTarget</id> - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-pmd-plugin</artifactId> - <configuration> - <rulesetsTargetDirectory>${project.build.directory}/pmd-custom</rulesetsTargetDirectory> - </configuration> - </plugin> - </plugins> - </build> - </profile> - </profiles> -</project> diff --git a/src/it/MPMD-296-rulesetsTargetDirectory/src/main/java/test/MyClass.java b/src/it/MPMD-296-rulesetsTargetDirectory/src/main/java/test/MyClass.java deleted file mode 100644 index 0be3612..0000000 --- a/src/it/MPMD-296-rulesetsTargetDirectory/src/main/java/test/MyClass.java +++ /dev/null @@ -1,31 +0,0 @@ -package test; - -/* - * 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 MyClass -{ - - public static void main( String[] args ) - { - ; - return; - } - -} diff --git a/src/it/MPMD-296-rulesetsTargetDirectory/verify.groovy b/src/it/MPMD-296-rulesetsTargetDirectory/verify.groovy deleted file mode 100644 index 5435ee0..0000000 --- a/src/it/MPMD-296-rulesetsTargetDirectory/verify.groovy +++ /dev/null @@ -1,34 +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() - -// default configuration -File defaultRuleset = new File( basedir, 'target/pmd/rulesets/001-maven-pmd-plugin-default.xml' ) -assert defaultRuleset.exists() - -// backwards compatible configuration (profile customTargetOld) -File customTargetOld = new File( basedir, 'target/001-maven-pmd-plugin-default.xml' ) -assert customTargetOld.exists() - -// custom configuration (profile customTarget) -File customTarget = new File( basedir, 'target/pmd-custom/001-maven-pmd-plugin-default.xml' ) -assert customTarget.exists() diff --git a/src/it/mpmd-80-included/pom.xml b/src/it/mpmd-80-included/pom.xml deleted file mode 100644 index 5a2cf75..0000000 --- a/src/it/mpmd-80-included/pom.xml +++ /dev/null @@ -1,56 +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 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-80-included</artifactId> - <version>1.0-SNAPSHOT</version> - - <name>MPMD-80 included</name> - <description> - Test that the cpd.xml and pmd.xml files are included in the generated reports output directory. - </description> - - <build> - <plugins> - <plugin> - <artifactId>maven-site-plugin</artifactId> - <version>@sitePluginVersion@</version> - </plugin> - </plugins> - </build> - - <reporting> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-pmd-plugin</artifactId> - <version>@project.version@</version> - <configuration> - <skipPmdError>false</skipPmdError> - <includeXmlInReports>true</includeXmlInReports> - </configuration> - </plugin> - </plugins> - </reporting> -</project> diff --git a/src/it/mpmd-80-included/verify.groovy b/src/it/mpmd-80-included/verify.groovy deleted file mode 100644 index e66dc95..0000000 --- a/src/it/mpmd-80-included/verify.groovy +++ /dev/null @@ -1,27 +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 targetDir = new File( basedir, "target" ); -File siteDir = new File( targetDir, "site" ); - -File pmdXmlInSite = new File( siteDir, "pmd.xml" ) -assert pmdXmlInSite.exists() - -File cpdXmlInSite = new File( siteDir, "cpd.xml" ) -assert cpdXmlInSite.exists() diff --git a/src/it/mpmd-80-not-included/pom.xml b/src/it/mpmd-80-not-included/pom.xml deleted file mode 100644 index fb71456..0000000 --- a/src/it/mpmd-80-not-included/pom.xml +++ /dev/null @@ -1,52 +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 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-80-not-included</artifactId> - <version>1.0-SNAPSHOT</version> - - <name>MPMD-80 not included</name> - <description> - Test that the cpd.xml and pmd.xml files are NOT included in the generated site. - </description> - - <build> - <plugins> - <plugin> - <artifactId>maven-site-plugin</artifactId> - <version>@sitePluginVersion@</version> - </plugin> - </plugins> - </build> - - <reporting> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-pmd-plugin</artifactId> - <version>@project.version@</version> - </plugin> - </plugins> - </reporting> -</project> diff --git a/src/it/mpmd-80-not-included/verify.groovy b/src/it/mpmd-80-not-included/verify.groovy deleted file mode 100644 index 157a399..0000000 --- a/src/it/mpmd-80-not-included/verify.groovy +++ /dev/null @@ -1,27 +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 targetDir = new File( basedir, "target" ); -File siteDir = new File( targetDir, "site" ); - -File pmdXmlInSite = new File( siteDir, "pmd.xml" ) -assert !pmdXmlInSite.exists() - -File cpdXmlInSite = new File( siteDir, "cpd.xml" ) -assert !cpdXmlInSite.exists() diff --git a/src/test/java/org/apache/maven/plugins/pmd/CpdReportTest.java b/src/test/java/org/apache/maven/plugins/pmd/CpdReportTest.java index 2b9d052..4b6d591 100644 --- a/src/test/java/org/apache/maven/plugins/pmd/CpdReportTest.java +++ b/src/test/java/org/apache/maven/plugins/pmd/CpdReportTest.java @@ -23,12 +23,14 @@ import javax.xml.parsers.DocumentBuilderFactory; import java.io.File; import java.io.IOException; +import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Locale; +import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; import org.apache.maven.api.plugin.testing.Basedir; import org.apache.maven.api.plugin.testing.InjectMojo; @@ -150,6 +152,9 @@ public class CpdReportTest { assertTrue(lowerCaseContains(str, "AnotherSample.java")); assertTrue(lowerCaseContains(str, "public static void main( String[] args )")); assertTrue(lowerCaseContains(str, "private String unusedMethod(")); + + // cpd.xml is only copied into the site when includeXmlInReports is set (MPMD-80) + assertFalse(new File(outputDir, "cpd.xml").exists()); } /** @@ -291,6 +296,75 @@ public class CpdReportTest { assertTrue(lowerCaseContains(str, "SampleDup.js")); } + /** + * MPMD-187: nothing is generated when CPD is skipped. + */ + @Basedir("/unit/default-configuration") + @InjectMojo(goal = "cpd", pom = "cpd-default-configuration-plugin-config.xml") + @MojoParameter(name = "siteDirectory", value = "src/site") + @MojoParameter(name = "skip", value = "true") + @Test + public void testSkipConfiguration(CpdReport mojo) throws Exception { + File cpdXml = new File(getBasedir(), "target/test/unit/default-configuration/target/cpd.xml"); + File generatedReport = new File(mojo.getReportOutputDirectory(), mojo.getOutputPath() + ".html"); + FileUtils.deleteQuietly(cpdXml); + FileUtils.deleteQuietly(generatedReport); + + mojo.execute(); + + assertFalse(cpdXml.exists()); + assertFalse(generatedReport.exists()); + + // the fact, the CPD execution has been skipped, should be logged + String output = CapturingPrintStream.getOutput(); + assertTrue(output.contains("Skipping org.apache.maven.plugins:maven-pmd-plugin"), output); + } + + /** + * MPMD-289: the xml report is written even if only the html report is requested, since the cpd-check goal reads it. + */ + @Basedir("/unit/default-configuration") + @InjectMojo(goal = "cpd", pom = "cpd-default-configuration-plugin-config.xml") + @MojoParameter(name = "siteDirectory", value = "src/site") + @MojoParameter(name = "format", value = "html") + @Test + public void testFormatHtmlStillWritesXml(CpdReport mojo) throws Exception { + File cpdXml = new File(getBasedir(), "target/test/unit/default-configuration/target/cpd.xml"); + FileUtils.deleteQuietly(cpdXml); + + mojo.execute(); + + assertTrue(new File(mojo.getReportOutputDirectory(), mojo.getOutputPath() + ".html").exists()); + assertTrue(cpdXml.exists()); + assertTrue(readFile(cpdXml, StandardCharsets.UTF_8).contains("</pmd-cpd>")); + } + + /** + * MPMD-290: CPD tokenizes C# sources, so the license header comment is not reported as duplication. + */ + @Basedir("/unit/default-configuration") + @InjectMojo(goal = "cpd", pom = "cpd-cs-plugin-config.xml") + @MojoParameter(name = "siteDirectory", value = "src/site") + @Test + public void testCpdCSharpConfiguration(CpdReport mojo) throws Exception { + File generatedFile = new File(getBasedir(), "target/test/unit/default-configuration/target/cpd.xml"); + FileUtils.deleteQuietly(generatedFile); + + mojo.execute(); + + assertTrue(generatedFile.exists()); + String str = readFile(generatedFile, StandardCharsets.UTF_8); + assertEquals(1, StringUtils.countMatches(str, "<duplication")); + + // no duplication for the license header - if this is reported, then CPD uses the wrong language/tokenizer + assertFalse(str.contains("<duplication lines=\"20\" tokens=\"148\">")); + assertFalse(str.contains("line=\"1\"")); + + // the only valid duplication + assertTrue(str.contains("<duplication lines=\"7\" tokens=\"26\">")); + assertTrue(str.contains("line=\"20\"")); + } + @Basedir("/unit/default-configuration") @InjectMojo(goal = "cpd", pom = "cpd-jsp-plugin-config.xml") @MojoParameter(name = "siteDirectory", value = "src/site") @@ -358,4 +432,8 @@ public class CpdReportTest { protected String readFile(File file) throws IOException { return new String(Files.readAllBytes(file.toPath())); } + + private static String readFile(File file, Charset charset) throws IOException { + return new String(Files.readAllBytes(file.toPath()), charset); + } } diff --git a/src/test/java/org/apache/maven/plugins/pmd/CpdViolationCheckMojoTest.java b/src/test/java/org/apache/maven/plugins/pmd/CpdViolationCheckMojoTest.java index c69ecd5..64ab324 100644 --- a/src/test/java/org/apache/maven/plugins/pmd/CpdViolationCheckMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/pmd/CpdViolationCheckMojoTest.java @@ -120,6 +120,10 @@ public class CpdViolationCheckMojoTest { violationMessages.stream() .filter(message -> message.toString().startsWith("CPD Failure:")) .count()); + // the duplication is reported with its size (MPMD-290) + assertTrue(violationMessages.stream() + .anyMatch(message -> + message.toString().equals("CPD Failure: Found 29 lines of duplicated code at locations:"))); } } } diff --git a/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java b/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java index 1eda2d8..77f6f7c 100644 --- a/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java +++ b/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java @@ -22,6 +22,7 @@ import java.io.File; import java.io.IOException; import java.net.ServerSocket; import java.net.URL; +import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.Locale; @@ -29,10 +30,12 @@ import java.util.Locale; import com.github.tomakehurst.wiremock.WireMockServer; import com.github.tomakehurst.wiremock.client.WireMock; import net.sourceforge.pmd.renderers.Renderer; +import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; import org.apache.maven.api.plugin.testing.Basedir; import org.apache.maven.api.plugin.testing.InjectMojo; +import org.apache.maven.api.plugin.testing.MojoExtension; import org.apache.maven.api.plugin.testing.MojoParameter; import org.apache.maven.api.plugin.testing.MojoTest; import org.apache.maven.plugin.MojoExecutionException; @@ -214,6 +217,10 @@ public class PmdReportTest { String str = readFile(generatedReport); assertTrue(str.contains("Avoid using global variables")); + + // the violation is also part of the xml report, which is what the check goal evaluates + generatedFile = new File(getBasedir(), "target/test/unit/default-configuration/target/pmd.xml"); + assertTrue(readFile(generatedFile, StandardCharsets.UTF_8).contains("GlobalVariable")); } @Basedir("/unit/default-configuration") @@ -351,6 +358,10 @@ public class PmdReportTest { assertTrue(lowerCaseContains(str, "veryLongVariableNameWithViolation")); // notSoLongVariableName should not be reported assertFalse(lowerCaseContains(str, "notSoLongVariableName")); + + // pmd.xml is only copied into the site when includeXmlInReports is set (MPMD-80) + assertTrue(new File(getBasedir(), "target/test/unit/custom-configuration/target/pmd.csv").exists()); + assertFalse(new File(outputDir, "pmd.xml").exists()); } /** @@ -480,6 +491,166 @@ public class PmdReportTest { assertTrue(pmdXml.contains("</pmd>")); } + /** + * MPMD-165: the generated report uses the configured output encoding. + */ + @Basedir("/unit/default-configuration") + @InjectMojo(goal = "pmd", pom = "default-configuration-plugin-config.xml") + @MojoParameter(name = "siteDirectory", value = "src/site") + @MojoParameter(name = "outputEncoding", value = "UTF-16") + @Test + public void testOutputEncoding(PmdReport mojo) throws Exception { + mojo.execute(); + + File generatedReport = new File(mojo.getReportOutputDirectory(), mojo.getOutputPath() + ".html"); + assertTrue(generatedReport.exists()); + + // the file is UTF-16 encoded, so it must be decoded as such to find the ascii text + String html = readFile(generatedReport, StandardCharsets.UTF_16); + assertTrue(html.contains("<meta charset=\"UTF-16\" />")); + } + + /** + * MPMD-181: the benchmark is written to the configured file. + */ + @Basedir("/unit/default-configuration") + @InjectMojo(goal = "pmd", pom = "default-configuration-plugin-config.xml") + @MojoParameter(name = "siteDirectory", value = "src/site") + @MojoParameter(name = "benchmark", value = "true") + @Test + public void testBenchmark(PmdReport mojo) throws Exception { + File targetDirectory = new File(getBasedir(), "target/test/unit/default-configuration/target"); + File benchmarkFile = new File(targetDirectory, "my-own-pmd-benchmark.txt"); + File defaultBenchmarkFile = new File(targetDirectory, "pmd-benchmark.txt"); + FileUtils.deleteQuietly(benchmarkFile); + FileUtils.deleteQuietly(defaultBenchmarkFile); + MojoExtension.setVariableValueToObject(mojo, "benchmarkOutputFilename", benchmarkFile.getAbsolutePath()); + + mojo.execute(); + + assertTrue(benchmarkFile.exists()); + assertFalse(defaultBenchmarkFile.exists()); + } + + /** + * MPMD-181: without the benchmark option, no benchmark file is written to the configured or default location. + */ + @Basedir("/unit/default-configuration") + @InjectMojo(goal = "pmd", pom = "default-configuration-plugin-config.xml") + @MojoParameter(name = "siteDirectory", value = "src/site") + @Test + public void testNoBenchmark(PmdReport mojo) throws Exception { + File targetDirectory = new File(getBasedir(), "target/test/unit/default-configuration/target"); + File benchmarkFile = new File(targetDirectory, "my-own-pmd-benchmark.txt"); + // the default is ${project.build.directory}/pmd-benchmark.txt + File defaultBenchmarkFile = new File(getBasedir(), "target/pmd-benchmark.txt"); + FileUtils.deleteQuietly(benchmarkFile); + FileUtils.deleteQuietly(defaultBenchmarkFile); + + mojo.execute(); + + assertTrue(new File(targetDirectory, "pmd.xml").exists()); + assertFalse(benchmarkFile.exists()); + assertFalse(defaultBenchmarkFile.exists()); + assertFalse(new File(targetDirectory, "pmd-benchmark.txt").exists()); + } + + /** + * MPMD-268: a deprecated rule name is logged once. + */ + @Basedir("/unit/default-configuration") + @InjectMojo(goal = "pmd", pom = "default-configuration-plugin-config.xml") + @MojoParameter(name = "siteDirectory", value = "src/site") + @Test + public void testDeprecatedRuleNameIsLoggedOnce(PmdReport mojo) throws Exception { + URL ruleset = + getClass().getClassLoader().getResource("unit/default-configuration/rulesets/deprecated-rule.xml"); + assertNotNull(ruleset); + mojo.setRulesets(new String[] {ruleset.toString()}); + + mojo.execute(); + + String output = CapturingPrintStream.getOutput(); + assertEquals( + 1, + StringUtils.countMatches( + output, + "Use Rule name category/java/codestyle.xml/ControlStatementBraces" + + " instead of the deprecated Rule name"), + output); + } + + /** + * MPMD-289: the xml report is written even if only the html report is requested, since the check goal reads it. + */ + @Basedir("/unit/default-configuration") + @InjectMojo(goal = "pmd", pom = "default-configuration-plugin-config.xml") + @MojoParameter(name = "siteDirectory", value = "src/site") + @MojoParameter(name = "format", value = "html") + @Test + public void testFormatHtmlStillWritesXml(PmdReport mojo) throws Exception { + File targetDirectory = new File(getBasedir(), "target/test/unit/default-configuration/target"); + File pmdXml = new File(targetDirectory, "pmd.xml"); + FileUtils.deleteQuietly(pmdXml); + + mojo.execute(); + + assertTrue(new File(mojo.getReportOutputDirectory(), mojo.getOutputPath() + ".html").exists()); + assertTrue(pmdXml.exists()); + assertTrue(readFile(pmdXml, StandardCharsets.UTF_8).contains("</pmd>")); + } + + /** + * MPMD-296: the resolved rulesets are copied to ${project.build.directory}/pmd/rulesets by default. + */ + @Basedir("/unit/default-configuration") + @InjectMojo(goal = "pmd", pom = "pmd-report-default-rulesets-target-directory.xml") + @MojoParameter(name = "siteDirectory", value = "src/site") + @Test + public void testRulesetsTargetDirectoryDefault(PmdReport mojo) throws Exception { + File rulesetsDirectory = new File(getBasedir(), "target/pmd/rulesets"); + FileUtils.deleteQuietly(rulesetsDirectory); + + mojo.execute(); + + assertTrue(new File(rulesetsDirectory, "001-maven-pmd-plugin-default.xml").exists()); + } + + /** + * MPMD-296: rulesetsTargetDirectory set to the build directory, as it was before the option got a sub directory. + */ + @Basedir("/unit/default-configuration") + @InjectMojo(goal = "pmd", pom = "default-configuration-plugin-config.xml") + @MojoParameter(name = "siteDirectory", value = "src/site") + @Test + public void testRulesetsTargetDirectoryBuildDirectory(PmdReport mojo) throws Exception { + File targetDirectory = new File(getBasedir(), "target/test/unit/default-configuration/target"); + File ruleset = new File(targetDirectory, "001-maven-pmd-plugin-default.xml"); + FileUtils.deleteQuietly(ruleset); + MojoExtension.setVariableValueToObject(mojo, "rulesetsTargetDirectory", targetDirectory); + + mojo.execute(); + + assertTrue(ruleset.exists()); + } + + /** + * MPMD-296: rulesetsTargetDirectory set to a custom directory. + */ + @Basedir("/unit/default-configuration") + @InjectMojo(goal = "pmd", pom = "default-configuration-plugin-config.xml") + @MojoParameter(name = "siteDirectory", value = "src/site") + @Test + public void testRulesetsTargetDirectoryCustom(PmdReport mojo) throws Exception { + File customDirectory = new File(getBasedir(), "target/test/unit/default-configuration/target/pmd-custom"); + FileUtils.deleteQuietly(customDirectory); + MojoExtension.setVariableValueToObject(mojo, "rulesetsTargetDirectory", customDirectory); + + mojo.execute(); + + assertTrue(new File(customDirectory, "001-maven-pmd-plugin-default.xml").exists()); + } + /** * Verify the correct working of the locationTemp method. */ @@ -619,6 +790,12 @@ public class PmdReportTest { fail("Expected exception"); } catch (MojoExecutionException e) { assertTrue(e.getCause().getMessage().endsWith("Found 1 PMD processing error")); + + // the processing error and the broken file are logged (MPMD-219) + String output = CapturingPrintStream.getOutput(); + assertTrue(output.contains("PMD processing errors"), output); + assertTrue(output.contains("ParseException: Parse exception in file"), output); + assertTrue(output.contains("BrokenFile.java"), output); } } @@ -830,4 +1007,8 @@ public class PmdReportTest { protected String readFile(File file) throws IOException { return new String(Files.readAllBytes(file.toPath())); } + + private static String readFile(File file, Charset charset) throws IOException { + return new String(Files.readAllBytes(file.toPath()), charset); + } } diff --git a/src/test/java/org/apache/maven/plugins/pmd/PmdViolationCheckMojoOnLinuxTest.java b/src/test/java/org/apache/maven/plugins/pmd/PmdViolationCheckMojoOnLinuxTest.java index b1fca4c..466ada9 100644 --- a/src/test/java/org/apache/maven/plugins/pmd/PmdViolationCheckMojoOnLinuxTest.java +++ b/src/test/java/org/apache/maven/plugins/pmd/PmdViolationCheckMojoOnLinuxTest.java @@ -192,4 +192,93 @@ public class PmdViolationCheckMojoOnLinuxTest { .count()); } } + + /** + * MPMD-163: with a failure priority that nothing reaches, every violation is reported once, as a warning. + */ + @Basedir("/unit/default-configuration") + @InjectMojo(goal = "check", pom = "pmd-check-default-configuration-plugin-config.xml") + @MojoParameter(name = "siteDirectory", value = "src/site") + @MojoParameter(name = "targetDirectory", value = "pmd-report") + @MojoParameter(name = "verbose", value = "true") + @MojoParameter(name = "printFailingErrors", value = "true") + @MojoParameter(name = "failurePriority", value = "0") + @Test + public void testWarningsAreNotDuplicated(PmdViolationCheckMojo mojo) throws Exception { + Log log = mock(Log.class); + mojo.setLog(log); + + mojo.execute(); + + List<String> messages = warnings(log); + assertEquals( + 0, messages.stream().filter(m -> m.startsWith("PMD Failure:")).count()); + assertEquals( + 8, messages.stream().filter(m -> m.startsWith("PMD Warning:")).count()); + assertTrue(messages.contains("PMD Warning: def.configuration.AppSample:45 Rule:UnusedFormalParameter" + + " Priority:3 Avoid unused method parameters such as 'notUsedParam'..")); + assertEquals( + 1, + messages.stream() + .filter(m -> + m.startsWith("PMD " + AbstractPmdReport.getPmdVersion() + " has issued 8 warnings.")) + .count()); + } + + /** + * MPMD-205: a violation in a file without a java class, like javascript, is reported by its file name and fails + * the build. + */ + @Basedir("/unit/default-configuration") + @InjectMojo(goal = "check", pom = "pmd-check-default-configuration-plugin-config.xml") + @MojoParameter(name = "siteDirectory", value = "src/site") + @MojoParameter(name = "targetDirectory", value = "pmd-report-js") + @Test + public void testJavascriptViolationFailsTheBuild(PmdViolationCheckMojo mojo) throws Exception { + Log log = mock(Log.class); + mojo.setLog(log); + + try { + mojo.execute(); + + fail("MojoFailureException should be thrown."); + } catch (MojoFailureException e) { + assertTrue( + e.getMessage().startsWith("PMD " + AbstractPmdReport.getPmdVersion() + " has found 1 violation.")); + } + assertTrue(warnings(log) + .contains( + "PMD Failure: PmdJsCheck.js:23 Rule:GlobalVariable Priority:1 Avoid using global variables.")); + } + + /** + * MPMD-243: violations listed in excludeFromFailureFile do not fail the build, but are still reported as warnings. + */ + @Basedir("/unit/default-configuration") + @InjectMojo(goal = "check", pom = "pmd-check-pmd-exclusions-configuration-plugin-config.xml") + @MojoParameter(name = "siteDirectory", value = "src/site") + @MojoParameter(name = "targetDirectory", value = "pmd-report") + @MojoParameter(name = "verbose", value = "true") + @Test + public void testExcludedViolationsAreReportedAsWarnings(PmdViolationCheckMojo mojo) throws Exception { + Log log = mock(Log.class); + mojo.setLog(log); + + mojo.execute(); + + List<String> messages = warnings(log); + assertEquals( + 0, messages.stream().filter(m -> m.startsWith("PMD Failure:")).count()); + assertEquals( + 8, messages.stream().filter(m -> m.startsWith("PMD Warning:")).count()); + assertTrue(messages.stream().anyMatch(m -> m.startsWith("PMD Warning: def.configuration.App2:22 "))); + assertTrue(messages.stream() + .anyMatch(m -> m.startsWith("PMD " + AbstractPmdReport.getPmdVersion() + " has issued 8 warnings."))); + } + + private static List<String> warnings(Log log) { + ArgumentCaptor<CharSequence> messages = ArgumentCaptor.forClass(CharSequence.class); + verify(log, atLeastOnce()).warn(messages.capture()); + return messages.getAllValues().stream().map(CharSequence::toString).collect(Collectors.toList()); + } } diff --git a/src/it/MPMD-290-cpd-for-csharp/pom.xml b/src/test/resources/unit/default-configuration/cpd-cs-plugin-config.xml similarity index 53% rename from src/it/MPMD-290-cpd-for-csharp/pom.xml rename to src/test/resources/unit/default-configuration/cpd-cs-plugin-config.xml index 38907b4..7350628 100644 --- a/src/it/MPMD-290-cpd-for-csharp/pom.xml +++ b/src/test/resources/unit/default-configuration/cpd-cs-plugin-config.xml @@ -1,5 +1,3 @@ -<?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 @@ -9,7 +7,7 @@ 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 + 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 @@ -19,50 +17,46 @@ 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"> +<project> <modelVersion>4.0.0</modelVersion> - - <groupId>org.apache.maven.plugins.pmd.its</groupId> - <artifactId>MPMD-290-cpd-for-csharp</artifactId> + <groupId>def.configuration</groupId> + <artifactId>cpd-cs</artifactId> + <packaging>jar</packaging> <version>1.0-SNAPSHOT</version> - - <description> - Use CPD via m-pmd-p to analyze duplications in c# files. - </description> - + <inceptionYear>2006</inceptionYear> + <name>Maven CPD Plugin C# Configuration Test</name> + <url>http://maven.apache.org</url> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-pmd-plugin</artifactId> - <version>@project.version@</version> <configuration> - <language>cs</language> + <project implementation="org.apache.maven.plugins.pmd.stubs.DefaultConfigurationMavenProjectStub"/> + <outputDirectory>${basedir}/target/test/unit/default-configuration/target/site</outputDirectory> + <targetDirectory>${basedir}/target/test/unit/default-configuration/target</targetDirectory> + <format>xml</format> + <linkXRef>false</linkXRef> + <xrefLocation>${basedir}/target/test/unit/default-configuration/target/site/xref</xrefLocation> <minimumTokens>10</minimumTokens> + <language>cs</language> <includes> <include>**/*.cs</include> </includes> <compileSourceRoots> - <compileSourceRoot>${basedir}/src/main/cs</compileSourceRoot> + <compileSourceRoot>${basedir}</compileSourceRoot> </compileSourceRoots> - <printFailingErrors>true</printFailingErrors> + <inputEncoding>UTF-8</inputEncoding> </configuration> - <executions> - <execution> - <goals> - <goal>cpd-check</goal> - </goals> - </execution> - </executions> - <dependencies> - <dependency> - <groupId>net.sourceforge.pmd</groupId> - <artifactId>pmd-cs</artifactId> - <version>@pmdVersion@</version> - </dependency> - </dependencies> </plugin> </plugins> </build> - + <reporting> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jxr-plugin</artifactId> + </plugin> + </plugins> + </reporting> </project> diff --git a/src/it/MPMD-290-cpd-for-csharp/src/main/cs/Sample1.cs b/src/test/resources/unit/default-configuration/cs/Sample1.cs similarity index 100% rename from src/it/MPMD-290-cpd-for-csharp/src/main/cs/Sample1.cs rename to src/test/resources/unit/default-configuration/cs/Sample1.cs diff --git a/src/it/MPMD-290-cpd-for-csharp/src/main/cs/Sample2.cs b/src/test/resources/unit/default-configuration/cs/Sample2.cs similarity index 100% rename from src/it/MPMD-290-cpd-for-csharp/src/main/cs/Sample2.cs rename to src/test/resources/unit/default-configuration/cs/Sample2.cs diff --git a/src/test/resources/unit/default-configuration/pmd-report-default-rulesets-target-directory.xml b/src/test/resources/unit/default-configuration/pmd-report-default-rulesets-target-directory.xml new file mode 100644 index 0000000..bfc873b --- /dev/null +++ b/src/test/resources/unit/default-configuration/pmd-report-default-rulesets-target-directory.xml @@ -0,0 +1,65 @@ +<!-- +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>def.configuration</groupId> + <artifactId>default-configuration</artifactId> + <packaging>jar</packaging> + <version>1.0-SNAPSHOT</version> + <inceptionYear>2006</inceptionYear> + <name>Maven PMD Plugin Default Rulesets Target Directory Test</name> + <url>http://maven.apache.org</url> + <build> + <finalName>default-configuration</finalName> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-pmd-plugin</artifactId> + <configuration> + <project implementation="org.apache.maven.plugins.pmd.stubs.DefaultConfigurationMavenProjectStub"/> + <outputDirectory>${basedir}/target/test/unit/default-configuration/target/site</outputDirectory> + <targetDirectory>${basedir}/target/test/unit/default-configuration/target</targetDirectory> + <format>xml</format> + <linkXRef>true</linkXRef> + <xrefLocation>${basedir}/target/test/unit/default-configuration/target/site/xref</xrefLocation> + <inputEncoding>UTF-8</inputEncoding> + <compileSourceRoots> + <compileSourceRoot>${basedir}</compileSourceRoot> + </compileSourceRoots> + </configuration> + <dependencies> + <dependency> + <groupId>pmd</groupId> + <artifactId>pmd</artifactId> + <version>3.6</version> + </dependency> + </dependencies> + </plugin> + </plugins> + </build> + <reporting> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jxr-plugin</artifactId> + </plugin> + </plugins> + </reporting> +</project> diff --git a/src/it/MPMD-243-excludeFromFailureFile/config/ruleset.xml b/src/test/resources/unit/default-configuration/pmd-report-js/pmd.xml similarity index 50% rename from src/it/MPMD-243-excludeFromFailureFile/config/ruleset.xml rename to src/test/resources/unit/default-configuration/pmd-report-js/pmd.xml index 47daac1..68156bf 100644 --- a/src/it/MPMD-243-excludeFromFailureFile/config/ruleset.xml +++ b/src/test/resources/unit/default-configuration/pmd-report-js/pmd.xml @@ -8,7 +8,7 @@ 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 + 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 @@ -17,14 +17,11 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> -<ruleset name="Ruleset for MPMD-243" - xmlns="http://pmd.sourceforge.net/ruleset/2.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd"> - - <description> - MPMD-243 - </description> - - <rule ref="category/java/codestyle.xml/TooManyStaticImports"/> -</ruleset> +<!-- The file name has no directory, so that the check goal reports the same name on every operating system. --> +<pmd xmlns="http://pmd.sourceforge.net/report/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pmd.sourceforge.net/report/2.0.0 https://pmd.github.io/schema/report_2_0_0.xsd" version="7.18.0" timestamp="2025-12-15T19:12:14.544"> +<file name="PmdJsCheck.js"> +<violation beginline="23" endline="23" begincolumn="5" endcolumn="23" rule="GlobalVariable" ruleset="Best Practices" externalInfoUrl="https://docs.pmd-code.org/pmd-doc-7.18.0/pmd_rules_ecmascript_bestpractices.html#globalvariable" priority="1"> +Avoid using global variables +</violation> +</file> +</pmd> diff --git a/src/it/MPMD-268-deprecated-rules/ruleset.xml b/src/test/resources/unit/default-configuration/rulesets/deprecated-rule.xml similarity index 100% rename from src/it/MPMD-268-deprecated-rules/ruleset.xml rename to src/test/resources/unit/default-configuration/rulesets/deprecated-rule.xml
