Skip to content

Commit

Permalink
[MPMD-277] Plugin tries to download local submodules from repo
Browse files Browse the repository at this point in the history
* Add Integration Test
* Exclude modules of the reactor build
* Issue a warning if the modules are not built yet
* Add FAQ section
  • Loading branch information
adangel committed Apr 6, 2019
1 parent 70ad1f0 commit 953adf0
Show file tree
Hide file tree
Showing 16 changed files with 422 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/it/MPMD-266-typeresolution-aggregated/invoker.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
# specific language governing permissions and limitations
# under the License.

invoker.goals = clean install
invoker.goals.2 = site
invoker.goals = clean verify
invoker.goals.2 = verify site -DskipTests
invoker.maven.version = 3+
13 changes: 13 additions & 0 deletions src/it/MPMD-266-typeresolution-aggregated/module-a/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,17 @@ under the License.

<artifactId>MPMD-266-typeresolution-aggregated-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>
14 changes: 14 additions & 0 deletions src/it/MPMD-266-typeresolution-aggregated/module-b/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ under the License.

<artifactId>MPMD-266-typeresolution-aggregated-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>
Expand Down
5 changes: 5 additions & 0 deletions src/it/MPMD-266-typeresolution-aggregated/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ under the License.
<version>@project.version@</version>
<configuration>
<typeResolution>true</typeResolution>
<aggregate>false</aggregate>
<failurePriority>1</failurePriority>
<rulesets>
<ruleset>ruleset.xml</ruleset>
</rulesets>
</configuration>
<executions>
<execution>
Expand Down
4 changes: 3 additions & 1 deletion src/it/MPMD-266-typeresolution-aggregated/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ under the License.
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-266</description>

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

</ruleset>
20 changes: 20 additions & 0 deletions src/it/MPMD-277-multi-module-check/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 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 package
invoker.goals.2 = verify
invoker.maven.version = 3+
33 changes: 33 additions & 0 deletions src/it/MPMD-277-multi-module-check/module-a/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?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-277-multi-module-check-parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>MPMD-277-multi-module-check-module-a</artifactId>

</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
{
}
46 changes: 46 additions & 0 deletions src/it/MPMD-277-multi-module-check/module-b/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-277-multi-module-check-parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>MPMD-277-multi-module-check-module-b</artifactId>

<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>MPMD-277-multi-module-check-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 );
}
}
69 changes: 69 additions & 0 deletions src/it/MPMD-277-multi-module-check/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?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-277-multi-module-check-parent</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>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
<configuration>
<typeResolution>true</typeResolution>
<aggregate>true</aggregate>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
</plugin>
</plugins>
</build>
</project>
30 changes: 30 additions & 0 deletions src/it/MPMD-277-multi-module-check/ruleset.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?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-277</description>

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

</ruleset>
Loading

0 comments on commit 953adf0

Please sign in to comment.