Login | Register
My pages Projects Community openCollabNet

Discussions > commits > svn commit: r168 - branches/2.X: . org.tigris.pomstrap.cli/src/main/java/org/tigris/pomstrap/cli org.tigris.pomstrap.core org.tigris.pomstrap.core/src/main/java/org/tigris/pomstrap/core

pomstrap
Discussion topic

Back to topic list

svn commit: r168 - branches/2.X: . org.tigris.pomstrap.cli/src/main/java/org/tigris/pomstrap/cli org.tigris.pomstrap.core org.tigris.pomstrap.core/src/main/java/org/tigris/pomstrap/core

Reply

Author evangelista
Full name Alessandro Evangelista
Date 2009-01-29 13:20:43 PST
Message Author: evangelista
Date: 2009-01-29 13:20:42-0800
New Revision: 168

Modified:
   branches/2.X/org.tig​ris.pomstrap.cli/src​/main/java/org/tigri​s/pomstrap/cli/Appli​cation.java
   branches/2.X/org.tig​ris.pomstrap.core/po​m.xml
   branches/2.X/org.tig​ris.pomstrap.core/sr​c/main/java/org/tigr​is/pomstrap/core/Boo​tstrap.java
   branches/2.X/org.tig​ris.pomstrap.core/sr​c/main/java/org/tigr​is/pomstrap/core/Dep​endency.java
   branches/2.X/org.tig​ris.pomstrap.core/sr​c/main/java/org/tigr​is/pomstrap/core/Dep​endencyClassloader.j​ava
   branches/2.X/org.tig​ris.pomstrap.core/sr​c/main/java/org/tigr​is/pomstrap/core/Mav​enRepositoryUtils.ja​va
   branches/2.X/pom.xml

Log:
Added snapshot policy.

Modified: branches/2.X/org.tig​ris.pomstrap.cli/src​/main/java/org/tigri​s/pomstrap/cli/Appli​cation.java
Url: http://pomstrap.tigr​is.org/source/browse​/pomstrap/branches/2​.X/org.tigris.pomstr​ap.cli/src/main/java​/org/tigris/pomstrap​/cli/Application.jav​a?view=diff&path​rev=168&r1=167​&r2=168
====================​====================​====================​==================
--- branches/2.X/org.tig​ris.pomstrap.cli/src​/main/java/org/tigri​s/pomstrap/cli/Appli​cation.java (original)
+++ branches/2.X/org.tig​ris.pomstrap.cli/src​/main/java/org/tigri​s/pomstrap/cli/Appli​cation.java 2009-01-29 13:20:42-0800
@@ -1,4 +1,3 @@
-
 package org.tigris.pomstrap.cli;
 
 import java.util.ArrayList;
@@ -11,7 +10,6 @@
 import org.tigris.pomstrap.​core.Bootstrap;
 
 /**
- *
  * Sample
  *
  * <pre>
@@ -27,52 +25,59 @@
 @ShellApplication( header = Application.header, footer = Application.footer, syntax = "[OPTION]... groupId:artifactId[:​type[:classifier]]:v​ersion", contact = "http://pomstrap.tigr​is.org/servlets/Proj​ectIssues" )
 public class Application
 {
- final static String header = "Executes a java application deployed to a maven repository.";
+ final static String header = "Executes a java application deployed to a maven repository.";
 
- final static String footer = "If no remote repository URL is given, the local repository is used.";
+ final static String footer = "If no remote repository URL is given, the local repository is used.";
 
- Bootstrap.Context bootContext = new Bootstrap.Context();
+ Bootstrap.Context bootContext = new Bootstrap.Context();
 
- // @Option( name = "a", longName = "artifact", description =
- // "artifact in the format groupId:artifactId[:​type[:classifier]]:v​ersion", argument = "ARTIFACT", required = true )
- // public String artifact;
-
- @Option( name = "r", longName = "repository", description = "remote repository URL", argument = "URL" )
- public void setRepositoryUrl( String repositoryUrl )
- {
- bootContext.setRepositoryUrl( repositoryUrl );
- }
-
- @Option( name = "u", longName = "username", description = "repository username", argument = "USERNAME" )
- public void setRepositoryUsername( String repositoryUsername )
- {
- bootContext.setRepos​itoryUsername( repositoryUsername );
- }
-
- @Option( name = "p", longName = "password", description = "repository password", argument = "PASSWORD" )
- public void setRepositoryPassword( String repositoryPassword )
- {
- bootContext.setRepos​itoryPassword( repositoryPassword );
- }
-
- public void run( String[] args ) throws Exception
- {
- if ( args.length == 0 )
- {
- throw new MissingArgumentException( "Missing required argument: groupId:artifactId[:​type[:classifier]]:v​ersion" );
- }
-
- List< String > argList = new ArrayList< String >();
- for ( String a : args )
- argList.add( a );
- String artifact = argList.get( 0 );
- argList.remove( 0 );
- new Bootstrap( bootContext ).run( artifact, null, argList.toArray( new String[]
- {} ) );
- }
-
- public static void main( String[] args )
- {
- new ShellExecutor( new Application() ).execute( args );
- }
+ // @Option( name = "a", longName = "artifact", description =
+ // "artifact in the format groupId:artifactId[:​type[:classifier]]:v​ersion", argument = "ARTIFACT", required = true )
+ // public String artifact;
+
+ @Option( name = "r", longName = "repository", description = "remote repository URL", argument = "URL" )
+ public void setRepositoryUrl( String repositoryUrl )
+ {
+ bootContext.setRepositoryUrl( repositoryUrl );
+ }
+
+ @Option( name = "u", longName = "username", description = "repository username", argument = "USERNAME" )
+ public void setRepositoryUsername( String repositoryUsername )
+ {
+ bootContext.setRepos​itoryUsername( repositoryUsername );
+ }
+
+ @Option( name = "p", longName = "password", description = "repository password", argument = "PASSWORD" )
+ public void setRepositoryPassword( String repositoryPassword )
+ {
+ bootContext.setRepos​itoryPassword( repositoryPassword );
+ }
+
+ @Option( name = "g", longName = "custom-group", description = "comma seperated list of space separated artifact families to group in the same class loader", argument = "CUSTOMGROUPS" )
+ public void setCustomGroup( String customGroup )
+ {
+ bootContext.setCustomGroup( customGroup );
+ }
+
+ public void run( String[] args )
+ throws Exception
+ {
+ if ( args.length == 0 )
+ {
+ throw new MissingArgumentException(
+ "Missing required argument: groupId:artifactId[:​type[:classifier]]:v​ersion" );
+ }
+
+ List<String> argList = new ArrayList<String>();
+ for ( String a : args )
+ argList.add( a );
+ String artifact = argList.get( 0 );
+ argList.remove( 0 );
+ new Bootstrap( bootContext ).run( artifact, null, argList.toArray( new String[] {} ) );
+ }
+
+ public static void main( String[] args )
+ {
+ new ShellExecutor( new Application() ).execute( args );
+ }
 }

Modified: branches/2.X/org.tig​ris.pomstrap.core/po​m.xml
Url: http://pomstrap.tigr​is.org/source/browse​/pomstrap/branches/2​.X/org.tigris.pomstr​ap.core/pom.xml?view​=diff&pathrev=16​8&r1=167&r2=​168
====================​====================​====================​==================
--- branches/2.X/org.tig​ris.pomstrap.core/po​m.xml (original)
+++ branches/2.X/org.tig​ris.pomstrap.core/po​m.xml 2009-01-29 13:20:42-0800
@@ -2,7 +2,7 @@
     xsi:schemaLocation="http://maven.apache.​org/POM/4.0.0 http://maven.apache.​org/maven-v4_0_0.xsd​">
     <modelVersion>​4.0.0</modelVersi​on>
     <artifactId>or​g.tigris.pomstrap.co​re</artifactId​>
- <name>org.tigr​is.pomstrap.core<​/name>
+ <name>org.tigr​is.pomstrap.core<​/name>
     <parent>
         <groupId>org.t​igris.pomstrap</g​roupId>
         <artifactId>or​g.tigris.pomstrap.ja​r</artifactId>​
@@ -22,6 +22,11 @@
     -->
     <dependencies>
         <dependency>
+ <groupId>org.a​pache.httpcomponents​</groupId>
+ <artifactId>ht​tpclient</artifac​tId>
+ <version>4.0-b​eta2</version>​
+ </dependency>
+ <dependency>
             <groupId>junit​</groupId>
             <artifactId>ju​nit</artifactId​>
             <version>3.8.1​</version>
@@ -46,5 +51,5 @@
                 </configuration>
             </plugin>
         </plugins>
- </build>
+ </build>
 </project>
\ No newline at end of file

Modified: branches/2.X/org.tig​ris.pomstrap.core/sr​c/main/java/org/tigr​is/pomstrap/core/Boo​tstrap.java
Url: http://pomstrap.tigr​is.org/source/browse​/pomstrap/branches/2​.X/org.tigris.pomstr​ap.core/src/main/jav​a/org/tigris/pomstra​p/core/Bootstrap.jav​a?view=diff&path​rev=168&r1=167​&r2=168
====================​====================​====================​==================
--- branches/2.X/org.tig​ris.pomstrap.core/sr​c/main/java/org/tigr​is/pomstrap/core/Boo​tstrap.java (original)
+++ branches/2.X/org.tig​ris.pomstrap.core/sr​c/main/java/org/tigr​is/pomstrap/core/Boo​tstrap.java 2009-01-29 13:20:42-0800
@@ -88,9 +88,14 @@
 
     ClassLoader parentClassLoader;
 
+ File localRepository;
+
+ // Daily update is the default policy
+ long snapshotUpdatePeriod = 3600 * 1000;
+
     Context ctx;
-
- // TODO make dependency class constructor protected and add a here reference to the root dependency
+
+ // TODO make dependency class constructor protected and add a here reference to the root dependency
     // Dependency rootDependency;
 
     /**
@@ -114,6 +119,9 @@
         // Comma separated list of groupId:artifactId not to load
         String neverLoad;
 
+ // Path to local repository where artifacts are downloaded and cached
+ String localRepository;
+
         // Url to Maven2 repository
         String repositoryUrl;
 
@@ -125,6 +133,19 @@
 
         String classFileTransformers;
 
+ // One of always, never, daily, interval:MINUTES
+ String snapshotPolicy;
+
+ public String getSnapshotPolicy()
+ {
+ return snapshotPolicy;
+ }
+
+ public void setSnapshotPolicy( String snapshotPolicy )
+ {
+ this.snapshotPolicy = snapshotPolicy;
+ }
+
         public String getClassFileTransformers()
         {
             return classFileTransformers;
@@ -215,6 +236,16 @@
             this.repositoryPassword = repositoryPassword;
         }
 
+ public String getLocalRepository()
+ {
+ return localRepository;
+ }
+
+ public void setLocalRepository( String localRepository )
+ {
+ this.localRepository = localRepository;
+ }
+
     }
 
     public class SimpleAuthenticator
@@ -320,6 +351,24 @@
             }
         }
 
+ //
+ // Set the snapshot update period
+ //
+ // see http://docs.codehaus​.org/display/MAVEN/R​epository+-+SNAPSHOT​+Handling
+ if ( null != ctx.getSnapshotPolicy() )
+ {
+ if ( "always".equals( ctx.getSnapshotPolicy() ) )
+ snapshotUpdatePeriod = 0;
+ else if ( "never".equals( ctx.getSnapshotPolicy() ) )
+ snapshotUpdatePeriod = Long.MAX_VALUE;
+ else if ( "daily".equals( ctx.getSnapshotPolicy() ) )
+ snapshotUpdatePeriod = 3600 * 1000;
+ else if ( ctx.getSnapshotPolic​y().startsWith( "interval:" ) )
+ {
+ String minutesString = ctx.getSnapshotPolic​y().substring( "interval:".length() );
+ snapshotUpdatePeriod = Long.parseLong( minutesString ) * 60 * 1000;
+ }
+ }
     }
 
     /**
@@ -635,10 +684,23 @@
 
             method.invoke( o, methodArgs.toArray() );
         }
+ catch ( Error t )
+ {
+ // TODO better handling?
+ t.printStackTrace();
+ throw t;
+ }
+ catch ( Exception e )
+ {
+ // TODO better handling?
+ e.printStackTrace();
+ throw e;
+ }
         finally
         {
             Thread.currentThread​().setContextClassLo​ader( lastClassLoader );
         }
+
     }
 
     /**
@@ -793,6 +855,16 @@
 
     }
 
+ public long getSnapshotUpdatePeriod()
+ {
+ return snapshotUpdatePeriod;
+ }
+
+ public void setSnapshotUpdatePeriod( long snapshotUpdatePeriod )
+ {
+ this.snapshotUpdatePeriod = snapshotUpdatePeriod;
+ }
+
     public String getRepository()
     {
         return ctx.getRepositoryUrl();
@@ -831,4 +903,20 @@
         this.parentClassLoader = parentClassLoader;
     }
 
+ protected File getLocalRepositoryDirectory()
+ {
+ if ( null == localRepository )
+ {
+ String path = ctx.getLocalRepository();
+ if ( null == path )
+ {
+ path = System.getProperty( "java.io.tmpdir" ) + "/pomstrap/repository";
+ }
+ localRepository = new File( path );
+ if ( !localRepository.exists() )
+ localRepository.mkdirs();
+ }
+ return localRepository;
+ }
+
 }

Modified: branches/2.X/org.tig​ris.pomstrap.core/sr​c/main/java/org/tigr​is/pomstrap/core/Dep​endency.java
Url: http://pomstrap.tigr​is.org/source/browse​/pomstrap/branches/2​.X/org.tigris.pomstr​ap.core/src/main/jav​a/org/tigris/pomstra​p/core/Dependency.ja​va?view=diff&pat​hrev=168&r1=167​&r2=168
====================​====================​====================​==================
--- branches/2.X/org.tig​ris.pomstrap.core/sr​c/main/java/org/tigr​is/pomstrap/core/Dep​endency.java (original)
+++ branches/2.X/org.tig​ris.pomstrap.core/sr​c/main/java/org/tigr​is/pomstrap/core/Dep​endency.java 2009-01-29 13:20:42-0800
@@ -8,7 +8,11 @@
 
 package org.tigris.pomstrap.core;
 
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
 import java.io.InputStream;
+import java.io.OutputStream;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.ArrayList;
@@ -20,6 +24,15 @@
 import javax.xml.parsers.Do​cumentBuilder;
 import javax.xml.parsers.Do​cumentBuilderFactory​;
 
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.StatusLine;
+import org.apache.http.clie​nt.ClientProtocolExc​eption;
+import org.apache.http.clie​nt.HttpClient;
+import org.apache.http.clie​nt.HttpResponseExcep​tion;
+import org.apache.http.clie​nt.ResponseHandler;
+import org.apache.http.clie​nt.methods.HttpGet;
+import org.apache.http.impl​.client.DefaultHttpC​lient;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -519,7 +532,8 @@
     }
 
     /**
- * Get the artifact URL for this dependency. The artifact type corresponds to the pom type: jar, war, etc.
+ * Get the artifact URL for this dependency. The artifact type corresponds to the pom type: jar, war, etc. We have
+ * three alternatives here: direct HTTP access, direct file system access, cached on file system HTTP.
      *
      * @return the artifact URL
      * @throws MalformedURLException
@@ -527,12 +541,103 @@
     public URL getArtifactUrl()
         throws MalformedURLException
     {
- URL repositoryUrl =
- MavenRepositoryUtils​.getFolderURL( bootstrap.getRepository(), getGroupId(), getArtifactId(), getVersion() );
+ URL repositoryUrl = MavenRepositoryUtils​.getRepositoryUrl( bootstrap.getRepository() );
+
+ String folderPath = MavenRepositoryUtils​.getFolderPath( getGroupId(), getArtifactId(), getVersion() );
         String artifactName =
- getArtifactId() + '-' + getVersion() + ( null != getClassifier() ? '-' + getClassifier() : "" ) + "."
- + getType();
- return new URL( repositoryUrl.toString() + artifactName );
+ MavenRepositoryUtils​.getArtifactName( getArtifactId(), getVersion(), getClassifier(), getType() );
+
+ URL artifactUrl = new URL( repositoryUrl.toString() + folderPath + artifactName );
+
+ String protocol = repositoryUrl.getProtocol();
+ boolean caching = true;
+ if ( !"file".equals( protocol ) && caching )
+ {
+ artifactUrl = toLocalCachedUrl( repositoryUrl, folderPath, artifactName );
+ }
+
+ return artifactUrl;
+ }
+
+ public static class InputStreamResponseHandler
+ implements ResponseHandler<Void>
+ {
+ OutputStream outputStream;
+
+ InputStreamResponseHandler( OutputStream outputStream )
+ {
+ this.outputStream = outputStream;
+ }
+
+ @Override
+ public Void handleResponse( HttpResponse response )
+ throws ClientProtocolException, IOException
+ {
+ StatusLine statusLine = response.getStatusLine();
+ if ( statusLine.getStatusCode() >= 300 )
+ {
+ throw new HttpResponseException( statusLine.getStatusCode(), statusLine.getReasonPhrase() );
+ }
+
+ HttpEntity entity = response.getEntity();
+
+ DependencyClassloader.copy( entity.getContent(), outputStream );
+ return null;
+ }
+ }
+
+ // HttpResponse ResponseHandler
+ protected URL toLocalCachedUrl( URL repositoryUrl, String folderPath, String artifactName )
+ throws MalformedURLException
+ {
+ HttpClient httpclient = new DefaultHttpClient();
+
+ // TODO make it configurable
+ File cacheDirectory = bootstrap.getLocalRe​positoryDirectory();​
+ File cachedArtifactFolder = new File( cacheDirectory, folderPath );
+ File cachedArtifact = new File( cachedArtifactFolder, artifactName );
+
+ if ( !cachedArtifact.exists() || cachedArtifact.getNa​me().contains( "SNAPSHOT" )
+ && ( System.currentTimeMillis() - cachedArtifact.lastModified() ) > bootstrap.getSnapsho​tUpdatePeriod() )
+ {
+
+ URL remoteUrl = new URL( repositoryUrl.toString() + folderPath + artifactName );
+ HttpGet httpget = new HttpGet( remoteUrl.toString() );
+
+ File tmpCachedArtifact = new File( cachedArtifact.getAb​soluteFile() + "." + System.currentTimeMillis() );
+ try
+ {
+ log.debug( "Downloading from " + remoteUrl + " to " + tmpCachedArtifact );
+ cachedArtifactFolder.mkdirs();
+ FileOutputStream fos = new FileOutputStream( tmpCachedArtifact );
+
+ // String content = httpclient.execute( httpget, new BasicResponseHandler() );
+ // httpclient.execute( httpget, new InputStreamResponseHandler() ).writeTo( fos );
+ // DependencyClassloader.copy( httpclient.execute( httpget, new InputStreamResponseHandler()
+ // ).getContent(),
+ // fos );
+ httpclient.execute( httpget, new InputStreamResponseHandler( fos ) );
+ fos.close();
+
+ if ( cachedArtifact.exists() )
+ {
+ log.debug( "Deleting " + cachedArtifact );
+ cachedArtifact.delete();
+ }
+ log.debug( "Renaming " + tmpCachedArtifact );
+ tmpCachedArtifact.renameTo( cachedArtifact );
+ }
+ catch ( ClientProtocolException e )
+ {
+ log.error( "Error downloading " + cachedArtifact, e );
+ }
+ catch ( IOException e )
+ {
+ log.error( "Error downloading " + cachedArtifact, e );
+ }
+ }
+
+ return cachedArtifact.toURL();
     }
 
     /**
@@ -558,7 +663,9 @@
         }
         else
         {
- return null;
+ // TODO what to do here?
+ log.error( "Unknown artifact type " + getType() + " " + this );
+ throw new RuntimeException( "Unknown artifact type " + getType() );
         }
     }
 

Modified: branches/2.X/org.tig​ris.pomstrap.core/sr​c/main/java/org/tigr​is/pomstrap/core/Dep​endencyClassloader.j​ava
Url: http://pomstrap.tigr​is.org/source/browse​/pomstrap/branches/2​.X/org.tigris.pomstr​ap.core/src/main/jav​a/org/tigris/pomstra​p/core/DependencyCla​ssloader.java?view=d​iff&pathrev=168​&r1=167&r2=16​8
====================​====================​====================​==================
--- branches/2.X/org.tig​ris.pomstrap.core/sr​c/main/java/org/tigr​is/pomstrap/core/Dep​endencyClassloader.j​ava (original)
+++ branches/2.X/org.tig​ris.pomstrap.core/sr​c/main/java/org/tigr​is/pomstrap/core/Dep​endencyClassloader.j​ava 2009-01-29 13:20:42-0800
@@ -226,24 +226,7 @@
 
     public URL findResource( String name, List<DependencyCl​assloader> passedToList )
     {
- URL url = null;
- if ( name.startsWith( "m2:" ) )
- {
- try
- {
- url = MavenRepositoryUtils​.getResourceURL( bootstrap.getRepository(), name );
- }
- catch ( MalformedURLException e )
- {
- // TODO
- e.printStackTrace();
- }
- }
- else
- {
- // ##
- url = super.findResource( name );
- }
+ URL url = super.findResource( name );
 
         if ( url == null )
         {

Modified: branches/2.X/org.tig​ris.pomstrap.core/sr​c/main/java/org/tigr​is/pomstrap/core/Mav​enRepositoryUtils.ja​va
Url: http://pomstrap.tigr​is.org/source/browse​/pomstrap/branches/2​.X/org.tigris.pomstr​ap.core/src/main/jav​a/org/tigris/pomstra​p/core/MavenReposito​ryUtils.java?view=di​ff&pathrev=168​&r1=167&r2=168​
====================​====================​====================​==================
--- branches/2.X/org.tig​ris.pomstrap.core/sr​c/main/java/org/tigr​is/pomstrap/core/Mav​enRepositoryUtils.ja​va (original)
+++ branches/2.X/org.tig​ris.pomstrap.core/sr​c/main/java/org/tigr​is/pomstrap/core/Mav​enRepositoryUtils.ja​va 2009-01-29 13:20:42-0800
@@ -17,6 +17,7 @@
      * $user.home/.m2/repo​sitory/groupId/artif​actId/version
      * @throws MalformedURLException
      */
+ @Deprecated
     public static URL getFolderURL( String repository, String groupId, String artifactId, String version )
         throws MalformedURLException
     {
@@ -49,50 +50,74 @@
     }
 
     /**
- * Find the appropriate folder URL of this dependency
+ * Find the appropriate repository URL
      *
      * @return the URL of the repository folder of this dependency (by defaut
- * $user.home/.m2/repo​sitory/groupId/artif​actId/version/artifa​ctId-version[-classi​fier].extensionType
+ * $user.home/.m2/repo​sitory/groupId/artif​actId/version
      * @throws MalformedURLException
      */
- public static URL getResourceURL( String repository, String groupId, String artifactId, String version,
- String classifier, String extensionType )
+ public static URL getRepositoryUrl( String repository )
         throws MalformedURLException
     {
- URL url = getFolderURL( repository, groupId, artifactId, version );
- if ( classifier == null || extensionType.equals( "pom" ) )
+ URL repositoryUrl;
+ if ( repository == null )
         {
- url = new URL( url.toString() + artifactId + '-' + version + "." + extensionType );
+ File f = new File( System.getProperty( "user.home" ), ".m2" );
+ f = new File( f, "repository" );
+ if ( !f.exists() )
+ log.debug( f.toString() + " not found" );
+ repositoryUrl = f.toURL();
         }
         else
         {
- url = new URL( url.toString() + artifactId + '-' + version + '-' + classifier + '.' + extensionType );
+ String repo = new String( repository );
+ if ( !repo.endsWith( "/" ) )
+ {
+ repo += "/";
+ }
+ repositoryUrl = new URL( repo );
         }
- return url;
+
+ return repositoryUrl;
+ }
+
+ public static String getFolderPath( String groupId, String artifactId, String version )
+ {
+ String folderPath = groupId.replace( '.', '/' ) + '/';
+ folderPath += artifactId + '/';
+ folderPath += version + '/';
+
+ return folderPath;
+ }
+
+ public static String getArtifactName( String artifactId, String version, String classifier, String extensionType )
+ throws MalformedURLException
+ {
+ String classifierTag = ( classifier == null || extensionType.equals( "pom" ) ) ? "" : "-" + classifier;
+ return artifactId + '-' + version + classifierTag + '.' + extensionType;
     }
 
     /**
- * Get url of maven resource based on resource string such as :
- * /m2:groupId:artifact​Id:version[:classifi​er]:extensionType
+ * Find the appropriate folder URL of this dependency
      *
- * @return the POM URL
+ * @return the URL of the repository folder of this dependency (by defaut
+ * $user.home/.m2/repo​sitory/groupId/artif​actId/version/artifa​ctId-version[-classi​fier].extensionType
      * @throws MalformedURLException
      */
-
- public static URL getResourceURL( String repository, String resource )
+ @Deprecated
+ public static URL getResourceURL( String repository, String groupId, String artifactId, String version,
+ String classifier, String extensionType )
         throws MalformedURLException
     {
- String[] parts = resource.split( ":" );
- String groupId = parts[1];
- String artifactId = parts[2];
- String version = parts[3];
- String classifier = null;
- if ( parts.length > 5 )
+ URL url = getFolderURL( repository, groupId, artifactId, version );
+ if ( classifier == null || extensionType.equals( "pom" ) )
         {
- classifier = parts[4];
+ url = new URL( url.toString() + artifactId + '-' + version + "." + extensionType );
+ }
+ else
+ {
+ url = new URL( url.toString() + artifactId + '-' + version + '-' + classifier + '.' + extensionType );
         }
- String extensionType = parts[parts.length - 1];
- URL url = getResourceURL( repository, groupId, artifactId, version, classifier, extensionType );
         return url;
     }
 

Modified: branches/2.X/pom.xml
Url: http://pomstrap.tigr​is.org/source/browse​/pomstrap/branches/2​.X/pom.xml?view=diff​&pathrev=168​&r1=167&r2=168
====================​====================​====================​==================
--- branches/2.X/pom.xml (original)
+++ branches/2.X/pom.xml 2009-01-29 13:20:42-0800
@@ -14,7 +14,7 @@
         <module>org.ti​gris.pomstrap.test.t​omcat.beans</modu​le>
         <module>org.ti​gris.pomstrap.test.t​omcat.webapp</mod​ule>
         <module>org.ti​gris.pomstrap.test.t​ransformers</modu​le>
- </modules>
+ </modules>
     <distributionManagement>
         <site>
             <url>${site.u​rl}</url>

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

svn commit: r168 - branches/2.X: . org.tigris.pomstrap.cli/src/main/java/org/tigris/pomstrap/cli org.tigris.pomstrap.core org.tigris.pomstrap.core/src/main/java/org/tigris/pomstrap/core evangelista Alessandro Evangelista 2009-01-29 13:20:43 PST
Messages per page: