fixes related to changing the path of parent poms, though the actual functionality is not implemented

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@164346 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-04-23 06:24:08 +00:00
parent 3711af1761
commit 23835350c8
11 changed files with 125 additions and 60 deletions

View File

@ -49,8 +49,11 @@ public class DefaultRepositoryLayout
StringBuffer path = new StringBuffer();
path.append( artifact.getGroupId().replace( '.', '/' ) ).append( '/' );
// if ( !artifact.getType().equals( "pom" ) )
// {
path.append( artifact.getArtifactId() ).append( '/' );
path.append( artifact.getBaseVersion() ).append( '/' );
// }
path.append( artifact.getArtifactId() ).append( '-' ).append( artifact.getVersion() );
if ( artifact.hasClassifier() )
@ -74,8 +77,12 @@ public class DefaultRepositoryLayout
StringBuffer path = new StringBuffer();
path.append( artifact.getGroupId().replace( '.', '/' ) ).append( '/' );
// if ( !artifact.getType().equals( "pom" ) )
// {
path.append( artifact.getArtifactId() ).append( '/' );
path.append( artifact.getBaseVersion() ).append( '/' );
// }
path.append( metadata.getFilename() );
return path.toString();

View File

@ -223,8 +223,11 @@ public class Verifier
}
else if ( "default".equals( localRepoLayout ) )
{
String pathGroup = a[0].replace( '.', '/' );
repositoryPath = pathGroup + "/" + a[1] + "/" + a[2];
repositoryPath = a[0].replace( '.', '/' );
// if ( !a[3].equals( "pom" ) )
// {
repositoryPath = repositoryPath + "/" + a[1] + "/" + a[2];
// }
repositoryPath = repositoryPath + "/" + a[1] + "-" + a[2] + "." + ext;
}
else

View File

@ -378,6 +378,13 @@ public class DefaultMaven
line();
}
if ( getLogger().isDebugEnabled() )
{
getLogger().debug( "Trace", e );
line();
}
stats( r.getStart(), r.getFinish() );
line();

View File

@ -21,6 +21,7 @@ import org.apache.maven.artifact.factory.DefaultArtifactFactory;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.apache.maven.model.Dependency;
@ -32,6 +33,7 @@ import org.apache.maven.project.ProjectBuildingException;
import org.apache.maven.wagon.util.IoUtils;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
@ -74,9 +76,9 @@ public class MavenMetadataSource
public Set retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories )
throws ArtifactMetadataRetrievalException
{
Artifact metadataArtifact = artifactFactory.createArtifact( artifact.getGroupId(), artifact.getArtifactId(),
artifact.getBaseVersion(), artifact.getScope(),
"pom", null );
// TODO: only metadata is really needed - resolve as metadata
artifact = artifactFactory.createArtifact( artifact.getGroupId(), artifact.getArtifactId(),
artifact.getVersion(), artifact.getScope(), "pom" );
List dependencies = null;
@ -86,7 +88,7 @@ public class MavenMetadataSource
{
try
{
MavenProject p = mavenProjectBuilder.buildFromRepository( metadataArtifact, remoteRepositories,
MavenProject p = mavenProjectBuilder.buildFromRepository( artifact, remoteRepositories,
localRepository );
dependencies = p.getDependencies();
}
@ -103,7 +105,7 @@ public class MavenMetadataSource
try
{
artifactResolver.resolve( metadataArtifact, remoteRepositories, localRepository );
artifactResolver.resolve( artifact, remoteRepositories, localRepository );
}
catch ( ArtifactResolutionException e )
{
@ -113,7 +115,10 @@ public class MavenMetadataSource
FileReader reader = null;
try
{
reader = new FileReader( metadataArtifact.getFile() );
// String path = localRepository.pathOfMetadata( new ProjectArtifactMetadata( artifact, null ) );
// File file = new File( localRepository.getBasedir(), path );
File file = artifact.getFile();
reader = new FileReader( file );
Model model = this.reader.read( reader );
dependencies = model.getDependencies();
}

View File

@ -37,7 +37,8 @@ public class MBoot
{
String[] builds = new String[]{"maven-model", "maven-settings", "maven-monitor", "maven-plugin-api",
"maven-plugin-descriptor", "maven-artifact", "maven-script/maven-script-marmalade",
"maven-project", "maven-core", "maven-archiver", "maven-plugin-tools/maven-plugin-tools-api",
"maven-project", "maven-core", "maven-archiver",
"maven-plugin-tools/maven-plugin-tools-api",
"maven-plugin-tools/maven-plugin-tools-java",
"maven-plugin-tools/maven-plugin-tools-pluggy",
"maven-plugin-tools/maven-plugin-tools-marmalade", "maven-core-it-verifier"};
@ -733,7 +734,8 @@ public class MBoot
String groupId = reader.getGroupId();
File pom = localRepository.getArtifactFile( groupId, artifactId, version, "pom" );
File pom = localRepository.getMetadataFile( groupId, artifactId, version, reader.getPackaging(),
artifactId + "-" + version + ".pom" );
System.out.println( "Installing POM: " + pom );
@ -760,6 +762,8 @@ public class MBoot
File metadata = localRepository.getMetadataFile( groupId, artifactId, version, type,
finalName + ".version.txt" );
metadata.getParentFile().mkdirs();
IOUtil.copy( new StringReader( version ), new FileWriter( metadata ) );
}

View File

@ -92,11 +92,6 @@ public class ArtifactDownloader
continue;
}
if ( destinationFile.exists() && !snapshot )
{
continue;
}
getRemoteArtifact( dep, destinationFile );
if ( !destinationFile.exists() )
@ -139,56 +134,72 @@ public class ArtifactDownloader
{
Repository remoteRepo = (Repository) i.next();
// The username and password parameters are not being
// used here. Those are the "" parameters you see below.
// The username and password parameters are not being used here.
String url = remoteRepo.getBasedir() + "/" + remoteRepo.getArtifactPath( dep );
if ( !url.startsWith( "file" ) )
{
url = replace( url, "//", "/" );
if ( url.startsWith( "https" ) )
{
url = replace( url, "https:/", "https://" );
}
else
{
url = replace( url, "http:/", "http://" );
}
}
else
{
// THe JDK URL for file: should have one or no / instead of // for some reason
url = replace( url, "file://", "file:" );
}
// Attempt to retrieve the artifact and set the checksum if retrieval
// of the checksum file was successful.
try
{
String version = dep.getVersion();
if ( isSnapshot( dep ) )
{
String filename = getSnapshotMetadataFile( destinationFile.getPath(), "SNAPSHOT.version.txt" );
String metaUrl = getSnapshotMetadataFile( url, "SNAPSHOT.version.txt" );
String filename = getSnapshotMetadataFile( destinationFile.getName(), "SNAPSHOT.version.txt" );
File file = localRepository.getMetadataFile( dep.getGroupId(), dep.getArtifactId(),
dep.getVersion(), dep.getType(), filename );
String metadataPath = remoteRepo.getMetadataPath( dep.getGroupId(), dep.getArtifactId(),
dep.getVersion(), dep.getType(), filename );
String metaUrl = remoteRepo.getBasedir() + "/" + metadataPath;
log( "Downloading " + metaUrl );
try
{
HttpUtils.getFile( metaUrl, new File( filename ), ignoreErrors, false, proxyHost, proxyPort,
proxyUserName, proxyPassword, false );
String version = FileUtils.fileRead( filename );
HttpUtils.getFile( metaUrl, file, ignoreErrors, false, proxyHost, proxyPort, proxyUserName,
proxyPassword, false );
version = FileUtils.fileRead( file );
log( "Resolved version: " + version );
version = version.substring( version.lastIndexOf( "-", version.lastIndexOf( "-" ) - 1 ) + 1 );
String ver = version.substring( version.lastIndexOf( "-", version.lastIndexOf( "-" ) - 1 ) + 1 );
String extension = url.substring( url.length() - 4 );
url = getSnapshotMetadataFile( url, version + extension );
url = getSnapshotMetadataFile( url, ver + extension );
}
catch ( IOException e )
{
log( "WARNING: SNAPSHOT version not found, using default" );
log( "WARNING: SNAPSHOT version not found, using default: " + e.getMessage() );
}
}
if ( !dep.getType().equals( "pom" ) )
{
File file = localRepository.getMetadataFile( dep.getGroupId(), dep.getArtifactId(),
dep.getVersion(), dep.getType(),
dep.getArtifactId() + "-" + dep.getVersion() + ".pom" );
file.getParentFile().mkdirs();
if ( !file.exists() || version.indexOf( "SNAPSHOT" ) >= 0 )
{
String filename = dep.getArtifactId() + "-" + version + ".pom";
String metadataPath = remoteRepo.getMetadataPath( dep.getGroupId(), dep.getArtifactId(),
dep.getVersion(), dep.getType(), filename );
String metaUrl = remoteRepo.getBasedir() + "/" + metadataPath;
log( "Downloading " + metaUrl );
try
{
HttpUtils.getFile( metaUrl, file, ignoreErrors, false, proxyHost, proxyPort, proxyUserName,
proxyPassword, false );
}
catch ( IOException e )
{
log( "Couldn't find POM - ignoring: " + e.getMessage() );
}
}
}
if ( !destinationFile.exists() || version.indexOf( "SNAPSHOT" ) >= 0 )
{
log( "Downloading " + url );
HttpUtils.getFile( url, destinationFile, ignoreErrors, useTimestamp, proxyHost, proxyPort,
proxyUserName, proxyPassword, true );
}
// Artifact was found, continue checking additional remote repos (if any)
// in case there is a newer version (i.e. snapshots) in another repo

View File

@ -202,7 +202,7 @@ public class ModelReader
}
// actually, these should be transtive (see MNG-77) - but some projects have circular deps that way (marmalade, and currently m2)
ModelReader p = retrievePom( parentGroupId, parentArtifactId, parentVersion, false );
ModelReader p = retrievePom( parentGroupId, parentArtifactId, parentVersion, "pom", false );
addDependencies( p.getDependencies(), parentDependencies, null );
@ -219,7 +219,8 @@ public class ModelReader
if ( resolveTransitiveDependencies )
{
ModelReader p = retrievePom( currentDependency.getGroupId(), currentDependency.getArtifactId(),
currentDependency.getVersion(), resolveTransitiveDependencies );
currentDependency.getVersion(), currentDependency.getType(),
resolveTransitiveDependencies );
addDependencies( p.getDependencies(), transitiveDependencies, currentDependency.getScope() );
}
@ -383,7 +384,7 @@ public class ModelReader
return false;
}
private ModelReader retrievePom( String groupId, String artifactId, String version,
private ModelReader retrievePom( String groupId, String artifactId, String version, String type,
boolean resolveTransitiveDependencies )
throws SAXException
{
@ -400,11 +401,13 @@ public class ModelReader
try
{
Dependency pom = new Dependency( groupId, artifactId, version, "pom" );
Dependency pom = new Dependency( groupId, artifactId, version, type );
downloader.downloadDependencies( Collections.singletonList( pom ) );
Repository localRepository = downloader.getLocalRepository();
p.parse( localRepository.getArtifactFile( pom ) );
p.parse(
localRepository.getMetadataFile( groupId, artifactId, version, type,
artifactId + "-" + version + ".pom" ) );
}
catch ( IOException e )
{

View File

@ -69,8 +69,11 @@ public class Repository
}
else if ( LAYOUT_DEFAULT.equals( layout ) )
{
String pathGroup = dependency.getGroupId().replace( '.', '/' );
repositoryPath = pathGroup + "/" + dependency.getArtifactId() + "/" + dependency.getVersion();
repositoryPath = dependency.getGroupId().replace( '.', '/' );
// if ( !dependency.getType().equals( "pom" ) )
// {
repositoryPath = repositoryPath + "/" + dependency.getArtifactId() + "/" + dependency.getVersion();
// }
repositoryPath = repositoryPath + "/" + dependency.getArtifact();
}
else
@ -81,6 +84,13 @@ public class Repository
}
public File getMetadataFile( String groupId, String artifactId, String version, String type, String filename )
{
String repositoryPath = getMetadataPath( groupId, artifactId, version, type, filename );
return new File( basedir, repositoryPath );
}
public String getMetadataPath( String groupId, String artifactId, String version, String type, String filename )
{
Dependency dependency = new Dependency( groupId, artifactId, version, type );
@ -91,16 +101,18 @@ public class Repository
}
else if ( LAYOUT_DEFAULT.equals( layout ) )
{
String pathGroup = dependency.getGroupId().replace( '.', '/' );
repositoryPath = pathGroup + "/" + dependency.getArtifactId() + "/" + dependency.getVersion();
repositoryPath = dependency.getGroupId().replace( '.', '/' );
// if ( !dependency.getType().equals( "pom" ) )
// {
repositoryPath = repositoryPath + "/" + dependency.getArtifactId() + "/" + dependency.getVersion();
// }
repositoryPath = repositoryPath + "/" + filename;
}
else
{
throw new IllegalStateException( "Unknown layout: " + layout );
}
return new File( basedir, repositoryPath );
return repositoryPath;
}
public String toString()

View File

@ -58,8 +58,16 @@ public abstract class AbstractReader
InputSource is = new InputSource( new StringReader( out ) );
try
{
parser.parse( is, this );
}
catch ( SAXException e )
{
System.err.println( "Error reading POM: " + file );
throw e;
}
}
public void warning( SAXParseException spe )
{

View File

@ -20,7 +20,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-modello-plugin</artifactId>
<version>1.0-alpha-1</version>
<version>1.0-alpha-2-SNAPSHOT</version>
<configuration>
<version>4.0.0</version>
<model>maven.mdo</model>

View File

@ -185,13 +185,18 @@ public class DefaultMavenProjectBuilder
{
try
{
// TODO: can't assume artifact is a POM
artifactResolver.resolve( artifact, remoteArtifactRepositories, localRepository );
}
catch ( ArtifactResolutionException e )
{
throw new ProjectBuildingException( "Unable to find artifact: " + artifact.toString(), e );
}
model = readModel( artifact.getFile() );
// String path = localRepository.pathOfMetadata( new ProjectArtifactMetadata( artifact, null ) );
// File file = new File( localRepository.getBasedir(), path );
File file = artifact.getFile();
model = readModel( file );
}
return model;
}