Skip to content

Commit 3ffd4d3

Browse files
committed
[MPMD-308] Set Maven 3.1.0 as minimum version
Remove now unnecessary maven-compat, fix test Downgrade wiremock, to use a with maven compatible guava version. Closes #46
1 parent 5ae53f1 commit 3ffd4d3

File tree

4 files changed

+34
-19
lines changed

4 files changed

+34
-19
lines changed

pom.xml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ under the License.
8585
</distributionManagement>
8686

8787
<properties>
88-
<mavenVersion>3.0</mavenVersion>
88+
<mavenVersion>3.1.0</mavenVersion>
8989
<doxiaVersion>1.9.1</doxiaVersion>
9090
<doxiaSitetoolsVersion>1.9.2</doxiaSitetoolsVersion>
9191
<javaVersion>8</javaVersion><!-- Because PMD 6.35.0+ requires Java 8 -->
@@ -131,12 +131,18 @@ under the License.
131131
<dependency>
132132
<groupId>org.apache.maven.shared</groupId>
133133
<artifactId>maven-common-artifact-filters</artifactId>
134-
<version>3.1.0</version>
134+
<version>${mavenVersion}</version>
135+
<exclusions>
136+
<exclusion>
137+
<groupId>org.sonatype.sisu</groupId>
138+
<artifactId>sisu-guice</artifactId>
139+
</exclusion>
140+
</exclusions>
135141
</dependency>
136142
<dependency>
137143
<groupId>org.apache.maven</groupId>
138144
<artifactId>maven-embedder</artifactId>
139-
<version>3.1.0</version>
145+
<version>${mavenVersion}</version>
140146
<scope>provided</scope>
141147
<exclusions>
142148
<!-- exclude old asm:asm, as pmd brings in a newer version (org.ow2.asm:asm) -->
@@ -238,22 +244,20 @@ under the License.
238244
</dependency>
239245

240246
<!-- test -->
241-
<dependency>
242-
<groupId>org.apache.maven</groupId>
243-
<artifactId>maven-compat</artifactId>
244-
<version>${mavenVersion}</version>
245-
<scope>test</scope>
246-
</dependency>
247247
<dependency>
248248
<groupId>org.apache.maven.plugin-testing</groupId>
249249
<artifactId>maven-plugin-testing-harness</artifactId>
250-
<version>2.1</version>
250+
<version>${mavenVersion}</version>
251251
<scope>test</scope>
252252
</dependency>
253253
<dependency>
254254
<groupId>com.github.tomakehurst</groupId>
255255
<artifactId>wiremock</artifactId>
256-
<version>2.9.0</version>
256+
<!-- that's a very old version, but it's the newest one that brings in
257+
a old guava version, that is compatible with maven 3.1.0.
258+
maven 3.1.0 uses guava 10, wiremock 1.49 uses guava 13.0.1
259+
-->
260+
<version>1.49</version>
257261
<scope>test</scope>
258262
</dependency>
259263
<dependency>

src/test/java/org/apache/maven/plugins/pmd/CpdViolationCheckMojoTest.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,22 @@ protected void setUp()
4242
public void testDefaultConfiguration()
4343
throws Exception
4444
{
45+
File testPom =
46+
new File( getBasedir(),
47+
"src/test/resources/unit/default-configuration/cpd-default-configuration-plugin-config.xml" );
48+
final CpdReport mojo = (CpdReport) lookupMojo( "cpd", testPom );
49+
mojo.execute();
50+
51+
// clear the output from previous pmd:cpd execution
52+
CapturingPrintStream.init( true );
53+
4554
try
4655
{
47-
final File testPom =
56+
testPom =
4857
new File( getBasedir(),
4958
"src/test/resources/unit/default-configuration/pmd-check-default-configuration-plugin-config.xml" );
50-
final CpdViolationCheckMojo mojo = (CpdViolationCheckMojo) lookupMojo( "cpd-check", testPom );
51-
mojo.execute();
59+
final CpdViolationCheckMojo cpdViolationMojo = (CpdViolationCheckMojo) lookupMojo( "cpd-check", testPom );
60+
cpdViolationMojo.execute();
5261

5362
fail( "MojoFailureException should be thrown." );
5463
}

src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,11 @@ public void testFileURL()
245245
final String sonarProfileUrl = sonarBaseUrl + "/export?format=pmd&language=java&name=Sonar%2520way";
246246
final String sonarExportRulesetUrl = "http://localhost:" + mockServer.port() + sonarProfileUrl;
247247

248-
mockServer.stubFor( WireMock.get( WireMock.urlEqualTo( sonarBaseUrl ) ).willReturn( WireMock.aResponse().withStatus( 200 ).withHeader( "Content-Type",
248+
WireMock.configureFor( "localhost", port );
249+
WireMock.stubFor( WireMock.get( WireMock.urlEqualTo( sonarBaseUrl ) ).willReturn( WireMock.aResponse().withStatus( 200 ).withHeader( "Content-Type",
249250
"text/html" ).withBody( sonarMainPageHtml ) ) );
250251

251-
mockServer.stubFor( WireMock.get( WireMock.urlEqualTo( sonarProfileUrl ) ).willReturn( WireMock.aResponse().withStatus( 200 ).withHeader( "Content-Type",
252+
WireMock.stubFor( WireMock.get( WireMock.urlEqualTo( sonarProfileUrl ) ).willReturn( WireMock.aResponse().withStatus( 200 ).withHeader( "Content-Type",
252253
"text/xml" ).withBody( sonarRuleset ) ) );
253254

254255
URL url = getClass().getClassLoader().getResource( "rulesets/java/basic.xml" );
@@ -719,10 +720,11 @@ public void testPmdReportResolveRulesets()
719720
final String myRulesetBaseUrl = "/config/my-ruleset.xml";
720721
final String myRulesetUrl = "http://localhost:" + mockServer.port() + myRulesetBaseUrl;
721722

722-
mockServer.stubFor( WireMock.get( WireMock.urlEqualTo( sonarProfileUrl ) )
723+
WireMock.configureFor( "localhost", port );
724+
WireMock.stubFor( WireMock.get( WireMock.urlEqualTo( sonarProfileUrl ) )
723725
.willReturn( WireMock.aResponse().withStatus( 200 ).withHeader( "Content-Type",
724726
"text/xml" ).withBody( sonarRuleset ) ) );
725-
mockServer.stubFor( WireMock.get( WireMock.urlEqualTo( myRulesetBaseUrl ) )
727+
WireMock.stubFor( WireMock.get( WireMock.urlEqualTo( myRulesetBaseUrl ) )
726728
.willReturn( WireMock.aResponse().withStatus( 200 ).withHeader( "Content-Type",
727729
"text/xml" ).withBody( sonarRuleset ) ) );
728730

src/test/java/org/apache/maven/plugins/pmd/exec/ExecutorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
import java.net.URLClassLoader;
2626

2727
import org.apache.commons.lang3.SystemUtils;
28-
import org.junit.Assert;
2928

29+
import junit.framework.Assert;
3030
import junit.framework.TestCase;
3131

3232
public class ExecutorTest extends TestCase

0 commit comments

Comments
 (0)