snapshot repo separation for mboot

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@226760 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-08-01 08:17:12 +00:00
parent fea880dce0
commit 5aacdad52f
3 changed files with 72 additions and 6 deletions

View File

@ -116,6 +116,16 @@ public class ArtifactDownloader
{ {
Repository remoteRepo = (Repository) i.next(); Repository remoteRepo = (Repository) i.next();
boolean snapshot = isSnapshot( dep );
if ( snapshot && !remoteRepo.isSnapshots() )
{
continue;
}
if ( !snapshot && !remoteRepo.isReleases() )
{
continue;
}
// The username and password parameters are not being used here. // The username and password parameters are not being used here.
String url = remoteRepo.getBasedir() + "/" + remoteRepo.getArtifactPath( dep ); String url = remoteRepo.getBasedir() + "/" + remoteRepo.getArtifactPath( dep );
@ -124,7 +134,7 @@ public class ArtifactDownloader
try try
{ {
String version = dep.getVersion(); String version = dep.getVersion();
if ( isSnapshot( dep ) ) if ( snapshot )
{ {
String filename = getSnapshotMetadataFile( destinationFile.getName(), "SNAPSHOT.version.txt" ); String filename = getSnapshotMetadataFile( destinationFile.getName(), "SNAPSHOT.version.txt" );
File file = localRepository.getMetadataFile( dep.getGroupId(), dep.getArtifactId(), File file = localRepository.getMetadataFile( dep.getGroupId(), dep.getArtifactId(),
@ -255,7 +265,7 @@ public class ArtifactDownloader
if ( remoteRepositories.isEmpty() ) if ( remoteRepositories.isEmpty() )
{ {
// TODO: use super POM? // TODO: use super POM?
remoteRepositories.add( new Repository( "central", REPO_URL, Repository.LAYOUT_DEFAULT ) ); remoteRepositories.add( new Repository( "central", REPO_URL, Repository.LAYOUT_DEFAULT, false, true ) );
} }
return remoteRepositories; return remoteRepositories;

View File

@ -94,6 +94,10 @@ public class ModelReader
private boolean insideDependencyManagement = false; private boolean insideDependencyManagement = false;
private boolean insideReleases;
private boolean insideSnapshots;
public ModelReader( ArtifactDownloader downloader, boolean resolveTransitiveDependencies ) public ModelReader( ArtifactDownloader downloader, boolean resolveTransitiveDependencies )
{ {
this.downloader = downloader; this.downloader = downloader;
@ -157,6 +161,14 @@ public class ModelReader
insideResource = true; insideResource = true;
} }
else if ( rawName.equals( "snapshots" ) && insideRepository )
{
insideSnapshots = true;
}
else if ( rawName.equals( "releases" ) && insideRepository )
{
insideReleases = true;
}
depth++; depth++;
} }
@ -324,6 +336,25 @@ public class ModelReader
{ {
currentRepository.setLayout( getBodyText() ); currentRepository.setLayout( getBodyText() );
} }
else if ( rawName.equals( "enabled" ) )
{
if ( insideSnapshots )
{
currentRepository.setSnapshots( Boolean.valueOf( getBodyText() ).booleanValue() );
}
else if ( insideReleases )
{
currentRepository.setReleases( Boolean.valueOf( getBodyText() ).booleanValue() );
}
}
else if ( rawName.equals( "snapshots" ) )
{
insideSnapshots = false;
}
else if ( rawName.equals( "releases" ) )
{
insideReleases = false;
}
} }
else if ( depth == 2 ) else if ( depth == 2 )
{ {
@ -409,9 +440,8 @@ public class ModelReader
downloader.downloadDependencies( Collections.singletonList( pom ) ); downloader.downloadDependencies( Collections.singletonList( pom ) );
Repository localRepository = downloader.getLocalRepository(); Repository localRepository = downloader.getLocalRepository();
p.parse( p.parse( localRepository.getMetadataFile( groupId, artifactId, version, type,
localRepository.getMetadataFile( groupId, artifactId, version, type, artifactId + "-" + pom.getResolvedVersion() + ".pom" ) );
artifactId + "-" + pom.getResolvedVersion() + ".pom" ) );
} }
catch ( IOException e ) catch ( IOException e )
{ {

View File

@ -36,15 +36,21 @@ public class Repository
private String id; private String id;
private boolean releases;
private boolean snapshots;
public Repository() public Repository()
{ {
} }
public Repository( String id, String basedir, String layout ) public Repository( String id, String basedir, String layout, boolean snapshots, boolean releases )
{ {
this.id = id; this.id = id;
this.basedir = basedir; this.basedir = basedir;
this.layout = layout; this.layout = layout;
this.snapshots = snapshots;
this.releases = releases;
} }
public File getArtifactFile( String groupId, String artifactId, String version, String type ) public File getArtifactFile( String groupId, String artifactId, String version, String type )
@ -156,4 +162,24 @@ public class Repository
{ {
return layout; return layout;
} }
public void setReleases( boolean releases )
{
this.releases = releases;
}
public void setSnapshots( boolean snapshots )
{
this.snapshots = snapshots;
}
public boolean isReleases()
{
return releases;
}
public boolean isSnapshots()
{
return snapshots;
}
} }