Author: nicolas Date: Wed Apr 23 04:11:09 2008 New Revision: 650825 URL: http://svn.apache.org/viewvc?rev=650825&view=rev Log: MENFORCER-44 banTimestamps to enable timestamp SNAPSHOT (as release plugin does)
Modified: maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java maven/enforcer/trunk/enforcer-rules/src/site/apt/rules/requirePluginVersions.apt maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequirePluginVersions.java Modified: maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java?rev=650825&r1=650824&r2=650825&view=diff ============================================================================== --- maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java (original) +++ maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java Wed Apr 23 04:11:09 2008 @@ -97,6 +97,12 @@ public boolean banSnapshots = true; /** + * Don't allow timestamp snapshot plugins. + */ + public boolean banTimestamps = true; + + + /** * The comma separated list of phases that should be used to find lifecycle plugin bindings. The default value is * "clean,deploy,site". * @@ -196,7 +202,7 @@ { StringBuffer newMsg = new StringBuffer(); newMsg.append( "Some plugins are missing valid versions:" ); - if ( banLatest || banRelease || banSnapshots ) + if ( banLatest || banRelease || banSnapshots || banTimestamps ) { newMsg.append( "(" ); if ( banLatest ) @@ -207,7 +213,7 @@ { newMsg.append( "RELEASE " ); } - if ( banSnapshots ) + if ( banSnapshots || banTimestamps ) { newMsg.append( "SNAPSHOT " ); } @@ -537,8 +543,15 @@ protected boolean isSnapshot( String baseVersion ) { - return Artifact.VERSION_FILE_PATTERN.matcher( baseVersion ).matches() || - baseVersion.endsWith( Artifact.SNAPSHOT_VERSION ); + if ( banTimestamps ) + { + return Artifact.VERSION_FILE_PATTERN.matcher( baseVersion ).matches() || + baseVersion.endsWith( Artifact.SNAPSHOT_VERSION ); + } + else + { + return baseVersion.endsWith( Artifact.SNAPSHOT_VERSION ); + } } /* @@ -969,5 +982,22 @@ public void setBanSnapshots( boolean theBanSnapshots ) { this.banSnapshots = theBanSnapshots; + } + + + /** + * @return the banTimestamps + */ + public boolean isBanTimestamps() + { + return this.banTimestamps; + } + + /** + * @param theBanTimestamps the banTimestamps to set + */ + public void setBanTimestamps( boolean theBanTimestamps ) + { + this.banTimestamps = theBanTimestamps; } } Modified: maven/enforcer/trunk/enforcer-rules/src/site/apt/rules/requirePluginVersions.apt URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/enforcer-rules/src/site/apt/rules/requirePluginVersions.apt?rev=650825&r1=650824&r2=650825&view=diff ============================================================================== --- maven/enforcer/trunk/enforcer-rules/src/site/apt/rules/requirePluginVersions.apt (original) +++ maven/enforcer/trunk/enforcer-rules/src/site/apt/rules/requirePluginVersions.apt Wed Apr 23 04:11:09 2008 @@ -36,7 +36,9 @@ * banRelease - disallow any use of "RELEASE" as a version for any plugin. Default = true. * banSnapshots - disallow any use of SNAPSHOT plugins. Default = true. - + + * banTimestamps - disallow any use of snapshot plugins with timestamp version (only enabled when banSnapshots is true). Default = true. + * phases - The comma separated list of phases that should be used to find lifecycle plugin bindings. The default value is "clean,deploy,site". Modified: maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequirePluginVersions.java URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequirePluginVersions.java?rev=650825&r1=650824&r2=650825&view=diff ============================================================================== --- maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequirePluginVersions.java (original) +++ maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequirePluginVersions.java Wed Apr 23 04:11:09 2008 @@ -70,6 +70,7 @@ plugins.add( EnforcerTestUtils.newPlugin( "group", "f-artifact", "1.0" ) ); plugins.add( EnforcerTestUtils.newPlugin( "group", "f-artifact", "LATEST" ) ); plugins.add( EnforcerTestUtils.newPlugin( "group", "f-artifact", "1.0-SNAPSHOT" ) ); + plugins.add( EnforcerTestUtils.newPlugin( "group", "g-artifact", "1.0-12345678.123456-1" ) ); RequirePluginVersions rule = new RequirePluginVersions(); rule.setBanLatest( false ); @@ -96,6 +97,11 @@ rule.setBanLatest( false ); rule.setBanSnapshots( true ); assertFalse( rule.hasValidVersionSpecified( helper, source, plugins ) ); + + // check that TIMESTAMP is allowed + rule.setBanTimestamps( false ); + source.setArtifactId( "g-artifact" ); + assertTrue( rule.hasValidVersionSpecified( helper, source, plugins ) ); // check that RELEASE is allowed source.setArtifactId( "d-artifact" );