Initial revision

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@162914 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2004-08-09 18:37:31 +00:00
parent 57922db9c9
commit 15a7eb7ef2
48 changed files with 2979 additions and 0 deletions

11
maven-artifact/.cvsignore Normal file
View File

@ -0,0 +1,11 @@
*~
*.log
target
dist
*.ipr
*.iws
*.iml
dist
target
.classpath
.project

46
maven-artifact/pom.xml Normal file
View File

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>maven</groupId>
<artifactId>maven-artifact</artifactId>
<name>Maven</name>
<version>2.0-SNAPSHOT</version>
<inceptionYear>2001</inceptionYear>
<package>org.apache.maven</package>
<logo>/images/maven.gif</logo>
<dependencies>
<dependency>
<groupId>maven</groupId>
<artifactId>wagon-api</artifactId>
<version>0.9-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>wagon-http-lightweight</artifactId>
<version>0.9-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>plexus</groupId>
<artifactId>plexus</artifactId>
<version>0.16-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>classworlds</groupId>
<artifactId>classworlds</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>xpp3</groupId>
<artifactId>xpp3</artifactId>
<version>1.1.3.3</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,4 @@
maven.log
target
.classpath
.project

View File

@ -0,0 +1,49 @@
package org.apache.maven.artifact;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerNotFoundException;
import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.repository.ArtifactRepository;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
*/
public class AbstractArtifactComponent
extends AbstractLogEnabled
{
private ArtifactHandlerManager artifactHandlerManager;
protected ArtifactHandler getArtifactHandler( String type )
throws ArtifactHandlerNotFoundException
{
return artifactHandlerManager.getArtifactHandler( type );
}
protected String path( Artifact artifact )
{
return artifactHandlerManager.path( artifact );
}
protected void setLocalRepositoryPath( Artifact artifact, ArtifactRepository localRepository )
{
artifact.setPath( artifactHandlerManager.localRepositoryPath( artifact, localRepository ) );
}
}

View File

@ -0,0 +1,52 @@
package org.apache.maven.artifact;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.io.File;
public interface Artifact
{
String getGroupId();
String getArtifactId();
String getVersion();
String getType();
String getExtension();
// ----------------------------------------------------------------------
void setPath( String path );
String getPath();
File getFile();
boolean exists();
// ----------------------------------------------------------------------
File getChecksumFile();
// ----------------------------------------------------------------------
String getId();
String getConflictId();
}

View File

@ -0,0 +1,146 @@
package org.apache.maven.artifact;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.io.File;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
*/
public class DefaultArtifact
implements Artifact
{
// ----------------------------------------------------------------------
// These are the only things i need to specify
// ----------------------------------------------------------------------
private String groupId;
private String artifactId;
private String version;
private String type;
private String extension;
private String path;
public DefaultArtifact( String groupId, String artifactId, String version, String type, String extension )
{
this.groupId = groupId;
this.artifactId = artifactId;
this.version = version;
this.type = type;
this.extension = extension;
}
public DefaultArtifact( String groupId, String artifactId, String version, String type )
{
this( groupId, artifactId, version, type, type );
}
public String getGroupId()
{
return groupId;
}
public String getArtifactId()
{
return artifactId;
}
public String getVersion()
{
return version;
}
public String getType()
{
return type;
}
public String getExtension()
{
if ( extension != null )
{
return extension;
}
return type;
}
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
public String getPath()
{
return path;
}
public void setPath( String path )
{
this.path = path;
}
public boolean exists()
{
return getFile().exists();
}
public File getFile()
{
return new File( getPath() );
}
public File getChecksumFile()
{
return new File( getFile().getAbsolutePath() + ".md5" );
}
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
public String toString()
{
return getId();
}
public String getId()
{
return getGroupId() + ":" +
getArtifactId() + ":" +
getType() + ":" +
getVersion();
}
public String getConflictId()
{
return getGroupId() + ":" +
getArtifactId() + ":" +
getType();
}
}

View File

@ -0,0 +1,34 @@
package org.apache.maven.artifact.deployer;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepository;
import java.io.File;
public interface ArtifactDeployer
{
String ROLE = ArtifactDeployer.class.getName();
void deploy( String basedir, Artifact artifact, ArtifactRepository deploymentRepository )
throws ArtifactDeploymentException;
void deploy( File source, Artifact artifact, ArtifactRepository deploymentRepository )
throws ArtifactDeploymentException;
}

View File

@ -0,0 +1,40 @@
package org.apache.maven.artifact.deployer;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
*/
public class ArtifactDeploymentException
extends Exception
{
public ArtifactDeploymentException( String message )
{
super( message );
}
public ArtifactDeploymentException( Throwable cause )
{
super( cause );
}
public ArtifactDeploymentException( String message, Throwable cause )
{
super( message, cause );
}
}

View File

@ -0,0 +1,65 @@
package org.apache.maven.artifact.deployer;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.AbstractArtifactComponent;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerNotFoundException;
import org.apache.maven.artifact.manager.WagonManager;
import java.io.File;
/**
* @todo snapshot notions need to be dealt with in one place.
*/
public class DefaultArtifactDeployer
extends AbstractArtifactComponent
implements ArtifactDeployer
{
private WagonManager wagonManager;
public void deploy( String basedir, Artifact artifact, ArtifactRepository deploymentRepository )
throws ArtifactDeploymentException
{
File source = null;
try
{
source = getArtifactHandler( artifact.getType() ).source( basedir, artifact );
}
catch ( ArtifactHandlerNotFoundException e )
{
throw new ArtifactDeploymentException( "Error deploying artifact: ", e );
}
deploy( source, artifact, deploymentRepository );
}
public void deploy( File source, Artifact artifact, ArtifactRepository deploymentRepository )
throws ArtifactDeploymentException
{
try
{
wagonManager.put( source, artifact, deploymentRepository );
}
catch ( Exception e )
{
throw new ArtifactDeploymentException( "Error deploying artifact: ", e );
}
}
}

View File

@ -0,0 +1,45 @@
package org.apache.maven.artifact.handler;
import org.apache.maven.artifact.Artifact;
import org.codehaus.plexus.util.StringUtils;
import java.io.File;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
*/
public abstract class AbstractArtifactHandler
implements ArtifactHandler
{
public File source( String basedir, Artifact artifact )
{
return new File( basedir, artifact.getArtifactId() + "-" + artifact.getVersion() + "." + extension() );
}
public String extension()
{
return "jar";
}
public String directory()
{
return "jars";
}
}

View File

@ -0,0 +1,36 @@
package org.apache.maven.artifact.handler;
import org.apache.maven.artifact.Artifact;
import java.io.File;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
*/
public interface ArtifactHandler
{
static String ROLE = ArtifactHandler.class.getName();
File source( String basedir, Artifact artifact );
String extension();
String directory();
}

View File

@ -0,0 +1,30 @@
package org.apache.maven.artifact.handler;
import org.apache.maven.artifact.Artifact;
import java.io.File;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
*/
public class JarHandler
extends AbstractArtifactHandler
{
}

View File

@ -0,0 +1,34 @@
package org.apache.maven.artifact.handler;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.maven.artifact.Artifact;
import java.io.File;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
*/
public class PluginHandler
extends AbstractArtifactHandler
{
public String directory()
{
return "plugins";
}
}

View File

@ -0,0 +1,39 @@
package org.apache.maven.artifact.handler;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.maven.artifact.Artifact;
import java.io.File;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
*/
public class PomHandler
extends AbstractArtifactHandler
{
public String extension()
{
return "pom";
}
public String directory()
{
return "poms";
}
}

View File

@ -0,0 +1,30 @@
package org.apache.maven.artifact.handler;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.maven.artifact.Artifact;
import java.io.File;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
*/
public class TestHandler
extends AbstractArtifactHandler
{
}

View File

@ -0,0 +1,42 @@
package org.apache.maven.artifact.handler.manager;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.repository.ArtifactRepository;
import java.util.Set;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
*/
public interface ArtifactHandlerManager
{
String ROLE = ArtifactHandlerManager.class.getName();
ArtifactHandler getArtifactHandler( String type )
throws ArtifactHandlerNotFoundException;
String localRepositoryPath( Artifact artifact, ArtifactRepository localRepository );
String path( Artifact artifact );
Set getHandlerTypes();
}

View File

@ -0,0 +1,40 @@
package org.apache.maven.artifact.handler.manager;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
*/
public class ArtifactHandlerNotFoundException
extends Exception
{
public ArtifactHandlerNotFoundException( String message )
{
super( message );
}
public ArtifactHandlerNotFoundException( Throwable cause )
{
super( cause );
}
public ArtifactHandlerNotFoundException( String message, Throwable cause )
{
super( message, cause );
}
}

View File

@ -0,0 +1,112 @@
package org.apache.maven.artifact.handler.manager;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.codehaus.plexus.util.StringUtils;
import java.util.Map;
import java.util.Set;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
*/
public class DefaultArtifactHandlerManager
implements ArtifactHandlerManager
{
private Map artifactHandlers;
public ArtifactHandler getArtifactHandler( String type )
throws ArtifactHandlerNotFoundException
{
ArtifactHandler handler = (ArtifactHandler) artifactHandlers.get( type );
if ( handler == null )
{
throw new ArtifactHandlerNotFoundException(
"Artifact handler for type '" + type + "' cannot be found." );
}
return handler;
}
public Set getHandlerTypes()
{
return artifactHandlers.keySet();
}
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
private String layout;
public String getLayout()
{
if ( layout == null )
{
return "${groupId}/${directory}/${artifactId}-${version}.${extension}";
}
return layout;
}
public String localRepositoryPath( Artifact artifact, ArtifactRepository localRepository )
{
return localRepository.getBasedir() + "/" + path( artifact );
}
public String artifactUrl( Artifact artifact, ArtifactRepository remoteRepository )
{
return remoteRepository.getUrl() + "/" + path( artifact );
}
public String path( Artifact artifact )
{
ArtifactHandler handler = (ArtifactHandler) artifactHandlers.get( artifact.getType() );
return interpolateLayout( artifact.getGroupId(),
artifact.getArtifactId(),
artifact.getVersion(),
handler.directory(),
handler.extension() );
}
private String interpolateLayout( String groupId,
String artifactId,
String version,
String directory,
String extension )
{
String layout = getLayout();
layout = StringUtils.replace( layout, "${groupId}", groupId );
layout = StringUtils.replace( layout, "${artifactId}", artifactId );
layout = StringUtils.replace( layout, "${directory}", directory );
layout = StringUtils.replace( layout, "${version}", version );
layout = StringUtils.replace( layout, "${extension}", extension );
return layout;
}
}

View File

@ -0,0 +1,40 @@
package org.apache.maven.artifact.installer;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
*/
public class ArtifactInstallationException
extends Exception
{
public ArtifactInstallationException( String message )
{
super( message );
}
public ArtifactInstallationException( Throwable cause )
{
super( cause );
}
public ArtifactInstallationException( String message, Throwable cause )
{
super( message, cause );
}
}

View File

@ -0,0 +1,38 @@
package org.apache.maven.artifact.installer;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepository;
import java.io.File;
/**
* @author <a href="michal@codehaus.org">Michal Maczka</a>
* @version $Id$
*/
public interface ArtifactInstaller
{
String ROLE = ArtifactInstaller.class.getName();
void install( String basedir, Artifact artifact, ArtifactRepository localRepository )
throws ArtifactInstallationException;
void install( File source, Artifact artifact, ArtifactRepository localRepository )
throws ArtifactInstallationException;
}

View File

@ -0,0 +1,72 @@
package org.apache.maven.artifact.installer;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.maven.artifact.AbstractArtifactComponent;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerNotFoundException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.codehaus.plexus.util.FileUtils;
import java.io.File;
/**
* @todo notions of snapshots should be dealt with in one single place.
*/
public class DefaultArtifactInstaller
extends AbstractArtifactComponent
implements ArtifactInstaller
{
public void install( String basedir, Artifact artifact, ArtifactRepository localRepository )
throws ArtifactInstallationException
{
File source = null;
try
{
source = getArtifactHandler( artifact.getType() ).source( basedir, artifact );
}
catch ( ArtifactHandlerNotFoundException e )
{
throw new ArtifactInstallationException( "Error installing artifact: ", e );
}
install( source, artifact, localRepository );
}
public void install( File source, Artifact artifact, ArtifactRepository localRepository )
throws ArtifactInstallationException
{
setLocalRepositoryPath( artifact, localRepository );
if ( !artifact.getFile().getParentFile().exists() )
{
artifact.getFile().getParentFile().mkdirs();
}
try
{
getLogger().info( "Installing " + source.getPath() + " to " + artifact.getPath() );
FileUtils.copyFile( source, artifact.getFile() );
}
catch ( Exception e )
{
throw new ArtifactInstallationException( "Error installing artifact: ", e );
}
}
}

View File

@ -0,0 +1,223 @@
package org.apache.maven.artifact.manager;
/* ====================================================================
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.AbstractArtifactComponent;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.wagon.ConnectionException;
import org.apache.maven.wagon.ResourceDoesNotExistException;
import org.apache.maven.wagon.TransferFailedException;
import org.apache.maven.wagon.UnsupportedProtocolException;
import org.apache.maven.wagon.Wagon;
import org.apache.maven.wagon.authentication.AuthenticationException;
import org.apache.maven.wagon.authorization.AuthorizationException;
import org.apache.maven.wagon.observers.ChecksumObserver;
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.context.Context;
import org.codehaus.plexus.context.ContextException;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
import java.io.File;
import java.util.Iterator;
import java.util.Set;
public class DefaultWagonManager
extends AbstractArtifactComponent
implements WagonManager, Contextualizable
{
private PlexusContainer container;
public Wagon getWagon( String protocol )
throws UnsupportedProtocolException
{
Wagon wagon;
try
{
wagon = (Wagon) container.lookup( Wagon.ROLE, protocol );
}
catch ( ComponentLookupException e )
{
throw new UnsupportedProtocolException( "Cannot find wagon which supports the requested protocol: " + protocol );
}
return wagon;
}
/**
* @param wagon
* @throws Exception
* @todo how we can handle exception here? Maybe we should just swallow it?
* Plexus exception handling is not very precise here (it sucks in short words:) )
* Maybe plexus should not throw any exception here as this is internal problem of plexus
* and any ingeration from outside or intelligent error handlig are rather excluded.
*/
public void releaseWagon( Wagon wagon )
throws Exception
{
container.release( wagon );
}
public void put( File source, Artifact artifact, ArtifactRepository repository )
throws Exception
{
Wagon wagon = getWagon( repository.getProtocol() );
wagon.connect( repository );
wagon.put( source, path( artifact ) );
wagon.disconnect();
releaseWagon( wagon );
}
/**
* Get the requested artifact from any of the remote repositories and place in
* the specified local ArtifactRepository.
*
* @param artifact
* @param remoteRepositories
* @param localRepository
* @throws TransferFailedException
*/
public void get( Artifact artifact, Set remoteRepositories, ArtifactRepository localRepository )
throws TransferFailedException
{
get( artifact, artifact.getFile(), remoteRepositories );
}
/**
* Look in a set of repositories and return when the first valid artifact is
* found.
*/
/**
* @param artifact
* @param destination
* @throws TransferFailedException
* @todo I want to somehow plug artifact validators at such low level.
* Simply if artifact was downloaded but it was rejected by validator(s)
* the loop should continue. Some of the validators can be feeded directly using events
* so number of i/o operation could be limited.
* <p/>
* If we won't plug validation process here the question is what we can do afterwards?
* We don't know from which ArtifactRepository artifact was fetched and where we should restart.
* We should be also fetching md5 sums and such from the same exact directory then artifacts
*/
public void get( Artifact artifact, File destination, Set repositories )
throws TransferFailedException
{
boolean transfered = false;
File temp = null;
try
{
temp = File.createTempFile( "wagon", "tmp" );
temp.deleteOnExit();
}
catch ( Exception e )
{
throw new TransferFailedException( "Could not create temporary file for transfering artificat: " + artifact );
}
for ( Iterator iter = repositories.iterator(); iter.hasNext(); )
{
ArtifactRepository repository = (ArtifactRepository) iter.next();
try
{
Wagon wagon = getWagon( repository.getProtocol() );
// ----------------------------------------------------------------------
// These can certainly be configurable ... registering listeners ...
//ChecksumObserver md5SumObserver = new ChecksumObserver();
// ----------------------------------------------------------------------
//wagon.addTransferListener( md5SumObserver );
wagon.connect( repository );
wagon.get( path( artifact ), temp );
transfered = true;
wagon.disconnect();
releaseWagon( wagon );
}
catch ( UnsupportedProtocolException e )
{
throw new TransferFailedException( "Unsupported Protocol: ", e );
}
catch ( ConnectionException e )
{
throw new TransferFailedException( "Connection failed: ", e );
}
catch ( AuthenticationException e )
{
throw new TransferFailedException( "Authentication failed: ", e );
}
catch ( AuthorizationException e )
{
throw new TransferFailedException( "Authorization failed: ", e );
}
catch ( ResourceDoesNotExistException e )
{
throw new TransferFailedException( "Resource doesn't exist: ", e );
}
catch ( Exception e )
{
throw new TransferFailedException( "Release of wagon failed: ", e );
}
}
if ( transfered )
{
if ( !destination.getParentFile().exists() )
{
destination.getParentFile().mkdirs();
}
transfered = temp.renameTo( destination );
return;
}
else
{
temp.delete();
}
}
public void contextualize( Context context )
throws ContextException
{
container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
}
}

View File

@ -0,0 +1,50 @@
package org.apache.maven.artifact.manager;
/* ====================================================================
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.wagon.TransferFailedException;
import org.apache.maven.wagon.UnsupportedProtocolException;
import org.apache.maven.wagon.Wagon;
import java.io.File;
import java.util.Set;
/**
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
* @version $Id$
*/
public interface WagonManager
{
String ROLE = WagonManager.class.getName();
Wagon getWagon( String protocol )
throws UnsupportedProtocolException;
void releaseWagon( Wagon wagon )
throws Exception;
void get( Artifact artifact, Set remoteRepositories, ArtifactRepository localRepository )
throws TransferFailedException;
void put( File source, Artifact artifact, ArtifactRepository deploymentRepository )
throws Exception;
}

View File

@ -0,0 +1,40 @@
package org.apache.maven.artifact.metadata;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
*/
public class ArtifactMetadataRetrievalException
extends Exception
{
public ArtifactMetadataRetrievalException( String message )
{
super( message );
}
public ArtifactMetadataRetrievalException( Throwable cause )
{
super( cause );
}
public ArtifactMetadataRetrievalException( String message, Throwable cause )
{
super( message, cause );
}
}

View File

@ -0,0 +1,37 @@
package org.apache.maven.artifact.metadata;
import org.apache.maven.artifact.Artifact;
import java.io.Reader;
import java.util.Set;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Currently the only thing we need from the artifact metadata source is the
// dependency information, but i figure I'll just leave this generally as a
// metadata retrieval mechanism so we can retrieve whatever metadata about
// the artifact we may wish to provide in this layer. jvz.
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
*/
public interface ArtifactMetadataSource
{
Set retrieve( Artifact artifact )
throws ArtifactMetadataRetrievalException;
}

View File

@ -0,0 +1,90 @@
package org.apache.maven.artifact.repository;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.maven.wagon.repository.Repository;
import org.codehaus.plexus.util.StringUtils;
/**
* This class is an abstraction of the location from/to resources
* can be transfered.
*
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
* @version $Id$
*/
public class ArtifactRepository
extends Repository
{
public ArtifactRepository()
{
}
public ArtifactRepository( String id, String url)
{
super( id, url );
}
/*
private String layout;
public String getLayout()
{
if ( layout == null )
{
return "${groupId}/${type}s/${artifactId}-${version}.${extension}";
}
return layout;
}
public String artifactPath( Artifact artifact )
{
return interpolateLayout( artifact.getGroupId(),
artifact.getArtifactId(),
artifact.getVersion(),
artifact.getType(),
artifact.getExtension() );
}
public String fullArtifactPath( Artifact artifact )
{
return getBasedir() + "/" + artifactPath( artifact );
}
public String artifactUrl( Artifact artifact )
{
return getUrl() + "/" + artifactPath( artifact );
}
private String interpolateLayout( String groupId, String artifactId, String version, String type, String extension )
{
String layout = getLayout();
layout = StringUtils.replace( layout, "${groupId}", groupId );
layout = StringUtils.replace( layout, "${artifactId}", artifactId );
layout = StringUtils.replace( layout, "${type}", type );
layout = StringUtils.replace( layout, "${version}", version );
layout = StringUtils.replace( layout, "${extension}", extension );
return layout;
}
*/
}

View File

@ -0,0 +1,26 @@
package org.apache.maven.artifact.request;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
*/
public class ArtifactRequest
{
}

View File

@ -0,0 +1,46 @@
package org.apache.maven.artifact.request;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepository;
import java.util.Map;
import java.util.Set;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
*/
public interface ArtifactRequestTransformation
{
static String ROLE = ArtifactRequestTransformation.class.getName();
/**
* Take in a artifact and return the transformed artifact. If no
* transformation has occured the original artifact is returned.
*
* @param artifact Artifact to be transformed.
* @return The transformed Artifact
*/
Artifact transform( Artifact artifact,
ArtifactRepository localRepository,
Set remoteRepositories,
Map parameters )
throws Exception;
}

View File

@ -0,0 +1,40 @@
package org.apache.maven.artifact.request;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
*/
public class ArtifactRequestTransformationException
extends Exception
{
public ArtifactRequestTransformationException( String message )
{
super( message );
}
public ArtifactRequestTransformationException( Throwable cause )
{
super( cause );
}
public ArtifactRequestTransformationException( String message, Throwable cause )
{
super( message, cause );
}
}

View File

@ -0,0 +1,40 @@
package org.apache.maven.artifact.resolver;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
*/
public class ArtifactCollectionException
extends Exception
{
public ArtifactCollectionException( String message )
{
super( message );
}
public ArtifactCollectionException( Throwable cause )
{
super( cause );
}
public ArtifactCollectionException( String message, Throwable cause )
{
super( message, cause );
}
}

View File

@ -0,0 +1,42 @@
package org.apache.maven.artifact.resolver;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
*/
public class ArtifactResolutionException
extends Exception
{
public ArtifactResolutionException( String message )
{
super( message );
}
public ArtifactResolutionException( Throwable cause )
{
super( cause );
}
public ArtifactResolutionException( String message, Throwable cause )
{
super( message, cause );
}
}

View File

@ -0,0 +1,48 @@
package org.apache.maven.artifact.resolver;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.util.HashMap;
import java.util.Map;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
*/
public class ArtifactResolutionResult
{
private Map artifacts;
private Map conflicts;
public ArtifactResolutionResult()
{
artifacts = new HashMap();
conflicts = new HashMap();
}
public Map getArtifacts()
{
return artifacts;
}
public Map getConflicts()
{
return conflicts;
}
}

View File

@ -0,0 +1,43 @@
package org.apache.maven.artifact.resolver;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
import java.util.Set;
/**
* I want to use it for hidding the fact that sometime artifact must
* be downloaded. I am just asking LocalRepository for given artifact
* and I don't care if it is alredy there or how it will get there.
*
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
* @version $Id$
*/
public interface ArtifactResolver
{
static String ROLE = ArtifactResolver.class.getName();
Artifact resolve( Artifact artifact,
Set remoteRepositories,
ArtifactRepository localRepository )
throws ArtifactResolutionException;
ArtifactResolutionResult resolveTransitively( Artifact artifact,
Set remoteRepositories,
ArtifactRepository localRepository,
ArtifactMetadataSource source )
throws ArtifactResolutionException;
Set resolve( Set artifacts,
Set remoteRepositories,
ArtifactRepository localRepository )
throws ArtifactResolutionException;
ArtifactResolutionResult resolveTransitively( Set artifacts,
Set remoteRepositories,
ArtifactRepository localRepository,
ArtifactMetadataSource source )
throws ArtifactResolutionException;
}

View File

@ -0,0 +1,255 @@
package org.apache.maven.artifact.resolver;
import org.apache.maven.artifact.AbstractArtifactComponent;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.manager.WagonManager;
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.wagon.TransferFailedException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
// ArtifactSourceReader to ArtifactMetadataReader
// Possibly give the resolver the metadata reader
// resolver.setMetadataReader( foo )
// resolver.setRepositories( Set )
// resolveTransitively instead of parameter
public class DefaultArtifactResolver
extends AbstractArtifactComponent
implements ArtifactResolver
{
private WagonManager wagonManager;
public Artifact resolve( Artifact artifact,
Set remoteRepositories,
ArtifactRepository localRepository )
throws ArtifactResolutionException
{
// ----------------------------------------------------------------------
// Perform any transformation on the artifacts
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
// Check for the existence of the artifact in the specified local
// ArtifactRepository. If it is present then simply return as the request
// for resolution has been satisfied.
// ----------------------------------------------------------------------
setLocalRepositoryPath( artifact, localRepository );
if ( artifact.exists() )
{
return artifact;
}
try
{
wagonManager.get( artifact, remoteRepositories, localRepository );
}
catch ( TransferFailedException e )
{
throw new ArtifactResolutionException( artifactNotFound( artifact,
remoteRepositories,
localRepository ), e );
}
return artifact;
}
private String artifactNotFound( Artifact artifact,
Set remoteRepositories,
ArtifactRepository localRepository )
{
StringBuffer sb = new StringBuffer();
sb.append( "The artifact is not present locally as:" )
.append( "\n" )
.append( artifact.getPath() )
.append( "\n" )
.append( "or in any of the specified remote repositories:" )
.append( "\n" );
for ( Iterator i = remoteRepositories.iterator(); i.hasNext(); )
{
ArtifactRepository remoteRepository = (ArtifactRepository) i.next();
sb.append( remoteRepository.getUrl() );
}
return sb.toString();
}
public Set resolve( Set artifacts,
Set remoteRepositories,
ArtifactRepository localRepository )
throws ArtifactResolutionException
{
Set resolvedArtifacts = new HashSet();
for ( Iterator i = artifacts.iterator(); i.hasNext(); )
{
Artifact artifact = (Artifact) i.next();
Artifact resolvedArtifact = resolve( artifact, remoteRepositories, localRepository );
resolvedArtifacts.add( resolvedArtifact );
}
return resolvedArtifacts;
}
// ----------------------------------------------------------------------
// Transitive modes
// ----------------------------------------------------------------------
public ArtifactResolutionResult resolveTransitively( Set artifacts,
Set remoteRepositories,
ArtifactRepository localRepository,
ArtifactMetadataSource source )
throws ArtifactResolutionException
{
try
{
ArtifactResolutionResult artifactResolutionResult = collect( artifacts,
localRepository,
remoteRepositories,
source );
for ( Iterator i = artifactResolutionResult.getArtifacts().values().iterator(); i.hasNext(); )
{
resolve( (Artifact) i.next(), remoteRepositories, localRepository );
}
return artifactResolutionResult;
}
catch ( ArtifactCollectionException e )
{
throw new ArtifactResolutionException( "Error while resolving transitive dependencies: ", e );
}
}
public ArtifactResolutionResult resolveTransitively( Artifact artifact,
Set remoteRepositories,
ArtifactRepository localRepository,
ArtifactMetadataSource source )
throws ArtifactResolutionException
{
Set s = new HashSet();
s.add( artifact );
return resolveTransitively( s, remoteRepositories, localRepository, source );
}
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
public ArtifactResolutionResult collect( Set artifacts,
ArtifactRepository localRepository,
Set remoteRepositories,
ArtifactMetadataSource source )
throws ArtifactCollectionException
{
ArtifactResolutionResult result = new ArtifactResolutionResult();
Map resolvedArtifacts = new HashMap();
List queue = new LinkedList();
queue.add( artifacts );
while ( !queue.isEmpty() )
{
Set currentArtifacts = (Set) queue.remove( 0 );
for ( Iterator i = currentArtifacts.iterator(); i.hasNext(); )
{
Artifact newArtifact = (Artifact) i.next();
String id = newArtifact.getConflictId();
if ( resolvedArtifacts.containsKey( id ) )
{
Artifact knownArtifact = (Artifact) resolvedArtifacts.get( id );
String newVersion = newArtifact.getVersion();
String knownVersion = knownArtifact.getVersion();
if ( !newVersion.equals( knownVersion ) )
{
/*
getLogger().warn( "Version conflict: " + id + ", " +
"using version: " + knownArtifact.getVersion() + ", " +
"found version: " + newArtifact.getVersion() );
addConflict( result, knownArtifact, newArtifact );
*/
}
}
else
{
//It's the first time we have encountered this artifact
resolvedArtifacts.put( id, newArtifact );
Set referencedDependencies = null;
try
{
referencedDependencies = source.retrieve( newArtifact );
}
catch ( Exception e )
{
throw new ArtifactCollectionException( "Problem building project: ", e );
}
// the pom for given dependency exisit we will add it to the queue
queue.add( referencedDependencies );
}
}
}
// the dependencies list is keyed by groupId+artifactId+type
// so it must be 'rekeyed' to the complete id: groupId+artifactId+type+version
Map artifactResult = result.getArtifacts();
for ( Iterator it = resolvedArtifacts.values().iterator(); it.hasNext(); )
{
Artifact artifact = (Artifact) it.next();
setLocalRepositoryPath( artifact, localRepository );
artifactResult.put( artifact.getId(), artifact );
}
return result;
}
private void addConflict( ArtifactResolutionResult result, Artifact knownArtifact, Artifact newArtifact )
{
List conflicts;
conflicts = (List) result.getConflicts().get( newArtifact.getConflictId() );
if ( conflicts == null )
{
conflicts = new LinkedList();
conflicts.add( knownArtifact );
result.getConflicts().put( newArtifact.getConflictId(), conflicts );
}
conflicts.add( newArtifact );
}
}

View File

@ -0,0 +1,25 @@
package org.apache.maven.artifact.resolver.conflict;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
*/
public interface ConflictResolver
{
}

View File

@ -0,0 +1,26 @@
package org.apache.maven.artifact.resolver.conflict;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
*/
public class DefaultConflictResolver
implements ConflictResolver
{
}

View File

@ -0,0 +1,111 @@
<component-set>
<components>
<!--
|
| Resolver
|
-->
<component>
<role>org.apache.maven.artifact.resolver.ArtifactResolver</role>
<implementation>org.apache.maven.artifact.resolver.DefaultArtifactResolver</implementation>
<requirements>
<requirement>
<role>org.apache.maven.artifact.manager.WagonManager</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
</requirement>
</requirements>
</component>
<!--
|
| WagonManager
|
-->
<component>
<role>org.apache.maven.artifact.manager.WagonManager</role>
<implementation>org.apache.maven.artifact.manager.DefaultWagonManager</implementation>
<requirements>
<requirement>
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
</requirement>
</requirements>
</component>
<!--
|
| ArtifactInstaller
|
-->
<component>
<role>org.apache.maven.artifact.installer.ArtifactInstaller</role>
<implementation>org.apache.maven.artifact.installer.DefaultArtifactInstaller</implementation>
<requirements>
<requirement>
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
</requirement>
</requirements>
</component>
<!--
|
| ArtifactDeployer
|
-->
<component>
<role>org.apache.maven.artifact.deployer.ArtifactDeployer</role>
<implementation>org.apache.maven.artifact.deployer.DefaultArtifactDeployer</implementation>
<requirements>
<requirement>
<role>org.apache.maven.artifact.manager.WagonManager</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
</requirement>
</requirements>
</component>
<!--
|
| ArtifactHandlerManager
|
-->
<component>
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
<implementation>org.apache.maven.artifact.handler.manager.DefaultArtifactHandlerManager</implementation>
<requirements>
<requirement>
<role>org.apache.maven.artifact.handler.ArtifactHandler</role>
<field-name>artifactHandlers</field-name>
</requirement>
</requirements>
</component>
<component>
<role>org.apache.maven.artifact.handler.ArtifactHandler</role>
<role-hint>jar</role-hint>
<implementation>org.apache.maven.artifact.handler.JarHandler</implementation>
</component>
<component>
<role>org.apache.maven.artifact.handler.ArtifactHandler</role>
<role-hint>plugin</role-hint>
<implementation>org.apache.maven.artifact.handler.PluginHandler</implementation>
</component>
<component>
<role>org.apache.maven.artifact.handler.ArtifactHandler</role>
<role-hint>test</role-hint>
<implementation>org.apache.maven.artifact.handler.TestHandler</implementation>
</component>
<component>
<role>org.apache.maven.artifact.handler.ArtifactHandler</role>
<role-hint>pom</role-hint>
<implementation>org.apache.maven.artifact.handler.PomHandler</implementation>
</component>
</components>
</component-set>

View File

@ -0,0 +1,191 @@
package org.apache.maven.artifact;
import org.codehaus.plexus.PlexusTestCase;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
import org.apache.maven.artifact.repository.ArtifactRepository;
import java.io.File;
import java.io.Writer;
import java.io.FileWriter;
import java.util.Set;
import java.util.HashSet;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
*/
public abstract class ArtifactComponentTestCase
extends PlexusTestCase
{
protected ArtifactHandlerManager artifactHandlerManager;
protected void setUp()
throws Exception
{
super.setUp();
artifactHandlerManager = (ArtifactHandlerManager) lookup( ArtifactHandlerManager.ROLE );
}
protected abstract String component();
protected ArtifactRepository localRepository()
{
ArtifactRepository localRepository = new ArtifactRepository();
localRepository.setUrl( "file://" + "target/test-classes/repositories/" + component() + "/local-repository" );
return localRepository;
}
protected ArtifactRepository remoteRepository()
{
ArtifactRepository localRepository = new ArtifactRepository();
localRepository.setUrl( "file://" + "target/test-classes/repositories/" + component() + "/remote-repository" );
return localRepository;
}
protected void assertRemoteArtifactPresent( Artifact artifact )
{
String path = artifactHandlerManager.path( artifact );
File file = new File( remoteRepository().getBasedir(), path );
if ( !file.exists() )
{
fail( "Local artifact " + file + " should be present." );
}
}
protected void assertLocalArtifactPresent( Artifact artifact )
{
String path = artifactHandlerManager.path( artifact );
File file = new File( localRepository().getBasedir(), path );
if ( !file.exists() )
{
fail( "Remote artifact " + file + " should be present." );
}
}
protected void assertRemoteArtifactNotPresent( Artifact artifact )
{
String path = artifactHandlerManager.path( artifact );
File file = new File( remoteRepository().getBasedir(), path );
if ( file.exists() )
{
fail( "Local artifact " + file + " should not be present." );
}
}
protected void assertLocalArtifactNotPresent( Artifact artifact )
{
String path = artifactHandlerManager.path( artifact );
File file = new File( localRepository().getBasedir(), path );
if ( file.exists() )
{
fail( "Remote artifact " + file + " should not be present." );
}
}
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
protected Set remoteRepositories()
{
Set remoteRepositories = new HashSet();
remoteRepositories.add( remoteRepository() );
return remoteRepositories;
}
// ----------------------------------------------------------------------
// Test artifact generation for unit tests
// ----------------------------------------------------------------------
protected Artifact createLocalArtifact( String artifactId, String version )
throws Exception
{
Artifact artifact = createArtifact( artifactId, version );
createArtifact( artifact, localRepository() );
return artifact;
}
protected Artifact createRemoteArtifact( String artifactId, String version )
throws Exception
{
Artifact artifact = createArtifact( artifactId, version );
createArtifact( artifact, remoteRepository() );
return artifact;
}
protected void createLocalArtifact( Artifact artifact )
throws Exception
{
createArtifact( artifact, localRepository() );
}
protected void createRemoteArtifact( Artifact artifact )
throws Exception
{
createArtifact( artifact, remoteRepository() );
}
protected void createArtifact( Artifact artifact, ArtifactRepository repository )
throws Exception
{
String path = artifactHandlerManager.path( artifact );
File artifactFile = new File( repository.getBasedir(), path );
if ( !artifactFile.getParentFile().exists() )
{
artifactFile.getParentFile().mkdirs();
}
Writer writer = new FileWriter( artifactFile );
writer.write( artifact.getId() );
writer.close();
}
protected Artifact createArtifact( String artifactId, String version )
{
return createArtifact( artifactId, version, "jar" );
}
protected Artifact createArtifact( String artifactId, String version, String type )
{
return new DefaultArtifact( "maven", artifactId, version, type );
}
}

View File

@ -0,0 +1,57 @@
package org.apache.maven.artifact.deployer;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.ArtifactComponentTestCase;
import java.io.File;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
*/
public class ArtifactDeployerTest
extends ArtifactComponentTestCase
{
private ArtifactDeployer artifactDeployer;
protected void setUp()
throws Exception
{
super.setUp();
artifactDeployer = (ArtifactDeployer) lookup( ArtifactDeployer.ROLE );
}
protected String component()
{
return "deployer";
}
public void testArtifactInstallation()
throws Exception
{
String artifactBasedir = new File( basedir, "src/test/resources/artifact-install" ).getAbsolutePath();
Artifact artifact = createArtifact( "artifact", "1.0" );
artifactDeployer.deploy( artifactBasedir, artifact, remoteRepository() );
assertRemoteArtifactPresent( artifact );
}
}

View File

@ -0,0 +1,58 @@
package org.apache.maven.artifact.installer;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.maven.artifact.ArtifactComponentTestCase;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact;
import java.io.File;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
*/
public class ArtifactInstallerTest
extends ArtifactComponentTestCase
{
private ArtifactInstaller artifactInstaller;
protected void setUp()
throws Exception
{
super.setUp();
artifactInstaller = (ArtifactInstaller) lookup( ArtifactInstaller.ROLE );
}
protected String component()
{
return "installer";
}
public void testArtifactInstallation()
throws Exception
{
String artifactBasedir = new File( basedir, "src/test/resources/artifact-install" ).getAbsolutePath();
Artifact artifact = createArtifact( "artifact", "1.0" );
artifactInstaller.install( artifactBasedir, artifact, localRepository() );
assertLocalArtifactPresent( artifact );
}
}

View File

@ -0,0 +1,74 @@
package org.apache.maven.artifact.manager;
/* ====================================================================
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
import org.apache.maven.wagon.UnsupportedProtocolException;
import org.apache.maven.wagon.Wagon;
import org.codehaus.plexus.PlexusTestCase;
/**
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
* @version $Id$
*/
public class DefaultWagonManagerTest
extends PlexusTestCase
{
public void testDefaultWagonManager()
throws Exception
{
WagonManager wagonManager = (WagonManager) lookup( WagonManager.ROLE );
Wagon wagon = null;
try
{
wagon = (Wagon) wagonManager.getWagon( "a" );
assertNotNull( wagon );
wagon = (Wagon) wagonManager.getWagon( "b1" );
assertNotNull( wagon );
wagon = (Wagon) wagonManager.getWagon( "b2" );
assertNotNull( wagon );
wagon = (Wagon) wagonManager.getWagon( "c" );
assertNotNull( wagon );
}
catch ( Exception e )
{
e.printStackTrace();
fail( e.getMessage() );
}
try
{
wagon = (Wagon) wagonManager.getWagon( "d" );
fail( "Expected :" + UnsupportedProtocolException.class.getName() );
}
catch ( UnsupportedProtocolException e )
{
//ok
}
}
}

View File

@ -0,0 +1,36 @@
package org.apache.maven.artifact.manager;
/* ====================================================================
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
import org.apache.maven.wagon.providers.file.FileWagon;
/**
*
*
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
*
* @version $Id$
*/
public class WagonA
extends FileWagon
{
public String[] getSupportedProtocols()
{
return new String[]{ "a" };
}
}

View File

@ -0,0 +1,36 @@
package org.apache.maven.artifact.manager;
/* ====================================================================
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
import org.apache.maven.wagon.providers.file.FileWagon;
/**
*
*
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
*
* @version $Id$
*/
public class WagonB
extends FileWagon
{
public String[] getSupportedProtocols()
{
return new String[]{ "b1", "b2" };
}
}

View File

@ -0,0 +1,36 @@
package org.apache.maven.artifact.manager;
/* ====================================================================
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
import org.apache.maven.wagon.providers.file.FileWagon;
/**
*
*
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
*
* @version $Id$
*/
public class WagonC
extends FileWagon
{
public String[] getSupportedProtocols()
{
return new String[]{ "c" };
}
}

View File

@ -0,0 +1,224 @@
package org.apache.maven.artifact.resolver;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.maven.artifact.ArtifactComponentTestCase;
import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.codehaus.plexus.util.FileUtils;
import java.io.File;
import java.io.Writer;
import java.io.FileWriter;
import java.util.Set;
import java.util.HashSet;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
*/
// It would be cool if there was a hook that i could use to setup a test environment.
// I want to setup a local/remote repositories for testing but i don't want to have
// to change them when i change the layout of the repositories. So i want to generate
// the structure i want to test by using the artifact handler manager which dictates
// the layout used for a particular artifact type.
public class ArtifactResolverTest
extends ArtifactComponentTestCase
{
private ArtifactResolver artifactResolver;
protected void setUp()
throws Exception
{
super.setUp();
artifactResolver = (ArtifactResolver) lookup( ArtifactResolver.ROLE );
}
protected String component()
{
return "resolver";
}
public void testResolutionOfASingleArtifactWhereTheArtifactIsPresentInTheLocalRepository()
throws Exception
{
Artifact a = createLocalArtifact( "a", "1.0" );
artifactResolver.resolve( a, remoteRepositories(), localRepository() );
assertLocalArtifactPresent( a );
}
public void testResolutionOfASingleArtifactWhereTheArtifactIsNotPresentLocallyAndMustBeRetrievedFromTheRemoteRepository()
throws Exception
{
Artifact b = createLocalArtifact( "b", "1.0" );
artifactResolver.resolve( b, remoteRepositories(), localRepository() );
assertLocalArtifactPresent( b );
}
public void testResolutionOfASetOfArtifactsWhereTheArtifactsArePresentInTheLocalRepository()
throws Exception
{
Set artifacts = new HashSet();
Artifact c = createLocalArtifact( "c", "1.0" );
Artifact d = createLocalArtifact( "d", "1.0" );
artifacts.add( c );
artifacts.add( d );
Set resolvedArtifacts = artifactResolver.resolve( artifacts, remoteRepositories(), localRepository() );
assertEquals( 2, resolvedArtifacts.size() );
// The artifacts have undergone no transformations and they are present so the original
// artifacts sent into the resolver should be returned as they were sent in.
assertTrue( resolvedArtifacts.contains( c ) );
assertTrue( resolvedArtifacts.contains( d ) );
}
public void testResolutionOfASetOfArtifactsWhereTheArtifactsAreNotPresentInTheLocalRepositoryAndMustBeRetrievedFromTheRemoteRepository()
throws Exception
{
Set artifacts = new HashSet();
Artifact e = createRemoteArtifact( "e", "1.0" );
Artifact f = createRemoteArtifact( "f", "1.0" );
artifacts.add( e );
artifacts.add( f );
Set resolvedArtifacts = artifactResolver.resolve( artifacts, remoteRepositories(), localRepository() );
assertEquals( 2, resolvedArtifacts.size() );
// The artifacts have undergone no transformations and they are present so the original
// artifacts sent into the resolver should be returned as they were sent in.
assertTrue( resolvedArtifacts.contains( e ) );
assertTrue( resolvedArtifacts.contains( f ) );
}
public void testTransitiveResolutionWhereAllArtifactsArePresentInTheLocalRepository()
throws Exception
{
Artifact g = createLocalArtifact( "g", "1.0" );
Artifact h = createLocalArtifact( "h", "1.0" );
ArtifactMetadataSource mds = new ArtifactMetadataSource()
{
public Set retrieve( Artifact artifact )
throws ArtifactMetadataRetrievalException
{
Set dependencies = new HashSet();
if ( artifact.getArtifactId().equals( "g" ) )
{
try
{
dependencies.add( createArtifact( "h", "1.0" ) );
}
catch ( Exception e )
{
throw new ArtifactMetadataRetrievalException( "Cannot retrieve metadata." );
}
}
return dependencies;
}
};
ArtifactResolutionResult result = artifactResolver.resolveTransitively( g,
remoteRepositories(),
localRepository(),
mds );
assertEquals( 2, result.getArtifacts().size() );
assertTrue( result.getArtifacts().containsKey( g.getId() ) );
assertTrue( result.getArtifacts().containsKey( h.getId() ) );
assertLocalArtifactPresent( g );
assertLocalArtifactPresent( h );
}
public void testTransitiveResolutionWhereAllArtifactsAreNotPresentInTheLocalRepositoryAndMustBeRetrievedFromTheRemoteRepository()
throws Exception
{
Artifact i = createRemoteArtifact( "i", "1.0" );
Artifact j = createRemoteArtifact( "j", "1.0" );
ArtifactMetadataSource mds = new ArtifactMetadataSource()
{
public Set retrieve( Artifact artifact )
throws ArtifactMetadataRetrievalException
{
Set dependencies = new HashSet();
if ( artifact.getArtifactId().equals( "i" ) )
{
try
{
dependencies.add( createArtifact( "j", "1.0" ) );
}
catch ( Exception e )
{
throw new ArtifactMetadataRetrievalException( "Cannot retrieve metadata." );
}
}
return dependencies;
}
};
ArtifactResolutionResult result = artifactResolver.resolveTransitively( i,
remoteRepositories(),
localRepository(),
mds );
assertEquals( 2, result.getArtifacts().size() );
assertTrue( result.getArtifacts().containsKey( i.getId() ) );
assertTrue( result.getArtifacts().containsKey( j.getId() ) );
assertLocalArtifactPresent( i );
assertLocalArtifactPresent( j );
}
}

View File

@ -0,0 +1 @@
dummy

View File

@ -0,0 +1,24 @@
<plexus>
<components>
<component>
<role>org.apache.maven.wagon.Wagon</role>
<role-hint>a</role-hint>
<implementation>org.apache.maven.artifact.manager.WagonA</implementation>
</component>
<component>
<role>org.apache.maven.wagon.Wagon</role>
<role-hint>b1</role-hint>
<implementation>org.apache.maven.artifact.manager.WagonB</implementation>
</component>
<component>
<role>org.apache.maven.wagon.Wagon</role>
<role-hint>b2</role-hint>
<implementation>org.apache.maven.artifact.manager.WagonB</implementation>
</component>
<component>
<role>org.apache.maven.wagon.Wagon</role>
<role-hint>c</role-hint>
<implementation>org.apache.maven.artifact.manager.WagonC</implementation>
</component>
</components>
</plexus>

View File

@ -0,0 +1,95 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>maven</groupId>
<artifactId>maven-core</artifactId>
<name>Maven</name>
<version>2.0-SNAPSHOT</version>
<inceptionYear>2001</inceptionYear>
<package>org.apache.maven</package>
<logo>/images/maven.gif</logo>
<dependencies>
<!-- maven component -->
<dependency>
<groupId>maven</groupId>
<artifactId>maven-model</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-plugin</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<!-- -->
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.0-beta-2</version>
</dependency>
<dependency>
<groupId>plexus</groupId>
<artifactId>plexus-i18n</artifactId>
<version>1.0-beta-2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>ognl</groupId>
<artifactId>ognl</artifactId>
<version>2.5.1</version>
</dependency>
<!-- Used to support maven.xml script and goal decorating in general. -->
<dependency>
<groupId>marmalade</groupId>
<artifactId>marmalade-core</artifactId>
<version>0.1</version>
</dependency>
<dependency>
<groupId>marmalade</groupId>
<artifactId>marmalade-el-ognl</artifactId>
<version>0.1</version>
</dependency>
<!-- This will eventually be removed -->
<dependency>
<groupId>plexus</groupId>
<artifactId>plexus-compiler-api</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>plexus</groupId>
<artifactId>plexus-compiler-javac</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>surefire</groupId>
<artifactId>surefire-booter</artifactId>
<version>1.1</version>
</dependency>
<!-- Wagon -->
<dependency>
<groupId>maven</groupId>
<artifactId>wagon-api</artifactId>
<version>0.9-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>wagon-http-lightweight</artifactId>
<version>0.9-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>wagon-ssh</artifactId>
<version>0.9-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>jsch</groupId>
<artifactId>jsch</artifactId>
<version>0.1.14</version>
</dependency>
<!-- plugin plugin -->
<dependency>
<groupId>qdox</groupId>
<artifactId>qdox</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
</project>