o Changed the repository to test.maven.codehaus.org for testing of the new repository and layout.

o Added <layout/> element to <repository/> elements in the maven.mdo
o Added pluginRepository configuration to the super-POM.
o Tested it all.


git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163791 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2005-04-06 01:28:29 +00:00
parent f8ca1e2c6d
commit 20620b4e09
8 changed files with 153 additions and 37 deletions

View File

@ -129,7 +129,7 @@ public class DefaultMavenProjectBuilder
try
{
Model superModel = getSuperModel();
LinkedList lineage = new LinkedList();
List aggregatedRemoteWagonRepositories = buildArtifactRepositories( superModel.getRepositories() );
@ -146,7 +146,7 @@ public class DefaultMavenProjectBuilder
previous = current;
}
project = processProjectLogic( project, localRepository, aggregatedRemoteWagonRepositories,
resolveDependencies, sourceProject );
@ -334,24 +334,24 @@ public class DefaultMavenProjectBuilder
List repos = new ArrayList();
// TODO: Replace with repository layout detection. This is a nasty hack.
String remoteRepoLayoutId = "legacy";
ArtifactRepositoryLayout remoteRepoLayout = null;
try
{
remoteRepoLayout = (ArtifactRepositoryLayout) container.lookup( ArtifactRepositoryLayout.ROLE,
remoteRepoLayoutId );
}
catch ( ComponentLookupException e )
{
throw new ProjectBuildingException( "Cannot find repository layout for: \'" + remoteRepoLayoutId + "\'.",
e );
}
for ( Iterator i = repositories.iterator(); i.hasNext(); )
{
Repository mavenRepo = (Repository) i.next();
String layout = mavenRepo.getLayout();
ArtifactRepositoryLayout remoteRepoLayout = null;
try
{
remoteRepoLayout = (ArtifactRepositoryLayout) container.lookup( ArtifactRepositoryLayout.ROLE,
layout );
}
catch ( ComponentLookupException e )
{
throw new ProjectBuildingException( "Cannot find layout implementation corresponding to: \'" + layout + "\' for remote repository with id: \'" + mavenRepo.getId() + "\'.",
e );
}
ArtifactRepository artifactRepo = artifactRepositoryFactory.createArtifactRepository( mavenRepo, settings,
remoteRepoLayout );
@ -367,38 +367,48 @@ public class DefaultMavenProjectBuilder
throws Exception
{
List remotePluginRepositories = new ArrayList();
// TODO: needs to be configured from the POM element
MavenSettings settings = mavenSettingsBuilder.buildSettings();
Repository pluginRepo = new Repository();
pluginRepo.setId( "plugin-repository" );
pluginRepo.setUrl( "http://repo1.maven.org/maven2" );
for ( Iterator it = pluginRepositories.iterator(); it.hasNext(); )
{
Repository mavenRepo = (Repository) it.next();
String layout = mavenRepo.getLayout();
// TODO: [jc] change this to detect the repository layout type somehow...
String repoLayoutId = "legacy";
ArtifactRepositoryLayout repositoryLayout = null;
try
{
repositoryLayout = (ArtifactRepositoryLayout) container.lookup( ArtifactRepositoryLayout.ROLE,
layout );
}
catch ( ComponentLookupException e )
{
throw new ProjectBuildingException( "Cannot find layout implementation corresponding to: \'" + layout + "\' for remote repository with id: \'" + mavenRepo.getId() + "\'.",
e );
}
ArtifactRepository pluginRepository = artifactRepositoryFactory.createArtifactRepository( mavenRepo, settings,
repositoryLayout );
ArtifactRepositoryLayout repositoryLayout = (ArtifactRepositoryLayout) container.lookup(
ArtifactRepositoryLayout.ROLE, repoLayoutId );
ArtifactRepository pluginRepository = artifactRepositoryFactory.createArtifactRepository( pluginRepo, settings,
repositoryLayout );
remotePluginRepositories.add( pluginRepository );
remotePluginRepositories.add( pluginRepository );
}
return remotePluginRepositories;
}
private ArtifactRepository buildDistributionManagementRepository( Repository dmRepo )
throws Exception
{
// TODO: needs to be configured from the POM element
if(dmRepo == null)
{
return null;
}
MavenSettings settings = mavenSettingsBuilder.buildSettings();
// TODO: [jc] change this to detect the repository layout type somehow...
String repoLayoutId = "legacy";
String repoLayoutId = dmRepo.getLayout();
ArtifactRepositoryLayout repositoryLayout = (ArtifactRepositoryLayout) container.lookup(
ArtifactRepositoryLayout.ROLE, repoLayoutId );

View File

@ -27,9 +27,12 @@ import org.apache.maven.model.PluginManagement;
import org.apache.maven.model.Repository;
import org.apache.maven.model.Scm;
import org.apache.maven.util.Xpp3DomUtils;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@ -43,6 +46,7 @@ import java.util.TreeMap;
* model.
*/
public class DefaultModelInheritanceAssembler
extends AbstractLogEnabled
implements ModelInheritanceAssembler
{
public void assembleModelInheritance( Model child, Model parent )
@ -151,6 +155,20 @@ public class DefaultModelInheritanceAssembler
}
}
// Plugin Repositories :: aggregate
List parentPluginRepositories = parent.getPluginRepositories();
List childPluginRepositories = child.getPluginRepositories();
for ( Iterator iterator = parentPluginRepositories.iterator(); iterator.hasNext(); )
{
Repository repository = (Repository) iterator.next();
if ( !childPluginRepositories.contains( repository ) )
{
child.addPluginRepository( repository );
}
}
// Plugins are not aggregated
// Reports :: aggregate

View File

@ -6,9 +6,19 @@
<repository>
<id>central</id>
<name>Maven Repository Switchboard</name>
<url>http://repo1.maven.org/maven2</url>
<url>http://test.maven.codehaus.org/maven2</url>
<layout>default</layout>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>Maven Plugin Repository</name>
<url>http://test.maven.codehaus.org/maven2</url>
<layout>default</layout>
</pluginRepository>
</pluginRepositories>
<build>
<!-- This all may just fold into plugin parameters -->

View File

@ -117,7 +117,8 @@ public class ArtifactDownloader
if ( repositories.isEmpty() )
{
// TODO: use super POM?
Repository repository = new Repository( "http://repo1.maven.org/maven2", Repository.LAYOUT_LEGACY );
Repository repository = new Repository( "http://test.maven.codehaus.org/maven2", Repository.LAYOUT_DEFAULT );
// Repository repository = new Repository( "http://repo1.maven.org/maven2", Repository.LAYOUT_LEGACY );
remoteRepos.add( repository );
}
}

View File

@ -1860,6 +1860,13 @@
<type>String</type>
<defaultValue>daily</defaultValue>
</field>
<field>
<name>layout</name>
<version>4.0.0</version>
<description>The type of layout this repository uses for locating and storing aritfacts - can be "legacy" or "default".</description>
<type>String</type>
<defaultValue>default</defaultValue>
</field>
</fields>
<codeSegments>
<codeSegment>

View File

@ -21,6 +21,11 @@
<artifactId>marmalade-core</artifactId>
<version>1.0-alpha2</version>
</dependency>
<dependency>
<groupId>plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>1.0-alpha-2</version>
</dependency>
<dependency>
<groupId>plexus</groupId>
<artifactId>plexus-marmalade-factory</artifactId>

View File

@ -12,6 +12,18 @@
<version>1.0-alpha-2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>plexus</groupId>
<artifactId>plexus-mail-sender-api</artifactId>
<version>1.0-alpha-1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>plexus</groupId>
<artifactId>plexus-mail-sender-simple</artifactId>
<version>1.0-alpha-1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>plexus</groupId>
<artifactId>plexus-utils</artifactId>

View File

@ -30,6 +30,8 @@ import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.context.Context;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.mailsender.MailMessage;
import org.codehaus.plexus.mailsender.MailSender;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
import org.codehaus.plexus.util.IOUtil;
@ -38,9 +40,11 @@ import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
@ -55,6 +59,8 @@ public class RepositoryCleaner
public static final String ROLE = RepositoryCleaner.class.getName();
private ArtifactDigestVerifier artifactDigestVerifier;
private MailSender mailSender;
private ArtifactConstructionSupport artifactConstructionSupport = new ArtifactConstructionSupport();
@ -68,6 +74,8 @@ public class RepositoryCleaner
File sourceRepositoryBase = normalizeSourceRepositoryBase( configuration.getSourceRepositoryPath() );
File targetRepositoryBase = normalizeTargetRepositoryBase( configuration.getTargetRepositoryPath() );
boolean mailReport = false;
// do not proceed if we cannot produce reports, or if the repository is
// invalid.
@ -162,6 +170,11 @@ public class RepositoryCleaner
{
logger.warn( "Warning encountered while rewriting one or more artifacts from source repository to target repository." );
}
if(repoReporter.hasError())
{
mailReport = true;
}
}
finally
{
@ -170,6 +183,46 @@ public class RepositoryCleaner
repoReporter.close();
}
}
if(mailReport)
{
String reportContents = readReportFile(repoReporter.getReportFile());
MailMessage message = new MailMessage();
message.setContent(reportContents);
message.setSubject("[REPOCLEAN] Error converting repository.");
message.setFromName("Repoclean");
message.setFromAddress("jdcasey@codehaus.org");
message.setSendDate(new Date());
message.addTo("Maven-2 Developers List", "m2-dev@maven.apache.org");
mailSender.send(message);
}
}
}
private String readReportFile( File reportFile ) throws IOException
{
FileReader reader = null;
try
{
reader = new FileReader(reportFile);
StringBuffer reportContent = new StringBuffer();
char[] buffer = new char[512];
int read = -1;
while((read = reader.read(buffer)) > -1)
{
reportContent.append(buffer, 0, read);
}
return reportContent.toString();
}
finally
{
IOUtil.close(reader);
}
}