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();
boolean snapshot = isSnapshot( dep );
if ( snapshot && !remoteRepo.isSnapshots() )
{
continue;
}
if ( !snapshot && !remoteRepo.isReleases() )
{
continue;
}
// The username and password parameters are not being used here.
String url = remoteRepo.getBasedir() + "/" + remoteRepo.getArtifactPath( dep );
@ -124,7 +134,7 @@ public class ArtifactDownloader
try
{
String version = dep.getVersion();
if ( isSnapshot( dep ) )
if ( snapshot )
{
String filename = getSnapshotMetadataFile( destinationFile.getName(), "SNAPSHOT.version.txt" );
File file = localRepository.getMetadataFile( dep.getGroupId(), dep.getArtifactId(),
@ -255,7 +265,7 @@ public class ArtifactDownloader
if ( remoteRepositories.isEmpty() )
{
// 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;

View File

@ -94,6 +94,10 @@ public class ModelReader
private boolean insideDependencyManagement = false;
private boolean insideReleases;
private boolean insideSnapshots;
public ModelReader( ArtifactDownloader downloader, boolean resolveTransitiveDependencies )
{
this.downloader = downloader;
@ -157,6 +161,14 @@ public class ModelReader
insideResource = true;
}
else if ( rawName.equals( "snapshots" ) && insideRepository )
{
insideSnapshots = true;
}
else if ( rawName.equals( "releases" ) && insideRepository )
{
insideReleases = true;
}
depth++;
}
@ -324,6 +336,25 @@ public class ModelReader
{
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 )
{
@ -409,9 +440,8 @@ public class ModelReader
downloader.downloadDependencies( Collections.singletonList( pom ) );
Repository localRepository = downloader.getLocalRepository();
p.parse(
localRepository.getMetadataFile( groupId, artifactId, version, type,
artifactId + "-" + pom.getResolvedVersion() + ".pom" ) );
p.parse( localRepository.getMetadataFile( groupId, artifactId, version, type,
artifactId + "-" + pom.getResolvedVersion() + ".pom" ) );
}
catch ( IOException e )
{

View File

@ -36,15 +36,21 @@ public class Repository
private String id;
private boolean releases;
private boolean snapshots;
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.basedir = basedir;
this.layout = layout;
this.snapshots = snapshots;
this.releases = releases;
}
public File getArtifactFile( String groupId, String artifactId, String version, String type )
@ -156,4 +162,24 @@ public class Repository
{
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;
}
}