com.smartcodeltd
Class VersionMojo

java.lang.Object
  extended by org.apache.maven.plugin.AbstractMojo
      extended by com.smartcodeltd.ReleaseCandidateMojo
          extended by com.smartcodeltd.VersionMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

@Mojo(name="version",
      requiresProject=true,
      defaultPhase=PACKAGE,
      aggregator=true)
public class VersionMojo
extends ReleaseCandidateMojo

Retrieves project version specified in pom.xml and outputs it either to stdout or to a file, depending on configuration.


Field Summary
protected  String outputTemplate
           Defines how to structure the output of release-candidate:version
 
Fields inherited from class com.smartcodeltd.ReleaseCandidateMojo
charset, encoding, project
 
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
 
Constructor Summary
VersionMojo()
           
 
Method Summary
 void execute()
           
 
Methods inherited from class com.smartcodeltd.ReleaseCandidateMojo
firstExisting, getOrElse, info, parentVersion, parsed, projectVersion, root, versionOf, with
 
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

outputTemplate

@Parameter(defaultValue="{{ version }}",
           required=false,
           property="outputTemplate")
protected String outputTemplate

Defines how to structure the output of release-candidate:version

If your build server of choice understands text output produced by maven (which is the case if you're using TeamCity for example), you can specify the outputTemplate as:

<outputTemplate>
  ##teamcity[setParameter name='env.PROJECT_VERSION' value='{{ version }}']
  ##teamcity[message text='Project version: {{ version }}']
 </outputTemplate>

If your build server prefers to use env variables defined using property files (Jenkins with EnvInject plugin) you can specify the outputTemplate as:

<outputTemplate>PROJECT_VERSION={{ version }}</outputTemplate>

Please note that when using multi-line templates, leading whitespace characters will be stripped.

Constructor Detail

VersionMojo

public VersionMojo()
Method Detail

execute

public void execute()
             throws org.apache.maven.plugin.MojoExecutionException
Throws:
org.apache.maven.plugin.MojoExecutionException


Copyright © 2016 smartcode ltd. All rights reserved.