maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rfscho...@apache.org
Subject svn commit: r1669762 - in /maven/release/trunk: ./ maven-release-policies/maven-release-semver-policy/ maven-release-policies/maven-release-semver-policy/src/ maven-release-policies/maven-release-semver-policy/src/main/ maven-release-policies/maven-rel...
Date Sat, 28 Mar 2015 13:01:37 GMT
Author: rfscholte
Date: Sat Mar 28 13:01:36 2015
New Revision: 1669762

URL: http://svn.apache.org/r1669762
Log:
[MRELEASE-797] support semantic versioning

Added:
    maven/release/trunk/maven-release-policies/maven-release-semver-policy/
    maven/release/trunk/maven-release-policies/maven-release-semver-policy/pom.xml
    maven/release/trunk/maven-release-policies/maven-release-semver-policy/src/
    maven/release/trunk/maven-release-policies/maven-release-semver-policy/src/main/
    maven/release/trunk/maven-release-policies/maven-release-semver-policy/src/main/java/
    maven/release/trunk/maven-release-policies/maven-release-semver-policy/src/main/java/org/
    maven/release/trunk/maven-release-policies/maven-release-semver-policy/src/main/java/org/apache/
    maven/release/trunk/maven-release-policies/maven-release-semver-policy/src/main/java/org/apache/maven/
    maven/release/trunk/maven-release-policies/maven-release-semver-policy/src/main/java/org/apache/maven/shared/
    maven/release/trunk/maven-release-policies/maven-release-semver-policy/src/main/java/org/apache/maven/shared/release/
    maven/release/trunk/maven-release-policies/maven-release-semver-policy/src/main/java/org/apache/maven/shared/release/policy/
    maven/release/trunk/maven-release-policies/maven-release-semver-policy/src/main/java/org/apache/maven/shared/release/policy/semver/
    maven/release/trunk/maven-release-policies/maven-release-semver-policy/src/main/java/org/apache/maven/shared/release/policy/semver/SemVerVersionPolicy.java
    maven/release/trunk/maven-release-policies/maven-release-semver-policy/src/test/
    maven/release/trunk/maven-release-policies/maven-release-semver-policy/src/test/java/
    maven/release/trunk/maven-release-policies/maven-release-semver-policy/src/test/java/org/
    maven/release/trunk/maven-release-policies/maven-release-semver-policy/src/test/java/org/apache/
    maven/release/trunk/maven-release-policies/maven-release-semver-policy/src/test/java/org/apache/maven/
    maven/release/trunk/maven-release-policies/maven-release-semver-policy/src/test/java/org/apache/maven/shared/
    maven/release/trunk/maven-release-policies/maven-release-semver-policy/src/test/java/org/apache/maven/shared/release/
    maven/release/trunk/maven-release-policies/maven-release-semver-policy/src/test/java/org/apache/maven/shared/release/policy/
    maven/release/trunk/maven-release-policies/maven-release-semver-policy/src/test/java/org/apache/maven/shared/release/policy/semver/
    maven/release/trunk/maven-release-policies/maven-release-semver-policy/src/test/java/org/apache/maven/shared/release/policy/semver/SemVerVersionPolicyTest.java
Modified:
    maven/release/trunk/pom.xml

Added: maven/release/trunk/maven-release-policies/maven-release-semver-policy/pom.xml
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-policies/maven-release-semver-policy/pom.xml?rev=1669762&view=auto
==============================================================================
--- maven/release/trunk/maven-release-policies/maven-release-semver-policy/pom.xml (added)
+++ maven/release/trunk/maven-release-policies/maven-release-semver-policy/pom.xml Sat Mar
28 13:01:36 2015
@@ -0,0 +1,81 @@
+<?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 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>
+    <groupId>org.apache.maven.release</groupId>
+    <artifactId>maven-release</artifactId>
+    <version>2.5.2-SNAPSHOT</version>
+    <relativePath>../..</relativePath>
+  </parent>
+
+  <artifactId>maven-release-semver-policy</artifactId>
+
+  <name>Maven Release SemVer Policy</name>
+
+  <dependencies>
+    <dependency>
+      <groupId>${project.parent.groupId}</groupId>
+      <artifactId>maven-release-api</artifactId>
+      <version>${project.parent.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.semver</groupId>
+      <artifactId>api</artifactId>
+      <version>0.9.33</version>
+    </dependency>
+
+
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-component-annotations</artifactId>
+      <scope>provided</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.11</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.codehaus.plexus</groupId>
+        <artifactId>plexus-component-metadata</artifactId>
+        <version>1.5.5</version>
+        <executions>
+          <execution>
+            <id>process-classes</id>
+            <goals>
+              <goal>generate-metadata</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
\ No newline at end of file

Added: maven/release/trunk/maven-release-policies/maven-release-semver-policy/src/main/java/org/apache/maven/shared/release/policy/semver/SemVerVersionPolicy.java
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-policies/maven-release-semver-policy/src/main/java/org/apache/maven/shared/release/policy/semver/SemVerVersionPolicy.java?rev=1669762&view=auto
==============================================================================
--- maven/release/trunk/maven-release-policies/maven-release-semver-policy/src/main/java/org/apache/maven/shared/release/policy/semver/SemVerVersionPolicy.java
(added)
+++ maven/release/trunk/maven-release-policies/maven-release-semver-policy/src/main/java/org/apache/maven/shared/release/policy/semver/SemVerVersionPolicy.java
Sat Mar 28 13:01:36 2015
@@ -0,0 +1,75 @@
+package org.apache.maven.shared.release.policy.semver;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.shared.release.policy.PolicyException;
+import org.apache.maven.shared.release.policy.version.VersionPolicy;
+import org.apache.maven.shared.release.policy.version.VersionPolicyRequest;
+import org.apache.maven.shared.release.policy.version.VersionPolicyResult;
+import org.apache.maven.shared.release.versions.VersionParseException;
+import org.codehaus.plexus.component.annotations.Component;
+import org.semver.Version;
+import org.semver.Version.Element;
+
+@Component(
+           role = VersionPolicy.class,
+           hint = "SemVerVersionPolicy",
+           description = "A VersionPolicy following the SemVer rules"
+       )
+public class SemVerVersionPolicy implements VersionPolicy
+{
+
+    public VersionPolicyResult getReleaseVersion( VersionPolicyRequest request )
+        throws PolicyException, VersionParseException
+    {
+        Version version;
+        try 
+        {
+            version = Version.parse( request.getVersion() );
+        }
+        catch( IllegalArgumentException e )
+        {
+            throw new VersionParseException( e.getMessage() );
+        }
+        
+        VersionPolicyResult result = new VersionPolicyResult();
+        result.setVersion( version.toReleaseVersion().toString() );
+        return result;
+    }
+
+    public VersionPolicyResult getDevelopmentVersion( VersionPolicyRequest request )
+        throws PolicyException, VersionParseException
+    {
+        Version version;
+        try 
+        {
+            version = Version.parse( request.getVersion() );
+        }
+        catch( IllegalArgumentException e )
+        {
+            throw new VersionParseException( e.getMessage() );
+        }
+        
+        version = version.next( Element.MINOR );  
+        VersionPolicyResult result = new VersionPolicyResult();
+        result.setVersion( version.toString() + "-SNAPSHOT" );
+        return result;
+    }
+}

Added: maven/release/trunk/maven-release-policies/maven-release-semver-policy/src/test/java/org/apache/maven/shared/release/policy/semver/SemVerVersionPolicyTest.java
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-policies/maven-release-semver-policy/src/test/java/org/apache/maven/shared/release/policy/semver/SemVerVersionPolicyTest.java?rev=1669762&view=auto
==============================================================================
--- maven/release/trunk/maven-release-policies/maven-release-semver-policy/src/test/java/org/apache/maven/shared/release/policy/semver/SemVerVersionPolicyTest.java
(added)
+++ maven/release/trunk/maven-release-policies/maven-release-semver-policy/src/test/java/org/apache/maven/shared/release/policy/semver/SemVerVersionPolicyTest.java
Sat Mar 28 13:01:36 2015
@@ -0,0 +1,71 @@
+package org.apache.maven.shared.release.policy.semver;
+
+/*
+ * 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.
+ */
+
+import static org.junit.Assert.*;
+
+import org.apache.maven.shared.release.policy.version.VersionPolicy;
+import org.apache.maven.shared.release.policy.version.VersionPolicyRequest;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class SemVerVersionPolicyTest
+{
+
+    private VersionPolicy versionPolicy;
+
+    @Before
+    public void setUp()
+    {
+        versionPolicy = new SemVerVersionPolicy();
+    }
+
+    @After
+    public void tearDown()
+    {
+        versionPolicy = null;
+    }
+
+    @Test
+    public void testConvertToSnapshot()
+        throws Exception
+    {
+        String suggestedVersion = versionPolicy.getDevelopmentVersion( newVersionPolicyRequest(
"1.0.0" ) )
+                                               .getVersion();
+
+        assertEquals( "1.1.0-SNAPSHOT", suggestedVersion );
+    }
+
+    @Test
+    public void testConvertToRelease()
+        throws Exception
+    {
+        String suggestedVersion = versionPolicy.getReleaseVersion( newVersionPolicyRequest(
"1.0.0-SNAPSHOT" ) )
+                                               .getVersion();
+
+        assertEquals( "1.0.0", suggestedVersion );
+    }
+
+    private static VersionPolicyRequest newVersionPolicyRequest( String version )
+    {
+        return new VersionPolicyRequest().setVersion( version );
+    }
+}

Modified: maven/release/trunk/pom.xml
URL: http://svn.apache.org/viewvc/maven/release/trunk/pom.xml?rev=1669762&r1=1669761&r2=1669762&view=diff
==============================================================================
--- maven/release/trunk/pom.xml (original)
+++ maven/release/trunk/pom.xml Sat Mar 28 13:01:36 2015
@@ -41,6 +41,7 @@
     <module>maven-release-manager</module>
     <module>maven-release-plugin</module>
     <module>maven-release-policies/maven-release-oddeven-policy</module>
+    <module>maven-release-policies/maven-release-semver-policy</module>
   </modules>
 
   <scm>



Mime
View raw message