Commit 0b0d7b88 authored by mindthegab's avatar mindthegab
Browse files
parent 118e68f6
Loading
Loading
Loading
Loading

pom.xml

0 → 100644
+54 −0
Original line number Diff line number Diff line
<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>com.sourcesense.maven</groupId>
	<artifactId>maven-nosnapshot-plugin</artifactId>
	<packaging>maven-plugin</packaging>
	<version>0.0.3-SNAPSHOT</version>
	<name>maven-nosnapshot-plugin Maven Mojo</name>
	<url>http://maven.apache.org</url>
	<scm>
		<developerConnection>scm:svn:https://dev.sourcesense.com/repos/dev/maven-nosnapshot-plugin/tags/maven-nosnapshot-plugin-0.0.1</developerConnection>
		<url>https://dev.sourcesense.com/repos/dev/maven-nosnapshot-plugin/tags/maven-nosnapshot-plugin-0.0.1</url>
	</scm>
	<dependencies>
		<dependency>
			<groupId>org.apache.maven</groupId>
			<artifactId>maven-plugin-api</artifactId>
			<version>2.0</version>
		</dependency>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>3.8.1</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.apache.maven</groupId>
			<artifactId>maven-project</artifactId>
			<version>2.0.9</version>
		</dependency>
	</dependencies>
	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-release-plugin</artifactId>
				<configuration>
					<!-- useEditMode>true</useEditMode>-->
					<preparationGoals>clean</preparationGoals>
					<goals>deploy</goals>
					<tagBase>https://dev.sourcesense.com/repos/dev/maven-nosnapshot-plugin/tags</tagBase>
					<useEditMode>true</useEditMode>
					<username>g.columbro</username>
				</configuration>
			</plugin>

		</plugins>
	</build>
	<distributionManagement>
		<repository>
			<id>ss-public</id>
			<url>scpexe://repository.sourcesense.com/var/www/repository.sourcesense.com/maven2</url>
		</repository>
	</distributionManagement>
</project>
+63 −0
Original line number Diff line number Diff line
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);
    }
}