You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by og...@apache.org on 2009/04/27 20:23:15 UTC
svn commit: r769085 - in /maven/mercury/trunk: mercury-ant-tasks/
mercury-core/src/main/java/org/apache/maven/mercury/repository/api/
mercury-core/src/main/java/org/apache/maven/mercury/repository/local/map/
mercury-core/src/main/java/org/apache/maven/...
Author: ogusakov
Date: Mon Apr 27 18:23:14 2009
New Revision: 769085
URL: http://svn.apache.org/viewvc?rev=769085&view=rev
Log:
[MERCURY-117] - added "sufficient" repository flag
Added:
maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/local/map/ReactorStorage.java (with props)
Modified:
maven/mercury/trunk/mercury-ant-tasks/pom.xml
maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/AbstractRepository.java
maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/Repository.java
maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/local/map/LocalRepositoryReaderMap.java
maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/remote/m2/RemoteRepositoryReaderM2.java
maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/virtual/VirtualRepositoryReader.java
maven/mercury/trunk/mercury-it/src/test/java/org/apache/maven/mercury/repository/tests/ComprehensiveRepositoryTest.java
Modified: maven/mercury/trunk/mercury-ant-tasks/pom.xml
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-ant-tasks/pom.xml?rev=769085&r1=769084&r2=769085&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-ant-tasks/pom.xml (original)
+++ maven/mercury/trunk/mercury-ant-tasks/pom.xml Mon Apr 27 18:23:14 2009
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.maven.mercury</groupId>
<artifactId>mercury</artifactId>
- <version>1.0-alpha-6-SNAPSHOT</version>
+ <version>1.0-alpha-8-SNAPSHOT</version>
</parent>
<artifactId>mercury-ant-tasks</artifactId>
@@ -62,33 +62,7 @@
<dependency>
<groupId>org.apache.maven.mercury</groupId>
- <artifactId>mercury-artifact</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.maven.mercury</groupId>
- <artifactId>mercury-external</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.maven.mercury</groupId>
- <artifactId>mercury-repo-virtual</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.maven.mercury</groupId>
- <artifactId>mercury-repo-local-map
- </artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.maven.mercury</groupId>
- <artifactId>mercury-repo-remote-m2</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.maven.mercury</groupId>
- <artifactId>mercury-md-sat</artifactId>
+ <artifactId>mercury-core</artifactId>
</dependency>
<dependency>
@@ -131,10 +105,8 @@
<!-- Test dependencies -->
<dependency>
- <groupId>org.apache.maven.mercury
- </groupId>
- <artifactId>mercury-transport-http
- </artifactId>
+ <groupId>org.apache.maven.mercury</groupId>
+ <artifactId>mercury-core</artifactId>
<type>test-jar</type>
<scope>test</scope>
</dependency>
@@ -159,7 +131,9 @@
<plugins>
<plugin>
+ <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
+ <version>1.3-SNAPSHOT</version>
<executions>
<execution>
<phase>package</phase>
Modified: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/AbstractRepository.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/AbstractRepository.java?rev=769085&r1=769084&r2=769085&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/AbstractRepository.java (original)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/AbstractRepository.java Mon Apr 27 18:23:14 2009
@@ -73,6 +73,8 @@
protected DependencyProcessor dependencyProcessor;
protected Server server;
+
+ protected boolean isSufficient = false;
private static final byte[] __HEX_DIGITS = "0123456789abcdef".getBytes();
@@ -269,6 +271,16 @@
{
return repositoryQualityRange.isAcceptedQuality( quality );
}
+
+ public boolean isSufficient()
+ {
+ return isSufficient;
+ }
+
+ public void setSufficient( boolean isSufficient )
+ {
+ this.isSufficient = isSufficient;
+ }
// ---------------------------------------------------------------------------
public boolean hasServer()
Modified: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/Repository.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/Repository.java?rev=769085&r1=769084&r2=769085&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/Repository.java (original)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/api/Repository.java Mon Apr 27 18:23:14 2009
@@ -65,6 +65,14 @@
public boolean isSnapshots();
/**
+ * indicates that any version or artifact, found in the repository
+ * is sufficient and VirtualRepositoryReader should look no further
+ *
+ */
+ boolean isSufficient();
+ void setSufficient( boolean isSufficient );
+
+ /**
* indicates if the supplied code quality is served by this repository
*/
public boolean isAcceptedQuality( Quality quality );
Modified: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/local/map/LocalRepositoryReaderMap.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/local/map/LocalRepositoryReaderMap.java?rev=769085&r1=769084&r2=769085&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/local/map/LocalRepositoryReaderMap.java (original)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/local/map/LocalRepositoryReaderMap.java Mon Apr 27 18:23:14 2009
@@ -59,7 +59,7 @@
throw new IllegalArgumentException( "localRepo cannot be null" );
if ( dp == null )
- throw new IllegalArgumentException( "localRepo cannot be null" );
+ throw new IllegalArgumentException( "dependecny processor cannot be null" );
_mdProcessor = dp;
Added: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/local/map/ReactorStorage.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/local/map/ReactorStorage.java?rev=769085&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/local/map/ReactorStorage.java (added)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/local/map/ReactorStorage.java Mon Apr 27 18:23:14 2009
@@ -0,0 +1,142 @@
+package org.apache.maven.mercury.repository.local.map;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.maven.mercury.artifact.Artifact;
+import org.apache.maven.mercury.artifact.ArtifactMetadata;
+import org.apache.maven.mercury.util.FileUtil;
+import org.apache.maven.mercury.util.Util;
+import org.codehaus.plexus.lang.DefaultLanguage;
+import org.codehaus.plexus.lang.Language;
+
+/**
+ *
+ *
+ * @author Oleg Gusakov
+ * @version $Id$
+ *
+ */
+public class ReactorStorage
+implements Storage
+{
+ private static final Language _lang = new DefaultLanguage( ReactorStorage.class );
+
+ Map< String, Artifact > _artifacts;
+
+ Map< String, File > _files;
+
+ File _dir;
+
+ public ReactorStorage( File dir )
+ throws StorageException
+ {
+ if( dir == null )
+ {
+ try
+ {
+ _dir = File.createTempFile( "temp-", "-mercury-default-storage" );
+ _dir.deleteOnExit();
+ }
+ catch ( IOException e )
+ {
+ throw new StorageException(e);
+ }
+
+ _dir.delete();
+
+ _dir.mkdirs();
+ }
+ else
+ {
+ if( !dir.exists() )
+ dir.mkdirs();
+ else
+ if( dir.isDirectory() )
+ throw new StorageException( _lang.getMessage( "default.storage.bad.dir", dir.getAbsolutePath() ) );
+
+ _dir = dir;
+ }
+ }
+
+ public ReactorStorage()
+ throws StorageException
+ {
+ this( null );
+ }
+
+ public void add( ArtifactMetadata bmd, Artifact artifact )
+ {
+ if( _artifacts == null )
+ _artifacts = new HashMap<String, Artifact>(32);
+
+ _artifacts.put( bmd.toString(), artifact );
+ }
+
+ public Artifact findArtifact( ArtifactMetadata bmd )
+ {
+ if( _artifacts == null )
+ return null;
+
+ return _artifacts.get( bmd.getGAV() );
+ }
+
+ public byte[] findRaw( String key )
+ throws StorageException
+ {
+ if( Util.isEmpty( _files ) )
+ return null;
+
+ File f = _files.get( key );
+
+ if( f == null )
+ return null;
+
+ try
+ {
+ return FileUtil.readRawData( f );
+ }
+ catch ( IOException e )
+ {
+ throw new StorageException(e);
+ }
+ }
+
+ public void add( String key, byte[] bytes )
+ throws StorageException
+ {
+ try
+ {
+ add( key, FileUtil.writeTempData( bytes ) );
+ }
+ catch ( IOException e )
+ {
+ throw new StorageException(e);
+ }
+ }
+
+ public void add( String key, File file )
+ throws StorageException
+ {
+ if( file == null || !file.exists() )
+ throw new StorageException( _lang.getMessage( "defaultStorage.add.file.no.file", key ) );
+
+ if( _files == null )
+ _files = new HashMap<String, File>(32);
+
+ _files.put( key, file );
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.maven.mercury.repository.local.map.Storage#removeRaw(java.lang.String)
+ */
+ public void removeRaw( String key )
+ throws StorageException
+ {
+ if( Util.isEmpty( _files ) )
+ throw new StorageException( _lang.getMessage( "dep.cannot.remove", key ) );
+ }
+
+}
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/local/map/ReactorStorage.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/local/map/ReactorStorage.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/remote/m2/RemoteRepositoryReaderM2.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/remote/m2/RemoteRepositoryReaderM2.java?rev=769085&r1=769084&r2=769085&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/remote/m2/RemoteRepositoryReaderM2.java (original)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/remote/m2/RemoteRepositoryReaderM2.java Mon Apr 27 18:23:14 2009
@@ -991,12 +991,13 @@
// if( _log.isDebugEnabled() )
// _log.debug( "reading "+bmd+" from " + _repo.getId() );
+ mod = new ArtifactMetadata( md );
+ mod.setClassifier( classifier );
+ mod.setType( type );
+
// only cache poms at the moment
if ( _mdCache != null && "pom".equals( type ) )
{
- mod = new ArtifactMetadata( md );
- mod.setClassifier( classifier );
- mod.setType( type );
try
{
@@ -1015,9 +1016,11 @@
}
}
- mod =
- new ArtifactMetadata( md.getGroupId() + ":" + md.getArtifactId() + ":" + md.getVersion() + ":"
- + ( classifier == null ? "" : classifier ) + ":" + ( type == null ? md.getType() : type ) );
+// mod =
+// new ArtifactMetadata( md );
+// new ArtifactMetadata( md.getGroupId() + ":" + md.getArtifactId() + ":" + md.getVersion() + ":"
+// + ( classifier == null ? "" : classifier ) + ":" + ( type == null ? md.getType() : type )
+// );
// ArtifactLocation loc = new ArtifactLocation( "", mod );
Modified: maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/virtual/VirtualRepositoryReader.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/virtual/VirtualRepositoryReader.java?rev=769085&r1=769084&r2=769085&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/virtual/VirtualRepositoryReader.java (original)
+++ maven/mercury/trunk/mercury-core/src/main/java/org/apache/maven/mercury/repository/virtual/VirtualRepositoryReader.java Mon Apr 27 18:23:14 2009
@@ -35,7 +35,6 @@
import org.apache.maven.mercury.artifact.api.ArtifactListProcessor;
import org.apache.maven.mercury.artifact.api.ArtifactListProcessorException;
import org.apache.maven.mercury.artifact.version.DefaultArtifactVersion;
-import org.apache.maven.mercury.artifact.version.MetadataVersionComparator;
import org.apache.maven.mercury.builder.api.DependencyProcessor;
import org.apache.maven.mercury.builder.api.MetadataReader;
import org.apache.maven.mercury.builder.api.MetadataReaderException;
@@ -46,9 +45,9 @@
import org.apache.maven.mercury.event.MercuryEventListener;
import org.apache.maven.mercury.logging.IMercuryLogger;
import org.apache.maven.mercury.logging.MercuryLoggerManager;
-import org.apache.maven.mercury.repository.api.MetadataResults;
import org.apache.maven.mercury.repository.api.ArtifactResults;
import org.apache.maven.mercury.repository.api.LocalRepository;
+import org.apache.maven.mercury.repository.api.MetadataResults;
import org.apache.maven.mercury.repository.api.RemoteRepository;
import org.apache.maven.mercury.repository.api.Repository;
import org.apache.maven.mercury.repository.api.RepositoryException;
@@ -56,10 +55,8 @@
import org.apache.maven.mercury.repository.api.RepositoryReader;
import org.apache.maven.mercury.repository.api.RepositoryWriter;
import org.apache.maven.mercury.repository.cache.fs.MetadataCacheFs;
-import org.apache.maven.mercury.repository.metadata.MetadataException;
import org.apache.maven.mercury.repository.remote.m2.RemoteRepositoryM2;
import org.apache.maven.mercury.repository.remote.m2.RemoteRepositoryReaderM2;
-import org.apache.maven.mercury.transport.api.Server;
import org.apache.maven.mercury.util.Util;
import org.codehaus.plexus.lang.DefaultLanguage;
import org.codehaus.plexus.lang.Language;
@@ -395,32 +392,15 @@
{
res.add( key, rorRes );
}
-/*
- String keyVersion = key.getVersion();
- VersionRange keyVersionRange = null;
- try
- {
- keyVersionRange = VersionRangeFactory.create( key.getVersion() );
- }
- catch ( VersionException e )
- {
- throw new RepositoryException( LANG.getMessage( "query.element.bad.version",
- key.toString(), e.getMessage() ) );
- }
-
- if ( keyVersionRange.isSingleton() )
- {
- Quality keyQuality = new Quality( keyVersion );
- if ( keyQuality.compareTo( Quality.RELEASE_QUALITY ) == 0 )
- {
- // fixed release is found - no more scanning
- qList.remove( key );
- }
- }
-*/
- if ( !key.isVirtual() && key.isSingleton() )
+
+ if (
+ ( !key.isVirtual() && key.isSingleton() )
+ ||
+ ( key.isVirtual() && rr.getRepository().isSufficient() )
+ )
{
- // fixed release is found - no more scanning
+ // fixed release is found or virtual is found
+ // in a sufficient repo - no more scanning
qList.remove( key );
}
}
@@ -689,6 +669,11 @@
}
// ----------------------------------------------------------------------------------------------------------------------------
+ // TODO: Oleg: this is a copy of readArtifacts - optimize for the particular
+ // purpose - reading non-qualified virtuals, remove
+ //
+ // Now this can also be used to read artifacts without pooling them if there is such
+ //
public ArtifactResults readArtifactsNoBatch( Collection<? extends ArtifactMetadata> query )
throws RepositoryException
{
@@ -805,6 +790,8 @@
if ( virtuals != null )
{
+ // this makes them qualified because tracker will point to
+ // the repository
MetadataResults virtRes = readVersions( virtuals );
leftovers.removeAll( virtuals );
@@ -824,6 +811,7 @@
sMap.put( v, md );
}
+ // recursive call, this time for qualified artifacts
ArtifactResults ares = readArtifacts( virtuals );
if ( ares != null )
Modified: maven/mercury/trunk/mercury-it/src/test/java/org/apache/maven/mercury/repository/tests/ComprehensiveRepositoryTest.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-it/src/test/java/org/apache/maven/mercury/repository/tests/ComprehensiveRepositoryTest.java?rev=769085&r1=769084&r2=769085&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-it/src/test/java/org/apache/maven/mercury/repository/tests/ComprehensiveRepositoryTest.java (original)
+++ maven/mercury/trunk/mercury-it/src/test/java/org/apache/maven/mercury/repository/tests/ComprehensiveRepositoryTest.java Mon Apr 27 18:23:14 2009
@@ -583,6 +583,7 @@
assertEquals( "2.0.9-20090204.232324-24", aSN.getVersion() );
}
+ //
public void testWriteTimestampReadSnapshot2ReposReversed()
throws Exception
{
@@ -624,6 +625,52 @@
assertEquals( "2.0.9-20090204.232324-24", aSN.getVersion() );
}
+ public void testSufficientRepository()
+ throws Exception
+ {
+ String nameTS1 = "org.apache.maven:maven-core:2.0.9-20090204.232323-23";
+ String nameTS2 = "org.apache.maven:maven-core:2.0.9-20090204.232324-24";
+ String nameSN = "org.apache.maven:maven-core:2.0.9-SNAPSHOT";
+
+ File af = new File( _resourceBase, "maven-core-2.0.9.jar" );
+ File ap = new File( _resourceBase, "maven-core-2.0.9.pom" );
+
+ File aJar = new File( _base1, "org/apache/maven/maven-core/2.0.9-SNAPSHOT/maven-core-2.0.9-20090204.232323-23.jar");
+ writeArtifact( nameTS1, af, ap, _rr1, aJar );
+
+ // make this repo sufficient
+ _rr1.setSufficient( true );
+
+ aJar = new File( _base2, "org/apache/maven/maven-core/2.0.9-SNAPSHOT/maven-core-2.0.9-20090204.232324-24.jar");
+ writeArtifact( nameTS2, af, ap, _rr2, aJar );
+
+ List<ArtifactMetadata> vl = readVersions( nameSN, _rrs );
+
+ System.out.println(vl);
+
+ assertNotNull( vl );
+
+ assertEquals( 1, vl.size() );
+
+ List<Artifact> al = readArtifact( nameSN, _rrs );
+
+ System.out.println(al);
+
+ assertNotNull( al );
+
+ assertEquals( 1, al.size() );
+
+ Artifact aSN = al.get( 0 );
+
+ assertNotNull( aSN.getFile() );
+
+ assertTrue( aSN.getFile().exists() );
+
+ // the first one should be selected because
+ // it resides in the "sufficient" repository
+ assertEquals( "2.0.9-20090204.232323-23", aSN.getVersion() );
+ }
+
public void testLatest()
throws Exception
{