From 34828b6d85a16729574b3e0a6cfa08fd01f217f4 Mon Sep 17 00:00:00 2001 From: mindthegab Date: Tue, 17 Feb 2009 23:22:43 +0000 Subject: [PATCH] git-svn-id: http://maven-alfresco-archetypes.googlecode.com/svn/trunk@124 04253f4f-3451-0410-a141-5562f1e59037 --- plugins/maven-nosnapshot-plugin/pom.xml | 54 ++++++++++++++++ .../maven/NoSnapshotVersionMojo.java | 63 +++++++++++++++++++ 2 files changed, 117 insertions(+) create mode 100644 plugins/maven-nosnapshot-plugin/pom.xml create mode 100644 plugins/maven-nosnapshot-plugin/src/main/java/com/sourcesense/maven/NoSnapshotVersionMojo.java diff --git a/plugins/maven-nosnapshot-plugin/pom.xml b/plugins/maven-nosnapshot-plugin/pom.xml new file mode 100644 index 00000000..bba1dbd7 --- /dev/null +++ b/plugins/maven-nosnapshot-plugin/pom.xml @@ -0,0 +1,54 @@ + + 4.0.0 + com.sourcesense.maven + maven-nosnapshot-plugin + maven-plugin + 0.0.3-SNAPSHOT + maven-nosnapshot-plugin Maven Mojo + http://maven.apache.org + + scm:svn:https://dev.sourcesense.com/repos/dev/maven-nosnapshot-plugin/tags/maven-nosnapshot-plugin-0.0.1 + https://dev.sourcesense.com/repos/dev/maven-nosnapshot-plugin/tags/maven-nosnapshot-plugin-0.0.1 + + + + org.apache.maven + maven-plugin-api + 2.0 + + + junit + junit + 3.8.1 + test + + + org.apache.maven + maven-project + 2.0.9 + + + + + + org.apache.maven.plugins + maven-release-plugin + + + clean + deploy + https://dev.sourcesense.com/repos/dev/maven-nosnapshot-plugin/tags + true + g.columbro + + + + + + + + ss-public + scpexe://repository.sourcesense.com/var/www/repository.sourcesense.com/maven2 + + + diff --git a/plugins/maven-nosnapshot-plugin/src/main/java/com/sourcesense/maven/NoSnapshotVersionMojo.java b/plugins/maven-nosnapshot-plugin/src/main/java/com/sourcesense/maven/NoSnapshotVersionMojo.java new file mode 100644 index 00000000..5911ca9b --- /dev/null +++ b/plugins/maven-nosnapshot-plugin/src/main/java/com/sourcesense/maven/NoSnapshotVersionMojo.java @@ -0,0 +1,63 @@ +package com.sourcesense.maven; + +/* + * Copyright 2001-2005 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. + */ + +import java.text.MessageFormat; + +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.project.MavenProject; + +/** + * Goal which pushes a stripped version number in the maven project properties (any -SNAPSHOT suffix is removed) + * + * @goal strip + * @phase initialize + * + */ +public class NoSnapshotVersionMojo + extends AbstractMojo +{ + /** + * Current version of the project + * @parameter expression="${project.version}" + * @required + */ + private String version; + + /** + * The Maven project + * @parameter expression="${project}" + * @required + */ + private MavenProject project; + + public void execute() + throws MojoExecutionException + { + int indexOfDash = -1; + String noSnapshotVersion = version; + if((indexOfDash = version.indexOf("-SNAPSHOT")) != -1) + { + noSnapshotVersion = version.substring(0, indexOfDash); + } + getLog().info( + MessageFormat.format( "Storing noSnapshotVersion: {0} ", new Object[] { + noSnapshotVersion} ) ); + project.getProperties().put("noSnapshotVersion", noSnapshotVersion); + } +}