Skip to content

Commit

Permalink
[MPMD-308] Set Maven 3.1.0 as minimum version
Browse files Browse the repository at this point in the history
Remove now unnecessary maven-compat, fix test
Downgrade wiremock, to use a with maven compatible
guava version.

Closes #46
  • Loading branch information
adangel committed Sep 5, 2021
1 parent 5ae53f1 commit 3ffd4d3
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 19 deletions.
26 changes: 15 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ under the License.
</distributionManagement>

<properties>
<mavenVersion>3.0</mavenVersion>
<mavenVersion>3.1.0</mavenVersion>
<doxiaVersion>1.9.1</doxiaVersion>
<doxiaSitetoolsVersion>1.9.2</doxiaSitetoolsVersion>
<javaVersion>8</javaVersion><!-- Because PMD 6.35.0+ requires Java 8 -->
Expand Down Expand Up @@ -131,12 +131,18 @@ under the License.
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-common-artifact-filters</artifactId>
<version>3.1.0</version>
<version>${mavenVersion}</version>
<exclusions>
<exclusion>
<groupId>org.sonatype.sisu</groupId>
<artifactId>sisu-guice</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-embedder</artifactId>
<version>3.1.0</version>
<version>${mavenVersion}</version>
<scope>provided</scope>
<exclusions>
<!-- exclude old asm:asm, as pmd brings in a newer version (org.ow2.asm:asm) -->
Expand Down Expand Up @@ -238,22 +244,20 @@ under the License.
</dependency>

<!-- test -->
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-compat</artifactId>
<version>${mavenVersion}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-testing</groupId>
<artifactId>maven-plugin-testing-harness</artifactId>
<version>2.1</version>
<version>${mavenVersion}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock</artifactId>
<version>2.9.0</version>
<!-- that's a very old version, but it's the newest one that brings in
a old guava version, that is compatible with maven 3.1.0.
maven 3.1.0 uses guava 10, wiremock 1.49 uses guava 13.0.1
-->
<version>1.49</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,22 @@ protected void setUp()
public void testDefaultConfiguration()
throws Exception
{
File testPom =
new File( getBasedir(),
"src/test/resources/unit/default-configuration/cpd-default-configuration-plugin-config.xml" );
final CpdReport mojo = (CpdReport) lookupMojo( "cpd", testPom );
mojo.execute();

// clear the output from previous pmd:cpd execution
CapturingPrintStream.init( true );

try
{
final File testPom =
testPom =
new File( getBasedir(),
"src/test/resources/unit/default-configuration/pmd-check-default-configuration-plugin-config.xml" );
final CpdViolationCheckMojo mojo = (CpdViolationCheckMojo) lookupMojo( "cpd-check", testPom );
mojo.execute();
final CpdViolationCheckMojo cpdViolationMojo = (CpdViolationCheckMojo) lookupMojo( "cpd-check", testPom );
cpdViolationMojo.execute();

fail( "MojoFailureException should be thrown." );
}
Expand Down
10 changes: 6 additions & 4 deletions src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,11 @@ public void testFileURL()
final String sonarProfileUrl = sonarBaseUrl + "/export?format=pmd&language=java&name=Sonar%2520way";
final String sonarExportRulesetUrl = "http://localhost:" + mockServer.port() + sonarProfileUrl;

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

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

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

mockServer.stubFor( WireMock.get( WireMock.urlEqualTo( sonarProfileUrl ) )
WireMock.configureFor( "localhost", port );
WireMock.stubFor( WireMock.get( WireMock.urlEqualTo( sonarProfileUrl ) )
.willReturn( WireMock.aResponse().withStatus( 200 ).withHeader( "Content-Type",
"text/xml" ).withBody( sonarRuleset ) ) );
mockServer.stubFor( WireMock.get( WireMock.urlEqualTo( myRulesetBaseUrl ) )
WireMock.stubFor( WireMock.get( WireMock.urlEqualTo( myRulesetBaseUrl ) )
.willReturn( WireMock.aResponse().withStatus( 200 ).withHeader( "Content-Type",
"text/xml" ).withBody( sonarRuleset ) ) );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
import java.net.URLClassLoader;

import org.apache.commons.lang3.SystemUtils;
import org.junit.Assert;

import junit.framework.Assert;
import junit.framework.TestCase;

public class ExecutorTest extends TestCase
Expand Down

0 comments on commit 3ffd4d3

Please sign in to comment.