Skip to content

Commit

Permalink
[MPMD-283] Create a real aggregate goal
Browse files Browse the repository at this point in the history
Closes #45
  • Loading branch information
adangel committed Sep 5, 2021
1 parent 995edef commit 5ae53f1
Show file tree
Hide file tree
Showing 30 changed files with 1,029 additions and 26 deletions.
19 changes: 19 additions & 0 deletions src/it/MPMD-283-aggregated-pmd/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

invoker.goals = clean verify site
invoker.maven.version = 3+
46 changes: 46 additions & 0 deletions src/it/MPMD-283-aggregated-pmd/module-a/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

<project>
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.apache.maven.plugins.pmd.it</groupId>
<artifactId>MPMD-283-aggregated-pmd</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>MPMD-283-aggregated-pmd-module-a</artifactId>

<build>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<configuration>
<rulesets>
<ruleset>../ruleset.xml</ruleset>
</rulesets>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package module.a;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

public interface IModuleA
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package module.a;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

public class ModuleA implements IModuleA
{
}
60 changes: 60 additions & 0 deletions src/it/MPMD-283-aggregated-pmd/module-b/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

<project>
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.apache.maven.plugins.pmd.it</groupId>
<artifactId>MPMD-283-aggregated-pmd</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>MPMD-283-aggregated-pmd-module-b</artifactId>

<build>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<configuration>
<rulesets>
<ruleset>../ruleset.xml</ruleset>
</rulesets>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>MPMD-283-aggregated-pmd-module-a</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math</artifactId>
<version>2.2</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package module.b;

/*
* 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 module.a.IModuleA;
import module.a.ModuleA;
import org.apache.commons.math.complex.Complex;
import org.apache.commons.math.FieldElement;

public class ModuleB
{
public static void main( String[] args )
{
ModuleA m = new ModuleA();
doSomething( m );
}

// this method will be detected as being unsued,
// if typeresolution is not setup correctly: module a needs
// to be on PMD's auxclasspath, so that PMD knows, that ModuleA
// implements IModuleA
private static void doSomething( IModuleA module )
{
System.out.println( module );
}

public static void aPublicMethod()
{
Complex u = new Complex(1, 1);
aPrivateMethod( u );
}

private static void aPrivateMethod( FieldElement<Complex> u )
{
System.out.println( "aPrivateMethod: " + u );
}
}
107 changes: 107 additions & 0 deletions src/it/MPMD-283-aggregated-pmd/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<?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-283-aggregated-pmd</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<modules>
<module>module-a</module>
<module>module-b</module>
</modules>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>@sitePluginVersion@</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
<configuration>
<typeResolution>true</typeResolution>
<failurePriority>1</failurePriority>
<linkXRef>false</linkXRef>
<rulesets>
<ruleset>ruleset.xml</ruleset>
</rulesets>
</configuration>
<executions>
<execution>
<inherited>false</inherited> <!-- don't run aggregate in child modules -->
<goals>
<goal>aggregate-pmd-check</goal>
<goal>aggregate-cpd-check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

<reporting>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
<configuration>
<typeResolution>true</typeResolution>
<rulesets>
<ruleset>ruleset.xml</ruleset>
</rulesets>
<skipEmptyReport>false</skipEmptyReport>
<linkXRef>false</linkXRef>
</configuration>
<reportSets>
<reportSet><!-- default reportSet - this is empty to prevent creating reports in child modules -->
<reports></reports>
</reportSet>
<reportSet><!-- aggregate reportSet, to define in poms having modules -->
<id>aggregate</id>
<inherited>false</inherited> <!-- don't run aggregate in child modules -->
<reports>
<report>aggregate-pmd</report>
<report>aggregate-cpd</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
</project>
32 changes: 32 additions & 0 deletions src/it/MPMD-283-aggregated-pmd/ruleset.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

<ruleset name="Custom ruleset"
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>Custom Ruleset for test case MPMD-283</description>

<rule ref="category/java/bestpractices.xml/UnusedPrivateMethod">
<priority>5</priority>
</rule>

</ruleset>
Loading

0 comments on commit 5ae53f1

Please sign in to comment.