[MNG-7457] Warn about deprecated plugin Mojo

This commit is contained in:
Slawomir Jaranowski 2022-04-23 21:48:58 +02:00
parent c8413005bc
commit cbafd073be
3 changed files with 20 additions and 6 deletions

View File

@ -106,7 +106,7 @@ public static Test suite()
// Tests that don't run stable and need to be fixed
// -------------------------------------------------------------------------------------------------------------
// suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137
suite.addTestSuite( MavenITmng5222MojoDeprecatedParamsTest.class );
suite.addTestSuite( MavenITmng5222MojoDeprecatedTest.class );
suite.addTestSuite( MavenITmng7390SelectModuleOutsideCwdTest.class );
suite.addTestSuite( MavenITmng7244IgnorePomPrefixInExpressions.class );
suite.addTestSuite( MavenITmng7349RelocationWarningTest.class );

View File

@ -28,12 +28,14 @@
import org.apache.maven.it.util.ResourceExtractor;
/**
* Test for <a href="https://issues.apache.org/jira/browse/MNG-5222">MNG-5222</a>
* Test for
* <a href="https://issues.apache.org/jira/browse/MNG-5222">MNG-5222</a>
* <a href="https://issues.apache.org/jira/browse/MNG-7457">MNG-7457</a>
*/
public class MavenITmng5222MojoDeprecatedParamsTest
public class MavenITmng5222MojoDeprecatedTest
extends AbstractMavenIntegrationTestCase
{
public MavenITmng5222MojoDeprecatedParamsTest()
public MavenITmng5222MojoDeprecatedTest()
{
super( "[3.9.0,)" );
}
@ -58,7 +60,11 @@ public void testEmptyConfiguration()
List<String> logLines = verifier.loadFile( verifier.getBasedir(), verifier.getLogFileName(), false );
List<String> warnLines = findDeprecationWarning( logLines );
assertTrue( "Log contains warnings: " + warnLines, warnLines.isEmpty() );
assertTrue( warnLines.remove(
"[WARNING] Goal 'deprecated-config' is deprecated: This goal is deprecated" ) );
assertTrue( "Not verified line: " + warnLines, warnLines.isEmpty() );
Properties configProps = verifier.loadProperties( "target/config.properties" );
@ -106,6 +112,9 @@ public void testDeprecatedProperty()
List<String> logLines = verifier.loadFile( verifier.getBasedir(), verifier.getLogFileName(), false );
List<String> warnLines = findDeprecationWarning( logLines );
assertTrue( warnLines.remove(
"[WARNING] Goal 'deprecated-config' is deprecated: This goal is deprecated" ) );
assertTrue( warnLines.remove(
"[WARNING] Parameter 'deprecatedParam2' (user property 'config.deprecatedParam2') is deprecated: No reason given" ) );
@ -170,6 +179,9 @@ public void testDeprecatedConfig()
List<String> logLines = verifier.loadFile( verifier.getBasedir(), verifier.getLogFileName(), false );
List<String> warnLines = findDeprecationWarning( logLines );
assertTrue( warnLines.remove(
"[WARNING] Goal 'deprecated-config' is deprecated: This goal is deprecated" ) );
assertTrue( warnLines.remove(
"[WARNING] Parameter 'deprecatedParam' is deprecated: I'm deprecated param" ) );
@ -238,7 +250,7 @@ public void testDeprecatedConfig()
private List<String> findDeprecationWarning( List<String> logLines )
{
Pattern pattern = Pattern.compile( "\\[WARNING] Parameter .* is deprecated:.*" );
Pattern pattern = Pattern.compile( "\\[WARNING] (Parameter|Goal) .* is deprecated:.*" );
List<String> result = new ArrayList<>();
for ( String line : logLines )
{

View File

@ -36,7 +36,9 @@
* Dumps this mojo's configuration into a properties file.
*
* @author Slawomir Jaranowski
* @deprecated This goal is deprecated
*/
@Deprecated
@Mojo( name = "deprecated-config", defaultPhase = LifecyclePhase.VALIDATE )
public class DeprecatedConfigMojo
extends AbstractMojo