servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r681984 - in /servicemix/maven-plugins/checksum-maven-plugin/trunk/src/main/java/org/apache/servicemix/maven/plugin/checksum: ChecksumGeneratorMojo.java ChecksumValidatorMojo.java
Date Sat, 02 Aug 2008 14:16:26 GMT
Author: chirino
Date: Sat Aug  2 07:16:26 2008
New Revision: 681984

URL: http://svn.apache.org/viewvc?rev=681984&view=rev
Log:
You can now wildcard the version number.  Also using a better artifact key in the property
file (easier to read).


Modified:
    servicemix/maven-plugins/checksum-maven-plugin/trunk/src/main/java/org/apache/servicemix/maven/plugin/checksum/ChecksumGeneratorMojo.java
    servicemix/maven-plugins/checksum-maven-plugin/trunk/src/main/java/org/apache/servicemix/maven/plugin/checksum/ChecksumValidatorMojo.java

Modified: servicemix/maven-plugins/checksum-maven-plugin/trunk/src/main/java/org/apache/servicemix/maven/plugin/checksum/ChecksumGeneratorMojo.java
URL: http://svn.apache.org/viewvc/servicemix/maven-plugins/checksum-maven-plugin/trunk/src/main/java/org/apache/servicemix/maven/plugin/checksum/ChecksumGeneratorMojo.java?rev=681984&r1=681983&r2=681984&view=diff
==============================================================================
--- servicemix/maven-plugins/checksum-maven-plugin/trunk/src/main/java/org/apache/servicemix/maven/plugin/checksum/ChecksumGeneratorMojo.java
(original)
+++ servicemix/maven-plugins/checksum-maven-plugin/trunk/src/main/java/org/apache/servicemix/maven/plugin/checksum/ChecksumGeneratorMojo.java
Sat Aug  2 07:16:26 2008
@@ -74,7 +74,7 @@
             for (Iterator iterator = checksums.entrySet().iterator(); iterator.hasNext();)
{
                 Map.Entry i = (Map.Entry)iterator.next();            
                 StringBuffer b = new StringBuffer();
-                for (Iterator iterator2 = ((List)i.getValue()).iterator(); iterator.hasNext();)
{
+                for (Iterator iterator2 = ((List)i.getValue()).iterator(); iterator2.hasNext();)
{
                     String s = (String)iterator2.next();            
                     if( b.length()!=0 ) {
                         b.append("|");
@@ -103,20 +103,23 @@
     /**
      * 
      * @param checksums
-     * @param pom
+     * @param artifact
      * @return true if this method modified the checksums
      * @throws MojoExecutionException
      */
-    private boolean processArtifact(HashMap checksums, Artifact pom) throws MojoExecutionException
{
-        String sum = checksum(pom.getFile());
-        List sums = (List)checksums.get(pom.getId());
+    private boolean processArtifact(HashMap checksums, Artifact artifact) throws MojoExecutionException
{
+        String sum = checksum(artifact.getFile());
+        List sums = (List)checksums.get(key(artifact));
+        if( sums == null ) {
+            sums = (List)checksums.get(keyAnyVersion(artifact));
+        }
         if( sums == null ) {
             sums = new ArrayList();
             sums.add(sum);
-            checksums.put(pom.getId(), sums);
+            checksums.put(key(artifact), sums);
             return true;
         } else {
-            if ( !sums.contains(sum) ) {
+            if ( !sums.contains(sum) && !sums.contains("*") ) {
                 sums.add(sum);
                 return true;
             }

Modified: servicemix/maven-plugins/checksum-maven-plugin/trunk/src/main/java/org/apache/servicemix/maven/plugin/checksum/ChecksumValidatorMojo.java
URL: http://svn.apache.org/viewvc/servicemix/maven-plugins/checksum-maven-plugin/trunk/src/main/java/org/apache/servicemix/maven/plugin/checksum/ChecksumValidatorMojo.java?rev=681984&r1=681983&r2=681984&view=diff
==============================================================================
--- servicemix/maven-plugins/checksum-maven-plugin/trunk/src/main/java/org/apache/servicemix/maven/plugin/checksum/ChecksumValidatorMojo.java
(original)
+++ servicemix/maven-plugins/checksum-maven-plugin/trunk/src/main/java/org/apache/servicemix/maven/plugin/checksum/ChecksumValidatorMojo.java
Sat Aug  2 07:16:26 2008
@@ -123,21 +123,49 @@
             
             
             String sum = checksum(pom.getFile());
-            List list = (List)checksums.get(pom.getId());
+            String key = key(pom);
+            List list = (List)checksums.get(key);
             if( list == null ) {
-                getLog().error("No checksum specified for "+pom.getId()+" in "+this.checksums+"
("+sum+")" );
+                list = (List)checksums.get(keyAnyVersion(pom));
+            }
+            if( list == null ) {
+                getLog().error("No checksum specified for "+key+" in "+this.checksums+" ("+sum+")"
);
                 failed = true;
             } else if ( !list.contains(sum) && !list.contains("*") ) {
-                getLog().error("Checksum mismatch for "+pom.getId()+" in "+this.checksums+"
expected one of "+list+" but was "+sum );
+                getLog().error("Checksum mismatch for "+key+" in "+this.checksums+" expected
one of "+list+" but was "+sum );
                 failed = true;
             }
         }
         
         if( failed ) {
-            throw new MojoExecutionException("Invalid checksums found.. see previous error
messages for more details.");
+            throw new MojoExecutionException("Invalid checksum(s) found.. see previous error
messages for more details.");
         }
     }
 
+    protected String key(Artifact pom) {
+        StringBuffer sb = new StringBuffer();
+        sb.append(pom.getGroupId());
+        sb.append("/");
+        sb.append(pom.getArtifactId());
+        sb.append("-");
+        sb.append(pom.getVersion());
+        sb.append(".");
+        sb.append(pom.getType());
+        return sb.toString();
+    }
+    
+    protected String keyAnyVersion(Artifact pom) {
+        StringBuffer sb = new StringBuffer();
+        sb.append(pom.getGroupId());
+        sb.append("/");
+        sb.append(pom.getArtifactId());
+        sb.append("-");
+        sb.append("*");
+        sb.append(".");
+        sb.append(pom.getType());
+        return sb.toString();
+    }
+
     protected LinkedHashMap getCheckSums() throws MojoExecutionException {
         LinkedHashMap rc = new LinkedHashMap();
         



Mime
View raw message