From 15a7eb7ef2abf74fa87f0692102423a40ab586b6 Mon Sep 17 00:00:00 2001 From: Jason van Zyl Date: Mon, 9 Aug 2004 18:37:31 +0000 Subject: [PATCH] Initial revision git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@162914 13f79535-47bb-0310-9956-ffa450edef68 --- maven-artifact/.cvsignore | 11 + maven-artifact/pom.xml | 46 ++++ maven-artifact/src/.cvsignore | 4 + .../artifact/AbstractArtifactComponent.java | 49 ++++ .../org/apache/maven/artifact/Artifact.java | 52 ++++ .../maven/artifact/DefaultArtifact.java | 146 ++++++++++ .../artifact/deployer/ArtifactDeployer.java | 34 +++ .../deployer/ArtifactDeploymentException.java | 40 +++ .../deployer/DefaultArtifactDeployer.java | 65 +++++ .../handler/AbstractArtifactHandler.java | 45 ++++ .../artifact/handler/ArtifactHandler.java | 36 +++ .../maven/artifact/handler/JarHandler.java | 30 +++ .../maven/artifact/handler/PluginHandler.java | 34 +++ .../maven/artifact/handler/PomHandler.java | 39 +++ .../maven/artifact/handler/TestHandler.java | 30 +++ .../manager/ArtifactHandlerManager.java | 42 +++ .../ArtifactHandlerNotFoundException.java | 40 +++ .../DefaultArtifactHandlerManager.java | 112 ++++++++ .../ArtifactInstallationException.java | 40 +++ .../artifact/installer/ArtifactInstaller.java | 38 +++ .../installer/DefaultArtifactInstaller.java | 72 +++++ .../artifact/manager/DefaultWagonManager.java | 223 +++++++++++++++ .../maven/artifact/manager/WagonManager.java | 50 ++++ .../ArtifactMetadataRetrievalException.java | 40 +++ .../metadata/ArtifactMetadataSource.java | 37 +++ .../repository/ArtifactRepository.java | 90 +++++++ .../artifact/request/ArtifactRequest.java | 26 ++ .../ArtifactRequestTransformation.java | 46 ++++ ...rtifactRequestTransformationException.java | 40 +++ .../resolver/ArtifactCollectionException.java | 40 +++ .../resolver/ArtifactResolutionException.java | 42 +++ .../resolver/ArtifactResolutionResult.java | 48 ++++ .../artifact/resolver/ArtifactResolver.java | 43 +++ .../resolver/DefaultArtifactResolver.java | 255 ++++++++++++++++++ .../resolver/conflict/ConflictResolver.java | 25 ++ .../conflict/DefaultConflictResolver.java | 26 ++ .../resources/META-INF/plexus/components.xml | 111 ++++++++ .../artifact/ArtifactComponentTestCase.java | 191 +++++++++++++ .../deployer/ArtifactDeployerTest.java | 57 ++++ .../installer/ArtifactInstallerTest.java | 58 ++++ .../manager/DefaultWagonManagerTest.java | 74 +++++ .../apache/maven/artifact/manager/WagonA.java | 36 +++ .../apache/maven/artifact/manager/WagonB.java | 36 +++ .../apache/maven/artifact/manager/WagonC.java | 36 +++ .../resolver/ArtifactResolverTest.java | 224 +++++++++++++++ .../artifact-install/artifact-1.0.jar | 1 + .../manager/DefaultWagonManagerTest.xml | 24 ++ maven-artifact/src/test/resources/pom.xml | 95 +++++++ 48 files changed, 2979 insertions(+) create mode 100644 maven-artifact/.cvsignore create mode 100644 maven-artifact/pom.xml create mode 100644 maven-artifact/src/.cvsignore create mode 100644 maven-artifact/src/main/java/org/apache/maven/artifact/AbstractArtifactComponent.java create mode 100644 maven-artifact/src/main/java/org/apache/maven/artifact/Artifact.java create mode 100644 maven-artifact/src/main/java/org/apache/maven/artifact/DefaultArtifact.java create mode 100644 maven-artifact/src/main/java/org/apache/maven/artifact/deployer/ArtifactDeployer.java create mode 100644 maven-artifact/src/main/java/org/apache/maven/artifact/deployer/ArtifactDeploymentException.java create mode 100644 maven-artifact/src/main/java/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.java create mode 100644 maven-artifact/src/main/java/org/apache/maven/artifact/handler/AbstractArtifactHandler.java create mode 100644 maven-artifact/src/main/java/org/apache/maven/artifact/handler/ArtifactHandler.java create mode 100644 maven-artifact/src/main/java/org/apache/maven/artifact/handler/JarHandler.java create mode 100644 maven-artifact/src/main/java/org/apache/maven/artifact/handler/PluginHandler.java create mode 100644 maven-artifact/src/main/java/org/apache/maven/artifact/handler/PomHandler.java create mode 100644 maven-artifact/src/main/java/org/apache/maven/artifact/handler/TestHandler.java create mode 100644 maven-artifact/src/main/java/org/apache/maven/artifact/handler/manager/ArtifactHandlerManager.java create mode 100644 maven-artifact/src/main/java/org/apache/maven/artifact/handler/manager/ArtifactHandlerNotFoundException.java create mode 100644 maven-artifact/src/main/java/org/apache/maven/artifact/handler/manager/DefaultArtifactHandlerManager.java create mode 100644 maven-artifact/src/main/java/org/apache/maven/artifact/installer/ArtifactInstallationException.java create mode 100644 maven-artifact/src/main/java/org/apache/maven/artifact/installer/ArtifactInstaller.java create mode 100644 maven-artifact/src/main/java/org/apache/maven/artifact/installer/DefaultArtifactInstaller.java create mode 100644 maven-artifact/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java create mode 100644 maven-artifact/src/main/java/org/apache/maven/artifact/manager/WagonManager.java create mode 100644 maven-artifact/src/main/java/org/apache/maven/artifact/metadata/ArtifactMetadataRetrievalException.java create mode 100644 maven-artifact/src/main/java/org/apache/maven/artifact/metadata/ArtifactMetadataSource.java create mode 100644 maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepository.java create mode 100644 maven-artifact/src/main/java/org/apache/maven/artifact/request/ArtifactRequest.java create mode 100644 maven-artifact/src/main/java/org/apache/maven/artifact/request/ArtifactRequestTransformation.java create mode 100644 maven-artifact/src/main/java/org/apache/maven/artifact/request/ArtifactRequestTransformationException.java create mode 100644 maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactCollectionException.java create mode 100644 maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionException.java create mode 100644 maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionResult.java create mode 100644 maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolver.java create mode 100644 maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java create mode 100644 maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/ConflictResolver.java create mode 100644 maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/DefaultConflictResolver.java create mode 100644 maven-artifact/src/main/resources/META-INF/plexus/components.xml create mode 100644 maven-artifact/src/test/java/org/apache/maven/artifact/ArtifactComponentTestCase.java create mode 100644 maven-artifact/src/test/java/org/apache/maven/artifact/deployer/ArtifactDeployerTest.java create mode 100644 maven-artifact/src/test/java/org/apache/maven/artifact/installer/ArtifactInstallerTest.java create mode 100644 maven-artifact/src/test/java/org/apache/maven/artifact/manager/DefaultWagonManagerTest.java create mode 100644 maven-artifact/src/test/java/org/apache/maven/artifact/manager/WagonA.java create mode 100644 maven-artifact/src/test/java/org/apache/maven/artifact/manager/WagonB.java create mode 100644 maven-artifact/src/test/java/org/apache/maven/artifact/manager/WagonC.java create mode 100644 maven-artifact/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java create mode 100644 maven-artifact/src/test/resources/artifact-install/artifact-1.0.jar create mode 100644 maven-artifact/src/test/resources/org/apache/maven/artifact/manager/DefaultWagonManagerTest.xml create mode 100644 maven-artifact/src/test/resources/pom.xml diff --git a/maven-artifact/.cvsignore b/maven-artifact/.cvsignore new file mode 100644 index 0000000000..d9cded9200 --- /dev/null +++ b/maven-artifact/.cvsignore @@ -0,0 +1,11 @@ +*~ +*.log +target +dist +*.ipr +*.iws +*.iml +dist +target +.classpath +.project diff --git a/maven-artifact/pom.xml b/maven-artifact/pom.xml new file mode 100644 index 0000000000..d2f197b0e3 --- /dev/null +++ b/maven-artifact/pom.xml @@ -0,0 +1,46 @@ + + + + 4.0.0 + maven + maven-artifact + Maven + 2.0-SNAPSHOT + 2001 + org.apache.maven + /images/maven.gif + + + maven + wagon-api + 0.9-SNAPSHOT + + + maven + wagon-http-lightweight + 0.9-SNAPSHOT + + + + plexus + plexus + 0.16-SNAPSHOT + + + xstream + xstream + 1.0-SNAPSHOT + + + classworlds + classworlds + 1.1-SNAPSHOT + + + xpp3 + xpp3 + 1.1.3.3 + + + + diff --git a/maven-artifact/src/.cvsignore b/maven-artifact/src/.cvsignore new file mode 100644 index 0000000000..0366c1565c --- /dev/null +++ b/maven-artifact/src/.cvsignore @@ -0,0 +1,4 @@ +maven.log +target +.classpath +.project diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/AbstractArtifactComponent.java b/maven-artifact/src/main/java/org/apache/maven/artifact/AbstractArtifactComponent.java new file mode 100644 index 0000000000..bd34856acc --- /dev/null +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/AbstractArtifactComponent.java @@ -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 Jason van Zyl + * @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 ) ); + } +} diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/Artifact.java b/maven-artifact/src/main/java/org/apache/maven/artifact/Artifact.java new file mode 100644 index 0000000000..81ada5f621 --- /dev/null +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/Artifact.java @@ -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(); +} diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/DefaultArtifact.java b/maven-artifact/src/main/java/org/apache/maven/artifact/DefaultArtifact.java new file mode 100644 index 0000000000..95fa326e02 --- /dev/null +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/DefaultArtifact.java @@ -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 Jason van Zyl + * @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(); + } +} diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/deployer/ArtifactDeployer.java b/maven-artifact/src/main/java/org/apache/maven/artifact/deployer/ArtifactDeployer.java new file mode 100644 index 0000000000..e5014cf08e --- /dev/null +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/deployer/ArtifactDeployer.java @@ -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; +} diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/deployer/ArtifactDeploymentException.java b/maven-artifact/src/main/java/org/apache/maven/artifact/deployer/ArtifactDeploymentException.java new file mode 100644 index 0000000000..1e0907b2fe --- /dev/null +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/deployer/ArtifactDeploymentException.java @@ -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 Jason van Zyl + * @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 ); + } +} diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.java b/maven-artifact/src/main/java/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.java new file mode 100644 index 0000000000..0b7fc36ec7 --- /dev/null +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.java @@ -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 ); + } + } +} diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/handler/AbstractArtifactHandler.java b/maven-artifact/src/main/java/org/apache/maven/artifact/handler/AbstractArtifactHandler.java new file mode 100644 index 0000000000..d7821ace40 --- /dev/null +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/handler/AbstractArtifactHandler.java @@ -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 Jason van Zyl + * @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"; + } +} diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/handler/ArtifactHandler.java b/maven-artifact/src/main/java/org/apache/maven/artifact/handler/ArtifactHandler.java new file mode 100644 index 0000000000..a384716e4b --- /dev/null +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/handler/ArtifactHandler.java @@ -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 Jason van Zyl + * @version $Id$ + */ +public interface ArtifactHandler +{ + static String ROLE = ArtifactHandler.class.getName(); + + File source( String basedir, Artifact artifact ); + + String extension(); + + String directory(); +} diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/handler/JarHandler.java b/maven-artifact/src/main/java/org/apache/maven/artifact/handler/JarHandler.java new file mode 100644 index 0000000000..0d40c383eb --- /dev/null +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/handler/JarHandler.java @@ -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 Jason van Zyl + * @version $Id$ + */ +public class JarHandler + extends AbstractArtifactHandler +{ +} diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/handler/PluginHandler.java b/maven-artifact/src/main/java/org/apache/maven/artifact/handler/PluginHandler.java new file mode 100644 index 0000000000..6fc17b0db9 --- /dev/null +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/handler/PluginHandler.java @@ -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 Jason van Zyl + * @version $Id$ + */ +public class PluginHandler + extends AbstractArtifactHandler +{ + public String directory() + { + return "plugins"; + } +} diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/handler/PomHandler.java b/maven-artifact/src/main/java/org/apache/maven/artifact/handler/PomHandler.java new file mode 100644 index 0000000000..890dba1887 --- /dev/null +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/handler/PomHandler.java @@ -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 Jason van Zyl + * @version $Id$ + */ +public class PomHandler + extends AbstractArtifactHandler +{ + public String extension() + { + return "pom"; + } + + public String directory() + { + return "poms"; + } +} diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/handler/TestHandler.java b/maven-artifact/src/main/java/org/apache/maven/artifact/handler/TestHandler.java new file mode 100644 index 0000000000..372c21414b --- /dev/null +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/handler/TestHandler.java @@ -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 Jason van Zyl + * @version $Id$ + */ +public class TestHandler + extends AbstractArtifactHandler +{ +} diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/handler/manager/ArtifactHandlerManager.java b/maven-artifact/src/main/java/org/apache/maven/artifact/handler/manager/ArtifactHandlerManager.java new file mode 100644 index 0000000000..b9ebd9ed2c --- /dev/null +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/handler/manager/ArtifactHandlerManager.java @@ -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 Jason van Zyl + * @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(); + +} diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/handler/manager/ArtifactHandlerNotFoundException.java b/maven-artifact/src/main/java/org/apache/maven/artifact/handler/manager/ArtifactHandlerNotFoundException.java new file mode 100644 index 0000000000..39b2b0c636 --- /dev/null +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/handler/manager/ArtifactHandlerNotFoundException.java @@ -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 Jason van Zyl + * @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 ); + } +} diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/handler/manager/DefaultArtifactHandlerManager.java b/maven-artifact/src/main/java/org/apache/maven/artifact/handler/manager/DefaultArtifactHandlerManager.java new file mode 100644 index 0000000000..d0fcb70015 --- /dev/null +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/handler/manager/DefaultArtifactHandlerManager.java @@ -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 Jason van Zyl + * @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; + } +} diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/installer/ArtifactInstallationException.java b/maven-artifact/src/main/java/org/apache/maven/artifact/installer/ArtifactInstallationException.java new file mode 100644 index 0000000000..22903677a3 --- /dev/null +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/installer/ArtifactInstallationException.java @@ -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 Jason van Zyl + * @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 ); + } +} diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/installer/ArtifactInstaller.java b/maven-artifact/src/main/java/org/apache/maven/artifact/installer/ArtifactInstaller.java new file mode 100644 index 0000000000..924120f8b4 --- /dev/null +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/installer/ArtifactInstaller.java @@ -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 Michal Maczka + * @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; +} diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/installer/DefaultArtifactInstaller.java b/maven-artifact/src/main/java/org/apache/maven/artifact/installer/DefaultArtifactInstaller.java new file mode 100644 index 0000000000..a279b1eaab --- /dev/null +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/installer/DefaultArtifactInstaller.java @@ -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 ); + } + } +} diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java b/maven-artifact/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java new file mode 100644 index 0000000000..31af244a1b --- /dev/null +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java @@ -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. + *

+ * 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 ); + } +} diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/manager/WagonManager.java b/maven-artifact/src/main/java/org/apache/maven/artifact/manager/WagonManager.java new file mode 100644 index 0000000000..aab602db63 --- /dev/null +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/manager/WagonManager.java @@ -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 Michal Maczka + * @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; +} \ No newline at end of file diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/metadata/ArtifactMetadataRetrievalException.java b/maven-artifact/src/main/java/org/apache/maven/artifact/metadata/ArtifactMetadataRetrievalException.java new file mode 100644 index 0000000000..271be4b938 --- /dev/null +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/metadata/ArtifactMetadataRetrievalException.java @@ -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 Jason van Zyl + * @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 ); + } +} diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/metadata/ArtifactMetadataSource.java b/maven-artifact/src/main/java/org/apache/maven/artifact/metadata/ArtifactMetadataSource.java new file mode 100644 index 0000000000..89628faf54 --- /dev/null +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/metadata/ArtifactMetadataSource.java @@ -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 Jason van Zyl + * @version $Id$ + */ +public interface ArtifactMetadataSource +{ + Set retrieve( Artifact artifact ) + throws ArtifactMetadataRetrievalException; +} diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepository.java b/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepository.java new file mode 100644 index 0000000000..c88264e4cd --- /dev/null +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepository.java @@ -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 Michal Maczka + * @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; + } + */ +} diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/request/ArtifactRequest.java b/maven-artifact/src/main/java/org/apache/maven/artifact/request/ArtifactRequest.java new file mode 100644 index 0000000000..cf34a39310 --- /dev/null +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/request/ArtifactRequest.java @@ -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 Jason van Zyl + * @version $Id$ + */ +public class ArtifactRequest +{ + +} diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/request/ArtifactRequestTransformation.java b/maven-artifact/src/main/java/org/apache/maven/artifact/request/ArtifactRequestTransformation.java new file mode 100644 index 0000000000..519ec9327e --- /dev/null +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/request/ArtifactRequestTransformation.java @@ -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 Jason van Zyl + * @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; +} diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/request/ArtifactRequestTransformationException.java b/maven-artifact/src/main/java/org/apache/maven/artifact/request/ArtifactRequestTransformationException.java new file mode 100644 index 0000000000..4d61cc1d1f --- /dev/null +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/request/ArtifactRequestTransformationException.java @@ -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 Jason van Zyl + * @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 ); + } +} diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactCollectionException.java b/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactCollectionException.java new file mode 100644 index 0000000000..58479d71c7 --- /dev/null +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactCollectionException.java @@ -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 Jason van Zyl + * @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 ); + } +} diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionException.java b/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionException.java new file mode 100644 index 0000000000..1873ecf2de --- /dev/null +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionException.java @@ -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 Jason van Zyl + * @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 ); + } +} diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionResult.java b/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionResult.java new file mode 100644 index 0000000000..1609cf9175 --- /dev/null +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionResult.java @@ -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 Jason van Zyl + * @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; + } +} diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolver.java b/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolver.java new file mode 100644 index 0000000000..3d5b19c580 --- /dev/null +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolver.java @@ -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 Michal Maczka + * @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; +} diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java b/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java new file mode 100644 index 0000000000..13f863c4f9 --- /dev/null +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java @@ -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 ); + } +} diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/ConflictResolver.java b/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/ConflictResolver.java new file mode 100644 index 0000000000..342f267390 --- /dev/null +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/ConflictResolver.java @@ -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 Jason van Zyl + * @version $Id$ + */ +public interface ConflictResolver +{ +} diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/DefaultConflictResolver.java b/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/DefaultConflictResolver.java new file mode 100644 index 0000000000..ab86a0d553 --- /dev/null +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/DefaultConflictResolver.java @@ -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 Jason van Zyl + * @version $Id$ + */ +public class DefaultConflictResolver + implements ConflictResolver +{ +} diff --git a/maven-artifact/src/main/resources/META-INF/plexus/components.xml b/maven-artifact/src/main/resources/META-INF/plexus/components.xml new file mode 100644 index 0000000000..1eea0df6bb --- /dev/null +++ b/maven-artifact/src/main/resources/META-INF/plexus/components.xml @@ -0,0 +1,111 @@ + + + + + + org.apache.maven.artifact.resolver.ArtifactResolver + org.apache.maven.artifact.resolver.DefaultArtifactResolver + + + org.apache.maven.artifact.manager.WagonManager + + + org.apache.maven.artifact.handler.manager.ArtifactHandlerManager + + + + + + + org.apache.maven.artifact.manager.WagonManager + org.apache.maven.artifact.manager.DefaultWagonManager + + + org.apache.maven.artifact.handler.manager.ArtifactHandlerManager + + + + + + + org.apache.maven.artifact.installer.ArtifactInstaller + org.apache.maven.artifact.installer.DefaultArtifactInstaller + + + org.apache.maven.artifact.handler.manager.ArtifactHandlerManager + + + + + + + org.apache.maven.artifact.deployer.ArtifactDeployer + org.apache.maven.artifact.deployer.DefaultArtifactDeployer + + + org.apache.maven.artifact.manager.WagonManager + + + org.apache.maven.artifact.handler.manager.ArtifactHandlerManager + + + + + + + org.apache.maven.artifact.handler.manager.ArtifactHandlerManager + org.apache.maven.artifact.handler.manager.DefaultArtifactHandlerManager + + + org.apache.maven.artifact.handler.ArtifactHandler + artifactHandlers + + + + + + org.apache.maven.artifact.handler.ArtifactHandler + jar + org.apache.maven.artifact.handler.JarHandler + + + + org.apache.maven.artifact.handler.ArtifactHandler + plugin + org.apache.maven.artifact.handler.PluginHandler + + + + org.apache.maven.artifact.handler.ArtifactHandler + test + org.apache.maven.artifact.handler.TestHandler + + + + org.apache.maven.artifact.handler.ArtifactHandler + pom + org.apache.maven.artifact.handler.PomHandler + + + + diff --git a/maven-artifact/src/test/java/org/apache/maven/artifact/ArtifactComponentTestCase.java b/maven-artifact/src/test/java/org/apache/maven/artifact/ArtifactComponentTestCase.java new file mode 100644 index 0000000000..522a505cc7 --- /dev/null +++ b/maven-artifact/src/test/java/org/apache/maven/artifact/ArtifactComponentTestCase.java @@ -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 Jason van Zyl + * @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 ); + } +} diff --git a/maven-artifact/src/test/java/org/apache/maven/artifact/deployer/ArtifactDeployerTest.java b/maven-artifact/src/test/java/org/apache/maven/artifact/deployer/ArtifactDeployerTest.java new file mode 100644 index 0000000000..3be443b47b --- /dev/null +++ b/maven-artifact/src/test/java/org/apache/maven/artifact/deployer/ArtifactDeployerTest.java @@ -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 Jason van Zyl + * @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 ); + } +} \ No newline at end of file diff --git a/maven-artifact/src/test/java/org/apache/maven/artifact/installer/ArtifactInstallerTest.java b/maven-artifact/src/test/java/org/apache/maven/artifact/installer/ArtifactInstallerTest.java new file mode 100644 index 0000000000..0b790220d7 --- /dev/null +++ b/maven-artifact/src/test/java/org/apache/maven/artifact/installer/ArtifactInstallerTest.java @@ -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 Jason van Zyl + * @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 ); + } +} \ No newline at end of file diff --git a/maven-artifact/src/test/java/org/apache/maven/artifact/manager/DefaultWagonManagerTest.java b/maven-artifact/src/test/java/org/apache/maven/artifact/manager/DefaultWagonManagerTest.java new file mode 100644 index 0000000000..59c601feb5 --- /dev/null +++ b/maven-artifact/src/test/java/org/apache/maven/artifact/manager/DefaultWagonManagerTest.java @@ -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 Michal Maczka + * @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 + } + } +} diff --git a/maven-artifact/src/test/java/org/apache/maven/artifact/manager/WagonA.java b/maven-artifact/src/test/java/org/apache/maven/artifact/manager/WagonA.java new file mode 100644 index 0000000000..dcc6daf45d --- /dev/null +++ b/maven-artifact/src/test/java/org/apache/maven/artifact/manager/WagonA.java @@ -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 Jason van Zyl + * + * @version $Id$ + */ +public class WagonA + extends FileWagon +{ + public String[] getSupportedProtocols() + { + return new String[]{ "a" }; + } +} diff --git a/maven-artifact/src/test/java/org/apache/maven/artifact/manager/WagonB.java b/maven-artifact/src/test/java/org/apache/maven/artifact/manager/WagonB.java new file mode 100644 index 0000000000..4a4154560c --- /dev/null +++ b/maven-artifact/src/test/java/org/apache/maven/artifact/manager/WagonB.java @@ -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 Jason van Zyl + * + * @version $Id$ + */ +public class WagonB + extends FileWagon +{ + public String[] getSupportedProtocols() + { + return new String[]{ "b1", "b2" }; + } +} diff --git a/maven-artifact/src/test/java/org/apache/maven/artifact/manager/WagonC.java b/maven-artifact/src/test/java/org/apache/maven/artifact/manager/WagonC.java new file mode 100644 index 0000000000..d19378e2ec --- /dev/null +++ b/maven-artifact/src/test/java/org/apache/maven/artifact/manager/WagonC.java @@ -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 Jason van Zyl + * + * @version $Id$ + */ +public class WagonC + extends FileWagon +{ + public String[] getSupportedProtocols() + { + return new String[]{ "c" }; + } +} diff --git a/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java b/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java new file mode 100644 index 0000000000..8879c0af0a --- /dev/null +++ b/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java @@ -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 Jason van Zyl + * @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 ); + } +} \ No newline at end of file diff --git a/maven-artifact/src/test/resources/artifact-install/artifact-1.0.jar b/maven-artifact/src/test/resources/artifact-install/artifact-1.0.jar new file mode 100644 index 0000000000..421376db9e --- /dev/null +++ b/maven-artifact/src/test/resources/artifact-install/artifact-1.0.jar @@ -0,0 +1 @@ +dummy diff --git a/maven-artifact/src/test/resources/org/apache/maven/artifact/manager/DefaultWagonManagerTest.xml b/maven-artifact/src/test/resources/org/apache/maven/artifact/manager/DefaultWagonManagerTest.xml new file mode 100644 index 0000000000..5012968c86 --- /dev/null +++ b/maven-artifact/src/test/resources/org/apache/maven/artifact/manager/DefaultWagonManagerTest.xml @@ -0,0 +1,24 @@ + + + + org.apache.maven.wagon.Wagon + a + org.apache.maven.artifact.manager.WagonA + + + org.apache.maven.wagon.Wagon + b1 + org.apache.maven.artifact.manager.WagonB + + + org.apache.maven.wagon.Wagon + b2 + org.apache.maven.artifact.manager.WagonB + + + org.apache.maven.wagon.Wagon + c + org.apache.maven.artifact.manager.WagonC + + + \ No newline at end of file diff --git a/maven-artifact/src/test/resources/pom.xml b/maven-artifact/src/test/resources/pom.xml new file mode 100644 index 0000000000..8ed1ff5edc --- /dev/null +++ b/maven-artifact/src/test/resources/pom.xml @@ -0,0 +1,95 @@ + + + + 4.0.0 + maven + maven-core + Maven + 2.0-SNAPSHOT + 2001 + org.apache.maven + /images/maven.gif + + + + maven + maven-model + 2.0-SNAPSHOT + + + maven + maven-plugin + 2.0-SNAPSHOT + + + + commons-cli + commons-cli + 1.0-beta-2 + + + plexus + plexus-i18n + 1.0-beta-2-SNAPSHOT + + + ognl + ognl + 2.5.1 + + + + marmalade + marmalade-core + 0.1 + + + marmalade + marmalade-el-ognl + 0.1 + + + + plexus + plexus-compiler-api + 1.0 + + + plexus + plexus-compiler-javac + 1.0 + + + surefire + surefire-booter + 1.1 + + + + maven + wagon-api + 0.9-SNAPSHOT + + + maven + wagon-http-lightweight + 0.9-SNAPSHOT + + + maven + wagon-ssh + 0.9-SNAPSHOT + + + jsch + jsch + 0.1.14 + + + + qdox + qdox + 1.2 + + +