Author: schor
Date: Wed May 12 14:18:51 2010
New Revision: 943505

URL: http://svn.apache.org/viewvc?rev=943505&view=rev
Log:
[UIMA-1756] maven helper plugin - used to format the build date month and year 
and set maven properties with result

Added:
    uima/build/trunk/uima-build-helper-maven-plugin/pom.xml
    uima/build/trunk/uima-build-helper-maven-plugin/src/
    uima/build/trunk/uima-build-helper-maven-plugin/src/main/
    uima/build/trunk/uima-build-helper-maven-plugin/src/main/java/
    uima/build/trunk/uima-build-helper-maven-plugin/src/main/java/org/
    uima/build/trunk/uima-build-helper-maven-plugin/src/main/java/org/apache/
    
uima/build/trunk/uima-build-helper-maven-plugin/src/main/java/org/apache/uima/
    
uima/build/trunk/uima-build-helper-maven-plugin/src/main/java/org/apache/uima/buildhelper/
    
uima/build/trunk/uima-build-helper-maven-plugin/src/main/java/org/apache/uima/buildhelper/ParseDateTime.java
    
uima/build/trunk/uima-build-helper-maven-plugin/src/main/java/org/apache/uima/buildhelper/ParseSpec.java
    uima/build/trunk/uima-build-helper-maven-plugin/src/site/
    uima/build/trunk/uima-build-helper-maven-plugin/src/site/apt/
    uima/build/trunk/uima-build-helper-maven-plugin/src/site/apt/index.apt
    uima/build/trunk/uima-build-helper-maven-plugin/src/site/apt/usage.apt.vm
    uima/build/trunk/uima-build-helper-maven-plugin/src/site/site.xml
Modified:
    uima/build/trunk/uima-build-helper-maven-plugin/   (props changed)

Propchange: uima/build/trunk/uima-build-helper-maven-plugin/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed May 12 14:18:51 2010
@@ -0,0 +1,4 @@
+.settings
+target
+.classpath
+.project

Added: uima/build/trunk/uima-build-helper-maven-plugin/pom.xml
URL: 
http://svn.apache.org/viewvc/uima/build/trunk/uima-build-helper-maven-plugin/pom.xml?rev=943505&view=auto
==============================================================================
--- uima/build/trunk/uima-build-helper-maven-plugin/pom.xml (added)
+++ uima/build/trunk/uima-build-helper-maven-plugin/pom.xml Wed May 12 14:18:51 
2010
@@ -0,0 +1,70 @@
+<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/xsd/maven-4.0.0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <artifactId>maven-plugins</artifactId>
+    <groupId>org.apache.maven.plugins</groupId>
+    <version>18</version>
+  </parent>
+  
+  <groupId>org.apache.uima</groupId>
+  <artifactId>uima-build-helper</artifactId>
+  <version>1.0.0-SNAPSHOT</version>
+  <packaging>maven-plugin</packaging>
+
+  <name>uima-build-helper Maven Plugin</name>
+  <inceptionYear>2010</inceptionYear>
+  <url>http://maven.apache.org</url>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+      <version>2.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-model</artifactId>
+      <version>2.0.9</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-project</artifactId>
+      <version>2.0.9</version>
+    </dependency>
+    
+      
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-plugin-plugin</artifactId>
+        <version>2.5.1</version>
+        <configuration>
+          <goalPrefix>uima-build-helper</goalPrefix>
+        </configuration>
+        <executions>
+          <execution>
+            <id>generated-helpmojo</id>
+            <goals>
+              <goal>helpmojo</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Added: 
uima/build/trunk/uima-build-helper-maven-plugin/src/main/java/org/apache/uima/buildhelper/ParseDateTime.java
URL: 
http://svn.apache.org/viewvc/uima/build/trunk/uima-build-helper-maven-plugin/src/main/java/org/apache/uima/buildhelper/ParseDateTime.java?rev=943505&view=auto
==============================================================================
--- 
uima/build/trunk/uima-build-helper-maven-plugin/src/main/java/org/apache/uima/buildhelper/ParseDateTime.java
 (added)
+++ 
uima/build/trunk/uima-build-helper-maven-plugin/src/main/java/org/apache/uima/buildhelper/ParseDateTime.java
 Wed May 12 14:18:51 2010
@@ -0,0 +1,78 @@
+/*
+ * 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.
+ */
+package org.apache.uima.buildhelper;
+
+import java.text.MessageFormat;
+import java.util.Date;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+
+/**
+ * Parse the current time value into multiple properties. Each execution gets
+ * the current date and time, and sets 0 or more properties such as
+ * currentTime.year, currentTime.month, etc.
+ * 
+ * Users specify the property name and the format of the parsing; multiple sets
+ * of these can be configured to represent the same time.
+ * 
+ * @goal parse-date-time
+ * @phase validate
+ */
+public class ParseDateTime extends AbstractMojo {
+  /**
+   * Collection of parseSpecs. Each parseSpec has a name - the property name,
+   * and a format - see "Usage"
+   * 
+   * @parameter
+   * @required
+   * @since 1.0.0
+   */
+  private ParseSpec[] parseSpecs;
+  
+  /**
+   * The Maven project to analyze.
+   * 
+   * @parameter expression="${project}"
+   * @required
+   * @readonly
+   */
+  private MavenProject project;
+
+  public void execute() throws MojoExecutionException {
+   
+    Date [] now = new Date[] {new Date()};
+    
+    for (int i = 0; i < parseSpecs.length; i++) {
+      ParseSpec ps = parseSpecs[i]; 
+      String v = MessageFormat.format("{0,date," + ps.getFormat() + "}", now);
+      if (getLog().isDebugEnabled()) {
+        getLog().debug("Setting property " +
+            ps.getName() +
+            " with format " +
+            ps.getFormat() +
+            " to value '" +
+            v +
+            "'");
+      }
+      project.getProperties().setProperty(ps.getName(), v);
+    }  
+  }
+}

Added: 
uima/build/trunk/uima-build-helper-maven-plugin/src/main/java/org/apache/uima/buildhelper/ParseSpec.java
URL: 
http://svn.apache.org/viewvc/uima/build/trunk/uima-build-helper-maven-plugin/src/main/java/org/apache/uima/buildhelper/ParseSpec.java?rev=943505&view=auto
==============================================================================
--- 
uima/build/trunk/uima-build-helper-maven-plugin/src/main/java/org/apache/uima/buildhelper/ParseSpec.java
 (added)
+++ 
uima/build/trunk/uima-build-helper-maven-plugin/src/main/java/org/apache/uima/buildhelper/ParseSpec.java
 Wed May 12 14:18:51 2010
@@ -0,0 +1,64 @@
+/* 
+ * 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.    
+ */
+package org.apache.uima.buildhelper;
+
+public class ParseSpec {
+  
+  /**
+   * The name of the property to set
+   * 
+   * @parameter
+   * @required
+   * @since 1.0.0
+   */
+  private String name;
+  
+  /**
+   * The format string to use
+   * 
+   * @parameter
+   * @required
+   * @since 1.0.0
+   */
+  private String format;
+
+  public ParseSpec() {}
+  
+  public ParseSpec(String name, String format) {
+    this.name = name;
+    this.format = format;
+  }
+
+  public String getName() {
+    return name;
+  }
+
+  public void setName(String name) {
+    this.name = name;
+  }
+
+  public String getFormat() {
+    return format;
+  }
+
+  public void setFormat(String format) {
+    this.format = format;
+  }
+
+}

Added: uima/build/trunk/uima-build-helper-maven-plugin/src/site/apt/index.apt
URL: 
http://svn.apache.org/viewvc/uima/build/trunk/uima-build-helper-maven-plugin/src/site/apt/index.apt?rev=943505&view=auto
==============================================================================
--- uima/build/trunk/uima-build-helper-maven-plugin/src/site/apt/index.apt 
(added)
+++ uima/build/trunk/uima-build-helper-maven-plugin/src/site/apt/index.apt Wed 
May 12 14:18:51 2010
@@ -0,0 +1,47 @@
+~~ 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
+  ------
+
+UIMA Build Helper Plugin
+
+  The uima-build-helper plugin provides a set of goals that do helpful things
+  in Java for the UIMA builds.  
+
+* Goals Overview
+
+  The uima-build-helper plugin has one goal:
+
+  *{{{parse-date-time-mojo.html}uima-build-helper:parse-date-time}} 
+  captures the current date and time, and then takes a list of 
+  specifications defined in
+  the plugin configuration section and for each one sets
+  a specified property to a particular formatting of the current date and time.
+  
+    The format of the formatting string is the same as Java's 
+    
{{{http://java.sun.com/j2se/1.5.0/docs/api/java/text/SimpleDateFormat.html}SimpleDateFormat}}.
+  []
+
+* Usage
+
+  General instructions on how to use the uima-build-helper Plugin can be found 
on the {{{usage.html}usage page}}. 
+
+
+
+

Added: uima/build/trunk/uima-build-helper-maven-plugin/src/site/apt/usage.apt.vm
URL: 
http://svn.apache.org/viewvc/uima/build/trunk/uima-build-helper-maven-plugin/src/site/apt/usage.apt.vm?rev=943505&view=auto
==============================================================================
--- uima/build/trunk/uima-build-helper-maven-plugin/src/site/apt/usage.apt.vm 
(added)
+++ uima/build/trunk/uima-build-helper-maven-plugin/src/site/apt/usage.apt.vm 
Wed May 12 14:18:51 2010
@@ -0,0 +1,111 @@
+~~ 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.    
+ 
+  ------
+  Usage
+  ------
+
+Usage
+  
+* Generic Plugin configuration information
+
+  See the following links for information about including and configuring 
plugins in your project:
+  
+  
*{{{http://maven.apache.org/guides/mini/guide-configuring-plugins.html}Configuring
 Plugins}}
+  
+  
*{{{http://maven.apache.org/guides/plugin/guide-java-plugin-development.html}Plugin
 Development}}
+
+  
*{{{http://maven.apache.org/guides/introduction/introduction-to-plugin-prefix-mapping.html}Plugin
 Prefix}}
+
+* The <<<uima-helper-plugin:parse-date-time>>> mojo
+
+   This goal is bound to the first default lifecycle phase (validate) by 
default.
+   Configure it in your
+   <<<pom.xml>>>. 
+
+     []
+
+   Configure the plugin something like this:
+
++---+
+<project>
+  [...]
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.uima</groupId>
+        <artifactId>uima-build-helper-maven-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>get month</id>
+            <goals>
+              <goal>parse-date-time</goal>
+            </goals>
+            <configuration>
+              <parseSpecs>
+                <parseSpec>
+                  <propName>[ name of property to set, e.g. my.property 
]</propName>
+                  <format>[ format string - see below ]</format>
+                  <locale>[ optional - a Java locale string ]</locale>
+                </parseSpec>
+              </parseSpecs>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+  [...]
+</project>
+
++---+
+
+
+* Format of the parse strings  
+
+  The format string can contain arbitrary text, plus special patterns that 
must look something like
+
+    yyyy or MMMM
+  
+  The pattern is one of the patterns defined for
+  date or time in the 
+  
{{{http://java.sun.com/j2se/1.5.0/docs/api/java/text/SimpleDateFormat.html}SimpleDateFormat}}
+  Java class.
+  
+  Spaces and new lines in the pattern are significant, and are copied into the 
result,
+  except that leading or trailing white-space in the pattern is stripped.
+  
+  This means you can write:
++----+
+    <format>
+      yyyy
+    </format>
++----+
+  to get just the 4 digit year formatted.
+  
+  Any letters [a-z] or [A-Z] which you want copied into the result must be 
+  surrounded by single quotes; otherwise they are interpreted as formatting 
specifications. 
+
+  Some simple examples:
+  
++---+
+    <format>yyyy</format>          - produces, for example: 2010
+    <format>MMMM</format>          - produces, for example, January
+    <format>MMM</format>           - produces, for example, Jan
+    <format>MMMM, yyyy</format>    - produces, for example, January, 2010
+    <format>YYYY</format>          - causes an error - capital "Y" is not a 
valid formatting character.  
++---+  
\ No newline at end of file

Added: uima/build/trunk/uima-build-helper-maven-plugin/src/site/site.xml
URL: 
http://svn.apache.org/viewvc/uima/build/trunk/uima-build-helper-maven-plugin/src/site/site.xml?rev=943505&view=auto
==============================================================================
--- uima/build/trunk/uima-build-helper-maven-plugin/src/site/site.xml (added)
+++ uima/build/trunk/uima-build-helper-maven-plugin/src/site/site.xml Wed May 
12 14:18:51 2010
@@ -0,0 +1,36 @@
+<?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>
+  <skin>
+    <groupId>org.apache.maven.skins</groupId>
+    <artifactId>maven-stylus-skin</artifactId>
+    <version>1.1</version>
+  </skin>
+  <body>
+    <menu name="Overview">
+      <item name="Introduction" href="index.html"/>
+      <item name="Goals" href="plugin-info.html"/>
+      <item name="Usage" href="usage.html"/>
+      <!--item name="FAQ" href="faq.html"/-->
+    </menu>
+  </body>
+</project>


Reply via email to