Skip to content

Commit 5ae53f1

Browse files
committed
[MPMD-283] Create a real aggregate goal
Closes #45
1 parent 995edef commit 5ae53f1

30 files changed

+1029
-26
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
invoker.goals = clean verify site
19+
invoker.maven.version = 3+
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing,
15+
software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations
19+
under the License.
20+
-->
21+
22+
<project>
23+
<modelVersion>4.0.0</modelVersion>
24+
25+
<parent>
26+
<groupId>org.apache.maven.plugins.pmd.it</groupId>
27+
<artifactId>MPMD-283-aggregated-pmd</artifactId>
28+
<version>1.0-SNAPSHOT</version>
29+
</parent>
30+
31+
<artifactId>MPMD-283-aggregated-pmd-module-a</artifactId>
32+
33+
<build>
34+
<plugins>
35+
<plugin>
36+
<groupId>@project.groupId@</groupId>
37+
<artifactId>@project.artifactId@</artifactId>
38+
<configuration>
39+
<rulesets>
40+
<ruleset>../ruleset.xml</ruleset>
41+
</rulesets>
42+
</configuration>
43+
</plugin>
44+
</plugins>
45+
</build>
46+
</project>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package module.a;
2+
3+
/*
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing,
15+
* software distributed under the License is distributed on an
16+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
* KIND, either express or implied. See the License for the
18+
* specific language governing permissions and limitations
19+
* under the License.
20+
*/
21+
22+
public interface IModuleA
23+
{
24+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package module.a;
2+
3+
/*
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing,
15+
* software distributed under the License is distributed on an
16+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
* KIND, either express or implied. See the License for the
18+
* specific language governing permissions and limitations
19+
* under the License.
20+
*/
21+
22+
public class ModuleA implements IModuleA
23+
{
24+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing,
15+
software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations
19+
under the License.
20+
-->
21+
22+
<project>
23+
<modelVersion>4.0.0</modelVersion>
24+
25+
<parent>
26+
<groupId>org.apache.maven.plugins.pmd.it</groupId>
27+
<artifactId>MPMD-283-aggregated-pmd</artifactId>
28+
<version>1.0-SNAPSHOT</version>
29+
</parent>
30+
31+
<artifactId>MPMD-283-aggregated-pmd-module-b</artifactId>
32+
33+
<build>
34+
<plugins>
35+
<plugin>
36+
<groupId>@project.groupId@</groupId>
37+
<artifactId>@project.artifactId@</artifactId>
38+
<configuration>
39+
<rulesets>
40+
<ruleset>../ruleset.xml</ruleset>
41+
</rulesets>
42+
</configuration>
43+
</plugin>
44+
</plugins>
45+
</build>
46+
47+
<dependencies>
48+
<dependency>
49+
<groupId>${project.groupId}</groupId>
50+
<artifactId>MPMD-283-aggregated-pmd-module-a</artifactId>
51+
<version>${project.version}</version>
52+
</dependency>
53+
54+
<dependency>
55+
<groupId>org.apache.commons</groupId>
56+
<artifactId>commons-math</artifactId>
57+
<version>2.2</version>
58+
</dependency>
59+
</dependencies>
60+
</project>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package module.b;
2+
3+
/*
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing,
15+
* software distributed under the License is distributed on an
16+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
* KIND, either express or implied. See the License for the
18+
* specific language governing permissions and limitations
19+
* under the License.
20+
*/
21+
22+
import module.a.IModuleA;
23+
import module.a.ModuleA;
24+
import org.apache.commons.math.complex.Complex;
25+
import org.apache.commons.math.FieldElement;
26+
27+
public class ModuleB
28+
{
29+
public static void main( String[] args )
30+
{
31+
ModuleA m = new ModuleA();
32+
doSomething( m );
33+
}
34+
35+
// this method will be detected as being unsued,
36+
// if typeresolution is not setup correctly: module a needs
37+
// to be on PMD's auxclasspath, so that PMD knows, that ModuleA
38+
// implements IModuleA
39+
private static void doSomething( IModuleA module )
40+
{
41+
System.out.println( module );
42+
}
43+
44+
public static void aPublicMethod()
45+
{
46+
Complex u = new Complex(1, 1);
47+
aPrivateMethod( u );
48+
}
49+
50+
private static void aPrivateMethod( FieldElement<Complex> u )
51+
{
52+
System.out.println( "aPrivateMethod: " + u );
53+
}
54+
}
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing,
15+
software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations
19+
under the License.
20+
-->
21+
22+
<project>
23+
<modelVersion>4.0.0</modelVersion>
24+
25+
<groupId>org.apache.maven.plugins.pmd.it</groupId>
26+
<artifactId>MPMD-283-aggregated-pmd</artifactId>
27+
<version>1.0-SNAPSHOT</version>
28+
<packaging>pom</packaging>
29+
30+
<properties>
31+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
32+
<maven.compiler.source>1.8</maven.compiler.source>
33+
<maven.compiler.target>1.8</maven.compiler.target>
34+
</properties>
35+
36+
<modules>
37+
<module>module-a</module>
38+
<module>module-b</module>
39+
</modules>
40+
41+
<build>
42+
<pluginManagement>
43+
<plugins>
44+
<plugin>
45+
<groupId>org.apache.maven.plugins</groupId>
46+
<artifactId>maven-site-plugin</artifactId>
47+
<version>@sitePluginVersion@</version>
48+
</plugin>
49+
</plugins>
50+
</pluginManagement>
51+
<plugins>
52+
<plugin>
53+
<groupId>@project.groupId@</groupId>
54+
<artifactId>@project.artifactId@</artifactId>
55+
<version>@project.version@</version>
56+
<configuration>
57+
<typeResolution>true</typeResolution>
58+
<failurePriority>1</failurePriority>
59+
<linkXRef>false</linkXRef>
60+
<rulesets>
61+
<ruleset>ruleset.xml</ruleset>
62+
</rulesets>
63+
</configuration>
64+
<executions>
65+
<execution>
66+
<inherited>false</inherited> <!-- don't run aggregate in child modules -->
67+
<goals>
68+
<goal>aggregate-pmd-check</goal>
69+
<goal>aggregate-cpd-check</goal>
70+
</goals>
71+
</execution>
72+
</executions>
73+
</plugin>
74+
</plugins>
75+
</build>
76+
77+
<reporting>
78+
<plugins>
79+
<plugin>
80+
<groupId>@project.groupId@</groupId>
81+
<artifactId>@project.artifactId@</artifactId>
82+
<version>@project.version@</version>
83+
<configuration>
84+
<typeResolution>true</typeResolution>
85+
<rulesets>
86+
<ruleset>ruleset.xml</ruleset>
87+
</rulesets>
88+
<skipEmptyReport>false</skipEmptyReport>
89+
<linkXRef>false</linkXRef>
90+
</configuration>
91+
<reportSets>
92+
<reportSet><!-- default reportSet - this is empty to prevent creating reports in child modules -->
93+
<reports></reports>
94+
</reportSet>
95+
<reportSet><!-- aggregate reportSet, to define in poms having modules -->
96+
<id>aggregate</id>
97+
<inherited>false</inherited> <!-- don't run aggregate in child modules -->
98+
<reports>
99+
<report>aggregate-pmd</report>
100+
<report>aggregate-cpd</report>
101+
</reports>
102+
</reportSet>
103+
</reportSets>
104+
</plugin>
105+
</plugins>
106+
</reporting>
107+
</project>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing,
15+
software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations
19+
under the License.
20+
-->
21+
22+
<ruleset name="Custom ruleset"
23+
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
24+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
25+
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
26+
<description>Custom Ruleset for test case MPMD-283</description>
27+
28+
<rule ref="category/java/bestpractices.xml/UnusedPrivateMethod">
29+
<priority>5</priority>
30+
</rule>
31+
32+
</ruleset>

0 commit comments

Comments
 (0)