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 2008/03/03 00:41:28 UTC
svn commit: r632882 [1/7] - in /maven/enforcer/trunk: ./ enforcer-api/
enforcer-api/src/custom-rule-sample/ enforcer-api/src/custom-rule-sample/src/
enforcer-api/src/custom-rule-sample/src/main/java/org/apache/maven/enforcer/rule/
enforcer-api/src/main...
Author: brianf
Date: Sun Mar 2 15:41:23 2008
New Revision: 632882
URL: http://svn.apache.org/viewvc?rev=632882&view=rev
Log:
MENFORCER-32 fixed eol property
Modified:
maven/enforcer/trunk/enforcer-api/pom.xml (contents, props changed)
maven/enforcer/trunk/enforcer-api/src/custom-rule-sample/pom.xml (contents, props changed)
maven/enforcer/trunk/enforcer-api/src/custom-rule-sample/src/main/java/org/apache/maven/enforcer/rule/MyCustomRule.java (contents, props changed)
maven/enforcer/trunk/enforcer-api/src/custom-rule-sample/src/usage-pom.xml (contents, props changed)
maven/enforcer/trunk/enforcer-api/src/custom-rule-sample/usage-pom.xml (contents, props changed)
maven/enforcer/trunk/enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRule.java (contents, props changed)
maven/enforcer/trunk/enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleException.java (contents, props changed)
maven/enforcer/trunk/enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java (contents, props changed)
maven/enforcer/trunk/enforcer-api/src/site/apt/index.apt (contents, props changed)
maven/enforcer/trunk/enforcer-api/src/site/apt/writing-a-custom-rule.apt (contents, props changed)
maven/enforcer/trunk/enforcer-api/src/site/site.xml (contents, props changed)
maven/enforcer/trunk/enforcer-rules/pom.xml (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/AbstractBanDependencies.java (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/AbstractRequireFiles.java (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/AbstractStandardEnforcerRule.java (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/AbstractVersionEnforcer.java (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/BannedDependencies.java (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/DefaultEnforcementRuleHelper.java (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/EnforcerExpressionEvaluator.java (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/EvaluateBeanshell.java (props changed)
maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/NoSnapshots.java (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireActiveProfile.java (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireFilesDontExist.java (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireFilesExist.java (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireJavaVersion.java (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireMavenVersion.java (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireNoRepositories.java (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireOS.java (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java (props changed)
maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireProperty.java (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireReleaseDeps.java (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireReleaseVersion.java (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/utils/EnforcerRuleUtils.java (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/site/apt/rules/bannedDependencies.apt (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/site/apt/rules/evaluateBeanshell.apt (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/site/apt/rules/index.apt (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/site/apt/rules/noSnapshots.apt (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/site/apt/rules/requireJavaVersion.apt (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/site/apt/rules/requireMavenVersion.apt (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/site/apt/rules/requireNoRepositories.apt (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/site/apt/rules/requireOS.apt (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/site/apt/rules/requirePluginVersions.apt (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/site/apt/rules/requireProperty.apt (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/site/apt/rules/requireReleaseDeps.apt (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/site/apt/rules/versionRanges.apt (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/site/site.xml (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/EnforcerTestUtils.java (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/MockPathTranslator.java (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/MockPlexusContainer.java (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/MockProject.java (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/MockRuntimeInformation.java (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestAbstractVersionEnforcer.java (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestBannedDependencies.java (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestEvaluateBeanshell.java (props changed)
maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestMavenVersion.java (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestNoSnapshots.java (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireJavaVersion.java (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireOS.java (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequirePluginVersions.java (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireProperty.java (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireReleaseVersion.java (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/utils/MockEnforcerExpressionEvaluator.java (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/utils/TestEnforcerRuleUtils.java (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/utils/TestMockEnforcerExpressionEvaluator.java (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/test/resources/requirePluginVersions/checkPluginPropertyVersion/pom.xml (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/test/resources/requirePluginVersions/checkPluginVersionProfile/pom.xml (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/test/resources/requirePluginVersions/getPomRecursively/b/c/pom.xml (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/test/resources/requirePluginVersions/getPomRecursively/b/pom.xml (contents, props changed)
maven/enforcer/trunk/enforcer-rules/src/test/resources/requirePluginVersions/getPomRecursively/pom.xml (contents, props changed)
maven/enforcer/trunk/pom.xml (contents, props changed)
maven/enforcer/trunk/src/site/site.xml (contents, props changed)
Modified: maven/enforcer/trunk/enforcer-api/pom.xml
URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/enforcer-api/pom.xml?rev=632882&r1=632881&r2=632882&view=diff
==============================================================================
--- maven/enforcer/trunk/enforcer-api/pom.xml (original)
+++ maven/enforcer/trunk/enforcer-api/pom.xml Sun Mar 2 15:41:23 2008
@@ -1,69 +1,69 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * 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.
- *
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.maven.enforcer</groupId>
- <artifactId>enforcer</artifactId>
- <version>1-SNAPSHOT</version>
- </parent>
-
- <artifactId>enforcer-api</artifactId>
- <packaging>jar</packaging>
- <version>1.0-SNAPSHOT</version>
-
- <name>Enforcer API</name>
- <description>This component provides the generic interfaces needed to implement custom rules for the maven-enforcer-plugin.</description>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.4</source>
- <target>1.4</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-maven-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>descriptor</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-plugin-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-container-default</artifactId>
- <version>1.0-alpha-9</version>
- </dependency>
-
- </dependencies>
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+ *
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.maven.enforcer</groupId>
+ <artifactId>enforcer</artifactId>
+ <version>1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>enforcer-api</artifactId>
+ <packaging>jar</packaging>
+ <version>1.0-SNAPSHOT</version>
+
+ <name>Enforcer API</name>
+ <description>This component provides the generic interfaces needed to implement custom rules for the maven-enforcer-plugin.</description>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.4</source>
+ <target>1.4</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>descriptor</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-container-default</artifactId>
+ <version>1.0-alpha-9</version>
+ </dependency>
+
+ </dependencies>
+</project>
Propchange: maven/enforcer/trunk/enforcer-api/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Modified: maven/enforcer/trunk/enforcer-api/src/custom-rule-sample/pom.xml
URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/enforcer-api/src/custom-rule-sample/pom.xml?rev=632882&r1=632881&r2=632882&view=diff
==============================================================================
--- maven/enforcer/trunk/enforcer-api/src/custom-rule-sample/pom.xml (original)
+++ maven/enforcer/trunk/enforcer-api/src/custom-rule-sample/pom.xml Sun Mar 2 15:41:23 2008
@@ -1,54 +1,54 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>custom-rule</groupId>
- <artifactId>custom-rule-sample</artifactId>
- <packaging>jar</packaging>
- <version>1.0</version>
- <name>My Custom Rule</name>
- <description>This is my custom rule.</description>
- <properties>
- <api.version>1.0-SNAPSHOT</api.version>
- <maven.version>2.0.6</maven.version>
- </properties>
- <build>
- </build>
- <dependencies>
- <dependency>
- <groupId>org.apache.maven.enforcer</groupId>
- <artifactId>enforcer-api</artifactId>
- <version>${api.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-project</artifactId>
- <version>${maven.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-core</artifactId>
- <version>${maven.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-artifact</artifactId>
- <version>${maven.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-plugin-api</artifactId>
- <version>${maven.version}</version>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-container-default</artifactId>
- <version>1.0-alpha-9</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>custom-rule</groupId>
+ <artifactId>custom-rule-sample</artifactId>
+ <packaging>jar</packaging>
+ <version>1.0</version>
+ <name>My Custom Rule</name>
+ <description>This is my custom rule.</description>
+ <properties>
+ <api.version>1.0-SNAPSHOT</api.version>
+ <maven.version>2.0.6</maven.version>
+ </properties>
+ <build>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.enforcer</groupId>
+ <artifactId>enforcer-api</artifactId>
+ <version>${api.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-project</artifactId>
+ <version>${maven.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ <version>${maven.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-artifact</artifactId>
+ <version>${maven.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>${maven.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-container-default</artifactId>
+ <version>1.0-alpha-9</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
Propchange: maven/enforcer/trunk/enforcer-api/src/custom-rule-sample/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Modified: maven/enforcer/trunk/enforcer-api/src/custom-rule-sample/src/main/java/org/apache/maven/enforcer/rule/MyCustomRule.java
URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/enforcer-api/src/custom-rule-sample/src/main/java/org/apache/maven/enforcer/rule/MyCustomRule.java?rev=632882&r1=632881&r2=632882&view=diff
==============================================================================
--- maven/enforcer/trunk/enforcer-api/src/custom-rule-sample/src/main/java/org/apache/maven/enforcer/rule/MyCustomRule.java (original)
+++ maven/enforcer/trunk/enforcer-api/src/custom-rule-sample/src/main/java/org/apache/maven/enforcer/rule/MyCustomRule.java Sun Mar 2 15:41:23 2008
@@ -1,101 +1,101 @@
-package org.apache.maven.enforcer.rule;
-
-import org.apache.maven.artifact.resolver.ArtifactResolver;
-import org.apache.maven.enforcer.rule.api.EnforcerRule;
-import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
-import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
-import org.apache.maven.execution.MavenSession;
-import org.apache.maven.execution.RuntimeInformation;
-import org.apache.maven.plugin.logging.Log;
-import org.apache.maven.project.MavenProject;
-import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
-import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
-
-/**
- * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
- */
-public class MyCustomRule
- implements EnforcerRule
-{
- /**
- * Simple param. This rule will fail if the value is true.
- */
- private boolean shouldIfail = false;
-
- public void execute( EnforcerRuleHelper helper )
- throws EnforcerRuleException
- {
- Log log = helper.getLog();
-
- try
- {
- // get the various expressions out of the helper.
- MavenProject project = (MavenProject) helper.evaluate( "${project}" );
- MavenSession session = (MavenSession) helper.evaluate( "${session}" );
- String target = (String) helper.evaluate( "${project.build.directory}" );
- String artifactId = (String) helper.evaluate( "${project.artifactId}" );
-
- // retreive any component out of the session directly
- ArtifactResolver resolver = (ArtifactResolver) helper.getComponent( ArtifactResolver.class );
- RuntimeInformation rti = (RuntimeInformation) helper.getComponent( RuntimeInformation.class );
-
- log.info( "Retrieved Target Folder: " + target );
- log.info( "Retrieved ArtifactId: " +artifactId );
- log.info( "Retrieved Project: " + project );
- log.info( "Retrieved RuntimeInfo: " + rti );
- log.info( "Retrieved Session: " + session );
- log.info( "Retrieved Resolver: " + resolver );
-
- if ( this.shouldIfail )
- {
- throw new EnforcerRuleException( "Failing because my param said so." );
- }
- }
- catch ( ComponentLookupException e )
- {
- throw new EnforcerRuleException( "Unable to lookup a component " + e.getLocalizedMessage(), e );
- }
- catch ( ExpressionEvaluationException e )
- {
- throw new EnforcerRuleException( "Unable to lookup an expression " + e.getLocalizedMessage(), e );
- }
- }
-
- /**
- * If your rule is cacheable, you must return a unique id when parameters or conditions
- * change that would cause the result to be different. Multiple cached results are stored
- * based on their id.
- *
- * The easiest way to do this is to return a hash computed from the values of your parameters.
- *
- * If your rule is not cacheable, then the result here is not important, you may return anything.
- */
- public String getCacheId()
- {
- //no hash on boolean...only parameter so no hash is needed.
- return ""+this.shouldIfail;
- }
-
- /**
- * This tells the system if the results are cacheable at all. Keep in mind that during
- * forked builds and other things, a given rule may be executed more than once for the same
- * project. This means that even things that change from project to project may still
- * be cacheable in certain instances.
- */
- public boolean isCacheable()
- {
- return false;
- }
-
- /**
- * If the rule is cacheable and the same id is found in the cache, the stored results
- * are passed to this method to allow double checking of the results. Most of the time
- * this can be done by generating unique ids, but sometimes the results of objects returned
- * by the helper need to be queried. You may for example, store certain objects in your rule
- * and then query them later.
- */
- public boolean isResultValid( EnforcerRule arg0 )
- {
- return false;
- }
-}
+package org.apache.maven.enforcer.rule;
+
+import org.apache.maven.artifact.resolver.ArtifactResolver;
+import org.apache.maven.enforcer.rule.api.EnforcerRule;
+import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
+import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.execution.RuntimeInformation;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+
+/**
+ * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
+ */
+public class MyCustomRule
+ implements EnforcerRule
+{
+ /**
+ * Simple param. This rule will fail if the value is true.
+ */
+ private boolean shouldIfail = false;
+
+ public void execute( EnforcerRuleHelper helper )
+ throws EnforcerRuleException
+ {
+ Log log = helper.getLog();
+
+ try
+ {
+ // get the various expressions out of the helper.
+ MavenProject project = (MavenProject) helper.evaluate( "${project}" );
+ MavenSession session = (MavenSession) helper.evaluate( "${session}" );
+ String target = (String) helper.evaluate( "${project.build.directory}" );
+ String artifactId = (String) helper.evaluate( "${project.artifactId}" );
+
+ // retreive any component out of the session directly
+ ArtifactResolver resolver = (ArtifactResolver) helper.getComponent( ArtifactResolver.class );
+ RuntimeInformation rti = (RuntimeInformation) helper.getComponent( RuntimeInformation.class );
+
+ log.info( "Retrieved Target Folder: " + target );
+ log.info( "Retrieved ArtifactId: " +artifactId );
+ log.info( "Retrieved Project: " + project );
+ log.info( "Retrieved RuntimeInfo: " + rti );
+ log.info( "Retrieved Session: " + session );
+ log.info( "Retrieved Resolver: " + resolver );
+
+ if ( this.shouldIfail )
+ {
+ throw new EnforcerRuleException( "Failing because my param said so." );
+ }
+ }
+ catch ( ComponentLookupException e )
+ {
+ throw new EnforcerRuleException( "Unable to lookup a component " + e.getLocalizedMessage(), e );
+ }
+ catch ( ExpressionEvaluationException e )
+ {
+ throw new EnforcerRuleException( "Unable to lookup an expression " + e.getLocalizedMessage(), e );
+ }
+ }
+
+ /**
+ * If your rule is cacheable, you must return a unique id when parameters or conditions
+ * change that would cause the result to be different. Multiple cached results are stored
+ * based on their id.
+ *
+ * The easiest way to do this is to return a hash computed from the values of your parameters.
+ *
+ * If your rule is not cacheable, then the result here is not important, you may return anything.
+ */
+ public String getCacheId()
+ {
+ //no hash on boolean...only parameter so no hash is needed.
+ return ""+this.shouldIfail;
+ }
+
+ /**
+ * This tells the system if the results are cacheable at all. Keep in mind that during
+ * forked builds and other things, a given rule may be executed more than once for the same
+ * project. This means that even things that change from project to project may still
+ * be cacheable in certain instances.
+ */
+ public boolean isCacheable()
+ {
+ return false;
+ }
+
+ /**
+ * If the rule is cacheable and the same id is found in the cache, the stored results
+ * are passed to this method to allow double checking of the results. Most of the time
+ * this can be done by generating unique ids, but sometimes the results of objects returned
+ * by the helper need to be queried. You may for example, store certain objects in your rule
+ * and then query them later.
+ */
+ public boolean isResultValid( EnforcerRule arg0 )
+ {
+ return false;
+ }
+}
Propchange: maven/enforcer/trunk/enforcer-api/src/custom-rule-sample/src/main/java/org/apache/maven/enforcer/rule/MyCustomRule.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: maven/enforcer/trunk/enforcer-api/src/custom-rule-sample/src/usage-pom.xml
URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/enforcer-api/src/custom-rule-sample/src/usage-pom.xml?rev=632882&r1=632881&r2=632882&view=diff
==============================================================================
--- maven/enforcer/trunk/enforcer-api/src/custom-rule-sample/src/usage-pom.xml (original)
+++ maven/enforcer/trunk/enforcer-api/src/custom-rule-sample/src/usage-pom.xml Sun Mar 2 15:41:23 2008
@@ -1,44 +1,44 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-enforcer-plugin-it1</artifactId>
- <version>1</version>
- <packaging>pom</packaging>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-enforcer-plugin</artifactId>
- <version>1.0-SNAPSHOT</version>
- <dependencies>
- <dependency>
- <groupId>custom-rule</groupId>
- <artifactId>custom-rule-sample</artifactId>
- <version>1.0</version>
- </dependency>
- </dependencies>
- <executions>
- <execution>
- <id>enforce</id>
- <configuration>
- <rules>
- <requireJavaVersion>
- <version>[1.3,1.6]</version>
- </requireJavaVersion>
- <requireMavenVersion>
- <version>2.0.6</version>
- </requireMavenVersion>
- <myCustomRule implementation="org.apache.maven.enforcer.rule.MyCustomRule">
- <shouldIfail>true</shouldIfail>
- </myCustomRule>
- </rules>
- </configuration>
- <goals>
- <goal>enforce</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin-it1</artifactId>
+ <version>1</version>
+ <packaging>pom</packaging>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <dependencies>
+ <dependency>
+ <groupId>custom-rule</groupId>
+ <artifactId>custom-rule-sample</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>enforce</id>
+ <configuration>
+ <rules>
+ <requireJavaVersion>
+ <version>[1.3,1.6]</version>
+ </requireJavaVersion>
+ <requireMavenVersion>
+ <version>2.0.6</version>
+ </requireMavenVersion>
+ <myCustomRule implementation="org.apache.maven.enforcer.rule.MyCustomRule">
+ <shouldIfail>true</shouldIfail>
+ </myCustomRule>
+ </rules>
+ </configuration>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Propchange: maven/enforcer/trunk/enforcer-api/src/custom-rule-sample/src/usage-pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Modified: maven/enforcer/trunk/enforcer-api/src/custom-rule-sample/usage-pom.xml
URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/enforcer-api/src/custom-rule-sample/usage-pom.xml?rev=632882&r1=632881&r2=632882&view=diff
==============================================================================
--- maven/enforcer/trunk/enforcer-api/src/custom-rule-sample/usage-pom.xml (original)
+++ maven/enforcer/trunk/enforcer-api/src/custom-rule-sample/usage-pom.xml Sun Mar 2 15:41:23 2008
@@ -1,39 +1,39 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-enforcer-plugin-sample-usage</artifactId>
- <version>1</version>
- <packaging>jar</packaging>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-enforcer-plugin</artifactId>
- <version>1.0-SNAPSHOT</version>
- <dependencies>
- <dependency>
- <groupId>custom-rule</groupId>
- <artifactId>custom-rule-sample</artifactId>
- <version>1.0</version>
- </dependency>
- </dependencies>
- <executions>
- <execution>
- <id>enforce</id>
- <configuration>
- <rules>
- <myCustomRule implementation="org.apache.maven.enforcer.rule.MyCustomRule">
- <shouldIfail>false</shouldIfail>
- </myCustomRule>
- </rules>
- </configuration>
- <goals>
- <goal>enforce</goal>
- </goals>
-
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin-sample-usage</artifactId>
+ <version>1</version>
+ <packaging>jar</packaging>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <dependencies>
+ <dependency>
+ <groupId>custom-rule</groupId>
+ <artifactId>custom-rule-sample</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>enforce</id>
+ <configuration>
+ <rules>
+ <myCustomRule implementation="org.apache.maven.enforcer.rule.MyCustomRule">
+ <shouldIfail>false</shouldIfail>
+ </myCustomRule>
+ </rules>
+ </configuration>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Propchange: maven/enforcer/trunk/enforcer-api/src/custom-rule-sample/usage-pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Modified: maven/enforcer/trunk/enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRule.java
URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRule.java?rev=632882&r1=632881&r2=632882&view=diff
==============================================================================
--- maven/enforcer/trunk/enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRule.java (original)
+++ maven/enforcer/trunk/enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRule.java Sun Mar 2 15:41:23 2008
@@ -1,74 +1,74 @@
-package org.apache.maven.enforcer.rule.api;
-
-import org.apache.maven.plugin.MojoExecutionException;
-
-/*
- * 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.
- */
-
-/**
- * Inteface to be implemented by any rules executed by the enforcer.
- *
- * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
- * @version $Id$
- */
-public interface EnforcerRule
-{
- /**
- * This is the interface into the rule. This method should throw an exception
- * containing a reason message if the rule fails the check. The plugin will
- * then decide based on the fail flag if it should stop or just log the
- * message as a warning.
- *
- * @param helper
- * The helper provides access to the log, MavenSession and has
- * helpers to get at common components. It is also able to look
- * up components by class name.
- * @throws MojoExecutionException
- */
- public void execute( EnforcerRuleHelper helper )
- throws EnforcerRuleException;
-
- /**
- * This method tells the enforcer if the rule results may be cached. If the result is true,
- * the results will be remembered for future executions in the same build (ie children). Subsequent
- * iterations of the rule will be queried to see if they are also cacheable. This will allow the rule to be
- * uncached further down the tree if needed.
- *
- * @return
- */
- public boolean isCacheable();
-
- /**
- *
- * @param cachedRule the last cached instance of the rule. This is to be used by the rule to
- * potentially determine if the results are still valid (ie if the configuration has been overridden)
- * @return true if the stored results are valid for the same id.
- */
- public boolean isResultValid(EnforcerRule cachedRule);
-
- /**
- * If the rule is to be cached, this id is used as part of the key. This can allow rules to take parameters
- * that allow multiple results of the same rule to be cached.
- * @return id to be used by the enforcer to determine uniqueness of cache results. The ids only need to be unique
- * within a given rule implementation as the full key will be [classname]-[id]
- */
- public String getCacheId();
-
-
-}
+package org.apache.maven.enforcer.rule.api;
+
+import org.apache.maven.plugin.MojoExecutionException;
+
+/*
+ * 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.
+ */
+
+/**
+ * Inteface to be implemented by any rules executed by the enforcer.
+ *
+ * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
+ * @version $Id$
+ */
+public interface EnforcerRule
+{
+ /**
+ * This is the interface into the rule. This method should throw an exception
+ * containing a reason message if the rule fails the check. The plugin will
+ * then decide based on the fail flag if it should stop or just log the
+ * message as a warning.
+ *
+ * @param helper
+ * The helper provides access to the log, MavenSession and has
+ * helpers to get at common components. It is also able to look
+ * up components by class name.
+ * @throws MojoExecutionException
+ */
+ public void execute( EnforcerRuleHelper helper )
+ throws EnforcerRuleException;
+
+ /**
+ * This method tells the enforcer if the rule results may be cached. If the result is true,
+ * the results will be remembered for future executions in the same build (ie children). Subsequent
+ * iterations of the rule will be queried to see if they are also cacheable. This will allow the rule to be
+ * uncached further down the tree if needed.
+ *
+ * @return
+ */
+ public boolean isCacheable();
+
+ /**
+ *
+ * @param cachedRule the last cached instance of the rule. This is to be used by the rule to
+ * potentially determine if the results are still valid (ie if the configuration has been overridden)
+ * @return true if the stored results are valid for the same id.
+ */
+ public boolean isResultValid(EnforcerRule cachedRule);
+
+ /**
+ * If the rule is to be cached, this id is used as part of the key. This can allow rules to take parameters
+ * that allow multiple results of the same rule to be cached.
+ * @return id to be used by the enforcer to determine uniqueness of cache results. The ids only need to be unique
+ * within a given rule implementation as the full key will be [classname]-[id]
+ */
+ public String getCacheId();
+
+
+}
Propchange: maven/enforcer/trunk/enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRule.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: maven/enforcer/trunk/enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleException.java
URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleException.java?rev=632882&r1=632881&r2=632882&view=diff
==============================================================================
--- maven/enforcer/trunk/enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleException.java (original)
+++ maven/enforcer/trunk/enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleException.java Sun Mar 2 15:41:23 2008
@@ -1,104 +1,104 @@
-package org.apache.maven.enforcer.rule.api;
-
-/*
- * 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.
- */
-
-/**
- * An exception occuring during the execution of a rule. Based off of
- * EnforcerRuleException, but separated to keep the rule dependencies to a
- * minimum.
- *
- * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
- * @version $Id$
- */
-public class EnforcerRuleException
- extends Exception
-{
-
- /**
- * serialVersionUID
- */
- private static final long serialVersionUID = 1L;
-
- protected Object source;
-
- protected String longMessage;
-
- public String getLongMessage()
- {
- return longMessage;
- }
-
- public Object getSource()
- {
- return source;
- }
-
- /**
- * Construct a new <code>EnforcerRuleException</code> exception providing
- * the source and a short and long message.
- *
- * @param source
- * @param shortMessage
- * @param longMessage
- */
- public EnforcerRuleException( Object source, String shortMessage, String longMessage )
- {
- super( shortMessage );
- this.source = source;
- this.longMessage = longMessage;
- }
-
- /**
- * Construct a new <code>EnforcerRuleException</code> exception wrapping
- * an underlying <code>Exception</code> and providing a
- * <code>message</code>.
- *
- * @param message
- * @param cause
- */
- public EnforcerRuleException( String message, Exception cause )
- {
- super( message, cause );
- }
-
- /**
- * Construct a new <code>EnforcerRuleException</code> exception wrapping
- * an underlying <code>Throwable</code> and providing a
- * <code>message</code>.
- *
- * @param message
- * @param cause
- */
- public EnforcerRuleException( String message, Throwable cause )
- {
- super( message, cause );
- }
-
- /**
- * Construct a new <code>EnforcerRuleException</code> exception providing
- * a <code>message</code>.
- *
- * @param message
- */
- public EnforcerRuleException( String message )
- {
- super( message );
- }
+package org.apache.maven.enforcer.rule.api;
+
+/*
+ * 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.
+ */
+
+/**
+ * An exception occuring during the execution of a rule. Based off of
+ * EnforcerRuleException, but separated to keep the rule dependencies to a
+ * minimum.
+ *
+ * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
+ * @version $Id$
+ */
+public class EnforcerRuleException
+ extends Exception
+{
+
+ /**
+ * serialVersionUID
+ */
+ private static final long serialVersionUID = 1L;
+
+ protected Object source;
+
+ protected String longMessage;
+
+ public String getLongMessage()
+ {
+ return longMessage;
+ }
+
+ public Object getSource()
+ {
+ return source;
+ }
+
+ /**
+ * Construct a new <code>EnforcerRuleException</code> exception providing
+ * the source and a short and long message.
+ *
+ * @param source
+ * @param shortMessage
+ * @param longMessage
+ */
+ public EnforcerRuleException( Object source, String shortMessage, String longMessage )
+ {
+ super( shortMessage );
+ this.source = source;
+ this.longMessage = longMessage;
+ }
+
+ /**
+ * Construct a new <code>EnforcerRuleException</code> exception wrapping
+ * an underlying <code>Exception</code> and providing a
+ * <code>message</code>.
+ *
+ * @param message
+ * @param cause
+ */
+ public EnforcerRuleException( String message, Exception cause )
+ {
+ super( message, cause );
+ }
+
+ /**
+ * Construct a new <code>EnforcerRuleException</code> exception wrapping
+ * an underlying <code>Throwable</code> and providing a
+ * <code>message</code>.
+ *
+ * @param message
+ * @param cause
+ */
+ public EnforcerRuleException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
+
+ /**
+ * Construct a new <code>EnforcerRuleException</code> exception providing
+ * a <code>message</code>.
+ *
+ * @param message
+ */
+ public EnforcerRuleException( String message )
+ {
+ super( message );
+ }
}
Propchange: maven/enforcer/trunk/enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleException.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: maven/enforcer/trunk/enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java?rev=632882&r1=632881&r2=632882&view=diff
==============================================================================
--- maven/enforcer/trunk/enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java (original)
+++ maven/enforcer/trunk/enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java Sun Mar 2 15:41:23 2008
@@ -1,65 +1,65 @@
-package org.apache.maven.enforcer.rule.api;
-
-/*
- * 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.
- */
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.maven.plugin.logging.Log;
-import org.codehaus.plexus.PlexusContainer;
-import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator;
-import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
-
-/**
- * This is the interface that all helpers will use. This
- * provides access to the log, session and components to the
- * rules.
- *
- * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
- * @version $Id: EnforcerRuleHelper.java 571673 2007-09-01
- * 03:04:24Z brianf $
- */
-public interface EnforcerRuleHelper
- extends ExpressionEvaluator
-{
- public Log getLog ();
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.maven.shared.enforcer.rule.api.EnforcerRuleHelper#getRuntimeInformation()
- */
- public Object getComponent ( Class clazz )
- throws ComponentLookupException;
-
- public Object getComponent ( String componentKey )
- throws ComponentLookupException;
-
- public Object getComponent ( String role, String roleHint )
- throws ComponentLookupException;
-
- public Map getComponentMap ( String role )
- throws ComponentLookupException;
-
- public List getComponentList ( String role )
- throws ComponentLookupException;
-
- public PlexusContainer getContainer();
-}
+package org.apache.maven.enforcer.rule.api;
+
+/*
+ * 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.
+ */
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.maven.plugin.logging.Log;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+
+/**
+ * This is the interface that all helpers will use. This
+ * provides access to the log, session and components to the
+ * rules.
+ *
+ * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
+ * @version $Id: EnforcerRuleHelper.java 571673 2007-09-01
+ * 03:04:24Z brianf $
+ */
+public interface EnforcerRuleHelper
+ extends ExpressionEvaluator
+{
+ public Log getLog ();
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.maven.shared.enforcer.rule.api.EnforcerRuleHelper#getRuntimeInformation()
+ */
+ public Object getComponent ( Class clazz )
+ throws ComponentLookupException;
+
+ public Object getComponent ( String componentKey )
+ throws ComponentLookupException;
+
+ public Object getComponent ( String role, String roleHint )
+ throws ComponentLookupException;
+
+ public Map getComponentMap ( String role )
+ throws ComponentLookupException;
+
+ public List getComponentList ( String role )
+ throws ComponentLookupException;
+
+ public PlexusContainer getContainer();
+}
Propchange: maven/enforcer/trunk/enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: maven/enforcer/trunk/enforcer-api/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/enforcer-api/src/site/apt/index.apt?rev=632882&r1=632881&r2=632882&view=diff
==============================================================================
--- maven/enforcer/trunk/enforcer-api/src/site/apt/index.apt (original)
+++ maven/enforcer/trunk/enforcer-api/src/site/apt/index.apt Sun Mar 2 15:41:23 2008
@@ -1,32 +1,32 @@
-~~ 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.
-
- ------
- Introduction
- ------
- Brian Fox
- ------
- Mar 2007
- ------
-
-Maven Enforcer Rule API - Extending The Loving Iron Fist of Maven\x99
-
- Custom rules are easy to make with the <<<maven-enforcer-rule-api>>>. These rules can then be invoked with the
- {{{http://maven.apache.org/plugins/maven-enforcer-plugin}maven-enforcer-plugin}}.
-
- See {{{writing-a-custom-rule.html}here}} for instructions on how to make your own rule.
+~~ 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.
+
+ ------
+ Introduction
+ ------
+ Brian Fox
+ ------
+ Mar 2007
+ ------
+
+Maven Enforcer Rule API - Extending The Loving Iron Fist of Maven\x99
+
+ Custom rules are easy to make with the <<<maven-enforcer-rule-api>>>. These rules can then be invoked with the
+ {{{http://maven.apache.org/plugins/maven-enforcer-plugin}maven-enforcer-plugin}}.
+
+ See {{{writing-a-custom-rule.html}here}} for instructions on how to make your own rule.
Propchange: maven/enforcer/trunk/enforcer-api/src/site/apt/index.apt
------------------------------------------------------------------------------
svn:eol-style = native
Modified: maven/enforcer/trunk/enforcer-api/src/site/apt/writing-a-custom-rule.apt
URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/enforcer-api/src/site/apt/writing-a-custom-rule.apt?rev=632882&r1=632881&r2=632882&view=diff
==============================================================================
--- maven/enforcer/trunk/enforcer-api/src/site/apt/writing-a-custom-rule.apt (original)
+++ maven/enforcer/trunk/enforcer-api/src/site/apt/writing-a-custom-rule.apt Sun Mar 2 15:41:23 2008
@@ -1,276 +1,276 @@
-~~ 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.
-
- ------
- Writing a custom rule
- ------
- Brian Fox
- ------
- Nov 2007
- ------
-
-Writing a custom rule
-
- Custom rules are easy to make with the <<<maven-enforcer-rule-api>>>. These rules can then be invoked with the
- {{{http://maven.apache.org/plugins/maven-enforcer-plugin}maven-enforcer-plugin}}.
-
- Note: The files shown below may be downloaded here: {{{/custom-rule.zip}custom-rule.zip}}
-
- [[1]] First make a new jar project starting with the sample pom below:
-
-+---+
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>custom-rule</groupId>
- <artifactId>custom-rule-sample</artifactId>
- <packaging>jar</packaging>
- <version>1.0</version>
- <name>My Custom Rule</name>
- <description>This is my custom rule.</description>
- <properties>
- <api.version>1.0-SNAPSHOT</api.version>
- <maven.version>2.0.6</maven.version>
- </properties>
- <build>
- </build>
- <dependencies>
- <dependency>
- <groupId>org.apache.maven.enforcer</groupId>
- <artifactId>enforcer-api</artifactId>
- <version>${api.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-project</artifactId>
- <version>${maven.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-core</artifactId>
- <version>${maven.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-artifact</artifactId>
- <version>${maven.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-plugin-api</artifactId>
- <version>${maven.version}</version>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-container-default</artifactId>
- <version>1.0-alpha-9</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
-+---+
-
- [[2]] Create your rule class. The rule must implement the {{{apidocs/index.html}EnforcerRule}} interface.
- The rule can get access to components and the log via the {{{apidocs/index.html}EnforcerRuleHelper}} interface.
- If the rule succeeds, it should just simply return. If the rule fails, it should throw an {{{apidocs/index.html}EnforcerRuleException}} with a descriptive message telling the user why the rule failed.
-
- There are several methods that must be implemented related to caching.
-
- Here's a sample class that shows how to access the helper methods and retreive components by class name from the helper:
-
-+---+
-package org.apache.maven.enforcer.rule;
-
-import org.apache.maven.artifact.resolver.ArtifactResolver;
-import org.apache.maven.enforcer.rule.api.EnforcerRule;
-import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
-import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
-import org.apache.maven.execution.MavenSession;
-import org.apache.maven.execution.RuntimeInformation;
-import org.apache.maven.plugin.logging.Log;
-import org.apache.maven.project.MavenProject;
-import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
-import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
-
-/**
- * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
- */
-public class MyCustomRule
- implements EnforcerRule
-{
- /**
- * Simple param. This rule will fail if the value is true.
- */
- private boolean shouldIfail = false;
-
- public void execute( EnforcerRuleHelper helper )
- throws EnforcerRuleException
- {
- Log log = helper.getLog();
-
- try
- {
- // get the various expressions out of the helper.
- MavenProject project = (MavenProject) helper.evaluate( "${project}" );
- MavenSession session = (MavenSession) helper.evaluate( "${session}" );
- String target = (String) helper.evaluate( "${project.build.directory}" );
- String artifactId = (String) helper.evaluate( "${project.artifactId}" );
-
- // retreive any component out of the session directly
- ArtifactResolver resolver = (ArtifactResolver) helper.getComponent( ArtifactResolver.class );
- RuntimeInformation rti = (RuntimeInformation) helper.getComponent( RuntimeInformation.class );
-
- log.info( "Retrieved Target Folder: " + target );
- log.info( "Retrieved ArtifactId: " +artifactId );
- log.info( "Retrieved Project: " + project );
- log.info( "Retrieved RuntimeInfo: " + rti );
- log.info( "Retrieved Session: " + session );
- log.info( "Retrieved Resolver: " + resolver );
-
- if ( this.shouldIfail )
- {
- throw new EnforcerRuleException( "Failing because my param said so." );
- }
- }
- catch ( ComponentLookupException e )
- {
- throw new EnforcerRuleException( "Unable to lookup a component " + e.getLocalizedMessage(), e );
- }
- catch ( ExpressionEvaluationException e )
- {
- throw new EnforcerRuleException( "Unable to lookup an expression " + e.getLocalizedMessage(), e );
- }
- }
-
- /**
- * If your rule is cacheable, you must return a unique id when parameters or conditions
- * change that would cause the result to be different. Multiple cached results are stored
- * based on their id.
- *
- * The easiest way to do this is to return a hash computed from the values of your parameters.
- *
- * If your rule is not cacheable, then the result here is not important, you may return anything.
- */
- public String getCacheId()
- {
- //no hash on boolean...only parameter so no hash is needed.
- return ""+this.shouldIfail;
- }
-
- /**
- * This tells the system if the results are cacheable at all. Keep in mind that during
- * forked builds and other things, a given rule may be executed more than once for the same
- * project. This means that even things that change from project to project may still
- * be cacheable in certain instances.
- */
- public boolean isCacheable()
- {
- return false;
- }
-
- /**
- * If the rule is cacheable and the same id is found in the cache, the stored results
- * are passed to this method to allow double checking of the results. Most of the time
- * this can be done by generating unique ids, but sometimes the results of objects returned
- * by the helper need to be queried. You may for example, store certain objects in your rule
- * and then query them later.
- */
- public boolean isResultValid( EnforcerRule arg0 )
- {
- return false;
- }
-}
-+---+
-
- [[3]] Build and Install or Deploy your custom rule.
-
- [[4]] Add your custom-rule artifact as a dependency of the <<<maven-enforcer-plugin>>> in your build:
-
-+---+
-<project>
- ...
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-enforcer-plugin</artifactId>
- <dependencies>
- <dependency>
- <groupId>custom-rule</groupId>
- <artifactId>custom-rule-sample</artifactId>
- <version>1.0</version>
- </dependency>
- </dependencies>
- ...
- </plugin>
- </plugins>
- </build>
- ...
-</project>
-+---+
-
- [[5]] Add your rule to the configuration section of the <<<maven-enforcer-plugin>>>. The name of your class will be the name of the rule, and
- you must add an <<<implementation>>> hint that contains the fully qualified class name:
-
-+---+
-<configuration>
- <rules>
- <myCustomRule implementation="org.apache.maven.enforcer.rule.MyCustomRule">
- <shouldIfail>true</shouldIfail>
- </myCustomRule>
- </rules>
-</configuration>
-+---+
-
- [[6]] That's it. The full plugin config may look like this:
-
-+---+
-<plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-enforcer-plugin</artifactId>
- <version>1.0</version>
- <dependencies>
- <dependency>
- <groupId>custom-rule</groupId>
- <artifactId>custom-rule-sample</artifactId>
- <version>1.0</version>
- </dependency>
- </dependencies>
- <executions>
- <execution>
- <id>enforce</id>
- <configuration>
- <rules>
- <myCustomRule implementation="org.apache.maven.enforcer.rule.MyCustomRule">
- <shouldIfail>false</shouldIfail>
- </myCustomRule>
- </rules>
- </configuration>
- <goals>
- <goal>enforce</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-</plugins>
+~~ 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.
+
+ ------
+ Writing a custom rule
+ ------
+ Brian Fox
+ ------
+ Nov 2007
+ ------
+
+Writing a custom rule
+
+ Custom rules are easy to make with the <<<maven-enforcer-rule-api>>>. These rules can then be invoked with the
+ {{{http://maven.apache.org/plugins/maven-enforcer-plugin}maven-enforcer-plugin}}.
+
+ Note: The files shown below may be downloaded here: {{{/custom-rule.zip}custom-rule.zip}}
+
+ [[1]] First make a new jar project starting with the sample pom below:
+
++---+
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>custom-rule</groupId>
+ <artifactId>custom-rule-sample</artifactId>
+ <packaging>jar</packaging>
+ <version>1.0</version>
+ <name>My Custom Rule</name>
+ <description>This is my custom rule.</description>
+ <properties>
+ <api.version>1.0-SNAPSHOT</api.version>
+ <maven.version>2.0.6</maven.version>
+ </properties>
+ <build>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.enforcer</groupId>
+ <artifactId>enforcer-api</artifactId>
+ <version>${api.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-project</artifactId>
+ <version>${maven.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ <version>${maven.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-artifact</artifactId>
+ <version>${maven.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>${maven.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-container-default</artifactId>
+ <version>1.0-alpha-9</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
++---+
+
+ [[2]] Create your rule class. The rule must implement the {{{apidocs/index.html}EnforcerRule}} interface.
+ The rule can get access to components and the log via the {{{apidocs/index.html}EnforcerRuleHelper}} interface.
+ If the rule succeeds, it should just simply return. If the rule fails, it should throw an {{{apidocs/index.html}EnforcerRuleException}} with a descriptive message telling the user why the rule failed.
+
+ There are several methods that must be implemented related to caching.
+
+ Here's a sample class that shows how to access the helper methods and retreive components by class name from the helper:
+
++---+
+package org.apache.maven.enforcer.rule;
+
+import org.apache.maven.artifact.resolver.ArtifactResolver;
+import org.apache.maven.enforcer.rule.api.EnforcerRule;
+import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
+import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.execution.RuntimeInformation;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+
+/**
+ * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
+ */
+public class MyCustomRule
+ implements EnforcerRule
+{
+ /**
+ * Simple param. This rule will fail if the value is true.
+ */
+ private boolean shouldIfail = false;
+
+ public void execute( EnforcerRuleHelper helper )
+ throws EnforcerRuleException
+ {
+ Log log = helper.getLog();
+
+ try
+ {
+ // get the various expressions out of the helper.
+ MavenProject project = (MavenProject) helper.evaluate( "${project}" );
+ MavenSession session = (MavenSession) helper.evaluate( "${session}" );
+ String target = (String) helper.evaluate( "${project.build.directory}" );
+ String artifactId = (String) helper.evaluate( "${project.artifactId}" );
+
+ // retreive any component out of the session directly
+ ArtifactResolver resolver = (ArtifactResolver) helper.getComponent( ArtifactResolver.class );
+ RuntimeInformation rti = (RuntimeInformation) helper.getComponent( RuntimeInformation.class );
+
+ log.info( "Retrieved Target Folder: " + target );
+ log.info( "Retrieved ArtifactId: " +artifactId );
+ log.info( "Retrieved Project: " + project );
+ log.info( "Retrieved RuntimeInfo: " + rti );
+ log.info( "Retrieved Session: " + session );
+ log.info( "Retrieved Resolver: " + resolver );
+
+ if ( this.shouldIfail )
+ {
+ throw new EnforcerRuleException( "Failing because my param said so." );
+ }
+ }
+ catch ( ComponentLookupException e )
+ {
+ throw new EnforcerRuleException( "Unable to lookup a component " + e.getLocalizedMessage(), e );
+ }
+ catch ( ExpressionEvaluationException e )
+ {
+ throw new EnforcerRuleException( "Unable to lookup an expression " + e.getLocalizedMessage(), e );
+ }
+ }
+
+ /**
+ * If your rule is cacheable, you must return a unique id when parameters or conditions
+ * change that would cause the result to be different. Multiple cached results are stored
+ * based on their id.
+ *
+ * The easiest way to do this is to return a hash computed from the values of your parameters.
+ *
+ * If your rule is not cacheable, then the result here is not important, you may return anything.
+ */
+ public String getCacheId()
+ {
+ //no hash on boolean...only parameter so no hash is needed.
+ return ""+this.shouldIfail;
+ }
+
+ /**
+ * This tells the system if the results are cacheable at all. Keep in mind that during
+ * forked builds and other things, a given rule may be executed more than once for the same
+ * project. This means that even things that change from project to project may still
+ * be cacheable in certain instances.
+ */
+ public boolean isCacheable()
+ {
+ return false;
+ }
+
+ /**
+ * If the rule is cacheable and the same id is found in the cache, the stored results
+ * are passed to this method to allow double checking of the results. Most of the time
+ * this can be done by generating unique ids, but sometimes the results of objects returned
+ * by the helper need to be queried. You may for example, store certain objects in your rule
+ * and then query them later.
+ */
+ public boolean isResultValid( EnforcerRule arg0 )
+ {
+ return false;
+ }
+}
++---+
+
+ [[3]] Build and Install or Deploy your custom rule.
+
+ [[4]] Add your custom-rule artifact as a dependency of the <<<maven-enforcer-plugin>>> in your build:
+
++---+
+<project>
+ ...
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>custom-rule</groupId>
+ <artifactId>custom-rule-sample</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+ ...
+ </plugin>
+ </plugins>
+ </build>
+ ...
+</project>
++---+
+
+ [[5]] Add your rule to the configuration section of the <<<maven-enforcer-plugin>>>. The name of your class will be the name of the rule, and
+ you must add an <<<implementation>>> hint that contains the fully qualified class name:
+
++---+
+<configuration>
+ <rules>
+ <myCustomRule implementation="org.apache.maven.enforcer.rule.MyCustomRule">
+ <shouldIfail>true</shouldIfail>
+ </myCustomRule>
+ </rules>
+</configuration>
++---+
+
+ [[6]] That's it. The full plugin config may look like this:
+
++---+
+<plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <version>1.0</version>
+ <dependencies>
+ <dependency>
+ <groupId>custom-rule</groupId>
+ <artifactId>custom-rule-sample</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>enforce</id>
+ <configuration>
+ <rules>
+ <myCustomRule implementation="org.apache.maven.enforcer.rule.MyCustomRule">
+ <shouldIfail>false</shouldIfail>
+ </myCustomRule>
+ </rules>
+ </configuration>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+</plugins>
+---+
Propchange: maven/enforcer/trunk/enforcer-api/src/site/apt/writing-a-custom-rule.apt
------------------------------------------------------------------------------
svn:eol-style = native
Modified: maven/enforcer/trunk/enforcer-api/src/site/site.xml
URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/enforcer-api/src/site/site.xml?rev=632882&r1=632881&r2=632882&view=diff
==============================================================================
--- maven/enforcer/trunk/enforcer-api/src/site/site.xml (original)
+++ maven/enforcer/trunk/enforcer-api/src/site/site.xml Sun Mar 2 15:41:23 2008
@@ -1,64 +1,64 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
- ~ Copyright 2006 The Apache Software Foundation.
- ~
- ~ Licensed 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.
- -->
-
-<project name="Enforcer Rule API">
- <!-- TODO: banners, skin, publish date, version should be inherited from Maven itself -->
- <bannerLeft>
- <name>${project.name}</name>
- <src>http://maven.apache.org/images/apache-maven-project-2.png</src>
- <href>http://maven.apache.org/</href>
- </bannerLeft>
- <bannerRight>
- <src>http://maven.apache.org/images/maven-logo-2.gif</src>
- </bannerRight>
- <skin>
- <groupId>org.apache.maven.skins</groupId>
- <artifactId>maven-stylus-skin</artifactId>
- </skin>
- <publishDate format="dd MMM yyyy" position="left" />
- <version position="left" />
- <body>
- <!-- TODO: Link, head, reports should be inherited -->
- <!-- TODO: use breadcrumbs more structure, links for links, and inherit subprojects as a menu or not at all -->
- <links>
- <item name="Maven 1.x" href="http://maven.apache.org/maven-1.x"/>
- <item name="Maven 2.x" href="http://maven.apache.org/"/>
- <item name="Maven 2.x Plugins" href="http://maven.apache.org/plugins/"/>
- <item name="Continuum" href="http://maven.apache.org/continuum"/>
- <item name="SCM" href="http://maven.apache.org/scm"/>
- <item name="Wagon" href="http://maven.apache.org/wagon"/>
- <item name="JXR" href="http://maven.apache.org/jxr"/>
- <item name="Doxia" href="http://maven.apache.org/doxia"/>
- </links>
- <head>
- <script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
- </script>
- <script type="text/javascript">
- _uacct = "UA-140879-1";
- urchinTracker();
- </script>
- </head>
- <menu name="Overview">
- <item name="Introduction" href="index.html"/>
- <item name="Writing a custom rule" href="writing-a-custom-rule.html"/>
- </menu>
- <menu name="Rule Execution Engines">
- <item name="Maven Enforcer Plugin" href="http://maven.apache.org/plugins/maven-enforcer-plugin"/>
- </menu>
- <menu ref="reports" inherit="bottom" />
- </body>
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ ~ Copyright 2006 The Apache Software Foundation.
+ ~
+ ~ Licensed 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.
+ -->
+
+<project name="Enforcer Rule API">
+ <!-- TODO: banners, skin, publish date, version should be inherited from Maven itself -->
+ <bannerLeft>
+ <name>${project.name}</name>
+ <src>http://maven.apache.org/images/apache-maven-project-2.png</src>
+ <href>http://maven.apache.org/</href>
+ </bannerLeft>
+ <bannerRight>
+ <src>http://maven.apache.org/images/maven-logo-2.gif</src>
+ </bannerRight>
+ <skin>
+ <groupId>org.apache.maven.skins</groupId>
+ <artifactId>maven-stylus-skin</artifactId>
+ </skin>
+ <publishDate format="dd MMM yyyy" position="left" />
+ <version position="left" />
+ <body>
+ <!-- TODO: Link, head, reports should be inherited -->
+ <!-- TODO: use breadcrumbs more structure, links for links, and inherit subprojects as a menu or not at all -->
+ <links>
+ <item name="Maven 1.x" href="http://maven.apache.org/maven-1.x"/>
+ <item name="Maven 2.x" href="http://maven.apache.org/"/>
+ <item name="Maven 2.x Plugins" href="http://maven.apache.org/plugins/"/>
+ <item name="Continuum" href="http://maven.apache.org/continuum"/>
+ <item name="SCM" href="http://maven.apache.org/scm"/>
+ <item name="Wagon" href="http://maven.apache.org/wagon"/>
+ <item name="JXR" href="http://maven.apache.org/jxr"/>
+ <item name="Doxia" href="http://maven.apache.org/doxia"/>
+ </links>
+ <head>
+ <script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
+ </script>
+ <script type="text/javascript">
+ _uacct = "UA-140879-1";
+ urchinTracker();
+ </script>
+ </head>
+ <menu name="Overview">
+ <item name="Introduction" href="index.html"/>
+ <item name="Writing a custom rule" href="writing-a-custom-rule.html"/>
+ </menu>
+ <menu name="Rule Execution Engines">
+ <item name="Maven Enforcer Plugin" href="http://maven.apache.org/plugins/maven-enforcer-plugin"/>
+ </menu>
+ <menu ref="reports" inherit="bottom" />
+ </body>
</project>
Propchange: maven/enforcer/trunk/enforcer-api/src/site/site.xml
------------------------------------------------------------------------------
svn:eol-style = native