Author: skygo
Date: Thu May 30 00:20:15 2013
New Revision: 1487688

URL: http://svn.apache.org/r1487688
Log:
refactoring
add a mojo to check site (limited)

Added:
    
maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/AbstractDistCheckMojo.java
   (with props)
    
maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/ConfigurationLineInfo.java
   (with props)
    
maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/DistCheckSiteMojo.java
      - copied, changed from r1487599, 
maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/DistMojo.java
    
maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/DistCheckSourceReleaseMojo.java
      - copied, changed from r1487599, 
maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/DistMojo.java
Removed:
    
maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/DistMojo.java
Modified:
    maven/sandbox/trunk/dist-tools/dist-tool-plugin/nbactions.xml
    maven/sandbox/trunk/dist-tools/dist-tool-plugin/pom.xml
    maven/sandbox/trunk/dist-tools/dist-tool-plugin/test.sh

Modified: maven/sandbox/trunk/dist-tools/dist-tool-plugin/nbactions.xml
URL: 
http://svn.apache.org/viewvc/maven/sandbox/trunk/dist-tools/dist-tool-plugin/nbactions.xml?rev=1487688&r1=1487687&r2=1487688&view=diff
==============================================================================
--- maven/sandbox/trunk/dist-tools/dist-tool-plugin/nbactions.xml (original)
+++ maven/sandbox/trunk/dist-tools/dist-tool-plugin/nbactions.xml Thu May 30 
00:20:15 2013
@@ -1,11 +1,19 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <actions>
-        <action>
-            <actionName>CUSTOM-dummytest</actionName>
-            <displayName>dummytest</displayName>
-            <goals>
-                
<goal>org.apache.maven.dist.tools:dist-tool-plugin:check-source</goal>
-                <goal>-X</goal>
-            </goals>
-        </action>
-    </actions>
+    <action>
+        <actionName>CUSTOM-checksourcerelease</actionName>
+        <displayName>check-source-release</displayName>
+        <goals>
+            
<goal>org.apache.maven.dist.tools:dist-tool-plugin:check-source-release</goal>
+            <goal>-X</goal>
+        </goals>
+    </action> 
+    <action>
+        <actionName>CUSTOM-checksite</actionName>
+        <displayName>check-site</displayName>
+        <goals>
+            
<goal>org.apache.maven.dist.tools:dist-tool-plugin:check-site</goal>
+            <goal>-X</goal>
+        </goals>
+    </action>
+</actions>

Modified: maven/sandbox/trunk/dist-tools/dist-tool-plugin/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/sandbox/trunk/dist-tools/dist-tool-plugin/pom.xml?rev=1487688&r1=1487687&r2=1487688&view=diff
==============================================================================
--- maven/sandbox/trunk/dist-tools/dist-tool-plugin/pom.xml (original)
+++ maven/sandbox/trunk/dist-tools/dist-tool-plugin/pom.xml Thu May 30 00:20:15 
2013
@@ -42,6 +42,12 @@
             <artifactId>jsoup</artifactId>
             <version>1.7.2</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-core</artifactId>
+            <version>3.0.4</version>
+            <type>jar</type>
+        </dependency>
     </dependencies>
     <build>
         <plugins>

Added: 
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=1487688&view=auto
==============================================================================
--- 
maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/AbstractDistCheckMojo.java
 (added)
+++ 
maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/AbstractDistCheckMojo.java
 Thu May 30 00:20:15 2013
@@ -0,0 +1,80 @@
+package org.apache.maven.dist.tools;
+
+/*
+ * 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 java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URL;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Parameter;
+
+/**
+ *
+ * @author skygo
+ */
+public abstract class AbstractDistCheckMojo extends AbstractMojo
+{
+
+    @Parameter( property = "repository.url", defaultValue = 
"http://repo1.maven.org/maven2/"; )
+    private String repoBaseUrl;
+    @Parameter( property = "database.url", defaultValue = "db/mavendb.csv" )
+    private String dbLocation;
+
+    abstract void checkArtifact( ConfigurationLineInfo request, String 
repoBase ) throws MojoExecutionException;
+
+    @Override
+    public void execute() throws MojoExecutionException, MojoFailureException
+    {
+        URL dbURL;
+        if ( dbLocation.equals( "db/mavendb.csv" ) )
+        {
+            dbURL = 
Thread.currentThread().getContextClassLoader().getResource( "db/mavendb.csv" );
+        }
+        else
+        {
+            throw new MojoFailureException( "Custom data not implemented " );
+        }
+
+
+        try (BufferedReader input = new BufferedReader( new InputStreamReader( 
dbURL.openStream() ) ))
+        {
+            String text;
+            while ( (text = input.readLine()) != null )
+            {
+                if ( text.startsWith( "##" ) )
+                {
+                    getLog().info( text );
+                }
+                else
+                {
+                    String[] artifactInfo = text.split( ";" );
+                    checkArtifact( new ConfigurationLineInfo( artifactInfo[0], 
artifactInfo[1], artifactInfo[2] ), repoBaseUrl );
+                }
+
+            }
+        }
+        catch ( IOException ex )
+        {
+            throw new MojoFailureException( ex.getMessage(), ex );
+        }
+    }
+}

Propchange: 
maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/AbstractDistCheckMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
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=1487688&view=auto
==============================================================================
--- 
maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/ConfigurationLineInfo.java
 (added)
+++ 
maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/ConfigurationLineInfo.java
 Thu May 30 00:20:15 2013
@@ -0,0 +1,83 @@
+package org.apache.maven.dist.tools;
+/*
+ * 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.
+ */
+
+/**
+ *
+ * @author skygo
+ */
+class ConfigurationLineInfo
+{
+
+    private final String groupId;
+    private final String artifactId;
+    private final String dist;
+    private static final String URLSEP = "/";
+
+    public ConfigurationLineInfo( String groupId, String artifactId, String 
dist )
+    {
+        this.groupId = groupId;
+        this.artifactId = artifactId;
+        this.dist = dist;
+    }
+
+    /**
+     * @return the groupId
+     */
+    public String getGroupId()
+    {
+        return groupId;
+    }
+
+    /**
+     * @return the artifactId
+     */
+    public String getArtifactId()
+    {
+        return artifactId;
+    }
+
+    /**
+     * @return the dist
+     */
+    public String getDist()
+    {
+        return dist;
+    }
+
+    private String getBaseURL( String repoBaseUrl, String folder )
+    {
+        return repoBaseUrl + groupId.replaceAll( "\\.", URLSEP ) + URLSEP + 
artifactId + URLSEP + folder;
+    }
+
+    String getMetadataFileURL( String repoBaseUrl )
+    {
+        return getBaseURL( repoBaseUrl, "maven-metadata.xml" );
+    }
+
+    String getVersionnedFolderURL( String repoBaseUrl, String version )
+    {
+        return getBaseURL( repoBaseUrl, version );
+    }
+
+    String getVersionnedPomFileURL( String repoBaseUrl, String version )
+    {
+        return getBaseURL( repoBaseUrl, version + URLSEP + artifactId + "-" + 
version + ".pom" );
+    }
+}

Propchange: 
maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/ConfigurationLineInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: 
maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/DistCheckSiteMojo.java
 (from r1487599, 
maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/DistMojo.java)
URL: 
http://svn.apache.org/viewvc/maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/DistCheckSiteMojo.java?p2=maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/DistCheckSiteMojo.java&p1=maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/DistMojo.java&r1=1487599&r2=1487688&rev=1487688&view=diff
==============================================================================
--- 
maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/DistMojo.java
 (original)
+++ 
maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/DistCheckSiteMojo.java
 Thu May 30 00:20:15 2013
@@ -31,94 +31,101 @@ import java.util.logging.Logger;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBException;
 import javax.xml.bind.Unmarshaller;
-import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.model.Model;
+import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.plugins.annotations.Mojo;
-import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 import org.jsoup.Jsoup;
 import org.jsoup.nodes.Document;
 import org.jsoup.nodes.Element;
-import org.jsoup.select.Elements;
 
-
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
 /**
  *
  * @author skygo
  */
-@Mojo( name = "check-source" )
-public class DistMojo extends AbstractMojo
+@Mojo( name = "check-site" )
+public class DistCheckSiteMojo extends AbstractDistCheckMojo
 {
 
-    // parameters for future usage
-    @Parameter( property = "repository.url", defaultValue = 
"http://repo1.maven.org/maven2/"; )
-    private String repoBaseUrl;
-    @Parameter( property = "database.url", defaultValue = "db/mavendb.csv" )
-    private String dbLocation;
-
-    // parameters for future usage
-    private enum CheckType
+    interface HTMLChecker
     {
 
-        SOURCE
+        /**
+         * name of the checker.
+         *
+         * @return
+         */
+        String getName();
+
+        /**
+         * true if checker find patter in document
+         *
+         * @param doc
+         * @param version
+         * @return
+         */
+        boolean isOk( Document doc, String version );
     }
+    private List<HTMLChecker> checker = new LinkedList<>();
 
-    private void checkRepos( String repourl, Request r, String version, 
CheckType ct ) throws IOException
+    private void checkSite( String repourl, ConfigurationLineInfo r, String 
version ) throws MojoExecutionException
     {
-        Document doc = Jsoup.connect( repourl ).get();
-        Elements links = doc.select( "a[href]" );
-        List<String> expectedFile = new LinkedList<>();
-        List<String> retrievedFile = new LinkedList<>();
-        switch ( ct )
+        StringBuilder message = new StringBuilder();
+        try (BufferedReader input = new BufferedReader( new InputStreamReader( 
new URL( repourl ).openStream() ) ))
         {
-            case SOURCE:
+            MavenXpp3Reader mavenreader = new MavenXpp3Reader();
+            Model m = mavenreader.read( input );
+            // need to have parent information and resolve properties 
+            // 
+            MavenProject project = new MavenProject( m );
+
+
+            Document doc = Jsoup.connect( project.getUrl() ).get();
+            message.append( "Site for " ).append( project.getArtifactId() 
).append( " at " ).append( project.getUrl() ).append( " seek for" ).append( 
project.getVersion() ).append( "    " );
+            for ( HTMLChecker c : checker )
             {
-                // 
http://maven.apache.org/developers/release/maven-project-release-procedure.html#Copy_the_source_release_to_the_Apache_Distribution_Area
-                // build source artifact name
-                expectedFile.add( r.artifactId + "-" + version + "-" + 
"source-release.zip" );
-                expectedFile.add( r.artifactId + "-" + version + "-" + 
"source-release.zip.asc" );
-                expectedFile.add( r.artifactId + "-" + version + "-" + 
"source-release.zip.md5" );
+                message.append( "[" ).append( c.getName() ).append( c.isOk( 
doc, version ) ).append( "]" );
             }
-            break;
-            default:
-                getLog().warn( "For future extensions" );
-        }
 
-        for ( Element e : links )
+
+            getLog().warn( message.toString() );
+
+        }
+        catch ( MalformedURLException ex )
         {
-            retrievedFile.add( e.attr( "href" ) );
+            throw new MojoExecutionException( ex.getMessage(), ex );
         }
-        expectedFile.removeAll( retrievedFile );
-        if ( !expectedFile.isEmpty() )
+        catch ( IOException ex )
         {
-            for ( String sourceItem : expectedFile )
-            {
-                getLog().error( "Missing:" + sourceItem + " in " + repourl );
-            }
+            throw new MojoExecutionException( ex.getMessage(), ex );
         }
+        catch ( XmlPullParserException ex )
+        {
+            Logger.getLogger( DistCheckSiteMojo.class.getName() ).log( 
Level.SEVERE, null, ex );
+        }
+
     }
 
-    private void checkArtifact( Request r, CheckType ct ) throws 
MojoExecutionException
+    @Override
+    void checkArtifact( ConfigurationLineInfo configLine, String repoBaseUrl ) 
throws MojoExecutionException
     {
-        try (BufferedReader input = new BufferedReader( new InputStreamReader( 
new URL( r.getMetadataUrl( repoBaseUrl ) ).openStream() ) ))
+        try (BufferedReader input = new BufferedReader( new InputStreamReader( 
new URL( configLine.getMetadataFileURL( repoBaseUrl ) ).openStream() ) ))
         {
             JAXBContext context = JAXBContext.newInstance( MavenMetadata.class 
);
             Unmarshaller unmarshaller = context.createUnmarshaller();
             MavenMetadata metadata = ( MavenMetadata ) unmarshaller.unmarshal( 
input );
 
-            getLog().info( "Checking for artifact : " + r.getGroupId() + ":" + 
r.getArtifactId() + ":" + metadata.versioning.latest );
+            getLog().info( "Checking for site for artifact : " + 
configLine.getGroupId() + ":" + configLine.getArtifactId() + ":" + 
metadata.versioning.latest );
             // revert sort versions (not handling alpha and complex vesion 
scheme but more usefull version are displayed left side
             Collections.sort( metadata.versioning.versions, 
Collections.reverseOrder() );
             getLog().warn( metadata.versioning.versions + " version(s) 
detected " + repoBaseUrl );
 
             // central
-            checkRepos( r.getVersionnedURL( repoBaseUrl, 
metadata.versioning.latest ), r, metadata.versioning.latest, ct );
-            //dist
-            checkRepos( r.getDist(), r, metadata.versioning.latest, ct );
+            checkSite( configLine.getVersionnedPomFileURL( repoBaseUrl, 
metadata.versioning.latest ), configLine, metadata.versioning.latest );
+
         }
         catch ( MalformedURLException ex )
         {
@@ -133,97 +140,51 @@ public class DistMojo extends AbstractMo
     @Override
     public void execute() throws MojoExecutionException, MojoFailureException
     {
-
-        URL dbURL;
-        if ( dbLocation.equals( "db/mavendb.csv" ) )
-        {
-            dbURL = 
Thread.currentThread().getContextClassLoader().getResource( "db/mavendb.csv" );
-        }
-        else
+        //add  html checker
+        checker.add( new HTMLChecker()
         {
-            throw new MojoFailureException( "Custom data not implemented " );
-        }
-
+            @Override
+            public String getName()
+            {
+                return "Stylus Skin:";
+            }
 
-        try (BufferedReader input = new BufferedReader( new InputStreamReader( 
dbURL.openStream() ) ))
-        {
-            String text;
-            while ( (text = input.readLine()) != null )
+            @Override
+            public boolean isOk( Document doc, String version )
             {
-                if ( text.startsWith( "##" ) )
+                Element links = doc.select( "div.xright" ).first();
+                if ( links != null )
                 {
-                    getLog().info( text );
+                    return links.text().contains( version );
                 }
                 else
                 {
-                    String[] artifactInfo = text.split( ";" );
-                    checkArtifact( new Request( artifactInfo[0], 
artifactInfo[1], artifactInfo[2] ), CheckType.SOURCE );
+                    return false;
                 }
-
             }
-        }
-        catch ( IOException ex )
-        {
-            Logger.getLogger( DistMojo.class.getName() ).log( Level.SEVERE, 
null, ex );
-        }
-
-
-
-
-    }
-
-    private static class Request
-    {
-
-        private final String groupId;
-        private final String artifactId;
-        private final String dist;
-        private static final String URLSEP = "/";
-
-        public Request( String groupId, String artifactId, String dist )
-        {
-            this.groupId = groupId;
-            this.artifactId = artifactId;
-            this.dist = dist;
-        }
-
-        /**
-         * @return the groupId
-         */
-        public String getGroupId()
-        {
-            return groupId;
-        }
-
-        /**
-         * @return the artifactId
-         */
-        public String getArtifactId()
+        } );
+        checker.add( new HTMLChecker()
         {
-            return artifactId;
-        }
-
-        /**
-         * @return the dist
-         */
-        public String getDist()
-        {
-            return dist;
-        }
-
-        private String getBaseURL( String repoBaseUrl, String folder )
-        {
-            return repoBaseUrl + groupId.replaceAll( "\\.", URLSEP ) + URLSEP 
+ artifactId + URLSEP + folder;
-        }
-
-        private String getMetadataUrl( String repoBaseUrl )
-        {
-            return getBaseURL( repoBaseUrl, "maven-metadata.xml" );
-        }
+            @Override
+            public String getName()
+            {
+                return "Fluido Skin:";
+            }
 
-        private String getVersionnedURL( String repoBaseUrl, String version )
-        {
-            return getBaseURL( repoBaseUrl, version );
-        }
+            @Override
+            public boolean isOk( Document doc, String version )
+            {
+                Element links = doc.select( "li#projectVersion" ).first();
+                if ( links != null )
+                {
+                    return links.text().contains( version );
+                }
+                else
+                {
+                    return false;
+                }
+            }
+        } );
+        super.execute(); 
     }
 }

Copied: 
maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/DistCheckSourceReleaseMojo.java
 (from r1487599, 
maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/DistMojo.java)
URL: 
http://svn.apache.org/viewvc/maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/DistCheckSourceReleaseMojo.java?p2=maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/DistCheckSourceReleaseMojo.java&p1=maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/DistMojo.java&r1=1487599&r2=1487688&rev=1487688&view=diff
==============================================================================
--- 
maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/DistMojo.java
 (original)
+++ 
maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/DistCheckSourceReleaseMojo.java
 Thu May 30 00:20:15 2013
@@ -26,67 +26,40 @@ import java.net.URL;
 import java.util.Collections;
 import java.util.LinkedList;
 import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBException;
 import javax.xml.bind.Unmarshaller;
-import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.plugins.annotations.Mojo;
-import org.apache.maven.plugins.annotations.Parameter;
 import org.jsoup.Jsoup;
 import org.jsoup.nodes.Document;
 import org.jsoup.nodes.Element;
 import org.jsoup.select.Elements;
 
-
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
 /**
  *
+ * Check presence of source-release.zip in dist repo and central repo
+ *
  * @author skygo
  */
-@Mojo( name = "check-source" )
-public class DistMojo extends AbstractMojo
+@Mojo( name = "check-source-release" )
+public class DistCheckSourceReleaseMojo extends AbstractDistCheckMojo
 {
+//Artifact metadata retrieval done y hands.
 
-    // parameters for future usage
-    @Parameter( property = "repository.url", defaultValue = 
"http://repo1.maven.org/maven2/"; )
-    private String repoBaseUrl;
-    @Parameter( property = "database.url", defaultValue = "db/mavendb.csv" )
-    private String dbLocation;
-
-    // parameters for future usage
-    private enum CheckType
-    {
-
-        SOURCE
-    }
-
-    private void checkRepos( String repourl, Request r, String version, 
CheckType ct ) throws IOException
+    private void checkRepos( String repourl, ConfigurationLineInfo r, String 
version ) throws IOException
     {
         Document doc = Jsoup.connect( repourl ).get();
         Elements links = doc.select( "a[href]" );
         List<String> expectedFile = new LinkedList<>();
         List<String> retrievedFile = new LinkedList<>();
-        switch ( ct )
-        {
-            case SOURCE:
-            {
-                // 
http://maven.apache.org/developers/release/maven-project-release-procedure.html#Copy_the_source_release_to_the_Apache_Distribution_Area
-                // build source artifact name
-                expectedFile.add( r.artifactId + "-" + version + "-" + 
"source-release.zip" );
-                expectedFile.add( r.artifactId + "-" + version + "-" + 
"source-release.zip.asc" );
-                expectedFile.add( r.artifactId + "-" + version + "-" + 
"source-release.zip.md5" );
-            }
-            break;
-            default:
-                getLog().warn( "For future extensions" );
-        }
+        // 
http://maven.apache.org/developers/release/maven-project-release-procedure.html#Copy_the_source_release_to_the_Apache_Distribution_Area
+        // build source artifact name
+        expectedFile.add( r.getArtifactId() + "-" + version + "-" + 
"source-release.zip" );
+        expectedFile.add( r.getArtifactId() + "-" + version + "-" + 
"source-release.zip.asc" );
+        expectedFile.add( r.getArtifactId() + "-" + version + "-" + 
"source-release.zip.md5" );
+
+
 
         for ( Element e : links )
         {
@@ -102,9 +75,10 @@ public class DistMojo extends AbstractMo
         }
     }
 
-    private void checkArtifact( Request r, CheckType ct ) throws 
MojoExecutionException
+    @Override
+    void checkArtifact( ConfigurationLineInfo r, String repoBaseUrl ) throws 
MojoExecutionException
     {
-        try (BufferedReader input = new BufferedReader( new InputStreamReader( 
new URL( r.getMetadataUrl( repoBaseUrl ) ).openStream() ) ))
+        try (BufferedReader input = new BufferedReader( new InputStreamReader( 
new URL( r.getMetadataFileURL( repoBaseUrl ) ).openStream() ) ))
         {
             JAXBContext context = JAXBContext.newInstance( MavenMetadata.class 
);
             Unmarshaller unmarshaller = context.createUnmarshaller();
@@ -116,9 +90,9 @@ public class DistMojo extends AbstractMo
             getLog().warn( metadata.versioning.versions + " version(s) 
detected " + repoBaseUrl );
 
             // central
-            checkRepos( r.getVersionnedURL( repoBaseUrl, 
metadata.versioning.latest ), r, metadata.versioning.latest, ct );
+            checkRepos( r.getVersionnedFolderURL( repoBaseUrl, 
metadata.versioning.latest ), r, metadata.versioning.latest );
             //dist
-            checkRepos( r.getDist(), r, metadata.versioning.latest, ct );
+            checkRepos( r.getDist(), r, metadata.versioning.latest );
         }
         catch ( MalformedURLException ex )
         {
@@ -129,101 +103,4 @@ public class DistMojo extends AbstractMo
             throw new MojoExecutionException( ex.getMessage(), ex );
         }
     }
-
-    @Override
-    public void execute() throws MojoExecutionException, MojoFailureException
-    {
-
-        URL dbURL;
-        if ( dbLocation.equals( "db/mavendb.csv" ) )
-        {
-            dbURL = 
Thread.currentThread().getContextClassLoader().getResource( "db/mavendb.csv" );
-        }
-        else
-        {
-            throw new MojoFailureException( "Custom data not implemented " );
-        }
-
-
-        try (BufferedReader input = new BufferedReader( new InputStreamReader( 
dbURL.openStream() ) ))
-        {
-            String text;
-            while ( (text = input.readLine()) != null )
-            {
-                if ( text.startsWith( "##" ) )
-                {
-                    getLog().info( text );
-                }
-                else
-                {
-                    String[] artifactInfo = text.split( ";" );
-                    checkArtifact( new Request( artifactInfo[0], 
artifactInfo[1], artifactInfo[2] ), CheckType.SOURCE );
-                }
-
-            }
-        }
-        catch ( IOException ex )
-        {
-            Logger.getLogger( DistMojo.class.getName() ).log( Level.SEVERE, 
null, ex );
-        }
-
-
-
-
-    }
-
-    private static class Request
-    {
-
-        private final String groupId;
-        private final String artifactId;
-        private final String dist;
-        private static final String URLSEP = "/";
-
-        public Request( String groupId, String artifactId, String dist )
-        {
-            this.groupId = groupId;
-            this.artifactId = artifactId;
-            this.dist = dist;
-        }
-
-        /**
-         * @return the groupId
-         */
-        public String getGroupId()
-        {
-            return groupId;
-        }
-
-        /**
-         * @return the artifactId
-         */
-        public String getArtifactId()
-        {
-            return artifactId;
-        }
-
-        /**
-         * @return the dist
-         */
-        public String getDist()
-        {
-            return dist;
-        }
-
-        private String getBaseURL( String repoBaseUrl, String folder )
-        {
-            return repoBaseUrl + groupId.replaceAll( "\\.", URLSEP ) + URLSEP 
+ artifactId + URLSEP + folder;
-        }
-
-        private String getMetadataUrl( String repoBaseUrl )
-        {
-            return getBaseURL( repoBaseUrl, "maven-metadata.xml" );
-        }
-
-        private String getVersionnedURL( String repoBaseUrl, String version )
-        {
-            return getBaseURL( repoBaseUrl, version );
-        }
-    }
 }

Modified: maven/sandbox/trunk/dist-tools/dist-tool-plugin/test.sh
URL: 
http://svn.apache.org/viewvc/maven/sandbox/trunk/dist-tools/dist-tool-plugin/test.sh?rev=1487688&r1=1487687&r2=1487688&view=diff
==============================================================================
--- maven/sandbox/trunk/dist-tools/dist-tool-plugin/test.sh (original)
+++ maven/sandbox/trunk/dist-tools/dist-tool-plugin/test.sh Thu May 30 00:20:15 
2013
@@ -1 +1,3 @@
-mvn org.apache.maven.dist.tools:dist-tool-plugin:check-source
\ No newline at end of file
+mvn clean install
+mvn org.apache.maven.dist.tools:dist-tool-plugin:check-site
+mvn org.apache.maven.dist.tools:dist-tool-plugin:check-site


Reply via email to