maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rfscho...@apache.org
Subject svn commit: r1538169 - in /maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools: AbstractDistCheckMojo.java ConfigurationLineInfo.java
Date Sat, 02 Nov 2013 11:08:37 GMT
Author: rfscholte
Date: Sat Nov  2 11:08:37 2013
New Revision: 1538169

URL: http://svn.apache.org/r1538169
Log:
Support ranges

Modified:
    maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/AbstractDistCheckMojo.java
    maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/ConfigurationLineInfo.java

Modified: maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/AbstractDistCheckMojo.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/AbstractDistCheckMojo.java?rev=1538169&r1=1538168&r2=1538169&view=diff
==============================================================================
--- maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/AbstractDistCheckMojo.java
(original)
+++ maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/AbstractDistCheckMojo.java
Sat Nov  2 11:08:37 2013
@@ -28,6 +28,7 @@ import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.PrintWriter;
 import java.net.URL;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.LinkedList;
 import java.util.List;
@@ -38,6 +39,9 @@ import org.apache.maven.artifact.reposit
 import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
 import org.apache.maven.artifact.repository.metadata.Metadata;
 import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
+import org.apache.maven.artifact.versioning.ArtifactVersion;
+import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
+import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
 import org.apache.maven.doxia.sink.Sink;
 import org.apache.maven.doxia.siterenderer.Renderer;
 import org.apache.maven.plugin.MojoExecutionException;
@@ -195,7 +199,15 @@ public abstract class AbstractDistCheckM
                 // 3 space
                 if ( line.startsWith( "   " ) )
                 {
-                    ConfigurationLineInfo aLine = new ConfigurationLineInfo( currentGroup,
line.trim().split( " " ) );
+                    ConfigurationLineInfo aLine;
+                    try
+                    {
+                        aLine = new ConfigurationLineInfo( currentGroup, line.trim().split(
" " ) );
+                    }
+                    catch ( InvalidVersionSpecificationException e )
+                    {
+                        throw new MojoExecutionException( e.getMessage() );
+                    }
                     if ( useDetailed() )
                     {
                         checkArtifact( aLine, getVersion( aLine ) );
@@ -203,7 +215,15 @@ public abstract class AbstractDistCheckM
                 }
                 else if ( line.startsWith( "  " ) ) 
                 {
-                    ConfigurationLineInfo aLine = new ConfigurationLineInfo( currentGroup,
line.trim().split( " " ) );
+                    ConfigurationLineInfo aLine;
+                    try
+                    {
+                        aLine = new ConfigurationLineInfo( currentGroup, line.trim().split(
" " ) );
+                    }
+                    catch ( InvalidVersionSpecificationException e )
+                    {
+                        throw new MojoExecutionException( e.getMessage() );
+                    }
 
                     checkArtifact( aLine, getVersion( aLine ) );
                 } 
@@ -227,10 +247,29 @@ public abstract class AbstractDistCheckM
 
             aLine.setMetadata( metadata );
 
-            String version =
-                ( aLine.getForcedVersion() == null ) ? metadata.getVersioning().getLatest()
-                                : aLine.getForcedVersion();
-
+            String version;
+            if ( aLine.getVersionRange() != null )
+            {
+                if ( aLine.getVersionRange().hasRestrictions() )
+                {
+                    List<ArtifactVersion> artifactVersions = new ArrayList<>();
+                    for ( String versioningVersion : metadata.getVersioning().getVersions()
)
+                    {
+                        artifactVersions.add( new DefaultArtifactVersion( versioningVersion
) );
+                    }
+                    version = aLine.getVersionRange().matchVersion( artifactVersions ).toString();
+                }
+                else
+                {
+                    version = aLine.getVersionRange().getRecommendedVersion().toString();
+                }
+                aLine.setForceVersion( version );
+            }
+            else
+            {
+                version = metadata.getVersioning().getLatest();
+            }
+            
             if ( getLog().isDebugEnabled() )
             {
                 getLog().debug( "Checking information for artifact: " + aLine.getGroupId()
+ ":"

Modified: maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/ConfigurationLineInfo.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/ConfigurationLineInfo.java?rev=1538169&r1=1538168&r2=1538169&view=diff
==============================================================================
--- maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/ConfigurationLineInfo.java
(original)
+++ maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/ConfigurationLineInfo.java
Sat Nov  2 11:08:37 2013
@@ -26,6 +26,8 @@ import java.util.LinkedList;
 import java.util.List;
 
 import org.apache.maven.artifact.repository.metadata.Metadata;
+import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
+import org.apache.maven.artifact.versioning.VersionRange;
 
 /**
  *
@@ -40,7 +42,9 @@ class ConfigurationLineInfo
     private final boolean srcBin;
 
     private final String artifactId;
-    private final String forceVersion;
+    private final VersionRange versionRange;
+    
+    private String forceVersion;
     private String indexPageId;
     private Metadata metadata;
 
@@ -51,18 +55,18 @@ class ConfigurationLineInfo
         this.srcBin = ( infos.length > 2 ) && "src+bin".equals( infos[2] );
 
         this.artifactId = null;
-        this.forceVersion = null;
+        this.versionRange = null;
         this.indexPageId = null;
     }
 
-    public ConfigurationLineInfo( ConfigurationLineInfo group, String[] infos )
+    public ConfigurationLineInfo( ConfigurationLineInfo group, String[] infos ) throws InvalidVersionSpecificationException
     {
         this.directory = group.getDirectory();
         this.groupId = group.getGroupId();
         this.srcBin = group.isSrcBin();
 
         this.artifactId = infos[0];
-        this.forceVersion = ( infos.length > 1 && !infos[1].startsWith( "IP" )
) ? infos[1] : null;
+        this.versionRange = ( infos.length > 1 && !infos[1].startsWith( "IP" )
) ? VersionRange.createFromVersionSpec( infos[1] ) : null;
         this.indexPageId = null;
         for ( String info : infos )
         {
@@ -83,6 +87,16 @@ class ConfigurationLineInfo
     {
         return forceVersion;
     }
+    
+    public void setForceVersion( String forceVersion )
+    {
+        this.forceVersion = forceVersion;
+    }
+    
+    public VersionRange getVersionRange()
+    {
+        return versionRange;
+    }
 
     /**
      * @return the groupId



Mime
View raw message