Author: brianf
Date: Mon Apr  2 18:56:19 2007
New Revision: 524996

URL: http://svn.apache.org/viewvc?view=rev&rev=524996
Log:
created site with sample

Added:
    maven/shared/trunk/maven-enforcer-rule-api/src/custom-rule-sample/
    maven/shared/trunk/maven-enforcer-rule-api/src/custom-rule-sample/pom.xml
    maven/shared/trunk/maven-enforcer-rule-api/src/custom-rule-sample/src/
    maven/shared/trunk/maven-enforcer-rule-api/src/custom-rule-sample/src/main/
    
maven/shared/trunk/maven-enforcer-rule-api/src/custom-rule-sample/src/main/java/
    
maven/shared/trunk/maven-enforcer-rule-api/src/custom-rule-sample/src/main/java/org/
    
maven/shared/trunk/maven-enforcer-rule-api/src/custom-rule-sample/src/main/java/org/apache/
    
maven/shared/trunk/maven-enforcer-rule-api/src/custom-rule-sample/src/main/java/org/apache/maven/
    
maven/shared/trunk/maven-enforcer-rule-api/src/custom-rule-sample/src/main/java/org/apache/maven/shared/
    
maven/shared/trunk/maven-enforcer-rule-api/src/custom-rule-sample/src/main/java/org/apache/maven/shared/rule/
    
maven/shared/trunk/maven-enforcer-rule-api/src/custom-rule-sample/src/main/java/org/apache/maven/shared/rule/myCustomRule.java
    
maven/shared/trunk/maven-enforcer-rule-api/src/custom-rule-sample/src/usage-pom.xml
    
maven/shared/trunk/maven-enforcer-rule-api/src/custom-rule-sample/usage-pom.xml
    maven/shared/trunk/maven-enforcer-rule-api/src/site/resources/
    
maven/shared/trunk/maven-enforcer-rule-api/src/site/resources/custom-rule.zip   
(with props)
Modified:
    maven/shared/trunk/maven-enforcer-rule-api/pom.xml
    
maven/shared/trunk/maven-enforcer-rule-api/src/main/java/org/apache/maven/shared/enforcer/rule/api/EnforcerRuleHelper.java
    
maven/shared/trunk/maven-enforcer-rule-api/src/site/apt/writing-a-custom-rule.apt
    maven/shared/trunk/maven-enforcer-rule-api/src/site/site.xml

Modified: maven/shared/trunk/maven-enforcer-rule-api/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/shared/trunk/maven-enforcer-rule-api/pom.xml?view=diff&rev=524996&r1=524995&r2=524996
==============================================================================
--- maven/shared/trunk/maven-enforcer-rule-api/pom.xml (original)
+++ maven/shared/trunk/maven-enforcer-rule-api/pom.xml Mon Apr  2 18:56:19 2007
@@ -108,4 +108,12 @@
                        <scope>test</scope>
                </dependency>   
        </dependencies>
+         <reporting>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-plugin-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </reporting>
 </project>

Added: maven/shared/trunk/maven-enforcer-rule-api/src/custom-rule-sample/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/shared/trunk/maven-enforcer-rule-api/src/custom-rule-sample/pom.xml?view=auto&rev=524996
==============================================================================
--- maven/shared/trunk/maven-enforcer-rule-api/src/custom-rule-sample/pom.xml 
(added)
+++ maven/shared/trunk/maven-enforcer-rule-api/src/custom-rule-sample/pom.xml 
Mon Apr  2 18:56:19 2007
@@ -0,0 +1,50 @@
+<?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>your.group</groupId>
+       <artifactId>custom-rule</artifactId>
+       <packaging>jar</packaging>
+       <version>1.0</version>
+       <name>My Custom Rule</name>
+       <description>This is my custom rule.</description>
+       <build> 
+       </build>
+       <dependencies>
+               <dependency>
+                       <groupId>org.apache.maven.shared</groupId>
+                       <artifactId>maven-enforcer-rule-api</artifactId>
+                       <version>1.0-alpha-1</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.apache.maven</groupId>
+                       <artifactId>maven-project</artifactId>
+                       <version>2.0.5</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.apache.maven</groupId>
+                       <artifactId>maven-core</artifactId>
+                       <version>2.0.5</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.apache.maven</groupId>
+                       <artifactId>maven-artifact</artifactId>
+                       <version>2.0.5</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.apache.maven</groupId>
+                       <artifactId>maven-plugin-api</artifactId>
+                       <version>2.0.5</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>

Added: 
maven/shared/trunk/maven-enforcer-rule-api/src/custom-rule-sample/src/main/java/org/apache/maven/shared/rule/myCustomRule.java
URL: 
http://svn.apache.org/viewvc/maven/shared/trunk/maven-enforcer-rule-api/src/custom-rule-sample/src/main/java/org/apache/maven/shared/rule/myCustomRule.java?view=auto&rev=524996
==============================================================================
--- 
maven/shared/trunk/maven-enforcer-rule-api/src/custom-rule-sample/src/main/java/org/apache/maven/shared/rule/myCustomRule.java
 (added)
+++ 
maven/shared/trunk/maven-enforcer-rule-api/src/custom-rule-sample/src/main/java/org/apache/maven/shared/rule/myCustomRule.java
 Mon Apr  2 18:56:19 2007
@@ -0,0 +1,65 @@
+package org.apache.maven.shared.rule;
+
+import java.io.File;
+
+import org.apache.maven.artifact.resolver.ArtifactResolver;
+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.apache.maven.shared.enforcer.rule.api.EnforcerRule;
+import org.apache.maven.shared.enforcer.rule.api.EnforcerRuleException;
+import org.apache.maven.shared.enforcer.rule.api.EnforcerRuleHelper;
+import 
org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
+import 
org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+
+/**
+ * @author <a href="mailto:[EMAIL PROTECTED]">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 );
+        }
+    }
+}

Added: 
maven/shared/trunk/maven-enforcer-rule-api/src/custom-rule-sample/src/usage-pom.xml
URL: 
http://svn.apache.org/viewvc/maven/shared/trunk/maven-enforcer-rule-api/src/custom-rule-sample/src/usage-pom.xml?view=auto&rev=524996
==============================================================================
--- 
maven/shared/trunk/maven-enforcer-rule-api/src/custom-rule-sample/src/usage-pom.xml
 (added)
+++ 
maven/shared/trunk/maven-enforcer-rule-api/src/custom-rule-sample/src/usage-pom.xml
 Mon Apr  2 18:56:19 2007
@@ -0,0 +1,43 @@
+<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>
+                               <dependencies>
+                                       <dependency>
+                                               <groupId>your.group</groupId>
+                                               
<artifactId>custom-rule</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.shared.rule.myCustomRule">
+                                                                       
<shouldIfail>false</shouldIfail>
+                                                               </myCustomRule>
+                                                       </rules>
+                                               </configuration>
+                                               <goals>
+                                                       
<goal>enforce-once</goal>
+                                               </goals>
+                                       </execution>
+                               </executions>
+                       </plugin>
+               </plugins>
+       </build>
+</project>

Added: 
maven/shared/trunk/maven-enforcer-rule-api/src/custom-rule-sample/usage-pom.xml
URL: 
http://svn.apache.org/viewvc/maven/shared/trunk/maven-enforcer-rule-api/src/custom-rule-sample/usage-pom.xml?view=auto&rev=524996
==============================================================================
--- 
maven/shared/trunk/maven-enforcer-rule-api/src/custom-rule-sample/usage-pom.xml 
(added)
+++ 
maven/shared/trunk/maven-enforcer-rule-api/src/custom-rule-sample/usage-pom.xml 
Mon Apr  2 18:56:19 2007
@@ -0,0 +1,43 @@
+<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>
+                               <dependencies>
+                                       <dependency>
+                                               <groupId>your.group</groupId>
+                                               
<artifactId>custom-rule</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.shared.rule.myCustomRule">
+                                                                       
<shouldIfail>false</shouldIfail>
+                                                               </myCustomRule>
+                                                       </rules>
+                                               </configuration>
+                                               <goals>
+                                                       
<goal>enforce-once</goal>
+                                               </goals>
+                                       </execution>
+                               </executions>
+                       </plugin>
+               </plugins>
+       </build>
+</project>

Modified: 
maven/shared/trunk/maven-enforcer-rule-api/src/main/java/org/apache/maven/shared/enforcer/rule/api/EnforcerRuleHelper.java
URL: 
http://svn.apache.org/viewvc/maven/shared/trunk/maven-enforcer-rule-api/src/main/java/org/apache/maven/shared/enforcer/rule/api/EnforcerRuleHelper.java?view=diff&rev=524996&r1=524995&r2=524996
==============================================================================
--- 
maven/shared/trunk/maven-enforcer-rule-api/src/main/java/org/apache/maven/shared/enforcer/rule/api/EnforcerRuleHelper.java
 (original)
+++ 
maven/shared/trunk/maven-enforcer-rule-api/src/main/java/org/apache/maven/shared/enforcer/rule/api/EnforcerRuleHelper.java
 Mon Apr  2 18:56:19 2007
@@ -19,10 +19,8 @@
  * under the License.
  */
 
-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.ExpressionEvaluator;
 import 
org.codehaus.plexus.component.repository.exception.ComponentLookupException;
 
 /**
@@ -33,17 +31,15 @@
  * @version $Id$
  */
 public interface EnforcerRuleHelper
+    extends ExpressionEvaluator
 {
     public Log getLog();
 
-    public MavenSession getSession();
-
+    /*
+     * (non-Javadoc)
+     * 
+     * @see 
org.apache.maven.shared.enforcer.rule.api.EnforcerRuleHelper#getRuntimeInformation()
+     */
     public Object getComponent( Class clazz )
-        throws ComponentLookupException;
-
-    public MavenProject getProject()
-        throws ComponentLookupException;
-
-    public RuntimeInformation getRuntimeInformation()
         throws ComponentLookupException;
 }

Modified: 
maven/shared/trunk/maven-enforcer-rule-api/src/site/apt/writing-a-custom-rule.apt
URL: 
http://svn.apache.org/viewvc/maven/shared/trunk/maven-enforcer-rule-api/src/site/apt/writing-a-custom-rule.apt?view=diff&rev=524996&r1=524995&r2=524996
==============================================================================
--- 
maven/shared/trunk/maven-enforcer-rule-api/src/site/apt/writing-a-custom-rule.apt
 (original)
+++ 
maven/shared/trunk/maven-enforcer-rule-api/src/site/apt/writing-a-custom-rule.apt
 Mon Apr  2 18:56:19 2007
@@ -28,6 +28,8 @@
   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:
   
 +---+
@@ -121,14 +123,18 @@
 
         try
         {
-            // get the various components out of the helper.
-            MavenProject project = helper.getProject();
-            RuntimeInformation rti = helper.getRuntimeInformation();
-            MavenSession session = helper.getSession();
+             // 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 );

Added: 
maven/shared/trunk/maven-enforcer-rule-api/src/site/resources/custom-rule.zip
URL: 
http://svn.apache.org/viewvc/maven/shared/trunk/maven-enforcer-rule-api/src/site/resources/custom-rule.zip?view=auto&rev=524996
==============================================================================
Binary file - no diff available.

Propchange: 
maven/shared/trunk/maven-enforcer-rule-api/src/site/resources/custom-rule.zip
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: maven/shared/trunk/maven-enforcer-rule-api/src/site/site.xml
URL: 
http://svn.apache.org/viewvc/maven/shared/trunk/maven-enforcer-rule-api/src/site/site.xml?view=diff&rev=524996&r1=524995&r2=524996
==============================================================================
--- maven/shared/trunk/maven-enforcer-rule-api/src/site/site.xml (original)
+++ maven/shared/trunk/maven-enforcer-rule-api/src/site/site.xml Mon Apr  2 
18:56:19 2007
@@ -1,29 +1,62 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
 <!--
- * 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. 
- *
--->
+  ~ 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>
+<project name="Shared">
+  <!-- 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="Apache" href="http://www.apache.org/"/>
+      <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 ref="reports" inherit="bottom" />
   </body>
-</project>
+</project>
\ No newline at end of file


Reply via email to