niclas      2004/04/13 23:48:18

  Added:       maven-plugins/versioning plugin.jelly plugin.properties
                        project.properties project.xml
               maven-plugins/versioning/src/plugin-resources
                        entity-template.ent
               maven-plugins/versioning/xdocs changes.xml goals.xml
                        index.xml navigation.xml properties.xml
  Log:
  First cut of the new Versioning Plugin.
  
  Revision  Changes    Path
  1.1                  avalon/maven-plugins/versioning/plugin.jelly
  
  Index: plugin.jelly
  ===================================================================
  <?xml version="1.0"?>
  <!-- 
  /*
   * Copyright 2001-2004 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 xmlns:j="jelly:core" xmlns:define="jelly:define"
      xmlns:util="jelly:util" xmlns:maven="jelly:maven" xmlns:ant="jelly:ant"
      xmlns:x="jelly:xml"
      xmlns:increment="increment">
      
    <define:taglib uri="increment">
    
      <define:tag name="inc-number" >
        <j:set var="number" value="${ number + 1 }" scope="parent" />
      </define:tag>
    
      <define:tag name="update-entities" >
        <increment:read/>    
        <ant:copy 
tofile="${maven.increment.central.entities}/${pom.artifactId}.ent" 
                  file="${plugin.resources}/entity-template.ent" 
                  filtering="true" 
                  overwrite="true" 
        >
          <filterset>
            <filter token="PROJECT-ID" value="${pom.artifactId}"/>
            <filter token="VERSION" 
value="${major}.${minor}.${phase}${number}"/>
          </filterset>
        </ant:copy>
      </define:tag>
    
      <define:tag name="read">
        <j:set var="versionFile" value="${maven.increment.dir}/build.numbers" />
        <util:file var="incrementSystem" name="${versionFile}"/>
        <j:if test="${ ! incrementSystem.exists() }" >
          <j:set var="major" value="1" scope="parent" />
          <j:set var="minor" value="0" scope="parent" />
          <j:set var="phase" value="dev-" scope="parent" />
          <j:set var="number" value="0" scope="parent" />
        </j:if>
       
        <j:if test="${ incrementSystem.exists() }" >
          <util:properties file="${versionFile}" var="versionProperties"/>
          <j:set var="major" 
value="${versionProperties.getProperty('build.major').trim()}" scope="parent" />
          <j:set var="minor" 
value="${versionProperties.getProperty('build.minor').trim()}" scope="parent" />
          <j:set var="phase" 
value="${versionProperties.getProperty('build.phase').trim()}" scope="parent" />
          <j:set var="number" 
value="${versionProperties.getProperty('build.number').trim()}" scope="parent" 
/>
        </j:if>
      </define:tag>
  
      <define:tag name="store">
        <ant:mkdir dir="${maven.increment.dir}" />
  <ant:echo file="${maven.increment.dir}/build.numbers">
  build.major=${major}
  build.minor=${minor}    
  build.phase=${phase}
  build.number=${number}
  </ant:echo>
        <increment:update-entities />
      </define:tag>
  
      <define:tag name="commit">
        <j:set var="commitToCVS" value="${maven.increment.commit}" />
        <j:if test="${commitToCVS}" >
          <ant:cvs command="-q commit -m &quot;New distribution 
(${pom.currentVersion}) created and uploaded to 
http://www.apache.org/dist/avalon/avalon-logkit/distributions/ &quot; " />
        </j:if>
      </define:tag>
      
      <define:tag name="tag">
        <j:if test="${tagCVS}" >
          <j:set var="tagCVS" value="${maven.increment.tag}" />
          <util:replace var="tag" oldChar="-" newChar="_" 
value="DIST_${major}_${minor}_${phase}${number}"/>
          <ant:cvs command="-q tag ${tag}" />
        </j:if>
      </define:tag>
        
    </define:taglib>
    
    
    <preGoal name="dist:deploy" >
      <j:set var="enable" value="${maven.increment.enable}" />
      <j:if test="${enable}" >
        <util:file var="incrementSystem" 
name="${maven.increment.dir}/build.numbers"/>
        <j:if test="${ ! incrementSystem.exists() }" >
          <ant:echo>
  *****************************************************************************
  *
  *  The Increment system was not initialized.
  *  It has now been initialized but it is required that Maven is restarted.
  *  Please make sure that the ${maven.increment.dir}/build.numbers contains
  *  the version numbers you intend to use.
  *
  *****************************************************************************
          </ant:echo>
          <attainGoal name="increment:initialize" />
        </j:if>
        <j:if test="${ incrementSystem.exists() }" >
          <j:set var="distDeployInProgress" value="true" />
          <attainGoal name="jar:deploy" />
        </j:if>
      </j:if>
    </preGoal>
  
    <preGoal name="jar:deploy" >
      <j:set var="enable" value="${maven.increment.enable}" />
      <j:if test="${enable}" >
        <util:file var="incrementSystem" 
name="${maven.increment.dir}/build.numbers"/>
        <j:if test="${ ! incrementSystem.exists() }" >
          <ant:echo>
  *****************************************************************************
  *
  *  The Increment system was not initialized.
  *  It has now been initialized but it is required that Maven is restarted.
  *  Please make sure that the ${maven.increment.dir}/build.numbers contains
  *  the version numbers you intend to use.
  *
  *****************************************************************************
          </ant:echo>
          <attainGoal name="increment:initialize" />
        </j:if>
      </j:if>
    </preGoal>
  
    <postGoal name="dist:deploy" >
      <j:set var="enable" value="${maven.increment.enable}" />
      <j:if test="${enable}" >
        <increment:read />
        <increment:inc-number/>
        <increment:store />
        <increment:commit />
      </j:if>
    </postGoal>
    
    <postGoal name="jar:deploy" >
      <j:set var="enable" value="${maven.increment.enable}" />
      <j:if test="${! distDeployInProgress }" >
        <j:if test="${enable}" >
          <increment:read />
          <increment:inc-number/>
          <increment:store />
          <increment:commit />
        </j:if>
      </j:if>
    </postGoal>
    
    <goal name="increment:major" description="Increases the MAJOR version 
number." >
      <j:set var="enable" value="${maven.increment.enable}" />
      <j:if test="${enable}" >
        <increment:read />
        <j:set var="major" value="${ major + 1 }" />
        <j:set var="minor" value="0" />
        <j:set var="phase" value="dev-" />
        <j:set var="number" value="0" />
        <increment:store />
      </j:if>
    </goal>
    
    <goal name="increment:minor" description="Increases the MINOR version 
number." >
      <j:set var="enable" value="${maven.increment.enable}" />
      <j:if test="${enable}" >
        <increment:read />
        <j:set var="minor" value="${ minor + 1 }" />
        <j:set var="phase" value="dev-" />
        <j:set var="number" value="0" />
        <increment:store />
      </j:if>
    </goal>
    
    <goal name="increment:phase" description="Changes the PHASE of the 
project/artifact." >
      <j:set var="enable" value="${maven.increment.enable}" />
      <j:if test="${enable}" >
        <increment:read />
        <j:if test="${ phase.equals( 'rc-' )}" >
          <j:set var="phase" value=" " />
        </j:if>
        <j:if test="${ phase.equals( 'dev-' )}" >
          <j:set var="phase" value="rc-" />
        </j:if>
        <j:set var="number" value="0" />
        <increment:store />
      </j:if>
    </goal>
    
    <goal name="increment:micro" >
      <j:set var="enable" value="${maven.increment.enable}" />
      <j:if test="${enable}" >
        <increment:read />
        <increment:inc-number />
        <increment:store />
      </j:if>
    </goal>
    
    <goal name="increment:initialize"  description="Initializes the Incrementor 
system." >
      <j:set var="enable" value="${maven.increment.enable}" />
      <j:if test="${enable}" >
        <increment:read />
        <increment:store />
        <increment:update-entities />
      </j:if>
    </goal>
    
    <goal name="increment" description="Automatic Versioning System, designed 
for Avalon." >
      <ant:echo>
  The 'Incrementor' is a versioning system, made specifically for 
  the Avalon project.
  It uses a version format of;
      MAJOR "." MINOR "." PHASE NUMBER
  where PHASE is "dev-", "rc-", ""
  
  To increment any of MAJOR, MINOR or PHASE, invoke the 
    increment:major
    increment:minor
    increment:phase
  
  The NUMBER is incremented automatically when the artifact/project is
  deployed to the central repository.
  
  Whenever a position is incremented, all the position to its right are
  reset to their respective start values.
    MINOR=0
    PHASE=dev-
    NUMBER=0
  
  
  Example of a cycle; 
    2.1.dev-34, 2.1.dev-35, 2.1.rc-0, 2.1.rc-1, 2.1.0, 2.1.1, 2.2.dev-0
    
  Before start using it, one must invoke the 
    increment:initialize
  or, if it is forgotten, it will do so automatically and require you to
  restart Maven, since the pom.currentVersion can't be updated after 
  start.
  
  The following properties are used (with their default values);
  
  # This property must be set to true, to enable the Versioning system
  maven.increment.enable = false
  
  # The directory where the versioning information is persisted.
  maven.increment.dir=${basedir}/versioning
  
  # The directory where the versioning information is persisted.
  maven.increment.central.entities=${basedir}/versioning
  
  # If the version number data should be committed to CVS after a deploy.
  maven.increment.commit=true
  
      </ant:echo>
    </goal>
    
  </project>
  
  
  
  1.1                  avalon/maven-plugins/versioning/plugin.properties
  
  Index: plugin.properties
  ===================================================================
  # -------------------------------------------------------------------
  # Copyright 2001-2004 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.
  # -------------------------------------------------------------------
  
  # This property must be set to true, to enable the Versioning system
  maven.increment.enable = false
  
  # The directory where the versioning information is persisted.
  maven.increment.dir = ${basedir}/versioning
  
  # The directory where the versioning information is persisted.
  maven.increment.central.entities = ${basedir}/versioning
  
  # If the version number data should be committed to CVS after a deploy.
  maven.increment.commit = true
  
  
  
  
  1.1                  avalon/maven-plugins/versioning/project.properties
  
  Index: project.properties
  ===================================================================
  # -------------------------------------------------------------------
  # Copyright 2001-2004 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.
  # -------------------------------------------------------------------
  
  # -------------------------------------------------------------------
  # P R O J E C T  P R O P E R T I E S
  # -------------------------------------------------------------------
  maven.xdoc.date=left
  maven.xdoc.version=${pom.currentVersion}
  maven.license.licenseFile=${basedir}/../../LICENSE.txt
  maven.checkstyle.header.file=${basedir}/../../LICENSE.txt
  maven.checkstyle.format = turbine
  
  maven.junit.fork=yes
  
  
  
  1.1                  avalon/maven-plugins/versioning/project.xml
  
  Index: project.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <!-- 
  /*
   * Copyright 2001-2004 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>
    <extend>../project.xml</extend>
    <id>avalon-versioning-plugin</id>
    <name>Avalon Versioning Maven Plugin</name>
    <currentVersion>1.0.dev-4</currentVersion>
    <description/>
    <shortDescription>Automatic generation and updates of 
Versions.</shortDescription>
    
    <url>http://avalon.apache.org/plugins/versioning/</url>
    <siteDirectory>/www/avalon.apache.org/plugins/versioning</siteDirectory>
  </project>
  
  
  
  1.1                  
avalon/maven-plugins/versioning/src/plugin-resources/entity-template.ent
  
  Index: entity-template.ent
  ===================================================================
  
  <!ENTITY @[EMAIL PROTECTED] "@PROJECT-ID@">
  <!ENTITY @[EMAIL PROTECTED] "@PROJECT-ID@">
  <!ENTITY @[EMAIL PROTECTED] "@VERSION@">
      
   
  
  
  
  1.1                  avalon/maven-plugins/versioning/xdocs/changes.xml
  
  Index: changes.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  
  <!-- 
  /*
   * Copyright 2001-2004 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.
   */
   -->
  
  <document>
    <properties>
      <title>Changes</title>
      <author email="[EMAIL PROTECTED]">Vincent Massol</author>
    </properties>
    <body>
      <release version="1.4" date="2004-03-07">
        <action dev="dion" type="fix">Prefix basedir on copied ant build file. 
Only create ant build file if the project has source. Only copy maven.src.dir 
if it exists.</action>
        <action dev="dion" type="update">Moved properties out to 
plugin.properties</action>
        <action dev="dion" type="fix">add ${basedir} to ant build file being 
moved</action>
      </release>
      <release version="1.3" date="2003-09-29">
        <action dev="dion" type="update">update to use 
maven.docs.*/maven.gen.docs</action>
        <action dev="dion" type="update">update to commons-lang 1.0.1</action>
      </release>
      <release version="1.1" date="2002-09-16">
        <action dev="jvanzyl" type="update">Released.</action>
      </release>
    </body>
  </document>
  
  
  
  1.1                  avalon/maven-plugins/versioning/xdocs/goals.xml
  
  Index: goals.xml
  ===================================================================
  <?xml version="1.0"?>
  <!-- 
  /*
   * Copyright 2001-2004 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.
   */
   -->
  
  <document>
  
    <properties>
      <title>Avalon Versioning Maven Plug-in Goals</title>
      <author email="[EMAIL PROTECTED]">Niclas Hedhman</author>
    </properties>
  
    <body>
      <goals>
        <goal>
          <name>increment</name>
          <description>
            This is the default goal of the plugin and simply print out
            an explaination about this plugin
          </description>
        </goal>
        <goal>
          <name>increment:initialize</name>
          <description>
            Initializes the Versioning system. Need to be run once before 
starting
            to use the plugin. If it has not been run, it will be run
            automatically at the first dist:deploy or jar:deploy, but require
            you to restart Maven's build again.
          </description>
        </goal>
        <goal>
          <name>increment:major</name>
          <description>
            This goal increments the <strong>Major</strong> number and reset the
            positions to the right.
          </description>
        </goal>
        <goal>
          <name>increment:minor</name>
            This goal increments the <strong>Minor</strong> number and reset the
            positions to the right.
          <description>
          </description>
        </goal>
        <goal>
          <name>increment:phase</name>
            This goal increments the <strong>Phase</strong> number and reset the
            build number to zero.
          <description>
          </description>
        </goal>
        <goal>
          <name>increment:micro</name>
          <description>
            This goal is mainly for internal and testing purposes. It increases
            the build number, and should probably never be used directly.
          </description>
        </goal>
      </goals>
   </body>
  </document>
  
  
  
  1.1                  avalon/maven-plugins/versioning/xdocs/index.xml
  
  Index: index.xml
  ===================================================================
  <?xml version="1.0"?>
  <!-- 
  /*
   * Copyright 2001-2004 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.
   */
   -->
  
  <document>
  
    <properties>
      <title>Avalon Versioning Maven Plug-in</title>
      <author email="[EMAIL PROTECTED]">Niclas Hedhman</author>
    </properties>
  
    <body>
      <section name="Avalon Versioning Maven Plug-in">
        <p>
          This plugin triggers on dist:deploy and jar:deploy goals, and
          increment the build number when the jar or distro has been uploaded.
          The CVS will also be tagged with the version, for proper maintenance.
        </p>
        <p>
          The plugin will need to initialize the project first, which is done
          with;
        </p>
        <source>
          maven increment:initialize
        </source>
        <p>
          This will create the initial setup and enable the Versioning plugin 
for
          the project. However, you will need to set the 
maven.versioning.enable 
          property in the project.properties file to true as well.
        </p>
        <p>
          Initially the version is set to 1.0.dev-0. The 'dev-' part means that
          it is development in-progress. We call this the "phase". There are
          only 3 phases, "dev-", "rc-" and "", where "rc" stands for 
          <strong>release candidate</strong>. The workflow is, when a new Minor
          version is started, the version starts in the "dev-" phase, and any
          deployment will increment the number (digits right of dev-). Once the
          code has stablized, i.e. no more incompatible changes, and 
          community-wide testing to start, the phase is incremented to "rc-".
          This is done by;
        </p>
        <source>
          maven increment:phase
        </source>
        <p>
          That will bring the version from, for instance, "1.0.dev-176" to 
          "1.0.rc-0". Next time the increment:phase goal is called the result
          would become "1.0.0".
        </p>
        <p>
          To increment the <strong>Major</strong> and <strong>Minor</strong>
          parts, you invoke
        </p>
        <source>
          maven increment:minor
          maven increment:major
        </source>
        <p>
          respectively. For a Minor increment, it will be set to "X.y.dev-0" 
and 
          for a Major increment the version will be set to "X.0.dev-0".
        </p>
      </section>
   </body>
  </document>
  
  
  
  1.1                  avalon/maven-plugins/versioning/xdocs/navigation.xml
  
  Index: navigation.xml
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1"?>
  <!-- 
  /*
   * Copyright 2001-2004 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="Avalon Versioning Maven Plugin">
  
    <title>Avalon Versioning Maven Plugin</title>
  
    <body>
      <links>
        <item name="Maven" href="http://maven.apache.org/"/>
      </links>
      <menu name="Overview">
        <item name="Goals"      href="/goals.html" />
        <item name="Properties" href="/properties.html" />
      </menu>
    </body>
  </project>
  
  
  
  1.1                  avalon/maven-plugins/versioning/xdocs/properties.xml
  
  Index: properties.xml
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1"?>
  <!-- 
  /*
   * Copyright 2001-2004 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.
   */
   -->
  
  <document>
    <properties>
      <title>Versioning Properties</title>
      <author email="[EMAIL PROTECTED]">Niclas Hedhman</author>
    </properties>
  
    <body>
      <section name="Versioning Settings">
        <table>
          <tr><th>Property</th><th>Optional?</th><th>Description</th></tr>
          <tr>
            <td>maven.increment.enable</td>
            <td>yes - default is false</td>
            <td>
              This enables Versioning for the project. If it is false, all
              versioning goals are disabled.
            </td>
          </tr> 
          <tr>
            <td>maven.increment.dir</td>
            <td>yes - default is ${basedir}/versioning</td>
            <td>
              The directory where the versioning information is stored.
            </td>
          </tr> 
          <tr>
            <td>maven.increment.central.entities</td>
            <td>yes - default is ${basedir}/versioning</td>
            <td>
              The directory where the XML &lt;!ENTITY ... &gt; file is stored,
              which is used to keep all versions in sync throughout all
              projects.
            </td>
          </tr> 
          <tr>
            <td>maven.increment.commit</td>
            <td>yes - default is true</td>
            <td>
              If true, the the whole source tree is committed, to ensure that 
the
              released version is placed into the CVS, and not only exist on the
              local system. <strong>NOTE:</strong> The commit only occurs when 
the
              content is uploaded to central repository. And the Entity file is 
NOT
              committed!
            </td>
          </tr> 
          <tr>
            <td>maven.increment.commit</td>
            <td>yes - default is true</td>
            <td>
              If true, the the whole source tree is tagged when a dist:deploy 
is 
              done, to ensure that the released version is marked properly in 
the
              CVS. <strong>NOTE:</strong> Only the ${basedir} and below is 
tagged.
            </td>
          </tr> 
        </table>
      </section>
    </body>
  </document>
  
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to