You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2013/11/01 18:32:37 UTC
svn commit: r1537994 -
/maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/DistCheckIndexPageMojo.java
Author: hboutemy
Date: Fri Nov 1 17:32:37 2013
New Revision: 1537994
URL: http://svn.apache.org/r1537994
Log:
cache index page instead of fetching content at each component
Modified:
maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/DistCheckIndexPageMojo.java
Modified: maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/DistCheckIndexPageMojo.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/DistCheckIndexPageMojo.java?rev=1537994&r1=1537993&r2=1537994&view=diff
==============================================================================
--- maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/DistCheckIndexPageMojo.java (original)
+++ maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/DistCheckIndexPageMojo.java Fri Nov 1 17:32:37 2013
@@ -56,19 +56,19 @@ public class DistCheckIndexPageMojo
// url title version date
aMap.put( "IP1", new Object[]
{
- "http://maven.apache.org/plugins/", "Plugins", 2, 3
+ "http://maven.apache.org/plugins/", "Plugins", 2, 3, null
} );
aMap.put( "IP2", new Object[]
{
- "http://maven.apache.org/shared/", "Shared", 1, 2
+ "http://maven.apache.org/shared/", "Shared", 1, 2, null
} );
aMap.put( "IP3", new Object[]
{
- "http://maven.apache.org/skins/", "Skins", 1, null
+ "http://maven.apache.org/skins/", "Skins", 1, null, null
} );
aMap.put( "IP4", new Object[]
{
- "http://maven.apache.org/pom/", "Poms", 1, 2
+ "http://maven.apache.org/pom/", "Poms", 1, 2, null
} );
INDEXES_REF = Collections.unmodifiableMap( aMap );
}
@@ -264,42 +264,51 @@ public class DistCheckIndexPageMojo
private void updateIndexPageInfo( ConfigurationLineInfo cli, CheckIndexPageResult r, Object[] inf )
throws IOException
{
- try
+ Document doc = (Document) inf[4];
+ if ( doc == null )
{
- Document doc = Jsoup.connect( (String) inf[0] ).get();
- Elements a = doc.select( "tr > td > a[href]:not(.externalLink)" );
- for ( Element e : a )
- {
- // skins do not have release date
- String art = e.attr( "href" );
- String id = cli.getArtifactId();
- // UGLY
- if ( cli.getArtifactId().equals( "maven-parent" ) )
- {
- id = "maven/";
- }
- if ( cli.getArtifactId().equals( "maven-skins" ) )
- {
- id = "skins/";
- }
- if ( cli.getArtifactId().equals( "apache" ) )
- {
- id = "asf/";
- }
-
- if ( art.contains( id ) )
- {
- r.setIndexVersion( e.parent().parent().child( ( Integer ) inf[2] ).ownText() );
- if ( inf[3] != null )
- {
- r.setIndexDate( e.parent().parent().child( ( Integer ) inf[3] ).ownText() );
- }
- }
+ // document not yet downloaded: download and cache
+ String url = (String) inf[0];
+ try
+ {
+ doc = Jsoup.connect( url ).get();
+ }
+ catch ( IOException ioe )
+ {
+ throw new IOException( "IOException while reading " + url, ioe );
}
+ inf[4] = doc;
}
- catch ( IOException ioe )
+
+ Elements a = doc.select( "tr > td > a[href]:not(.externalLink)" );
+
+ for ( Element e : a )
{
- throw new IOException( "IOException while reading " + (String) inf[0] , ioe );
+ // skins do not have release date
+ String art = e.attr( "href" );
+ String id = cli.getArtifactId();
+ // UGLY
+ if ( cli.getArtifactId().equals( "maven-parent" ) )
+ {
+ id = "maven/";
+ }
+ if ( cli.getArtifactId().equals( "maven-skins" ) )
+ {
+ id = "skins/";
+ }
+ if ( cli.getArtifactId().equals( "apache" ) )
+ {
+ id = "asf/";
+ }
+
+ if ( art.contains( id ) )
+ {
+ r.setIndexVersion( e.parent().parent().child( ( Integer ) inf[2] ).ownText() );
+ if ( inf[3] != null )
+ {
+ r.setIndexDate( e.parent().parent().child( ( Integer ) inf[3] ).ownText() );
+ }
+ }
}
}