You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by br...@apache.org on 2007/07/06 05:23:58 UTC
svn commit: r553715 - in /maven/plugins/trunk/maven-enforcer-plugin/src:
main/java/org/apache/maven/plugin/enforcer/ site/ site/apt/rules/
test/java/org/apache/maven/plugin/enforcer/
Author: brianf
Date: Thu Jul 5 20:23:57 2007
New Revision: 553715
URL: http://svn.apache.org/viewvc?view=rev&rev=553715
Log:
site updates for the new rules
Added:
maven/plugins/trunk/maven-enforcer-plugin/src/main/java/org/apache/maven/plugin/enforcer/NoSnapshots.java
- copied, changed from r553707, maven/plugins/trunk/maven-enforcer-plugin/src/main/java/org/apache/maven/plugin/enforcer/BanSnapshots.java
maven/plugins/trunk/maven-enforcer-plugin/src/site/apt/rules/bannedDependencies.apt
maven/plugins/trunk/maven-enforcer-plugin/src/site/apt/rules/noSnapshots.apt
maven/plugins/trunk/maven-enforcer-plugin/src/test/java/org/apache/maven/plugin/enforcer/TestNoSnapshots.java
- copied, changed from r553707, maven/plugins/trunk/maven-enforcer-plugin/src/test/java/org/apache/maven/plugin/enforcer/TestBanSnapshots.java
Removed:
maven/plugins/trunk/maven-enforcer-plugin/src/main/java/org/apache/maven/plugin/enforcer/BanSnapshots.java
maven/plugins/trunk/maven-enforcer-plugin/src/test/java/org/apache/maven/plugin/enforcer/TestBanSnapshots.java
Modified:
maven/plugins/trunk/maven-enforcer-plugin/src/main/java/org/apache/maven/plugin/enforcer/AbstractBanDependencies.java
maven/plugins/trunk/maven-enforcer-plugin/src/site/apt/rules/index.apt
maven/plugins/trunk/maven-enforcer-plugin/src/site/site.xml
Modified: maven/plugins/trunk/maven-enforcer-plugin/src/main/java/org/apache/maven/plugin/enforcer/AbstractBanDependencies.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-enforcer-plugin/src/main/java/org/apache/maven/plugin/enforcer/AbstractBanDependencies.java?view=diff&rev=553715&r1=553714&r2=553715
==============================================================================
--- maven/plugins/trunk/maven-enforcer-plugin/src/main/java/org/apache/maven/plugin/enforcer/AbstractBanDependencies.java (original)
+++ maven/plugins/trunk/maven-enforcer-plugin/src/main/java/org/apache/maven/plugin/enforcer/AbstractBanDependencies.java Thu Jul 5 20:23:57 2007
@@ -48,7 +48,6 @@
implements EnforcerRule
{
-
/**
* Specify if transitive dependencies should be searched
* (default) or only look at direct dependencies
@@ -100,16 +99,18 @@
// them
if ( !foundExcludes.isEmpty() )
{
- if ( message == null )
+ StringBuffer buf = new StringBuffer();
+ if (message !=null)
{
- StringBuffer buf = new StringBuffer();
- Iterator iter = foundExcludes.iterator();
- while ( iter.hasNext() )
- {
- buf.append( "Found Banned Dependency: " + ( (Artifact) iter.next() ).getId() + "\n" );
- }
- message = buf.toString();
+ buf.append( message +"\n");
}
+ Iterator iter = foundExcludes.iterator();
+ while ( iter.hasNext() )
+ {
+ buf.append( "Found Banned Dependency: " + ( (Artifact) iter.next() ).getId() + "\n" );
+ }
+ message = buf.toString();
+
throw new EnforcerRuleException( message );
}
@@ -125,7 +126,7 @@
*/
abstract protected Set checkDependencies( Set dependencies )
throws EnforcerRuleException;
-
+
/**
* @return the message
*/
@@ -151,7 +152,8 @@
}
/**
- * @param theSearchTransitive the searchTransitive to set
+ * @param theSearchTransitive the searchTransitive to
+ * set
*/
public void setSearchTransitive( boolean theSearchTransitive )
{
Copied: maven/plugins/trunk/maven-enforcer-plugin/src/main/java/org/apache/maven/plugin/enforcer/NoSnapshots.java (from r553707, maven/plugins/trunk/maven-enforcer-plugin/src/main/java/org/apache/maven/plugin/enforcer/BanSnapshots.java)
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-enforcer-plugin/src/main/java/org/apache/maven/plugin/enforcer/NoSnapshots.java?view=diff&rev=553715&p1=maven/plugins/trunk/maven-enforcer-plugin/src/main/java/org/apache/maven/plugin/enforcer/BanSnapshots.java&r1=553707&p2=maven/plugins/trunk/maven-enforcer-plugin/src/main/java/org/apache/maven/plugin/enforcer/NoSnapshots.java&r2=553715
==============================================================================
--- maven/plugins/trunk/maven-enforcer-plugin/src/main/java/org/apache/maven/plugin/enforcer/BanSnapshots.java (original)
+++ maven/plugins/trunk/maven-enforcer-plugin/src/main/java/org/apache/maven/plugin/enforcer/NoSnapshots.java Thu Jul 5 20:23:57 2007
@@ -44,7 +44,7 @@
* @version $Id$
*
*/
-public class BanSnapshots
+public class NoSnapshots
extends AbstractBanDependencies
{
Added: maven/plugins/trunk/maven-enforcer-plugin/src/site/apt/rules/bannedDependencies.apt
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-enforcer-plugin/src/site/apt/rules/bannedDependencies.apt?view=auto&rev=553715
==============================================================================
--- maven/plugins/trunk/maven-enforcer-plugin/src/site/apt/rules/bannedDependencies.apt (added)
+++ maven/plugins/trunk/maven-enforcer-plugin/src/site/apt/rules/bannedDependencies.apt Thu Jul 5 20:23:57 2007
@@ -0,0 +1,87 @@
+~~ Licensed to the Apache Software Foundation (ASF) under one
+~~ or more contributor license agreements. See the NOTICE file
+~~ distributed with this work for additional information
+~~ regarding copyright ownership. The ASF licenses this file
+~~ to you under the Apache License, Version 2.0 (the
+~~ "License"); you may not use this file except in compliance
+~~ with the License. You may obtain a copy of the License at
+~~
+~~ http://www.apache.org/licenses/LICENSE-2.0
+~~
+~~ Unless required by applicable law or agreed to in writing,
+~~ software distributed under the License is distributed on an
+~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+~~ KIND, either express or implied. See the License for the
+~~ specific language governing permissions and limitations
+~~ under the License.
+
+ ------
+ Banned Dependencies
+ ------
+ Brian Fox
+ ------
+ July 2007
+ ------
+
+Banned Dependencies
+
+ This rule checks the dependencies and fails if any of the matching excludes are found.
+
+
+ The following parameters are supported by this rule:
+
+ * searchTransitive - if transitive dependencies should be checked.
+
+ * excludes - a list of artifacts to ban. The format is groupId[:artifactId][:version] where artifactId and version are optional. Wildcards may be used to replace an entire section.
+ Examples:
+
+ *org.apache.maven
+
+ *org.apache.maven:badArtifact
+
+ *org.apache.maven:artifact:badVersion
+
+ *org.apache.maven:*:1.2
+
+ []
+ * message - an optional message to the user if the rule fails.
+
+ []
+
+
+ Sample Plugin Configuration:
+
++---+
+<project>
+ [...]
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>enforce-banned-dependencies</id>
+ <goals>
+ <goal>enforce-once</goal>
+ </goals>
+ <configuration>
+ <rules>
+ <bannedDependencies>
+ <excludes>
+ <exclude>org.apache.maven</exclude>
+ <exclude>org.apache.maven:badArtifact</exclude>
+ <exclude>*:badArtifact</exclude>
+ </excludes>
+ </bannedDependencies>
+ </rules>
+ <fail>true</fail>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ [...]
+</project>
++---+
\ No newline at end of file
Modified: maven/plugins/trunk/maven-enforcer-plugin/src/site/apt/rules/index.apt
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-enforcer-plugin/src/site/apt/rules/index.apt?view=diff&rev=553715&r1=553714&r2=553715
==============================================================================
--- maven/plugins/trunk/maven-enforcer-plugin/src/site/apt/rules/index.apt (original)
+++ maven/plugins/trunk/maven-enforcer-plugin/src/site/apt/rules/index.apt Thu Jul 5 20:23:57 2007
@@ -27,6 +27,13 @@
The following standard rules ship along with the enforcer plugin:
+
+ * {{{bannedDependencies.html}bannedDependencies}} - enforces that excluded dependencies aren't included.
+
+ * {{{evaluateBeanshell.html}evaluateBeanshell}} - evaluates a beanshell script.
+
+ * {{{noSnapshots.html}noSnapshots}} - enforces that no snapshots are included.
+
* {{{requireMavenVersion.html}requireMavenVersion}} - enforces the Maven version.
* {{{requireJavaVersion.html}requireJavaVersion}} - enforces the JDK version.
@@ -35,6 +42,5 @@
* {{{requireProperty.html}requireProperty}} - enforces the existence and values of properties.
- * {{{evaluateBeanshell.html}evaluateBeanshell}} - evaluates a beanshell script.
-
+ []
You may also create and inject your own custom rules by following the {{{http://maven.apache.org/shared/maven-enforcer-rule-api/writing-a-custom-rule.html}maven-enforcer-rule-api}} instructions.
Added: maven/plugins/trunk/maven-enforcer-plugin/src/site/apt/rules/noSnapshots.apt
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-enforcer-plugin/src/site/apt/rules/noSnapshots.apt?view=auto&rev=553715
==============================================================================
--- maven/plugins/trunk/maven-enforcer-plugin/src/site/apt/rules/noSnapshots.apt (added)
+++ maven/plugins/trunk/maven-enforcer-plugin/src/site/apt/rules/noSnapshots.apt Thu Jul 5 20:23:57 2007
@@ -0,0 +1,71 @@
+~~ Licensed to the Apache Software Foundation (ASF) under one
+~~ or more contributor license agreements. See the NOTICE file
+~~ distributed with this work for additional information
+~~ regarding copyright ownership. The ASF licenses this file
+~~ to you under the Apache License, Version 2.0 (the
+~~ "License"); you may not use this file except in compliance
+~~ with the License. You may obtain a copy of the License at
+~~
+~~ http://www.apache.org/licenses/LICENSE-2.0
+~~
+~~ Unless required by applicable law or agreed to in writing,
+~~ software distributed under the License is distributed on an
+~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+~~ KIND, either express or implied. See the License for the
+~~ specific language governing permissions and limitations
+~~ under the License.
+
+ ------
+ No Snapshots
+ ------
+ Brian Fox
+ ------
+ July 2007
+ ------
+
+No Snapshots
+
+ This rule checks the dependencies and fails if any snapshots are found.
+
+
+ The following parameters are supported by this rule:
+
+ * searchTransitive - if transitive dependencies should be checked.
+
+ * message - an optional message to the user if the rule fails.
+
+ []
+
+
+ Sample Plugin Configuration:
+
++---+
+<project>
+ [...]
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>enforce-no-snapshots</id>
+ <goals>
+ <goal>enforce-once</goal>
+ </goals>
+ <configuration>
+ <rules>
+ <noSnapshots>
+ <message>No Snapshots Allowed!</message>
+ </noSnapshots>
+ </rules>
+ <fail>true</fail>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ [...]
+</project>
++---+
\ No newline at end of file
Modified: maven/plugins/trunk/maven-enforcer-plugin/src/site/site.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-enforcer-plugin/src/site/site.xml?view=diff&rev=553715&r1=553714&r2=553715
==============================================================================
--- maven/plugins/trunk/maven-enforcer-plugin/src/site/site.xml (original)
+++ maven/plugins/trunk/maven-enforcer-plugin/src/site/site.xml Thu Jul 5 20:23:57 2007
@@ -29,10 +29,12 @@
</menu>
<menu name="Standard Rules">
<item name="Overview" href="rules/index.html"/>
+ <item name="BannedDependencies" href="rules/bannedDependencies.html"/>
+ <item name="EvaluateBeanshell" href="rules/evaluateBeanshell.html"/>
+ <item name="NoSnapshots" href="rules/noSnapshots.html"/>
<item name="RequireJavaVersion" href="rules/requireJavaVersion.html"/>
<item name="RequireMavenVersion" href="rules/requireMavenVersion.html"/>
<item name="RequireOS" href="rules/requireOS.html"/>
- <item name="EvaluateBeanshell" href="rules/evaluateBeanshell.html"/>
<item name="Version Range Specification" href="rules/versionRanges.html"/>
</menu>
<menu name="Custom Rules">
Copied: maven/plugins/trunk/maven-enforcer-plugin/src/test/java/org/apache/maven/plugin/enforcer/TestNoSnapshots.java (from r553707, maven/plugins/trunk/maven-enforcer-plugin/src/test/java/org/apache/maven/plugin/enforcer/TestBanSnapshots.java)
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-enforcer-plugin/src/test/java/org/apache/maven/plugin/enforcer/TestNoSnapshots.java?view=diff&rev=553715&p1=maven/plugins/trunk/maven-enforcer-plugin/src/test/java/org/apache/maven/plugin/enforcer/TestBanSnapshots.java&r1=553707&p2=maven/plugins/trunk/maven-enforcer-plugin/src/test/java/org/apache/maven/plugin/enforcer/TestNoSnapshots.java&r2=553715
==============================================================================
--- maven/plugins/trunk/maven-enforcer-plugin/src/test/java/org/apache/maven/plugin/enforcer/TestBanSnapshots.java (original)
+++ maven/plugins/trunk/maven-enforcer-plugin/src/test/java/org/apache/maven/plugin/enforcer/TestNoSnapshots.java Thu Jul 5 20:23:57 2007
@@ -32,7 +32,7 @@
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
*
*/
-public class TestBanSnapshots
+public class TestNoSnapshots
extends TestCase
{
@@ -44,7 +44,7 @@
EnforcerRuleHelper helper = EnforcerTestUtils.getHelper( project );
project.setArtifacts( factory.getMixedArtifacts() );
project.setDependencyArtifacts( factory.getScopedArtifacts() );
- BanSnapshots rule = new BanSnapshots();
+ NoSnapshots rule = new NoSnapshots();
rule.setSearchTransitive( false );
@@ -54,7 +54,7 @@
execute( rule, helper, true );
- }
+ }
/**
* Simpler wrapper to execute and deal with the expected
@@ -64,11 +64,11 @@
* @param helper
* @param shouldFail
*/
- private void execute( BanSnapshots rule, EnforcerRuleHelper helper, boolean shouldFail )
+ private void execute( NoSnapshots rule, EnforcerRuleHelper helper, boolean shouldFail )
{
try
{
- rule.message = null;
+ rule.message = "Test Message";
rule.execute( helper );
if ( shouldFail )
{
@@ -81,7 +81,7 @@
{
fail( "No Exception expected:" + e.getLocalizedMessage() );
}
- // helper.getLog().debug(e.getMessage());
+ helper.getLog().debug(e.getMessage());
}
}
}