Skip to content

Commit 45a5e54

Browse files
committed
[MPMD-322] Display when PMD/CPD is skipped
1 parent b8fc018 commit 45a5e54

File tree

5 files changed

+16
-4
lines changed

5 files changed

+16
-4
lines changed

src/main/java/org/apache/maven/plugins/pmd/CpdReport.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ public boolean canGenerateReport()
170170
{
171171
if ( skip )
172172
{
173+
getLog().info( "Skipping CPD execution" );
173174
return false;
174175
}
175176

src/main/java/org/apache/maven/plugins/pmd/CpdViolationCheckMojo.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,13 @@ public CpdViolationCheckMojo()
7575
public void execute()
7676
throws MojoExecutionException, MojoFailureException
7777
{
78-
if ( !skip )
78+
if ( skip )
7979
{
80-
executeCheck( "cpd.xml", "duplication", "CPD duplication", 10 );
80+
getLog().info( "Skipping CPD execution" );
81+
return;
8182
}
83+
84+
executeCheck( "cpd.xml", "duplication", "CPD duplication", 10 );
8285
}
8386

8487
/**

src/main/java/org/apache/maven/plugins/pmd/PmdReport.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ public boolean canGenerateReport()
315315
{
316316
if ( skip )
317317
{
318+
getLog().info( "Skipping PMD execution" );
318319
return false;
319320
}
320321

src/main/java/org/apache/maven/plugins/pmd/PmdViolationCheckMojo.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,13 @@ public PmdViolationCheckMojo()
8484
public void execute()
8585
throws MojoExecutionException, MojoFailureException
8686
{
87-
if ( !skip )
87+
if ( skip )
8888
{
89-
executeCheck( "pmd.xml", "violation", "PMD violation", failurePriority );
89+
getLog().info( "Skipping PMD execution" );
90+
return;
9091
}
92+
93+
executeCheck( "pmd.xml", "violation", "PMD violation", failurePriority );
9194
}
9295

9396
/**

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,10 @@ public void testSkipConfiguration()
365365

366366
generatedFile = new File( getBasedir(), "target/test/unit/custom-configuration/target/site/pmd.html" );
367367
assertFalse( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
368+
369+
// the fact, the PMD execution has been skipped, should be logged
370+
String output = CapturingPrintStream.getOutput();
371+
assertTrue ( output.contains( "Skipping PMD execution" ) );
368372
}
369373

370374
public void testSkipEmptyReportConfiguration()

0 commit comments

Comments
 (0)