o swapping the branch to trunk

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@779660 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2009-05-28 16:46:43 +00:00
commit d5fcfe0e19
841 changed files with 17817 additions and 30434 deletions

View File

@ -1,36 +0,0 @@
BOOTSTRAPPING BASICS
-----------------------
You'll need:
- Java 1.5
- Ant 1.6.5 or later
First, give Ant a location into which the completed Maven distro should be installed:
export M2_HOME=$HOME/apps/maven/apache-maven-3.0-SNAPSHOT
Then, run Ant:
ant -f build-mercury.xml
You can use additiona options on ant command line:
-Dmaven.repo.update.policy={never|always|daily}
-Dmaven.repo.system={mercury|legacy}
-Dmaven.home=$HOME/apps/maven/apache-maven-3.0-SNAPSHOT
if you'd like to debug the bootstrap from Eclipse, uncomment the debugging options in the build-mercury.xml around
line 310, then use the following commands:
For the first time - run the following, it will update the local repo
ant -f build-mercury.xml -Dmaven.repo.update.policy=always -Dmaven.repo.system=mercury
then you can run
ant -f build-mercury.xml -Dmaven.repo.update.policy=never -Dmaven.repo.system=mercury
not to bother with repo updates

View File

@ -23,11 +23,8 @@
<artifactId>maven</artifactId> <artifactId>maven</artifactId>
<version>3.0-SNAPSHOT</version> <version>3.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>apache-maven</artifactId> <artifactId>apache-maven</artifactId>
<name>Maven Distribution</name> <name>Maven Distribution</name>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.apache.maven</groupId> <groupId>org.apache.maven</groupId>
@ -37,10 +34,6 @@
<groupId>org.apache.maven</groupId> <groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId> <artifactId>maven-core</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.apache.maven</groupId> <groupId>org.apache.maven</groupId>
<artifactId>maven-toolchain</artifactId> <artifactId>maven-toolchain</artifactId>
@ -62,14 +55,6 @@
<groupId>org.apache.maven.wagon</groupId> <groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-http-lightweight</artifactId> <artifactId>wagon-http-lightweight</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh-external</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.apache.maven.wagon</groupId> <groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-file</artifactId> <artifactId>wagon-file</artifactId>

View File

@ -24,10 +24,10 @@
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.Reader; import java.io.Reader;
import org.apache.maven.settings.io.xpp3.SettingsXpp3Reader;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.maven.settings.io.xpp3.SettingsXpp3Reader;
/** /**
* Tests that the global settings.xml shipped with the distribution is in good state. * Tests that the global settings.xml shipped with the distribution is in good state.
* *

199
build.xml
View File

@ -7,7 +7,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an
@ -31,18 +31,18 @@ END SNIPPET: ant-bootstrap -->
<project default="all" basedir="." xmlns:artifact="urn:maven-artifact-ant"> <project default="all" basedir="." xmlns:artifact="urn:maven-artifact-ant">
<property name="it.workdir.version" value="3.0.x"/> <property name="it.workdir.version" value="3.0.x" />
<target name="initTaskDefs"> <target name="initTaskDefs">
<xmlproperty file="pom.xml" prefix="pom.xml" /> <xmlproperty file="pom.xml" prefix="pom.xml" />
<path id="maven-ant-tasks.classpath" path="maven-ant-tasks-2.1-SNAPSHOT.jar"/> <path id="maven-ant-tasks.classpath" path="maven-ant-tasks-2.1-SNAPSHOT.jar" />
<typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="urn:maven-artifact-ant" classpathref="maven-ant-tasks.classpath"/> <typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="urn:maven-artifact-ant" classpathref="maven-ant-tasks.classpath" />
</target> </target>
<target name="isMavenHomeSet" depends="initTaskDefs"> <target name="isMavenHomeSet" depends="initTaskDefs">
<property environment="env"/> <property environment="env" />
<condition property="maven.home" value="${env.M2_HOME}"> <condition property="maven.home" value="${env.M2_HOME}">
<isset property="env.M2_HOME"/> <isset property="env.M2_HOME" />
</condition> </condition>
<fail message="You must set the M2_HOME environment variable or specify a maven.home property to this Ant script"> <fail message="You must set the M2_HOME environment variable or specify a maven.home property to this Ant script">
<condition> <condition>
@ -57,181 +57,192 @@ END SNIPPET: ant-bootstrap -->
</target> </target>
<target name="init" depends="isMavenHomeSet"> <target name="init" depends="isMavenHomeSet">
<xmlproperty prefix="pom" file="pom.xml"/> <xmlproperty prefix="pom" file="pom.xml" />
<dirname file="${maven.home}" property="maven.home.dirname"/> <dirname file="${maven.home}" property="maven.home.dirname" />
<!-- Initialize properties --> <!-- Initialize properties -->
<property name="maven.home.basename.expected" value="apache-maven-${pom.project.version}"/> <property name="maven.home.basename.expected" value="apache-maven-${pom.project.version}" />
<property name="maven.home.effective" location="${maven.home.dirname}/${maven.home.basename.expected}"/> <property name="maven.home.effective" location="${maven.home.dirname}/${maven.home.basename.expected}" />
<property name="maven.assembly" location="apache-maven/target/${maven.home.basename.expected}-bin.zip"/> <property name="maven.assembly" location="apache-maven/target/${maven.home.basename.expected}-bin.zip" />
<property name="maven.repo.local" value="${user.home}/.m2/repository"/> <property name="maven.repo.local" value="${user.home}/.m2/repository" />
<property name="maven.debug" value="-e"/> <property name="maven.debug" value="-e" />
<property name="surefire.useFile" value="true"/> <property name="maven.test.skip" value="false" />
<!-- TODO: Change this default back to false once we're done -->
<property name="surefire.useFile" value="true" />
<echo>maven.home = ${maven.home.effective}</echo> <echo>maven.home = ${maven.home.effective}</echo>
<echo>maven.repo.local = ${maven.repo.local}</echo> <echo>maven.repo.local = ${maven.repo.local}</echo>
</target> </target>
<target name="clean-bootstrap" description="cleans up generated bootstrap classes"> <target name="clean-bootstrap" description="cleans up generated bootstrap classes">
<delete dir="bootstrap"/> <delete dir="bootstrap" />
</target> </target>
<target name="pull" depends="init" unless="skip.pull"> <target name="pull" depends="init" unless="skip.pull">
<property name="verbose" value="false"/> <property name="verbose" value="false" />
<!-- Pull the dependencies that Maven needs to build --> <!-- Pull the dependencies that Maven needs to build -->
<copy file="pom.xml" tofile="dependencies.xml"/> <copy file="pom.xml" tofile="dependencies.xml" />
<replace file="${basedir}/dependencies.xml" token="&lt;!--bootstrap-start-comment--&gt;" value="&lt;!--"/> <replace file="${basedir}/dependencies.xml" token="&lt;!--bootstrap-start-comment--&gt;" value="&lt;!--" />
<replace file="${basedir}/dependencies.xml" token="&lt;!--bootstrap-end-comment--&gt;" value="--&gt;"/> <replace file="${basedir}/dependencies.xml" token="&lt;!--bootstrap-end-comment--&gt;" value="--&gt;" />
<artifact:pom file="${basedir}/dependencies.xml" id="pom"/> <artifact:pom file="${basedir}/dependencies.xml" id="pom" />
<artifact:dependencies pathId="pom.pathid" filesetId="pom.fileset" verbose="${verbose}" useScope="compile"> <artifact:dependencies pathId="pom.pathid" filesetId="pom.fileset" verbose="${verbose}" useScope="compile">
<localRepository path="${maven.repo.local}"/> <localRepository path="${maven.repo.local}" />
<pom refid="pom"/> <pom refid="pom" />
</artifact:dependencies> </artifact:dependencies>
<delete file="${basedir}/dependencies.xml"/> <delete file="${basedir}/dependencies.xml" />
<!-- Pull the dependencies for Modello --> <!-- Pull the dependencies for Modello -->
<artifact:dependencies pathId="modello.pathid" filesetId="modello.fileset" verbose="${verbose}"> <artifact:dependencies pathId="modello.pathid" filesetId="modello.fileset" verbose="${verbose}">
<localRepository path="${maven.repo.local}"/> <localRepository path="${maven.repo.local}" />
<dependency groupId="org.codehaus.modello" artifactId="modello-maven-plugin" version="${pom.properties.modelloVersion}"/> <dependency groupId="org.codehaus.modello" artifactId="modello-maven-plugin" version="${pom.properties.modelloVersion}" />
</artifact:dependencies> </artifact:dependencies>
<!-- Pull the dependencies for the MetadataGenerator CLI --> <!-- Pull the dependencies for the MetadataGenerator CLI -->
<artifact:dependencies pathId="pmdg.pathid" filesetId="pmdg.fileset" verbose="${verbose}"> <artifact:dependencies pathId="pmdg.pathid" filesetId="pmdg.fileset" verbose="${verbose}">
<localRepository path="${maven.repo.local}"/> <localRepository path="${maven.repo.local}" />
<dependency groupId="org.codehaus.plexus" artifactId="plexus-component-metadata" version="${pom.properties.plexusVersion}"/> <dependency groupId="org.codehaus.plexus" artifactId="plexus-component-metadata" version="${pom.properties.plexusVersion}" />
</artifact:dependencies> </artifact:dependencies>
</target> </target>
<target name="process-classes" depends="pull" description="generates plexus component metadata."> <target name="process-classes" depends="pull" description="generates plexus component metadata.">
<mkdir dir="${basedir}/bootstrap/target"/> <mkdir dir="${basedir}/bootstrap/target" />
<mkdir dir="${basedir}/bootstrap/target/classes"/> <mkdir dir="${basedir}/bootstrap/target/classes" />
<path id="maven.classpath"> <path id="maven.classpath">
<pathelement location="bootstrap/target/classes"/> <pathelement location="bootstrap/target/classes" />
<path refid="sources"/> <path refid="sources" />
<path refid="pom.pathid"/> <path refid="pom.pathid" />
<path refid="pmdg.pathid"/> <path refid="pmdg.pathid" />
</path> </path>
<echo>Using plexus version ${pom.properties.plexusVersion}</echo> <echo>Using plexus version ${pom.properties.plexusVersion}</echo>
<java fork="fork" classname="org.codehaus.plexus.metadata.PlexusMetadataGeneratorCli" failonerror="true"> <java fork="fork" classname="org.codehaus.plexus.metadata.PlexusMetadataGeneratorCli" failonerror="true">
<classpath refid="maven.classpath"/> <classpath refid="maven.classpath" />
<!-- We need to generate component descriptors from the maven-artifact sources which use javadoc annotations. --> <!-- We need to generate component descriptors from the maven-artifact sources which use javadoc annotations. -->
<arg value="--source"/> <arg value="--source" />
<arg value="${basedir}/maven-compat/src/main/java"/> <arg value="${basedir}/maven-compat/src/main/java" />
<!-- We have separated the artifact handlers and lifecycle mappings into a separate file. --> <!-- We have separated the artifact handlers and lifecycle mappings into a separate file. -->
<arg value="--descriptors"/> <arg value="--descriptors" />
<arg value="${basedir}/maven-core/src/main/resources/META-INF/plexus"/> <arg value="${basedir}/maven-core/src/main/resources/META-INF/plexus" />
<!-- Search the classes for annotations that we've compiled. --> <!-- Search the classes for annotations that we've compiled. -->
<arg value="--classes"/> <arg value="--classes" />
<arg value="${basedir}/bootstrap/target/classes"/> <arg value="${basedir}/bootstrap/target/classes" />
<!-- We'll make one big fat components descriptor. --> <!-- We'll make one big fat components descriptor. -->
<arg value="--output"/> <arg value="--output" />
<arg value="${basedir}/bootstrap/target/classes/META-INF/plexus/components.xml"/> <arg value="${basedir}/bootstrap/target/classes/META-INF/plexus/components.xml" />
</java> </java>
</target> </target>
<target name="generate-sources" depends="pull" description="generates Java sources from Modello mdo model files"> <target name="generate-sources" depends="pull" description="generates Java sources from Modello mdo model files">
<mkdir dir="bootstrap/target"/> <mkdir dir="bootstrap/target" />
<mkdir dir="bootstrap/target/generated-sources"/> <mkdir dir="bootstrap/target/generated-sources" />
<macrodef name="modello-single-mode"> <macrodef name="modello-single-mode">
<attribute name="file"/> <attribute name="file" />
<attribute name="mode"/> <attribute name="mode" />
<attribute name="version"/> <attribute name="version" />
<sequential> <sequential>
<java fork="fork" classname="org.codehaus.modello.ModelloCli" failonerror="true"> <java fork="fork" classname="org.codehaus.modello.ModelloCli" failonerror="true">
<classpath refid="modello.pathid"/> <classpath refid="modello.pathid" />
<arg file="@{file}"/> <!-- model file --> <arg file="@{file}" />
<arg value="@{mode}"/> <!-- output type --> <!-- model file -->
<arg file="bootstrap/target/generated-sources"/> <!-- output directory --> <arg value="@{mode}" />
<arg value="@{version}"/> <!-- model version --> <!-- output type -->
<arg value="false"/> <!-- package with version --> <arg file="bootstrap/target/generated-sources" />
<arg value="true"/> <!-- use Java 5 --> <!-- output directory -->
<arg value="UTF-8"/> <!-- encoding --> <arg value="@{version}" />
<!-- model version -->
<arg value="false" />
<!-- package with version -->
<arg value="true" />
<!-- use Java 5 -->
<arg value="UTF-8" />
<!-- encoding -->
</java> </java>
</sequential> </sequential>
</macrodef> </macrodef>
<macrodef name="modello"> <macrodef name="modello">
<attribute name="file"/> <attribute name="file" />
<attribute name="version" default="1.0.0"/> <attribute name="version" default="1.0.0" />
<sequential> <sequential>
<echo taskname="modello" message="Generating sources for @{file}"/> <echo taskname="modello" message="Generating sources for @{file}" />
<modello-single-mode file="@{file}" version="@{version}" mode="java"/> <modello-single-mode file="@{file}" version="@{version}" mode="java" />
<modello-single-mode file="@{file}" version="@{version}" mode="xpp3-reader"/> <modello-single-mode file="@{file}" version="@{version}" mode="xpp3-reader" />
<modello-single-mode file="@{file}" version="@{version}" mode="xpp3-writer"/> <modello-single-mode file="@{file}" version="@{version}" mode="xpp3-writer" />
</sequential> </sequential>
</macrodef> </macrodef>
<modello file="maven-model/src/main/mdo/maven.mdo" version="4.0.0"/> <modello file="maven-model/src/main/mdo/maven.mdo" version="4.0.0" />
<modello file="maven-lifecycle/src/main/mdo/maven-lifecycle.mdo"/> <modello file="maven-plugin-api/src/main/mdo/lifecycle.mdo" />
<modello file="maven-plugin-api/src/main/mdo/lifecycle.mdo"/> <modello file="maven-model-builder/src/main/mdo/profiles.mdo" />
<modello file="maven-model-builder/src/main/mdo/profiles.mdo"/> <modello file="maven-core/src/main/mdo/settings.mdo" />
<modello file="maven-core/src/main/mdo/settings.mdo"/> <modello file="maven-toolchain/src/main/mdo/toolchains.mdo" />
<modello file="maven-toolchain/src/main/mdo/toolchains.mdo"/> <modello file="maven-compat/src/main/mdo/metadata.mdo" />
<modello file="maven-compat/src/main/mdo/metadata.mdo"/>
</target> </target>
<target name="compile-boot" depends="generate-sources" description="compiles the bootstrap sources"> <target name="compile-boot" depends="generate-sources" description="compiles the bootstrap sources">
<path id="sources"> <path id="sources">
<dirset dir="."> <dirset dir=".">
<include name="bootstrap/target/generated-sources"/> <include name="bootstrap/target/generated-sources" />
<include name="*/src/main/*"/> <include name="*/src/main/*" />
</dirset> </dirset>
</path> </path>
<mkdir dir="bootstrap/target/classes"/> <mkdir dir="bootstrap/target/classes" />
<javac destdir="bootstrap/target/classes" encoding="UTF-8" source="1.5" target="1.5" debug="true"> <javac destdir="bootstrap/target/classes" encoding="UTF-8" source="1.5" target="1.5" debug="true">
<src refid="sources"/> <src refid="sources" />
<classpath refid="pom.pathid"/> <classpath refid="pom.pathid" />
</javac> </javac>
<path id="maven.classpath"> <path id="maven.classpath">
<pathelement location="bootstrap/target/classes"/> <pathelement location="bootstrap/target/classes" />
<pathelement location="maven-compat/src/main/resources"/> <pathelement location="maven-compat/src/main/resources" />
<path refid="sources"/> <path refid="sources" />
<path refid="pom.pathid"/> <path refid="pom.pathid" />
</path> </path>
</target> </target>
<target name="maven-compile" depends="compile-boot,process-classes" description="compiles Maven using the bootstrap Maven, skipping automated tests"> <target name="maven-compile" depends="compile-boot,process-classes" description="compiles Maven using the bootstrap Maven, skipping automated tests">
<java fork="true" classname="org.apache.maven.cli.MavenCli" failonerror="true"> <java fork="true" classname="org.apache.maven.cli.MavenCli" failonerror="true">
<classpath refid="maven.classpath"/> <classpath refid="maven.classpath" />
<arg value="${maven.debug}"/> <arg value="${maven.debug}" />
<arg value="-B"/> <arg value="-B" />
<arg value="clean"/> <arg value="-X" />
<arg value="install"/> <arg value="-e" />
<arg value="-Dmaven.repo.local=${maven.repo.local}"/> <arg value="clean" />
<arg value="-Dsurefire.useFile=${surefire.useFile}"/> <arg value="install" />
<arg value="-Dmaven.test.skip=${maven.test.skip}" />
<arg value="-Dmaven.repo.local=${maven.repo.local}" />
<arg value="-Dsurefire.useFile=${surefire.useFile}" />
</java> </java>
</target> </target>
<target name="maven-assembly" depends="maven-compile" description="generates the Maven installation assembly using the bootstrap Maven"> <target name="maven-assembly" depends="maven-compile" description="generates the Maven installation assembly using the bootstrap Maven">
<echo> <echo>
The new Maven distribution was created as part of the MAVEN-COMPILE step, above. The new Maven distribution was created as part of the MAVEN-COMPILE step, above.
This goal just validates the presence of that distribution. This goal just validates the presence of that distribution.
</echo> </echo>
<condition property="build.failed"> <condition property="build.failed">
<not> <not>
<available file="${maven.assembly}"/> <available file="${maven.assembly}" />
</not> </not>
</condition> </condition>
<fail if="build.failed" message="Assembly task seemed to succeed, but couldn't find assembly file: ${maven.assembly}"/> <fail if="build.failed" message="Assembly task seemed to succeed, but couldn't find assembly file: ${maven.assembly}" />
</target> </target>
<target name="extract-assembly" depends="init,maven-assembly" description="extracts the maven assembly into maven.home"> <target name="extract-assembly" depends="init,maven-assembly" description="extracts the maven assembly into maven.home">
<echo>Extracting assembly to ${maven.home.dirname} ...</echo> <echo>Extracting assembly to ${maven.home.dirname} ...</echo>
<!-- If we are starting from scratch make sure the directory is created --> <!-- If we are starting from scratch make sure the directory is created -->
<delete dir="${maven.home.effective}"/> <delete dir="${maven.home.effective}" />
<mkdir dir="${maven.home.effective}"/> <mkdir dir="${maven.home.effective}" />
<unzip src="${maven.assembly}" dest="${maven.home.dirname}"/> <unzip src="${maven.assembly}" dest="${maven.home.dirname}" />
<chmod perm="+x"> <chmod perm="+x">
<fileset dir="${maven.home.effective}/bin"> <fileset dir="${maven.home.effective}/bin">
<include name="mvn"/> <include name="mvn" />
</fileset> </fileset>
</chmod> </chmod>
</target> </target>
<target name="all" depends="clean-bootstrap,init,extract-assembly"/> <target name="all" depends="clean-bootstrap,init,extract-assembly" />
</project> </project>

View File

@ -28,6 +28,10 @@
<groupId>org.apache.maven</groupId> <groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId> <artifactId>maven-model</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model-builder</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.codehaus.plexus</groupId> <groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-container-default</artifactId> <artifactId>plexus-container-default</artifactId>
@ -43,7 +47,10 @@
<dependency> <dependency>
<groupId>org.apache.maven.wagon</groupId> <groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-file</artifactId> <artifactId>wagon-file</artifactId>
<scope>test</scope> </dependency>
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-http-lightweight</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>easymock</groupId> <groupId>easymock</groupId>

View File

@ -19,6 +19,11 @@
* under the License. * under the License.
*/ */
import java.io.File;
import java.util.Collection;
import java.util.List;
import java.util.regex.Pattern;
import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
@ -27,17 +32,6 @@
import org.apache.maven.artifact.versioning.OverConstrainedVersionException; import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.artifact.versioning.VersionRange;
import java.io.File;
import java.util.Collection;
import java.util.List;
import java.util.regex.Pattern;
/**
* Description of an artifact.
*
* @todo do we really need an interface here?
* @todo get rid of the multiple states we can have (project, parent, etc artifacts, file == null, snapshot, etc) - construct subclasses and use accordingly?
*/
public interface Artifact public interface Artifact
extends Comparable extends Comparable
{ {
@ -73,20 +67,12 @@ public interface Artifact
void setVersion( String version ); void setVersion( String version );
/**
* Get the artifactScope of the artifact. If the artifact is a standalone rather than a dependency, it's artifactScope will be
* <code>null</code>. The artifactScope may not be the same as it was declared on the original dependency, as this is the
* result of combining it with the main project artifactScope.
*
* @return the artifactScope
*/
String getScope(); String getScope();
String getType(); String getType();
String getClassifier(); String getClassifier();
// only providing this since classifier is *very* optional...
boolean hasClassifier(); boolean hasClassifier();
File getFile(); File getFile();
@ -95,11 +81,8 @@ public interface Artifact
String getBaseVersion(); String getBaseVersion();
/** @todo would like to get rid of this - or at least only have one. Base version should be immutable. */
void setBaseVersion( String baseVersion ); void setBaseVersion( String baseVersion );
// ----------------------------------------------------------------------
String getId(); String getId();
String getDependencyConflictId(); String getDependencyConflictId();
@ -112,8 +95,7 @@ public interface Artifact
ArtifactRepository getRepository(); ArtifactRepository getRepository();
void updateVersion( String version, void updateVersion( String version, ArtifactRepository localRepository );
ArtifactRepository localRepository );
String getDownloadUrl(); String getDownloadUrl();
@ -125,14 +107,8 @@ void updateVersion( String version,
ArtifactHandler getArtifactHandler(); ArtifactHandler getArtifactHandler();
/**
* @return {@link List} &lt; {@link String} > with artifact ids
*/
List<String> getDependencyTrail(); List<String> getDependencyTrail();
/**
* @param dependencyTrail {@link List} &lt; {@link String} > with artifact ids
*/
void setDependencyTrail( List<String> dependencyTrail ); void setDependencyTrail( List<String> dependencyTrail );
void setScope( String scope ); void setScope( String scope );
@ -155,7 +131,6 @@ void updateVersion( String version,
void setResolvedVersion( String version ); void setResolvedVersion( String version );
/** @todo remove, a quick hack for the lifecycle executor */
void setArtifactHandler( ArtifactHandler handler ); void setArtifactHandler( ArtifactHandler handler );
boolean isRelease(); boolean isRelease();
@ -175,4 +150,8 @@ ArtifactVersion getSelectedVersion()
boolean isSelectedVersionKnown() boolean isSelectedVersionKnown()
throws OverConstrainedVersionException; throws OverConstrainedVersionException;
void setFromAuthoritativeRepository( boolean fromAuthoritativeRepository );
boolean isFromAuthoritativeRepository();
} }

View File

@ -1,115 +0,0 @@
package org.apache.maven.artifact;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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;
/**
* Type safe enumeration for the artifact status field.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id$
*/
public final class ArtifactStatus
implements Comparable
{
/** No trust - no information about status. */
public static final ArtifactStatus NONE = new ArtifactStatus( "none", 0 );
/** No trust - information was generated with defaults. */
public static final ArtifactStatus GENERATED = new ArtifactStatus( "generated", 1 );
/** Low trust - was converted from the Maven 1.x repository. */
public static final ArtifactStatus CONVERTED = new ArtifactStatus( "converted", 2 );
/** Moderate trust - it was deployed directly from a partner. */
public static final ArtifactStatus PARTNER = new ArtifactStatus( "partner", 3 );
/** Moderate trust - it was deployed directly by a user. */
public static final ArtifactStatus DEPLOYED = new ArtifactStatus( "deployed", 4 );
/** Trusted, as it has had its data verified by hand. */
public static final ArtifactStatus VERIFIED = new ArtifactStatus( "verified", 5 );
private final int rank;
private final String key;
private static Map<String,ArtifactStatus> map;
private ArtifactStatus( String key,
int rank )
{
this.rank = rank;
this.key = key;
if ( map == null )
{
map = new HashMap<String,ArtifactStatus>();
}
map.put( key, this );
}
public static ArtifactStatus valueOf( String status )
{
ArtifactStatus retVal = null;
if ( status != null )
{
retVal = map.get( status );
}
return retVal != null ? retVal : NONE;
}
public boolean equals( Object o )
{
if ( this == o )
{
return true;
}
if ( o == null || getClass() != o.getClass() )
{
return false;
}
final ArtifactStatus that = (ArtifactStatus) o;
return rank == that.rank;
}
public int hashCode()
{
return rank;
}
public String toString()
{
return key;
}
public int compareTo( Object o )
{
ArtifactStatus s = (ArtifactStatus) o;
return rank - s.rank;
}
}

View File

@ -19,8 +19,6 @@
* under the License. * under the License.
*/ */
import org.apache.maven.artifact.versioning.VersionRange;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@ -28,21 +26,17 @@
import java.util.Map; import java.util.Map;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import org.apache.maven.artifact.versioning.VersionRange;
public final class ArtifactUtils public final class ArtifactUtils
{ {
private ArtifactUtils()
{
}
public static boolean isSnapshot( String version )
{
return ( version != null ) &&
( version.toUpperCase().endsWith( Artifact.SNAPSHOT_VERSION ) || Artifact.VERSION_FILE_PATTERN.matcher( version )
.matches() );
}
public static String toSnapshotVersion( String version ) public static String toSnapshotVersion( String version )
{ {
if(version == null)
{
throw new IllegalArgumentException("version: null");
}
Matcher m = Artifact.VERSION_FILE_PATTERN.matcher( version ); Matcher m = Artifact.VERSION_FILE_PATTERN.matcher( version );
if ( m.matches() ) if ( m.matches() )
{ {
@ -53,51 +47,56 @@ public static String toSnapshotVersion( String version )
return version; return version;
} }
} }
public static String versionlessKey( Artifact artifact ) public static String versionlessKey( Artifact artifact )
{ {
return versionlessKey( artifact.getGroupId(), artifact.getArtifactId() ); return versionlessKey( artifact.getGroupId(), artifact.getArtifactId() );
} }
public static String versionlessKey( String groupId, public static String versionlessKey( String groupId, String artifactId )
String artifactId )
{ {
if ( groupId == null ) if ( groupId == null )
{ {
throw new NullPointerException( "groupId was null" ); throw new NullPointerException( "groupId is null" );
} }
if ( artifactId == null ) if ( artifactId == null )
{ {
throw new NullPointerException( "artifactId was null" ); throw new NullPointerException( "artifactId is null" );
} }
return groupId + ":" + artifactId; return groupId + ":" + artifactId;
} }
public static String artifactId( String groupId, public static String key( Artifact artifact )
String artifactId,
String type,
String version )
{ {
return artifactId( groupId, artifactId, type, null, version ); return key( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion() );
} }
public static String artifactId( String groupId, public static String key( String groupId, String artifactId, String version )
String artifactId,
String type,
String classifier,
String baseVersion )
{ {
return groupId + ":" + artifactId + ":" + type + ( classifier != null ? ":" + classifier : "" ) + ":" + if ( groupId == null )
baseVersion; {
} throw new NullPointerException( "groupId is null" );
}
if ( artifactId == null )
{
throw new NullPointerException( "artifactId is null" );
}
if ( version == null )
{
throw new NullPointerException( "version is null" );
}
return groupId + ":" + artifactId + ":" + version;
}
public static Map<String,Artifact> artifactMapByVersionlessId( Collection<Artifact> artifacts ) public static Map<String,Artifact> artifactMapByVersionlessId( Collection<Artifact> artifacts )
{ {
Map<String,Artifact> artifactMap = new LinkedHashMap<String,Artifact>(); Map<String,Artifact> artifactMap = new LinkedHashMap<String,Artifact>();
if ( artifacts != null ) if ( artifacts != null )
{ {
for (Artifact artifact : artifacts) { for (Artifact artifact : artifacts)
{
artifactMap.put(versionlessKey(artifact), artifact); artifactMap.put(versionlessKey(artifact), artifact);
} }
} }
@ -105,20 +104,6 @@ public static Map<String,Artifact> artifactMapByVersionlessId( Collection<Artifa
return artifactMap; return artifactMap;
} }
public static Map<String,Artifact> artifactMapByArtifactId( Collection<Artifact> artifacts )
{
Map<String,Artifact> artifactMap = new LinkedHashMap<String,Artifact>();
if ( artifacts != null )
{
for (Artifact artifact : artifacts) {
artifactMap.put(artifact.getId(), artifact);
}
}
return artifactMap;
}
public static Artifact copyArtifact( Artifact artifact ) public static Artifact copyArtifact( Artifact artifact )
{ {
VersionRange range = artifact.getVersionRange(); VersionRange range = artifact.getVersionRange();

View File

@ -19,16 +19,6 @@
* under the License. * under the License.
*/ */
import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.codehaus.plexus.util.StringUtils;
import java.io.File; import java.io.File;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
@ -37,10 +27,18 @@
import java.util.Map; import java.util.Map;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
import org.apache.maven.artifact.versioning.VersionRange;
import org.codehaus.plexus.util.StringUtils;
/** /**
* @author <a href="mailto:jason@maven.org">Jason van Zyl </a> * @author Jason van Zyl
* @version $Id$
* @todo this should possibly be replaced by type handler
*/ */
public class DefaultArtifact public class DefaultArtifact
implements Artifact implements Artifact
@ -49,11 +47,6 @@ public class DefaultArtifact
private String artifactId; private String artifactId;
/**
* The resolved version for the artifact after conflict resolution, that has not been transformed.
*
* @todo should be final
*/
private String baseVersion; private String baseVersion;
private final String type; private final String type;
@ -85,28 +78,20 @@ public class DefaultArtifact
private List<ArtifactVersion> availableVersions; private List<ArtifactVersion> availableVersions;
private Map<Object,ArtifactMetadata> metadataMap; private Map<Object,ArtifactMetadata> metadataMap;
private boolean optional; private boolean optional;
public DefaultArtifact( String groupId, public DefaultArtifact( String groupId, String artifactId, String version, String scope, String type, String classifier, ArtifactHandler artifactHandler )
String artifactId, {
VersionRange versionRange, this( groupId, artifactId, VersionRange.createFromVersion( version ), scope, type, classifier, artifactHandler, false );
String scope, }
String type,
String classifier, public DefaultArtifact( String groupId, String artifactId, VersionRange versionRange, String scope, String type, String classifier, ArtifactHandler artifactHandler )
ArtifactHandler artifactHandler )
{ {
this( groupId, artifactId, versionRange, scope, type, classifier, artifactHandler, false ); this( groupId, artifactId, versionRange, scope, type, classifier, artifactHandler, false );
} }
public DefaultArtifact( String groupId, public DefaultArtifact( String groupId, String artifactId, VersionRange versionRange, String scope, String type, String classifier, ArtifactHandler artifactHandler, boolean optional )
String artifactId,
VersionRange versionRange,
String scope,
String type,
String classifier,
ArtifactHandler artifactHandler,
boolean optional )
{ {
this.groupId = groupId; this.groupId = groupId;
@ -400,6 +385,7 @@ public void setBaseVersion( String baseVersion )
protected void setBaseVersionInternal( String baseVersion ) protected void setBaseVersionInternal( String baseVersion )
{ {
Matcher m = VERSION_FILE_PATTERN.matcher( baseVersion ); Matcher m = VERSION_FILE_PATTERN.matcher( baseVersion );
if ( m.matches() ) if ( m.matches() )
{ {
this.baseVersion = m.group( 1 ) + "-" + SNAPSHOT_VERSION; this.baseVersion = m.group( 1 ) + "-" + SNAPSHOT_VERSION;
@ -453,8 +439,7 @@ public int compareTo( Object o )
return result; return result;
} }
public void updateVersion( String version, public void updateVersion( String version, ArtifactRepository localRepository )
ArtifactRepository localRepository )
{ {
setResolvedVersion( version ); setResolvedVersion( version );
setFile( new File( localRepository.getBasedir(), localRepository.pathOf( this ) ) ); setFile( new File( localRepository.getBasedir(), localRepository.pathOf( this ) ) );
@ -608,4 +593,18 @@ public void setOptional( boolean optional )
{ {
this.optional = optional; this.optional = optional;
} }
//
private boolean fromAuthoritativeRepository;
public void setFromAuthoritativeRepository( boolean fromAuthoritativeRepository )
{
this.fromAuthoritativeRepository = fromAuthoritativeRepository;
}
public boolean isFromAuthoritativeRepository()
{
return fromAuthoritativeRepository;
}
} }

View File

@ -1,9 +1,9 @@
package org.apache.maven.artifact; package org.apache.maven.artifact;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file

View File

@ -19,11 +19,11 @@
* under the License. * under the License.
*/ */
import java.io.File;
import org.apache.maven.artifact.Artifact; 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 public interface ArtifactDeployer
{ {
String ROLE = ArtifactDeployer.class.getName(); String ROLE = ArtifactDeployer.class.getName();

View File

@ -34,123 +34,67 @@ public class DefaultArtifactFactory
@Requirement @Requirement
private ArtifactHandlerManager artifactHandlerManager; private ArtifactHandlerManager artifactHandlerManager;
public DefaultArtifactFactory() public Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type )
{
}
public Artifact createArtifact( String groupId,
String artifactId,
String version,
String scope,
String type )
{ {
return createArtifact( groupId, artifactId, version, scope, type, null, null ); return createArtifact( groupId, artifactId, version, scope, type, null, null );
} }
public Artifact createArtifactWithClassifier( String groupId, public Artifact createArtifactWithClassifier( String groupId, String artifactId, String version, String type, String classifier )
String artifactId,
String version,
String type,
String classifier )
{ {
return createArtifact( groupId, artifactId, version, null, type, classifier, null ); return createArtifact( groupId, artifactId, version, null, type, classifier, null );
} }
public Artifact createDependencyArtifact( String groupId, public Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type, String classifier, String scope )
String artifactId,
VersionRange versionRange,
String type,
String classifier,
String scope )
{ {
return createArtifact( groupId, artifactId, versionRange, type, classifier, scope, null ); return createArtifact( groupId, artifactId, versionRange, type, classifier, scope, null );
} }
public Artifact createDependencyArtifact( String groupId, public Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type, String classifier, String scope, boolean optional )
String artifactId,
VersionRange versionRange,
String type,
String classifier,
String scope,
boolean optional )
{ {
return createArtifact( groupId, artifactId, versionRange, type, classifier, scope, null, optional ); return createArtifact( groupId, artifactId, versionRange, type, classifier, scope, null, optional );
} }
public Artifact createDependencyArtifact( String groupId, public Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type, String classifier, String scope, String inheritedScope )
String artifactId,
VersionRange versionRange,
String type,
String classifier,
String scope,
String inheritedScope )
{ {
return createArtifact( groupId, artifactId, versionRange, type, classifier, scope, inheritedScope ); return createArtifact( groupId, artifactId, versionRange, type, classifier, scope, inheritedScope );
} }
public Artifact createDependencyArtifact( String groupId, public Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type, String classifier, String scope, String inheritedScope, boolean optional )
String artifactId,
VersionRange versionRange,
String type,
String classifier,
String scope,
String inheritedScope,
boolean optional )
{ {
return createArtifact( groupId, artifactId, versionRange, type, classifier, scope, inheritedScope, optional ); return createArtifact( groupId, artifactId, versionRange, type, classifier, scope, inheritedScope, optional );
} }
public Artifact createBuildArtifact( String groupId, public Artifact createBuildArtifact( String groupId, String artifactId, String version, String packaging )
String artifactId,
String version,
String packaging )
{ {
return createArtifact( groupId, artifactId, version, null, packaging, null, null ); return createArtifact( groupId, artifactId, version, null, packaging, null, null );
} }
public Artifact createProjectArtifact( String groupId, public Artifact createProjectArtifact( String groupId, String artifactId, String version )
String artifactId,
String version )
{ {
return createProjectArtifact( groupId, artifactId, version, null ); return createProjectArtifact( groupId, artifactId, version, null );
} }
public Artifact createParentArtifact( String groupId, public Artifact createParentArtifact( String groupId, String artifactId, String version )
String artifactId,
String version )
{ {
return createProjectArtifact( groupId, artifactId, version ); return createProjectArtifact( groupId, artifactId, version );
} }
public Artifact createPluginArtifact( String groupId, public Artifact createPluginArtifact( String groupId, String artifactId, VersionRange versionRange )
String artifactId,
VersionRange versionRange )
{ {
return createArtifact( groupId, artifactId, versionRange, "maven-plugin", null, Artifact.SCOPE_RUNTIME, null ); return createArtifact( groupId, artifactId, versionRange, "maven-plugin", null, Artifact.SCOPE_RUNTIME, null );
} }
public Artifact createProjectArtifact( String groupId, public Artifact createProjectArtifact( String groupId, String artifactId, String version, String scope )
String artifactId,
String version,
String scope )
{ {
return createArtifact( groupId, artifactId, version, scope, "pom" ); return createArtifact( groupId, artifactId, version, scope, "pom" );
} }
public Artifact createExtensionArtifact( String groupId, public Artifact createExtensionArtifact( String groupId, String artifactId, VersionRange versionRange )
String artifactId,
VersionRange versionRange )
{ {
return createArtifact( groupId, artifactId, versionRange, "jar", null, Artifact.SCOPE_RUNTIME, null ); return createArtifact( groupId, artifactId, versionRange, "jar", null, Artifact.SCOPE_RUNTIME, null );
} }
private Artifact createArtifact( String groupId, private Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type, String classifier, String inheritedScope )
String artifactId,
String version,
String scope,
String type,
String classifier,
String inheritedScope )
{ {
VersionRange versionRange = null; VersionRange versionRange = null;
if ( version != null ) if ( version != null )
@ -160,29 +104,15 @@ private Artifact createArtifact( String groupId,
return createArtifact( groupId, artifactId, versionRange, type, classifier, scope, inheritedScope ); return createArtifact( groupId, artifactId, versionRange, type, classifier, scope, inheritedScope );
} }
private Artifact createArtifact( String groupId, private Artifact createArtifact( String groupId, String artifactId, VersionRange versionRange, String type, String classifier, String scope, String inheritedScope )
String artifactId,
VersionRange versionRange,
String type,
String classifier,
String scope,
String inheritedScope )
{ {
return createArtifact( groupId, artifactId, versionRange, type, classifier, scope, inheritedScope, false ); return createArtifact( groupId, artifactId, versionRange, type, classifier, scope, inheritedScope, false );
} }
private Artifact createArtifact( String groupId, private Artifact createArtifact( String groupId, String artifactId, VersionRange versionRange, String type, String classifier, String scope, String inheritedScope, boolean optional )
String artifactId,
VersionRange versionRange,
String type,
String classifier,
String scope,
String inheritedScope,
boolean optional )
{ {
// TODO: can refactor - inherited artifactScope calculation belongs in the collector, use artifactScope handler
String desiredScope = Artifact.SCOPE_RUNTIME; String desiredScope = Artifact.SCOPE_RUNTIME;
if ( inheritedScope == null ) if ( inheritedScope == null )
{ {
desiredScope = scope; desiredScope = scope;
@ -215,7 +145,6 @@ else if ( Artifact.SCOPE_COMPILE.equals( scope ) && Artifact.SCOPE_COMPILE.equal
ArtifactHandler handler = artifactHandlerManager.getArtifactHandler( type ); ArtifactHandler handler = artifactHandlerManager.getArtifactHandler( type );
return new DefaultArtifact( groupId, artifactId, versionRange, desiredScope, type, classifier, handler, return new DefaultArtifact( groupId, artifactId, versionRange, desiredScope, type, classifier, handler, optional );
optional );
} }
} }

View File

@ -19,10 +19,10 @@
* under the License. * under the License.
*/ */
import org.apache.maven.artifact.handler.ArtifactHandler;
import java.util.Map; import java.util.Map;
import org.apache.maven.artifact.handler.ArtifactHandler;
/** /**
* @author Jason van Zyl * @author Jason van Zyl
* @version $Id$ * @version $Id$

View File

@ -19,14 +19,14 @@
* under the License. * under the License.
*/ */
import java.util.Map;
import java.util.Set;
import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.handler.DefaultArtifactHandler; import org.apache.maven.artifact.handler.DefaultArtifactHandler;
import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.component.annotations.Requirement;
import java.util.Map;
import java.util.Set;
/** /**
* @author Jason van Zyl * @author Jason van Zyl
* @version $Id$ * @version $Id$

View File

@ -19,11 +19,11 @@
* under the License. * under the License.
*/ */
import java.io.File;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import java.io.File;
/** /**
* @author <a href="michal@codehaus.org">Michal Maczka</a> * @author <a href="michal@codehaus.org">Michal Maczka</a>
* @version $Id$ * @version $Id$

View File

@ -19,6 +19,9 @@
* under the License. * under the License.
*/ */
import java.io.File;
import java.io.IOException;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
@ -30,9 +33,6 @@
import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.FileUtils;
import java.io.File;
import java.io.IOException;
/** /**
* @author Jason van Zyl * @author Jason van Zyl
*/ */

View File

@ -1,75 +0,0 @@
package org.apache.maven.artifact.manager;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.authentication.AuthenticationInfo;
public class CredentialsChangeRequest
{
private String resourceId;
private AuthenticationInfo authInfo;
private String oldPassword;
public CredentialsChangeRequest()
{
}
public CredentialsChangeRequest( String resourceId,
AuthenticationInfo authInfo,
String oldPassword )
{
super();
this.resourceId = resourceId;
this.authInfo = authInfo;
this.oldPassword = oldPassword;
}
public String getResourceId()
{
return resourceId;
}
public void setResourceId( String resourceId )
{
this.resourceId = resourceId;
}
public AuthenticationInfo getAuthInfo()
{
return authInfo;
}
public void setAuthInfo( AuthenticationInfo authInfo )
{
this.authInfo = authInfo;
}
public String getOldPassword()
{
return oldPassword;
}
public void setOldPassword( String oldPassword )
{
this.oldPassword = oldPassword;
}
}

View File

@ -1,56 +0,0 @@
package org.apache.maven.artifact.manager;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.authentication.AuthenticationInfo;
/**
* A wrapper class around setting/retrieving/caching authentication
* info by resource ID. Typical usage - accessing server authentication for
* by it's ID
*
* @author <a href="oleg@codehaus.org">Oleg Gusakov</a>
*/
public interface CredentialsDataSource
{
public static final String ROLE = CredentialsDataSource.class.getName();
/**
* find, if not found, prompt and create Authentication info
* for a given resource
*
* @param resourceId resource ID for which authentication is required
* @return resource AuthenticationInfo. Should always exist.
* @throws CredentialsDataSourceException
*/
AuthenticationInfo get( String resourceId )
throws CredentialsDataSourceException;
/**
* set, if not found, prompt and create Authentication info
* for a given resource. This one uses the old password
* member of AuthenticationInfo
*
* @throws CredentialsDataSourceException
*/
void set( CredentialsChangeRequest req )
throws CredentialsDataSourceException;
}

View File

@ -19,14 +19,6 @@
* under the License. * under the License.
*/ */
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.logging.Logger;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
@ -39,12 +31,19 @@
import java.util.Date; import java.util.Date;
import java.util.Properties; import java.util.Properties;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.logging.Logger;
@Component(role=UpdateCheckManager.class) @Component(role=UpdateCheckManager.class)
public class DefaultUpdateCheckManager public class DefaultUpdateCheckManager
extends AbstractLogEnabled extends AbstractLogEnabled
implements UpdateCheckManager implements UpdateCheckManager
{ {
public DefaultUpdateCheckManager() public DefaultUpdateCheckManager()
{ {
@ -74,7 +73,7 @@ public boolean isUpdateRequired( Artifact artifact, ArtifactRepository repositor
// we can safely assume that we're calculating based on the snapshot policy here if we've made it past the // we can safely assume that we're calculating based on the snapshot policy here if we've made it past the
// release-artifact short circuit above. // release-artifact short circuit above.
ArtifactRepositoryPolicy policy = repository.getSnapshots(); ArtifactRepositoryPolicy policy = repository.getSnapshots();
return isUpdateRequired( artifact, repository, policy ); return isUpdateRequired( artifact, repository, policy );
} }

View File

@ -1,22 +1,18 @@
package org.apache.maven.artifact.manager; package org.apache.maven.artifact.manager;
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
* or more contributor license agreements. See the NOTICE file * agreements. See the NOTICE file distributed with this work for additional information regarding
* distributed with this work for additional information * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
* regarding copyright ownership. The ASF licenses this file * "License"); you may not use this file except in compliance with the License. You may obtain a
* to you under the Apache License, Version 2.0 (the * copy of the License at
* "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
* *
* 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
* Unless required by applicable law or agreed to in writing, * or implied. See the License for the specific language governing permissions and limitations under
* software distributed under the License is distributed on an * the License.
* "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; import java.io.File;
@ -25,14 +21,13 @@
import java.net.URL; import java.net.URL;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
import org.apache.maven.wagon.ConnectionException; import org.apache.maven.wagon.ConnectionException;
import org.apache.maven.wagon.ResourceDoesNotExistException; import org.apache.maven.wagon.ResourceDoesNotExistException;
@ -40,14 +35,10 @@
import org.apache.maven.wagon.UnsupportedProtocolException; import org.apache.maven.wagon.UnsupportedProtocolException;
import org.apache.maven.wagon.Wagon; import org.apache.maven.wagon.Wagon;
import org.apache.maven.wagon.authentication.AuthenticationException; import org.apache.maven.wagon.authentication.AuthenticationException;
import org.apache.maven.wagon.authentication.AuthenticationInfo;
import org.apache.maven.wagon.authorization.AuthorizationException; import org.apache.maven.wagon.authorization.AuthorizationException;
import org.apache.maven.wagon.events.TransferListener; import org.apache.maven.wagon.events.TransferListener;
import org.apache.maven.wagon.observers.ChecksumObserver; import org.apache.maven.wagon.observers.ChecksumObserver;
import org.apache.maven.wagon.proxy.ProxyInfo;
import org.apache.maven.wagon.proxy.ProxyInfoProvider;
import org.apache.maven.wagon.repository.Repository; import org.apache.maven.wagon.repository.Repository;
import org.apache.maven.wagon.repository.RepositoryPermissions;
import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.component.annotations.Requirement;
@ -60,47 +51,26 @@
import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.FileUtils;
@Component(role=WagonManager.class) @Component(role = WagonManager.class)
public class DefaultWagonManager public class DefaultWagonManager
implements WagonManager implements WagonManager
{ {
private static final String[] CHECKSUM_IDS = {"md5", "sha1"}; private static final String[] CHECKSUM_IDS = { "md5", "sha1" };
/** have to match the CHECKSUM_IDS */ /** have to match the CHECKSUM_IDS */
private static final String[] CHECKSUM_ALGORITHMS = {"MD5", "SHA-1"}; private static final String[] CHECKSUM_ALGORITHMS = { "MD5", "SHA-1" };
@Requirement @Requirement
private Logger logger; private Logger logger;
@Requirement @Requirement
private PlexusContainer container; private PlexusContainer container;
// TODO: proxies, authentication and mirrors are via settings, and should come in via an alternate method - perhaps
// attached to ArtifactRepository before the method is called (so AR would be composed of WR, not inherit it)
private Map<String,ProxyInfo> proxies = new HashMap<String,ProxyInfo>();
private static Map<String,AuthenticationInfo> authenticationInfoMap = new HashMap<String,AuthenticationInfo>();
private Map<String,RepositoryPermissions> serverPermissionsMap = new HashMap<String,RepositoryPermissions>();
//used LinkedMap to preserve the order.
private Map<String,ArtifactRepository> mirrors = new LinkedHashMap<String,ArtifactRepository>();
/** Map( String, XmlPlexusConfiguration ) with the repository id and the wagon configuration */ /** Map( String, XmlPlexusConfiguration ) with the repository id and the wagon configuration */
private Map<String,XmlPlexusConfiguration> serverConfigurationMap = new HashMap<String,XmlPlexusConfiguration>(); private Map<String, XmlPlexusConfiguration> serverConfigurationMap = new HashMap<String, XmlPlexusConfiguration>();
private RepositoryPermissions defaultRepositoryPermissions; @Requirement(role = Wagon.class)
private Map<String,Wagon> wagons;
// Components
@Requirement
private ArtifactRepositoryFactory repositoryFactory;
@Requirement(role=Wagon.class)
private Map wagons;
//@Requirement
private CredentialsDataSource credentialsDataSource;
@Requirement @Requirement
private UpdateCheckManager updateCheckManager; private UpdateCheckManager updateCheckManager;
@ -108,24 +78,22 @@ public class DefaultWagonManager
private String httpUserAgent = "Apache-Maven/3.0-alpha-1"; private String httpUserAgent = "Apache-Maven/3.0-alpha-1";
private TransferListener downloadMonitor; private TransferListener downloadMonitor;
public void setDownloadMonitor( TransferListener downloadMonitor ) public void setDownloadMonitor( TransferListener downloadMonitor )
{ {
this.downloadMonitor = downloadMonitor; this.downloadMonitor = downloadMonitor;
} }
// TODO: this leaks the component in the public api - it is never released back to the container
public Wagon getWagon( Repository repository ) public Wagon getWagon( Repository repository )
throws UnsupportedProtocolException, WagonConfigurationException throws UnsupportedProtocolException, WagonConfigurationException
{ {
String protocol = repository.getProtocol(); String protocol = repository.getProtocol();
if ( protocol == null ) if ( protocol == null )
{ {
throw new UnsupportedProtocolException( "The repository " + repository + " does not specify a protocol" ); throw new UnsupportedProtocolException( "The repository " + repository + " does not specify a protocol" );
} }
Wagon wagon = getWagon( protocol ); Wagon wagon = getWagon( protocol );
configureWagon( wagon, repository.getId(), protocol ); configureWagon( wagon, repository.getId(), protocol );
@ -140,15 +108,13 @@ public Wagon getWagon( String protocol )
{ {
throw new UnsupportedProtocolException( "Unspecified protocol" ); throw new UnsupportedProtocolException( "Unspecified protocol" );
} }
String hint = protocol.toLowerCase( java.util.Locale.ENGLISH ); String hint = protocol.toLowerCase( java.util.Locale.ENGLISH );
Wagon wagon = (Wagon) wagons.get( hint ); Wagon wagon = (Wagon) wagons.get( hint );
if ( wagon == null ) if ( wagon == null )
{ {
throw new UnsupportedProtocolException( throw new UnsupportedProtocolException( "Cannot find wagon which supports the requested protocol: " + protocol );
"Cannot find wagon which supports the requested protocol: " + protocol );
} }
return wagon; return wagon;
@ -159,7 +125,7 @@ public void putArtifact( File source, Artifact artifact, ArtifactRepository depl
{ {
putRemoteFile( deploymentRepository, source, deploymentRepository.pathOf( artifact ), downloadMonitor ); putRemoteFile( deploymentRepository, source, deploymentRepository.pathOf( artifact ), downloadMonitor );
} }
public void putArtifact( File source, Artifact artifact, ArtifactRepository deploymentRepository, TransferListener downloadMonitor ) public void putArtifact( File source, Artifact artifact, ArtifactRepository deploymentRepository, TransferListener downloadMonitor )
throws TransferFailedException throws TransferFailedException
{ {
@ -173,7 +139,7 @@ public void putArtifactMetadata( File source, ArtifactMetadata artifactMetadata,
putRemoteFile( repository, source, repository.pathOfRemoteRepositoryMetadata( artifactMetadata ), null ); putRemoteFile( repository, source, repository.pathOfRemoteRepositoryMetadata( artifactMetadata ), null );
} }
private void putRemoteFile( ArtifactRepository repository, File source, String remotePath, TransferListener downloadMonitor ) public void putRemoteFile( ArtifactRepository repository, File source, String remotePath, TransferListener downloadMonitor )
throws TransferFailedException throws TransferFailedException
{ {
String protocol = repository.getProtocol(); String protocol = repository.getProtocol();
@ -195,9 +161,9 @@ private void putRemoteFile( ArtifactRepository repository, File source, String r
wagon.addTransferListener( downloadMonitor ); wagon.addTransferListener( downloadMonitor );
} }
Map<String,ChecksumObserver> checksums = new HashMap<String,ChecksumObserver>( 2 ); Map<String, ChecksumObserver> checksums = new HashMap<String, ChecksumObserver>( 2 );
Map<String,String> sums = new HashMap<String,String>( 2 ); Map<String, String> sums = new HashMap<String, String>( 2 );
// TODO: configure these on the repository // TODO: configure these on the repository
for ( int i = 0; i < CHECKSUM_IDS.length; i++ ) for ( int i = 0; i < CHECKSUM_IDS.length; i++ )
@ -208,27 +174,11 @@ private void putRemoteFile( ArtifactRepository repository, File source, String r
try try
{ {
try try
{ {
Repository artifactRepository = new Repository( repository.getId(), repository.getUrl() ); wagon.connect( new Repository( repository.getId(), repository.getUrl() ) );
AuthenticationInfo authenticationInfo = getAuthenticationInfo( repository.getId() );
wagon.connect( artifactRepository, authenticationInfo, new ProxyInfoProvider()
{
public ProxyInfo getProxyInfo( String protocol )
{
return getProxy( protocol );
}
});
wagon.put( source, remotePath ); wagon.put( source, remotePath );
} }
catch ( CredentialsDataSourceException e )
{
String err = "Problem with server credentials: " + e.getMessage();
logger.error( err );
throw new TransferFailedException( err );
}
finally finally
{ {
if ( downloadMonitor != null ) if ( downloadMonitor != null )
@ -238,19 +188,21 @@ public ProxyInfo getProxyInfo( String protocol )
} }
// Pre-store the checksums as any future puts will overwrite them // Pre-store the checksums as any future puts will overwrite them
for (String extension : checksums.keySet()) { for ( String extension : checksums.keySet() )
ChecksumObserver observer = checksums.get(extension); {
sums.put(extension, observer.getActualChecksum()); ChecksumObserver observer = checksums.get( extension );
sums.put( extension, observer.getActualChecksum() );
} }
// We do this in here so we can checksum the artifact metadata too, otherwise it could be metadata itself // We do this in here so we can checksum the artifact metadata too, otherwise it could be metadata itself
for (String extension : checksums.keySet()) { for ( String extension : checksums.keySet() )
{
// TODO: shouldn't need a file intermediatary - improve wagon to take a stream // TODO: shouldn't need a file intermediatary - improve wagon to take a stream
File temp = File.createTempFile("maven-artifact", null); File temp = File.createTempFile( "maven-artifact", null );
temp.deleteOnExit(); temp.deleteOnExit();
FileUtils.fileWrite(temp.getAbsolutePath(), "UTF-8", sums.get(extension)); FileUtils.fileWrite( temp.getAbsolutePath(), "UTF-8", sums.get( extension ) );
wagon.put(temp, remotePath + "." + extension); wagon.put( temp, remotePath + "." + extension );
} }
} }
catch ( ConnectionException e ) catch ( ConnectionException e )
@ -276,10 +228,12 @@ public ProxyInfo getProxyInfo( String protocol )
finally finally
{ {
// Remove every checksum listener // Remove every checksum listener
for (String aCHECKSUM_IDS : CHECKSUM_IDS) { for ( String aCHECKSUM_IDS : CHECKSUM_IDS )
TransferListener checksumListener = checksums.get(aCHECKSUM_IDS); {
if (checksumListener != null) { TransferListener checksumListener = checksums.get( aCHECKSUM_IDS );
wagon.removeTransferListener(checksumListener); if ( checksumListener != null )
{
wagon.removeTransferListener( checksumListener );
} }
} }
@ -289,8 +243,7 @@ public ProxyInfo getProxyInfo( String protocol )
} }
} }
private ChecksumObserver addChecksumObserver( Wagon wagon, private ChecksumObserver addChecksumObserver( Wagon wagon, String algorithm )
String algorithm )
throws TransferFailedException throws TransferFailedException
{ {
try try
@ -305,43 +258,38 @@ private ChecksumObserver addChecksumObserver( Wagon wagon,
} }
} }
// NOTE: It is not possible that this method throws TransferFailedException under current conditions. // NOTE: It is not possible that this method throws TransferFailedException under current conditions.
// FIXME: Change the throws clause to reflect the fact that we're never throwing TransferFailedException // FIXME: Change the throws clause to reflect the fact that we're never throwing TransferFailedException
public void getArtifact( Artifact artifact, ArtifactRepository remoteRepository, boolean force ) public void getArtifact( Artifact artifact, ArtifactRepository remoteRepository, boolean force )
throws TransferFailedException, ResourceDoesNotExistException throws TransferFailedException, ResourceDoesNotExistException
{ {
getArtifact( artifact, remoteRepository, downloadMonitor, force ); getArtifact( artifact, remoteRepository, downloadMonitor, force );
} }
public void getArtifact( Artifact artifact, ArtifactRepository remoteRepository ) public void getArtifact( Artifact artifact, ArtifactRepository remoteRepository )
throws TransferFailedException, ResourceDoesNotExistException throws TransferFailedException, ResourceDoesNotExistException
{ {
getArtifact( artifact, remoteRepository, downloadMonitor, true ); getArtifact( artifact, remoteRepository, downloadMonitor, true );
} }
public void getArtifact( Artifact artifact, List<ArtifactRepository> remoteRepositories, TransferListener downloadMonitor ) public void getArtifact( Artifact artifact, List<ArtifactRepository> remoteRepositories, TransferListener downloadMonitor )
throws TransferFailedException, ResourceDoesNotExistException throws TransferFailedException, ResourceDoesNotExistException
{ {
getArtifact( artifact, remoteRepositories, downloadMonitor, true ); getArtifact( artifact, remoteRepositories, downloadMonitor, true );
} }
public void getArtifact( Artifact artifact, List<ArtifactRepository> remoteRepositories, TransferListener downloadMonitor, boolean force ) public void getArtifact( Artifact artifact, List<ArtifactRepository> remoteRepositories, TransferListener downloadMonitor, boolean force )
throws TransferFailedException, ResourceDoesNotExistException throws TransferFailedException, ResourceDoesNotExistException
{ {
if(remoteRepositories == null) for ( ArtifactRepository repository : remoteRepositories )
{ {
throw new IllegalArgumentException("remoteRepositories: null");
}
for (ArtifactRepository repository : remoteRepositories) {
try try
{ {
getArtifact( artifact, repository, downloadMonitor, force ); getArtifact( artifact, repository, downloadMonitor, force );
if (artifact.isResolved()) if ( artifact.isResolved() )
{ {
break; break;
} }
} }
catch ( ResourceDoesNotExistException e ) catch ( ResourceDoesNotExistException e )
@ -349,16 +297,14 @@ public void getArtifact( Artifact artifact, List<ArtifactRepository> remoteRepos
// This one we will eat when looking through remote repositories // This one we will eat when looking through remote repositories
// because we want to cycle through them all before squawking. // because we want to cycle through them all before squawking.
logger.debug( "Unable to get resource '" + artifact.getId() + "' from repository " + logger.debug( "Unable to get resource '" + artifact.getId() + "' from repository " + repository.getId() + " (" + repository.getUrl() + ")", e );
repository.getId() + " (" + repository.getUrl() + ")", e );
} }
catch ( TransferFailedException e ) catch ( TransferFailedException e )
{ {
logger.debug( "Unable to get resource '" + artifact.getId() + "' from repository " + logger.debug( "Unable to get resource '" + artifact.getId() + "' from repository " + repository.getId() + " (" + repository.getUrl() + ")", e );
repository.getId() + " (" + repository.getUrl() + ")", e );
} }
} }
// if it already exists locally we were just trying to force it - ignore the update // if it already exists locally we were just trying to force it - ignore the update
if ( !artifact.getFile().exists() ) if ( !artifact.getFile().exists() )
{ {
@ -367,21 +313,24 @@ public void getArtifact( Artifact artifact, List<ArtifactRepository> remoteRepos
} }
public void getArtifact( Artifact artifact, ArtifactRepository repository, TransferListener downloadMonitor ) public void getArtifact( Artifact artifact, ArtifactRepository repository, TransferListener downloadMonitor )
throws TransferFailedException, throws TransferFailedException, ResourceDoesNotExistException
ResourceDoesNotExistException
{ {
getArtifact( artifact, repository, downloadMonitor, true ); getArtifact( artifact, repository, downloadMonitor, true );
} }
//TODO: all of this needs to move into the repository system
public void getArtifact( Artifact artifact, ArtifactRepository repository, TransferListener downloadMonitor, boolean force ) public void getArtifact( Artifact artifact, ArtifactRepository repository, TransferListener downloadMonitor, boolean force )
throws TransferFailedException, ResourceDoesNotExistException throws TransferFailedException, ResourceDoesNotExistException
{ {
String remotePath = repository.pathOf( artifact ); String remotePath = repository.pathOf( artifact );
ArtifactRepositoryPolicy policy = artifact.isSnapshot() ? repository.getSnapshots() : repository.getReleases(); ArtifactRepositoryPolicy policy = artifact.isSnapshot() ? repository.getSnapshots() : repository.getReleases();
boolean updateCheckIsRequired = updateCheckManager.isUpdateRequired( artifact, repository );
if ( !policy.isEnabled() ) if ( !policy.isEnabled() )
{ {
logger.debug( "Skipping disabled repository " + repository.getId() ); logger.debug( "Skipping disabled repository " + repository.getId() );
} }
else if ( repository.isBlacklisted() ) else if ( repository.isBlacklisted() )
@ -390,8 +339,8 @@ else if ( repository.isBlacklisted() )
} }
// If the artifact is a snapshot, we need to determine whether it's time to check this repository for an update: // If the artifact is a snapshot, we need to determine whether it's time to check this repository for an update:
// 1. If it's forced, then check // 1. If it's forced, then check
// 2. If the updateInterval has been exceeded since the last check for this artifact on this repository, then check. // 2. If the updateInterval has been exceeded since the last check for this artifact on this repository, then check.
else if ( artifact.isSnapshot() && ( force || updateCheckManager.isUpdateRequired( artifact, repository ) ) ) else if ( artifact.isSnapshot() && ( force || updateCheckIsRequired ) )
{ {
logger.debug( "Trying repository " + repository.getId() ); logger.debug( "Trying repository " + repository.getId() );
@ -401,7 +350,7 @@ else if ( artifact.isSnapshot() && ( force || updateCheckManager.isUpdateRequire
} }
finally finally
{ {
updateCheckManager.touch( artifact, repository ); updateCheckManager.touch( artifact, repository );
} }
logger.debug( " Artifact resolved" ); logger.debug( " Artifact resolved" );
@ -428,7 +377,7 @@ else if ( "pom".equals( artifact.getType() ) && !artifact.getFile().exists() )
{ {
// cache the POM failure // cache the POM failure
updateCheckManager.touch( artifact, repository ); updateCheckManager.touch( artifact, repository );
throw e; throw e;
} }
@ -442,7 +391,7 @@ else if ( "pom".equals( artifact.getType() ) && !artifact.getFile().exists() )
throw new ResourceDoesNotExistException( "Failure was cached in the local repository" ); throw new ResourceDoesNotExistException( "Failure was cached in the local repository" );
} }
} }
// If it's not a snapshot artifact, then we don't care what the force flag says. If it's on the local // If it's not a snapshot artifact, then we don't care what the force flag says. If it's on the local
// system, it's resolved. Releases are presumed to be immutable, so release artifacts are not ever updated. // system, it's resolved. Releases are presumed to be immutable, so release artifacts are not ever updated.
// NOTE: This is NOT the case for metadata files on relese-only repositories. This metadata may contain information // NOTE: This is NOT the case for metadata files on relese-only repositories. This metadata may contain information
@ -462,10 +411,7 @@ else if ( !artifact.isSnapshot() )
} }
} }
public void getArtifactMetadata( ArtifactMetadata metadata, public void getArtifactMetadata( ArtifactMetadata metadata, ArtifactRepository repository, File destination, String checksumPolicy )
ArtifactRepository repository,
File destination,
String checksumPolicy )
throws TransferFailedException, ResourceDoesNotExistException throws TransferFailedException, ResourceDoesNotExistException
{ {
String remotePath = repository.pathOfRemoteRepositoryMetadata( metadata ); String remotePath = repository.pathOfRemoteRepositoryMetadata( metadata );
@ -473,8 +419,7 @@ public void getArtifactMetadata( ArtifactMetadata metadata,
getRemoteFile( repository, destination, remotePath, null, checksumPolicy, true ); getRemoteFile( repository, destination, remotePath, null, checksumPolicy, true );
} }
public void getArtifactMetadataFromDeploymentRepository( ArtifactMetadata metadata, ArtifactRepository repository, public void getArtifactMetadataFromDeploymentRepository( ArtifactMetadata metadata, ArtifactRepository repository, File destination, String checksumPolicy )
File destination, String checksumPolicy )
throws TransferFailedException, ResourceDoesNotExistException throws TransferFailedException, ResourceDoesNotExistException
{ {
String remotePath = repository.pathOfRemoteRepositoryMetadata( metadata ); String remotePath = repository.pathOfRemoteRepositoryMetadata( metadata );
@ -482,16 +427,11 @@ public void getArtifactMetadataFromDeploymentRepository( ArtifactMetadata metada
getRemoteFile( repository, destination, remotePath, null, checksumPolicy, true ); getRemoteFile( repository, destination, remotePath, null, checksumPolicy, true );
} }
private void getRemoteFile( ArtifactRepository repository, public void getRemoteFile( ArtifactRepository repository, File destination, String remotePath, TransferListener downloadMonitor, String checksumPolicy, boolean force )
File destination,
String remotePath,
TransferListener downloadMonitor,
String checksumPolicy,
boolean force )
throws TransferFailedException, ResourceDoesNotExistException throws TransferFailedException, ResourceDoesNotExistException
{ {
String protocol = repository.getProtocol(); String protocol = repository.getProtocol();
Wagon wagon; Wagon wagon;
try try
@ -504,7 +444,7 @@ private void getRemoteFile( ArtifactRepository repository,
{ {
throw new TransferFailedException( "Unsupported Protocol: '" + protocol + "': " + e.getMessage(), e ); throw new TransferFailedException( "Unsupported Protocol: '" + protocol + "': " + e.getMessage(), e );
} }
if ( downloadMonitor != null ) if ( downloadMonitor != null )
{ {
wagon.addTransferListener( downloadMonitor ); wagon.addTransferListener( downloadMonitor );
@ -517,15 +457,8 @@ private void getRemoteFile( ArtifactRepository repository,
boolean downloaded = false; boolean downloaded = false;
try try
{ {
wagon.connect( new Repository( repository.getId(), repository.getUrl() ), wagon.connect( new Repository( repository.getId(), repository.getUrl() ) );
getAuthenticationInfo( repository.getId() ), new ProxyInfoProvider()
{
public ProxyInfo getProxyInfo( String protocol )
{
return getProxy( protocol );
}
});
boolean firstRun = true; boolean firstRun = true;
boolean retry = true; boolean retry = true;
@ -636,8 +569,7 @@ public ProxyInfo getProxyInfo( String protocol )
catch ( ResourceDoesNotExistException md5TryException ) catch ( ResourceDoesNotExistException md5TryException )
{ {
// this was a failed transfer, and we don't want to retry. // this was a failed transfer, and we don't want to retry.
handleChecksumFailure( checksumPolicy, "Error retrieving checksum file for " + remotePath, handleChecksumFailure( checksumPolicy, "Error retrieving checksum file for " + remotePath, md5TryException );
md5TryException );
} }
} }
@ -664,10 +596,6 @@ public ProxyInfo getProxyInfo( String protocol )
{ {
throw new TransferFailedException( "Authorization failed: " + e.getMessage(), e ); throw new TransferFailedException( "Authorization failed: " + e.getMessage(), e );
} }
catch ( CredentialsDataSourceException e )
{
throw new TransferFailedException( "Retrieving credentials failed: " + e.getMessage(), e );
}
finally finally
{ {
// Remove remaining TransferListener instances (checksum handlers removed in above finally clause) // Remove remaining TransferListener instances (checksum handlers removed in above finally clause)
@ -704,16 +632,13 @@ public ProxyInfo getProxyInfo( String protocol )
} }
catch ( IOException e ) catch ( IOException e )
{ {
throw new TransferFailedException( throw new TransferFailedException( "Error copying temporary file to the final destination: " + e.getMessage(), e );
"Error copying temporary file to the final destination: " + e.getMessage(), e );
} }
} }
} }
} }
private void handleChecksumFailure( String checksumPolicy, private void handleChecksumFailure( String checksumPolicy, String message, Throwable cause )
String message,
Throwable cause )
throws ChecksumFailedException throws ChecksumFailedException
{ {
if ( ArtifactRepositoryPolicy.CHECKSUM_POLICY_FAIL.equals( checksumPolicy ) ) if ( ArtifactRepositoryPolicy.CHECKSUM_POLICY_FAIL.equals( checksumPolicy ) )
@ -728,12 +653,7 @@ else if ( !ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE.equals( checksumPolic
// otherwise it is ignore // otherwise it is ignore
} }
private void verifyChecksum( ChecksumObserver checksumObserver, private void verifyChecksum( ChecksumObserver checksumObserver, File destination, File tempDestination, String remotePath, String checksumFileExtension, Wagon wagon )
File destination,
File tempDestination,
String remotePath,
String checksumFileExtension,
Wagon wagon )
throws ResourceDoesNotExistException, TransferFailedException, AuthorizationException throws ResourceDoesNotExistException, TransferFailedException, AuthorizationException
{ {
try try
@ -751,8 +671,7 @@ private void verifyChecksum( ChecksumObserver checksumObserver,
expectedChecksum = expectedChecksum.trim(); expectedChecksum = expectedChecksum.trim();
// check for 'ALGO (name) = CHECKSUM' like used by openssl // check for 'ALGO (name) = CHECKSUM' like used by openssl
if ( expectedChecksum.regionMatches( true, 0, "MD", 0, 2 ) if ( expectedChecksum.regionMatches( true, 0, "MD", 0, 2 ) || expectedChecksum.regionMatches( true, 0, "SHA", 0, 3 ) )
|| expectedChecksum.regionMatches( true, 0, "SHA", 0, 3 ) )
{ {
int lastSpacePos = expectedChecksum.lastIndexOf( ' ' ); int lastSpacePos = expectedChecksum.lastIndexOf( ' ' );
expectedChecksum = expectedChecksum.substring( lastSpacePos + 1 ); expectedChecksum = expectedChecksum.substring( lastSpacePos + 1 );
@ -779,8 +698,7 @@ private void verifyChecksum( ChecksumObserver checksumObserver,
} }
else else
{ {
throw new ChecksumFailedException( "Checksum failed on download: local = '" + actualChecksum + throw new ChecksumFailedException( "Checksum failed on download: local = '" + actualChecksum + "'; remote = '" + expectedChecksum + "'" );
"'; remote = '" + expectedChecksum + "'" );
} }
} }
catch ( IOException e ) catch ( IOException e )
@ -789,7 +707,6 @@ private void verifyChecksum( ChecksumObserver checksumObserver,
} }
} }
private void disconnectWagon( Wagon wagon ) private void disconnectWagon( Wagon wagon )
{ {
try try
@ -802,8 +719,7 @@ private void disconnectWagon( Wagon wagon )
} }
} }
private void releaseWagon( String protocol, private void releaseWagon( String protocol, Wagon wagon )
Wagon wagon )
{ {
try try
{ {
@ -815,21 +731,10 @@ private void releaseWagon( String protocol,
logger.debug( "", e ); logger.debug( "", e );
} }
} }
public ProxyInfo getProxy( String protocol )
{
return proxies.get( protocol );
}
public AuthenticationInfo getAuthenticationInfo( String id )
throws CredentialsDataSourceException
{
return authenticationInfoMap.get( id );
}
/** /**
* Checks the URL to see if this repository refers to an external repository * Checks the URL to see if this repository refers to an external repository
* *
* @param originalRepository * @param originalRepository
* @return true if external. * @return true if external.
*/ */
@ -838,7 +743,7 @@ public boolean isExternalRepo( ArtifactRepository originalRepository )
try try
{ {
URL url = new URL( originalRepository.getUrl() ); URL url = new URL( originalRepository.getUrl() );
return !( url.getHost().equals( "localhost" ) || url.getHost().equals( "127.0.0.1" ) || url.getProtocol().equals("file" ) ); return !( url.getHost().equals( "localhost" ) || url.getHost().equals( "127.0.0.1" ) || url.getProtocol().equals( "file" ) );
} }
catch ( MalformedURLException e ) catch ( MalformedURLException e )
{ {
@ -846,88 +751,14 @@ public boolean isExternalRepo( ArtifactRepository originalRepository )
return false; return false;
} }
} }
/**
* Set the proxy used for a particular protocol.
*
* @param protocol the protocol (required)
* @param host the proxy host name (required)
* @param port the proxy port (required)
* @param username the username for the proxy, or null if there is none
* @param password the password for the proxy, or null if there is none
* @param nonProxyHosts the set of hosts not to use the proxy for. Follows Java system property format:
* <code>*.foo.com|localhost</code>.
* @todo [BP] would be nice to configure this via plexus in some way
*/
public void addProxy( String protocol,
String host,
int port,
String username,
String password,
String nonProxyHosts )
{
ProxyInfo proxyInfo = new ProxyInfo();
proxyInfo.setHost( host );
proxyInfo.setType( protocol );
proxyInfo.setPort( port );
proxyInfo.setNonProxyHosts( nonProxyHosts );
proxyInfo.setUserName( username );
proxyInfo.setPassword( password );
proxies.put( protocol, proxyInfo );
}
// We are leaving this method here so that we can attempt to use the new maven-artifact
// library from the 2.0.x code so that we aren't maintaining two lines of code
// for the artifact management.
public void addAuthenticationInfo( String repositoryId,
String username,
String password,
String privateKey,
String passphrase
)
{
AuthenticationInfo authInfo = new AuthenticationInfo();
authInfo.setUserName( username );
authInfo.setPassword( password );
authInfo.setPrivateKey( privateKey );
authInfo.setPassphrase( passphrase );
authenticationInfoMap.put( repositoryId, authInfo );
}
public void addPermissionInfo( String repositoryId,
String filePermissions,
String directoryPermissions )
{
RepositoryPermissions permissions = new RepositoryPermissions();
boolean addPermissions = false;
if ( filePermissions != null )
{
permissions.setFileMode( filePermissions );
addPermissions = true;
}
if ( directoryPermissions != null )
{
permissions.setDirectoryMode( directoryPermissions );
addPermissions = true;
}
if ( addPermissions )
{
serverPermissionsMap.put( repositoryId, permissions );
}
}
/** /**
* Applies the server configuration to the wagon * Applies the server configuration to the wagon
* *
* @param wagon the wagon to configure * @param wagon the wagon to configure
* @param repository the repository that has the configuration * @param repository the repository that has the configuration
* @throws WagonConfigurationException wraps any error given during configuration of the wagon instance * @throws WagonConfigurationException wraps any error given during configuration of the wagon
* instance
*/ */
private void configureWagon( Wagon wagon, ArtifactRepository repository ) private void configureWagon( Wagon wagon, ArtifactRepository repository )
throws WagonConfigurationException throws WagonConfigurationException
@ -938,8 +769,8 @@ private void configureWagon( Wagon wagon, ArtifactRepository repository )
private void configureWagon( Wagon wagon, String repositoryId, String protocol ) private void configureWagon( Wagon wagon, String repositoryId, String protocol )
throws WagonConfigurationException throws WagonConfigurationException
{ {
PlexusConfiguration config = (PlexusConfiguration) serverConfigurationMap.get( repositoryId ); PlexusConfiguration config = (PlexusConfiguration) serverConfigurationMap.get( repositoryId );
if ( config != null ) if ( config != null )
{ {
ComponentConfigurator componentConfigurator = null; ComponentConfigurator componentConfigurator = null;
@ -971,7 +802,7 @@ private void configureWagon( Wagon wagon, String repositoryId, String protocol )
} }
} }
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -979,7 +810,7 @@ public void setHttpUserAgent( String userAgent )
{ {
this.httpUserAgent = userAgent; this.httpUserAgent = userAgent;
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -987,4 +818,9 @@ public String getHttpUserAgent()
{ {
return httpUserAgent; return httpUserAgent;
} }
public Set<String> getSupportProtocols()
{
return wagons.keySet();
}
} }

View File

@ -19,6 +19,11 @@
* under the License. * under the License.
*/ */
import java.io.File;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
@ -29,9 +34,6 @@
import org.apache.maven.wagon.events.TransferListener; import org.apache.maven.wagon.events.TransferListener;
import org.apache.maven.wagon.repository.Repository; import org.apache.maven.wagon.repository.Repository;
import java.io.File;
import java.util.List;
/** /**
* Manages <a href="http://maven.apache.org/wagon">Wagon</a> related operations in Maven. * Manages <a href="http://maven.apache.org/wagon">Wagon</a> related operations in Maven.
* *
@ -84,10 +86,14 @@ void getArtifactMetadata( ArtifactMetadata metadata, ArtifactRepository remoteRe
throws TransferFailedException, ResourceDoesNotExistException; throws TransferFailedException, ResourceDoesNotExistException;
void getArtifactMetadataFromDeploymentRepository( ArtifactMetadata metadata, ArtifactRepository remoteRepository, File file, String checksumPolicyWarn ) void getArtifactMetadataFromDeploymentRepository( ArtifactMetadata metadata, ArtifactRepository remoteRepository, File file, String checksumPolicyWarn )
throws TransferFailedException, ResourceDoesNotExistException;
Set<String> getSupportProtocols();
void getRemoteFile( ArtifactRepository repository, File destination, String remotePath, TransferListener downloadMonitor, String checksumPolicy, boolean force )
throws TransferFailedException, ResourceDoesNotExistException; throws TransferFailedException, ResourceDoesNotExistException;
void addAuthenticationInfo( String repositoryId, String username, String password, String privateKey, String passphrase ); void putRemoteFile( ArtifactRepository repository, File source, String remotePath, TransferListener downloadMonitor )
throws TransferFailedException;
void addProxy( String protocol, String host, int port, String username, String password, String nonProxyHosts );
} }

View File

@ -19,12 +19,13 @@
* under the License. * under the License.
*/ */
import java.util.List;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.ArtifactVersion;
import java.util.List;
/** /**
* Provides some metadata operations, like querying the remote repository for a list of versions available for an * Provides some metadata operations, like querying the remote repository for a list of versions available for an
* artifact. * artifact.
@ -34,19 +35,7 @@
*/ */
public interface ArtifactMetadataSource public interface ArtifactMetadataSource
{ {
String ROLE = ArtifactMetadataSource.class.getName(); ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
ResolutionGroup retrieve( Artifact artifact,
ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories )
throws ArtifactMetadataRetrievalException;
/**
* Resolve all relocations in the POM for this artifact, and return the new artifact coordinate.
*/
Artifact retrieveRelocatedArtifact( Artifact artifact,
ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories )
throws ArtifactMetadataRetrievalException; throws ArtifactMetadataRetrievalException;
/** /**
@ -61,9 +50,7 @@ Artifact retrieveRelocatedArtifact( Artifact artifact,
* @throws ArtifactMetadataRetrievalException * @throws ArtifactMetadataRetrievalException
* in case of error while retrieving repository metadata from the repository. * in case of error while retrieving repository metadata from the repository.
*/ */
List<ArtifactVersion> retrieveAvailableVersions( Artifact artifact, List<ArtifactVersion> retrieveAvailableVersions( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories )
throws ArtifactMetadataRetrievalException; throws ArtifactMetadataRetrievalException;
/** /**
@ -79,7 +66,6 @@ List<ArtifactVersion> retrieveAvailableVersions( Artifact artifact,
* @throws ArtifactMetadataRetrievalException * @throws ArtifactMetadataRetrievalException
* in case of error while retrieving repository metadata from the repository. * in case of error while retrieving repository metadata from the repository.
*/ */
List<ArtifactVersion> retrieveAvailableVersionsFromDeploymentRepository( Artifact artifact, List<ArtifactVersion> retrieveAvailableVersionsFromDeploymentRepository( Artifact artifact, ArtifactRepository localRepository, ArtifactRepository remoteRepository )
ArtifactRepository localRepository, throws ArtifactMetadataRetrievalException;
ArtifactRepository remoteRepository ) throws ArtifactMetadataRetrievalException;
} }

View File

@ -19,12 +19,12 @@
* under the License. * under the License.
*/ */
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
public class ResolutionGroup public class ResolutionGroup
{ {

View File

@ -1,34 +1,24 @@
package org.apache.maven.artifact.repository; package org.apache.maven.artifact.repository;
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
* or more contributor license agreements. See the NOTICE file * agreements. See the NOTICE file distributed with this work for additional information regarding
* distributed with this work for additional information * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
* regarding copyright ownership. The ASF licenses this file * "License"); you may not use this file except in compliance with the License. You may obtain a
* to you under the Apache License, Version 2.0 (the * copy of the License at
* "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
* *
* 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
* Unless required by applicable law or agreed to in writing, * or implied. See the License for the specific language governing permissions and limitations under
* software distributed under the License is distributed on an * the License.
* "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.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
/**
* Specifies the repository used for artifact handling.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id$
*/
public interface ArtifactRepository public interface ArtifactRepository
{ {
String pathOf( Artifact artifact ); String pathOf( Artifact artifact );
@ -38,6 +28,7 @@ public interface ArtifactRepository
String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository ); String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository );
String getUrl(); String getUrl();
void setUrl( String url ); void setUrl( String url );
String getBasedir(); String getBasedir();
@ -45,22 +36,28 @@ public interface ArtifactRepository
String getProtocol(); String getProtocol();
String getId(); String getId();
void setId( String id ); void setId( String id );
ArtifactRepositoryPolicy getSnapshots(); ArtifactRepositoryPolicy getSnapshots();
void setSnapshotUpdatePolicy( ArtifactRepositoryPolicy policy );
ArtifactRepositoryPolicy getReleases();
void setReleaseUpdatePolicy( ArtifactRepositoryPolicy policy );
ArtifactRepositoryLayout getLayout();
void setLayout( ArtifactRepositoryLayout layout );
String getKey();
boolean isUniqueVersion(); void setSnapshotUpdatePolicy( ArtifactRepositoryPolicy policy );
ArtifactRepositoryPolicy getReleases();
void setReleaseUpdatePolicy( ArtifactRepositoryPolicy policy );
ArtifactRepositoryLayout getLayout();
void setLayout( ArtifactRepositoryLayout layout );
String getKey();
void setBlacklisted( boolean blackListed ); void setBlacklisted( boolean blackListed );
boolean isBlacklisted(); boolean isBlacklisted();
// New interface methods for the repository system.
Artifact find( Artifact artifact );
} }

View File

@ -19,12 +19,12 @@
* under the License. * under the License.
*/ */
import java.io.File;
import org.apache.maven.artifact.InvalidRepositoryException; import org.apache.maven.artifact.InvalidRepositoryException;
import org.apache.maven.artifact.UnknownRepositoryLayoutException; import org.apache.maven.artifact.UnknownRepositoryLayoutException;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import java.io.File;
/** @author jdcasey */ /** @author jdcasey */
public interface ArtifactRepositoryFactory public interface ArtifactRepositoryFactory
{ {

View File

@ -19,6 +19,8 @@
* under the License. * under the License.
*/ */
import java.io.File;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
@ -31,6 +33,7 @@
* @author <a href="michal.maczka@dimatics.com">Michal Maczka </a> * @author <a href="michal.maczka@dimatics.com">Michal Maczka </a>
* @version $Id$ * @version $Id$
*/ */
//TODO: this needs to be decoupled from Wagon
public class DefaultArtifactRepository public class DefaultArtifactRepository
extends Repository extends Repository
implements ArtifactRepository implements ArtifactRepository
@ -41,10 +44,12 @@ public class DefaultArtifactRepository
private ArtifactRepositoryPolicy releases; private ArtifactRepositoryPolicy releases;
private boolean uniqueVersion = true;
private boolean blacklisted; private boolean blacklisted;
public DefaultArtifactRepository()
{
}
/** /**
* Create a local repository or a test repository. * Create a local repository or a test repository.
* *
@ -69,7 +74,6 @@ public DefaultArtifactRepository( String id, String url, ArtifactRepositoryLayou
{ {
super( id, url ); super( id, url );
this.layout = layout; this.layout = layout;
this.uniqueVersion = uniqueVersion;
} }
/** /**
@ -155,11 +159,6 @@ public String getKey()
return getId(); return getId();
} }
public boolean isUniqueVersion()
{
return uniqueVersion;
}
public boolean isBlacklisted() public boolean isBlacklisted()
{ {
return blacklisted; return blacklisted;
@ -177,11 +176,35 @@ public String toString()
sb.append( " id: " ).append( getId() ).append( "\n" ); sb.append( " id: " ).append( getId() ).append( "\n" );
sb.append( " url: " ).append( getUrl() ).append( "\n" ); sb.append( " url: " ).append( getUrl() ).append( "\n" );
sb.append( " layout: " ).append( layout != null ? layout.getId() : "none" ).append( "\n" ); sb.append( " layout: " ).append( layout != null ? layout.getId() : "none" ).append( "\n" );
sb.append( "snapshots: [enabled => " ).append( snapshots.isEnabled() );
sb.append( ", update => " ).append( snapshots.getUpdatePolicy() ).append( "]\n" ); if ( snapshots != null )
sb.append( " releases: [enabled => " ).append( releases.isEnabled() ); {
sb.append( ", update => " ).append( releases.getUpdatePolicy() ).append( "]\n" ); sb.append( "snapshots: [enabled => " ).append( snapshots.isEnabled() );
sb.append( ", update => " ).append( snapshots.getUpdatePolicy() ).append( "]\n" );
}
if ( releases != null )
{
sb.append( " releases: [enabled => " ).append( releases.isEnabled() );
sb.append( ", update => " ).append( releases.getUpdatePolicy() ).append( "]\n" );
}
return sb.toString(); return sb.toString();
} }
public Artifact find( Artifact artifact )
{
File artifactFile = new File( getBasedir(), pathOf( artifact ) );
// We need to set the file here or the resolver will fail with an NPE, not fully equipped to deal
// with multiple local repository implementations yet.
artifact.setFile( artifactFile );
if( artifactFile.exists() )
{
artifact.setResolved( true );
}
return artifact;
}
} }

View File

@ -19,17 +19,17 @@
* under the License. * under the License.
*/ */
import java.io.File;
import java.net.MalformedURLException;
import java.util.HashMap;
import java.util.Map;
import org.apache.maven.artifact.InvalidRepositoryException; import org.apache.maven.artifact.InvalidRepositoryException;
import org.apache.maven.artifact.UnknownRepositoryLayoutException; import org.apache.maven.artifact.UnknownRepositoryLayoutException;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.component.annotations.Requirement;
import java.io.File;
import java.net.MalformedURLException;
import java.util.HashMap;
import java.util.Map;
/** /**
* @author jdcasey * @author jdcasey
*/ */

View File

@ -67,8 +67,7 @@ public String pathOf( Artifact artifact )
return path.toString(); return path.toString();
} }
public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository )
ArtifactRepository repository )
{ {
return pathOfRepositoryMetadata( metadata, metadata.getLocalFilename( repository ) ); return pathOfRepositoryMetadata( metadata, metadata.getLocalFilename( repository ) );
} }

View File

@ -19,6 +19,11 @@
* under the License. * under the License.
*/ */
import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
@ -29,11 +34,6 @@
import org.codehaus.plexus.util.WriterFactory; import org.codehaus.plexus.util.WriterFactory;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
/** /**
* Shared methods of the repository metadata handling. * Shared methods of the repository metadata handling.
* *
@ -56,7 +56,7 @@ public String getRemoteFilename()
} }
public String getLocalFilename( ArtifactRepository repository ) public String getLocalFilename( ArtifactRepository repository )
{ {
return "maven-metadata-" + repository.getKey() + ".xml"; return "maven-metadata-" + repository.getKey() + ".xml";
} }

View File

@ -53,17 +53,6 @@ public class DefaultRepositoryMetadataManager
@Requirement @Requirement
private UpdateCheckManager updateCheckManager; private UpdateCheckManager updateCheckManager;
protected DefaultRepositoryMetadataManager( WagonManager wagonManager, UpdateCheckManager updateCheckManager, Logger logger )
{
this.wagonManager = wagonManager;
this.updateCheckManager = updateCheckManager;
enableLogging( logger );
}
public DefaultRepositoryMetadataManager()
{
}
public void resolve( RepositoryMetadata metadata, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository ) public void resolve( RepositoryMetadata metadata, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository )
throws RepositoryMetadataResolutionException throws RepositoryMetadataResolutionException
{ {

View File

@ -19,21 +19,17 @@
* under the License. * under the License.
*/ */
import java.util.List;
import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import java.util.List;
public interface RepositoryMetadataManager public interface RepositoryMetadataManager
{ {
void resolve( RepositoryMetadata repositoryMetadata, void resolve( RepositoryMetadata repositoryMetadata, List<ArtifactRepository> repositories, ArtifactRepository localRepository )
List<ArtifactRepository> repositories,
ArtifactRepository localRepository )
throws RepositoryMetadataResolutionException; throws RepositoryMetadataResolutionException;
void resolveAlways( RepositoryMetadata metadata, void resolveAlways( RepositoryMetadata metadata, ArtifactRepository localRepository, ArtifactRepository remoteRepository )
ArtifactRepository localRepository,
ArtifactRepository remoteRepository )
throws RepositoryMetadataResolutionException; throws RepositoryMetadataResolutionException;
/** /**
@ -43,9 +39,7 @@ void resolveAlways( RepositoryMetadata metadata,
* @param localRepository the local repository to install to first * @param localRepository the local repository to install to first
* @param deploymentRepository the remote repository to deploy to * @param deploymentRepository the remote repository to deploy to
*/ */
void deploy( ArtifactMetadata metadata, void deploy( ArtifactMetadata metadata, ArtifactRepository localRepository, ArtifactRepository deploymentRepository )
ArtifactRepository localRepository,
ArtifactRepository deploymentRepository )
throws RepositoryMetadataDeploymentException; throws RepositoryMetadataDeploymentException;
/** /**
@ -54,7 +48,6 @@ void deploy( ArtifactMetadata metadata,
* @param metadata the metadata * @param metadata the metadata
* @param localRepository the local repository * @param localRepository the local repository
*/ */
void install( ArtifactMetadata metadata, void install( ArtifactMetadata metadata, ArtifactRepository localRepository )
ArtifactRepository localRepository )
throws RepositoryMetadataInstallationException; throws RepositoryMetadataInstallationException;
} }

View File

@ -19,13 +19,13 @@
* under the License. * under the License.
*/ */
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
/** /**
* Base class for artifact resolution exceptions. * Base class for artifact resolution exceptions.
* *

View File

@ -19,16 +19,16 @@
* under the License. * under the License.
*/ */
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.resolver.conflict.ConflictResolver;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.conflict.ConflictResolver;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
/** /**
* Artifact collector - takes a set of original artifacts and resolves all of the best versions to use * Artifact collector - takes a set of original artifacts and resolves all of the best versions to use
* along with their metadata. No artifacts are downloaded. * along with their metadata. No artifacts are downloaded.
@ -38,33 +38,6 @@
*/ */
public interface ArtifactCollector public interface ArtifactCollector
{ {
/**
* The plexus role for this component.
*
* @since 3.0
*/
String ROLE = ArtifactCollector.class.getName();
// TODO: deprecate since conflict resolvers should always be specified
ArtifactResolutionResult collect( Set<Artifact> artifacts,
Artifact originatingArtifact,
ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories,
ArtifactMetadataSource source,
ArtifactFilter filter,
List<ResolutionListener> listeners );
// TODO: deprecate since conflict resolvers should always be specified
ArtifactResolutionResult collect( Set<Artifact> artifacts,
Artifact originatingArtifact,
Map managedVersions,
ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories,
ArtifactMetadataSource source,
ArtifactFilter filter,
List<ResolutionListener> listeners );
/** @since 3.0 */
ArtifactResolutionResult collect( Set<Artifact> artifacts, ArtifactResolutionResult collect( Set<Artifact> artifacts,
Artifact originatingArtifact, Artifact originatingArtifact,
Map managedVersions, Map managedVersions,
@ -73,6 +46,5 @@ ArtifactResolutionResult collect( Set<Artifact> artifacts,
ArtifactMetadataSource source, ArtifactMetadataSource source,
ArtifactFilter filter, ArtifactFilter filter,
List<ResolutionListener> listeners, List<ResolutionListener> listeners,
List<ConflictResolver> conflictResolvers ) List<ConflictResolver> conflictResolvers );
throws ArtifactResolutionException;
} }

View File

@ -1,124 +1,65 @@
package org.apache.maven.artifact.resolver; package org.apache.maven.artifact.resolver;
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
* or more contributor license agreements. See the NOTICE file * agreements. See the NOTICE file distributed with this work for additional information regarding
* distributed with this work for additional information * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
* regarding copyright ownership. The ASF licenses this file * "License"); you may not use this file except in compliance with the License. You may obtain a
* to you under the Apache License, Version 2.0 (the * copy of the License at
* "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
* *
* 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
* Unless required by applicable law or agreed to in writing, * or implied. See the License for the specific language governing permissions and limitations under
* software distributed under the License is distributed on an * the License.
* "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.List;
import org.apache.maven.artifact.Artifact; 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.ResourceDoesNotExistException; import org.apache.maven.wagon.ResourceDoesNotExistException;
import java.util.List;
/** /**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a> * @author Jason van Zyl
* @version $Id$
*/ */
public class ArtifactNotFoundException public class ArtifactNotFoundException
extends AbstractArtifactResolutionException extends AbstractArtifactResolutionException
{ {
private String downloadUrl; private String downloadUrl;
protected ArtifactNotFoundException( String message, protected ArtifactNotFoundException( String message, Artifact artifact, List<ArtifactRepository> remoteRepositories )
Artifact artifact,
List<ArtifactRepository> remoteRepositories )
{ {
super( message, artifact, remoteRepositories ); super( message, artifact, remoteRepositories );
} }
public ArtifactNotFoundException( String message, public ArtifactNotFoundException( String message, Artifact artifact )
Artifact artifact )
{ {
this( message, artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), this( message, artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), artifact.getClassifier(), null, artifact.getDownloadUrl(), artifact
artifact.getClassifier(), null, artifact.getDownloadUrl(), artifact.getDependencyTrail() ); .getDependencyTrail() );
} }
protected ArtifactNotFoundException( String message, protected ArtifactNotFoundException( String message, Artifact artifact, List<ArtifactRepository> remoteRepositories, ResourceDoesNotExistException cause )
Artifact artifact,
List<ArtifactRepository> remoteRepositories,
ResourceDoesNotExistException cause )
{ {
this( message, artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), this( message, artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), artifact.getClassifier(), remoteRepositories, artifact.getDownloadUrl(), artifact
artifact.getClassifier(), .getDependencyTrail(), cause );
remoteRepositories, artifact.getDownloadUrl(), artifact.getDependencyTrail(), cause );
} }
@Deprecated public ArtifactNotFoundException( String message, String groupId, String artifactId, String version, String type, String classifier, List<ArtifactRepository> remoteRepositories,
protected ArtifactNotFoundException( String message, String downloadUrl, List path, ResourceDoesNotExistException cause )
Artifact artifact,
List<ArtifactRepository> remoteRepositories,
Throwable cause )
{ {
this( message, artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), super( constructMissingArtifactMessage( message, "", groupId, artifactId, version, type, classifier, downloadUrl, path ), groupId, artifactId, version, type, classifier, remoteRepositories,
artifact.getClassifier(), null, cause );
remoteRepositories, artifact.getDownloadUrl(), artifact.getDependencyTrail(), cause );
}
@Deprecated
public ArtifactNotFoundException( String message,
String groupId,
String artifactId,
String version,
String type,
String classifier,
List<ArtifactRepository> remoteRepositories,
String downloadUrl,
List path,
Throwable cause )
{
super( constructMissingArtifactMessage( message, "", groupId, artifactId, version, type, classifier,
downloadUrl, path ), groupId, artifactId,
version, type, classifier, remoteRepositories, null, cause );
this.downloadUrl = downloadUrl; this.downloadUrl = downloadUrl;
} }
public ArtifactNotFoundException( String message, private ArtifactNotFoundException( String message, String groupId, String artifactId, String version, String type, String classifier, List<ArtifactRepository> remoteRepositories,
String groupId, String downloadUrl, List path )
String artifactId,
String version,
String type,
String classifier,
List<ArtifactRepository> remoteRepositories,
String downloadUrl,
List path,
ResourceDoesNotExistException cause )
{ {
super( constructMissingArtifactMessage( message, "", groupId, artifactId, version, type, classifier, super( constructMissingArtifactMessage( message, "", groupId, artifactId, version, type, classifier, downloadUrl, path ), groupId, artifactId, version, type, classifier, remoteRepositories,
downloadUrl, path ), groupId, artifactId, null );
version, type, classifier, remoteRepositories, null, cause );
this.downloadUrl = downloadUrl;
}
private ArtifactNotFoundException( String message,
String groupId,
String artifactId,
String version,
String type,
String classifier,
List<ArtifactRepository> remoteRepositories,
String downloadUrl,
List path )
{
super( constructMissingArtifactMessage( message, "", groupId, artifactId, version, type, classifier,
downloadUrl, path ), groupId, artifactId,
version, type, classifier, remoteRepositories, null );
this.downloadUrl = downloadUrl; this.downloadUrl = downloadUrl;
} }

View File

@ -19,15 +19,15 @@
* under the License. * under the License.
*/ */
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutionException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.wagon.TransferFailedException;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutionException;
import org.apache.maven.wagon.TransferFailedException;
/** /**
* @author Jason van Zyl * @author Jason van Zyl
* @version $Id$ * @version $Id$

View File

@ -6,7 +6,6 @@
import java.util.Set; import java.util.Set;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.wagon.events.TransferListener; import org.apache.maven.wagon.events.TransferListener;
@ -22,15 +21,14 @@ public class ArtifactResolutionRequest
private Artifact artifact; private Artifact artifact;
// Needs to go away // Needs to go away
// These are really overrides now, projects defining dependencies for a plugin that override what is
// specified in the plugin itself.
private Set<Artifact> artifactDependencies; private Set<Artifact> artifactDependencies;
private ArtifactRepository localRepository; private ArtifactRepository localRepository;
private List<ArtifactRepository> remoteRepositories; private List<ArtifactRepository> remoteRepositories;
// Not sure what to do with this?
// Scope
// Lock down lists
private ArtifactFilter filter; private ArtifactFilter filter;
// Needs to go away // Needs to go away
@ -39,24 +37,12 @@ public class ArtifactResolutionRequest
// This is like a filter but overrides all transitive versions // This is like a filter but overrides all transitive versions
private Map managedVersionMap; private Map managedVersionMap;
// This should not be in here, it's a component
private ArtifactMetadataSource metadataSource;
private TransferListener transferListener; private TransferListener transferListener;
private boolean resolveRoot = true; private boolean resolveRoot = true;
public ArtifactResolutionRequest() private boolean resolveTransitively = false;
{
}
public ArtifactResolutionRequest( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
{
this.artifact = artifact;
this.localRepository = localRepository;
this.remoteRepositories = remoteRepositories;
}
public Artifact getArtifact() public Artifact getArtifact()
{ {
return artifact; return artifact;
@ -136,22 +122,6 @@ public ArtifactResolutionRequest addListener( ResolutionListener listener )
return this; return this;
} }
// ------------------------------------------------------------------------
//
// ------------------------------------------------------------------------
public ArtifactMetadataSource getMetadataSource()
{
return metadataSource;
}
public ArtifactResolutionRequest setMetadataSource( ArtifactMetadataSource metadataSource )
{
this.metadataSource = metadataSource;
return this;
}
public Map getManagedVersionMap() public Map getManagedVersionMap()
{ {
return managedVersionMap; return managedVersionMap;
@ -175,6 +145,18 @@ public boolean isResolveRoot()
{ {
return resolveRoot; return resolveRoot;
} }
public ArtifactResolutionRequest setResolveTransitively( boolean resolveDependencies )
{
this.resolveTransitively = resolveDependencies;
return this;
}
public boolean isResolveTransitively()
{
return resolveTransitively;
}
public TransferListener getTransferListener() public TransferListener getTransferListener()
{ {
@ -194,8 +176,7 @@ public String toString()
.append( "artifact: " ).append( artifact ).append( "\n" ) .append( "artifact: " ).append( artifact ).append( "\n" )
.append( artifactDependencies ).append( "\n" ) .append( artifactDependencies ).append( "\n" )
.append( "localRepository: " ).append( localRepository ).append( "\n" ) .append( "localRepository: " ).append( localRepository ).append( "\n" )
.append( "remoteRepositories: " ).append( remoteRepositories ).append( "\n" ) .append( "remoteRepositories: " ).append( remoteRepositories ).append( "\n" );
.append( "metadataSource: " ).append( metadataSource ).append( "\n" );
return sb.toString(); return sb.toString();
} }

View File

@ -15,16 +15,16 @@
* the License. * the License.
*/ */
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
/** /**
* Specific problems during resolution that we want to account for: * Specific problems during resolution that we want to account for:
* <p/> * <p/>
@ -89,6 +89,11 @@ public Set<Artifact> getArtifacts()
return ( artifacts != null ) ? artifacts : Collections.<Artifact> emptySet(); return ( artifacts != null ) ? artifacts : Collections.<Artifact> emptySet();
} }
public void setArtifacts( Set<Artifact> artifacts )
{
this.artifacts = artifacts;
}
public void addRequestedArtifact( Artifact artifact ) public void addRequestedArtifact( Artifact artifact )
{ {
if ( requestedArtifacts == null ) if ( requestedArtifacts == null )

View File

@ -34,17 +34,14 @@
*/ */
public interface ArtifactResolver public interface ArtifactResolver
{ {
ArtifactResolutionResult resolve( ArtifactResolutionRequest request );
// The rest is deprecated
// USED BY MAVEN ASSEMBLY PLUGIN 2.2-beta-2 // USED BY MAVEN ASSEMBLY PLUGIN 2.2-beta-2
@Deprecated @Deprecated
String ROLE = ArtifactResolver.class.getName(); String ROLE = ArtifactResolver.class.getName();
void setOnline( boolean online );
boolean isOnline();
ArtifactResolutionResult resolve( ArtifactResolutionRequest request );
// USED BY SUREFIRE // USED BY SUREFIRE
@Deprecated @Deprecated
ArtifactResolutionResult resolveTransitively( Set<Artifact> artifacts, Artifact originatingArtifact, ArtifactResolutionResult resolveTransitively( Set<Artifact> artifacts, Artifact originatingArtifact,
@ -70,5 +67,9 @@ void resolve( Artifact artifact, List<ArtifactRepository> remoteRepositories, Ar
@Deprecated @Deprecated
void resolve( Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository, TransferListener downloadMonitor ) void resolve( Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository, TransferListener downloadMonitor )
throws ArtifactResolutionException, ArtifactNotFoundException; throws ArtifactResolutionException, ArtifactNotFoundException;
// USED BY ARCHETYPE DOWNLOADER
@Deprecated
void resolveAlways( Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository )
throws ArtifactResolutionException, ArtifactNotFoundException;
} }

View File

@ -19,13 +19,13 @@
* under the License. * under the License.
*/ */
import java.util.HashSet;
import java.util.Set;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.artifact.versioning.VersionRange;
import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.logging.Logger;
import java.util.Set;
import java.util.HashSet;
/** /**
* Send resolution events to the debug log. * Send resolution events to the debug log.
* *

View File

@ -19,6 +19,15 @@
* under the License. * under the License.
*/ */
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
@ -33,64 +42,29 @@
import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.artifact.versioning.VersionRange;
import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.logging.LogEnabled;
import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.logging.Logger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
/** /**
* Default implementation of the artifact collector.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a> * @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @author Jason van Zyl * @author Jason van Zyl
* @version $Id$
* @todo This needs to collect all errors and not die on the first error. If there are problems retrieving the metadata
* then we need all the information so that we can tell users about what we attempted to do.
* @todo there 8 places where we can can range exceptions which is bad, again the result of not using a graph.
*/ */
@Component(role=ArtifactCollector.class) @Component(role=ArtifactCollector.class)
public class DefaultArtifactCollector public class DefaultArtifactCollector
implements ArtifactCollector, LogEnabled implements ArtifactCollector
{ {
/**
* The conflict resolver to use when none is specified.
*/
@Requirement(hint="nearest") @Requirement(hint="nearest")
private ConflictResolver defaultConflictResolver; private ConflictResolver defaultConflictResolver;
@Requirement
private Logger logger; private Logger logger;
public ArtifactResolutionResult collect( Set<Artifact> artifacts, Artifact originatingArtifact, public ArtifactResolutionResult collect( Set<Artifact> artifacts,
Artifact originatingArtifact,
Map managedVersions,
ArtifactRepository localRepository, ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories, List<ArtifactRepository> remoteRepositories,
ArtifactMetadataSource source, ArtifactFilter filter, ArtifactMetadataSource source,
List<ResolutionListener> listeners ) ArtifactFilter filter,
{
return collect( artifacts, originatingArtifact, Collections.EMPTY_MAP, localRepository, remoteRepositories,
source, filter, listeners );
}
public ArtifactResolutionResult collect( Set<Artifact> artifacts, Artifact originatingArtifact,
Map managedVersions, ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories,
ArtifactMetadataSource source, ArtifactFilter filter,
List<ResolutionListener> listeners )
{
return collect( artifacts, originatingArtifact, managedVersions, localRepository, remoteRepositories, source,
filter, listeners, null );
}
public ArtifactResolutionResult collect( Set<Artifact> artifacts, Artifact originatingArtifact,
Map managedVersions, ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories,
ArtifactMetadataSource source, ArtifactFilter filter,
List<ResolutionListener> listeners, List<ResolutionListener> listeners,
List<ConflictResolver> conflictResolvers ) List<ConflictResolver> conflictResolvers )
{ {
@ -100,8 +74,6 @@ public ArtifactResolutionResult collect( Set<Artifact> artifacts, Artifact origi
if ( conflictResolvers == null ) if ( conflictResolvers == null )
{ {
// TODO: warn that we're using the default conflict resolver
conflictResolvers = Collections.singletonList( defaultConflictResolver ); conflictResolvers = Collections.singletonList( defaultConflictResolver );
} }
@ -130,8 +102,7 @@ public ArtifactResolutionResult collect( Set<Artifact> artifacts, Artifact origi
try try
{ {
recurse( result, root, resolvedArtifacts, versionMap, localRepository, remoteRepositories, source, filter, recurse( result, root, resolvedArtifacts, versionMap, localRepository, remoteRepositories, source, filter, listeners, conflictResolvers );
listeners, conflictResolvers );
} }
catch ( CyclicDependencyException e ) catch ( CyclicDependencyException e )
{ {
@ -224,10 +195,15 @@ private ManagedVersionMap getManagedVersionsMap( Artifact originatingArtifact, M
return versionMap; return versionMap;
} }
private void recurse( ArtifactResolutionResult result, ResolutionNode node, private void recurse( ArtifactResolutionResult result,
Map<Object, List<ResolutionNode>> resolvedArtifacts, ManagedVersionMap managedVersions, ResolutionNode node,
ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories, Map<Object, List<ResolutionNode>> resolvedArtifacts,
ArtifactMetadataSource source, ArtifactFilter filter, List<ResolutionListener> listeners, ManagedVersionMap managedVersions,
ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories,
ArtifactMetadataSource source,
ArtifactFilter filter,
List<ResolutionListener> listeners,
List<ConflictResolver> conflictResolvers ) List<ConflictResolver> conflictResolvers )
throws ArtifactResolutionException throws ArtifactResolutionException
{ {
@ -293,26 +269,19 @@ private void recurse( ArtifactResolutionResult result, ResolutionNode node,
{ {
try try
{ {
versions = versions = source.retrieveAvailableVersions( resetArtifact, localRepository, remoteRepositories );
source.retrieveAvailableVersions( resetArtifact, localRepository,
remoteRepositories );
resetArtifact.setAvailableVersions( versions ); resetArtifact.setAvailableVersions( versions );
} }
catch ( ArtifactMetadataRetrievalException e ) catch ( ArtifactMetadataRetrievalException e )
{ {
resetArtifact.setDependencyTrail( node.getDependencyTrail() ); resetArtifact.setDependencyTrail( node.getDependencyTrail() );
throw new ArtifactResolutionException( throw new ArtifactResolutionException( "Unable to get dependency information: " + e.getMessage(), resetArtifact, remoteRepositories, e );
"Unable to get dependency information: "
+ e.getMessage(), resetArtifact,
remoteRepositories, e );
} }
} }
// end hack // end hack
// MNG-2861: match version can return null // MNG-2861: match version can return null
ArtifactVersion selectedVersion = ArtifactVersion selectedVersion = resetArtifact.getVersionRange().matchVersion( resetArtifact.getAvailableVersions() );
resetArtifact.getVersionRange().matchVersion(
resetArtifact.getAvailableVersions() );
if ( selectedVersion != null ) if ( selectedVersion != null )
{ {
resetArtifact.selectVersion( selectedVersion.toString() ); resetArtifact.selectVersion( selectedVersion.toString() );
@ -341,20 +310,15 @@ private void recurse( ArtifactResolutionResult result, ResolutionNode node,
if ( resolved == null ) if ( resolved == null )
{ {
// TODO: add better exception that can detail the two conflicting artifacts // TODO: add better exception that can detail the two conflicting artifacts
result.addVersionRangeViolation( new ArtifactResolutionException( ArtifactResolutionException are = new ArtifactResolutionException( "Cannot resolve artifact version conflict between " + previous.getArtifact().getVersion()
"Cannot resolve artifact version conflict between " + " and " + node.getArtifact().getVersion(), previous.getArtifact() );
+ previous.getArtifact().getVersion() result.addVersionRangeViolation( are );
+ " and "
+ node.getArtifact().getVersion(),
previous.getArtifact() ) );
} }
if ( ( resolved != previous ) && ( resolved != node ) ) if ( ( resolved != previous ) && ( resolved != node ) )
{ {
// TODO: add better exception // TODO: add better exception
result.addVersionRangeViolation( new ArtifactResolutionException( result.addVersionRangeViolation( new ArtifactResolutionException( "Conflict resolver returned unknown resolution node: ", resolved.getArtifact() ) );
"Conflict resolver returned unknown resolution node: ",
resolved.getArtifact() ) );
} }
// TODO: should this be part of mediation? // TODO: should this be part of mediation?
@ -512,13 +476,6 @@ private void recurse( ArtifactResolutionResult result, ResolutionNode node,
artifact.selectVersion( version.toString() ); artifact.selectVersion( version.toString() );
fireEvent( ResolutionListener.SELECT_VERSION_FROM_RANGE, listeners, child ); fireEvent( ResolutionListener.SELECT_VERSION_FROM_RANGE, listeners, child );
} }
Artifact relocated = source.retrieveRelocatedArtifact( artifact, localRepository, childRemoteRepositories );
if ( !artifact.equals( relocated ) )
{
artifact = relocated;
child.setArtifact( artifact );
}
} }
while( !childKey.equals( child.getKey() ) ); while( !childKey.equals( child.getKey() ) );
@ -572,8 +529,7 @@ private void recurse( ArtifactResolutionResult result, ResolutionNode node,
} }
} }
private void manageArtifact( ResolutionNode node, ManagedVersionMap managedVersions, private void manageArtifact( ResolutionNode node, ManagedVersionMap managedVersions, List<ResolutionListener> listeners )
List<ResolutionListener> listeners )
{ {
Artifact artifact = (Artifact) managedVersions.get( node.getKey() ); Artifact artifact = (Artifact) managedVersions.get( node.getKey() );
@ -744,9 +700,4 @@ private void fireEvent( int event, List<ResolutionListener> listeners, Resolutio
} }
} }
} }
public void enableLogging( Logger logger )
{
this.logger = logger;
}
} }

View File

@ -19,6 +19,8 @@
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -27,6 +29,7 @@
import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.manager.WagonManager;
import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.metadata.Metadata; import org.apache.maven.artifact.repository.metadata.Metadata;
@ -53,13 +56,6 @@
public class DefaultArtifactResolver public class DefaultArtifactResolver
implements ArtifactResolver implements ArtifactResolver
{ {
private boolean online = true;
// ----------------------------------------------------------------------
// Components
// ----------------------------------------------------------------------
@Requirement @Requirement
private Logger logger; private Logger logger;
@ -78,36 +74,22 @@ public class DefaultArtifactResolver
@Requirement @Requirement
private ResolutionErrorHandler resolutionErrorHandler; private ResolutionErrorHandler resolutionErrorHandler;
@Requirement
private ArtifactMetadataSource source;
@Requirement @Requirement
private PlexusContainer container; private PlexusContainer container;
//@Requirement
private ArtifactMetadataSource metadataSource;
// ----------------------------------------------------------------------
// Implementation
// ----------------------------------------------------------------------
public void setOnline( boolean online )
{
this.online = online;
}
public boolean isOnline()
{
return online;
}
public void resolve( Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository, TransferListener resolutionListener ) public void resolve( Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository, TransferListener resolutionListener )
throws ArtifactResolutionException, ArtifactNotFoundException throws ArtifactResolutionException, ArtifactNotFoundException
{ {
resolve( artifact, remoteRepositories, localRepository, resolutionListener, false ); resolve( artifact, remoteRepositories, localRepository, resolutionListener, false );
} }
public void resolveAlways( Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository, TransferListener downloadMonitor ) public void resolveAlways( Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository )
throws ArtifactResolutionException, ArtifactNotFoundException throws ArtifactResolutionException, ArtifactNotFoundException
{ {
resolve( artifact, remoteRepositories, localRepository, downloadMonitor, true ); resolve( artifact, remoteRepositories, localRepository, null, true );
} }
private void resolve( Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository, TransferListener downloadMonitor, boolean force ) private void resolve( Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository, TransferListener downloadMonitor, boolean force )
@ -119,6 +101,7 @@ private void resolve( Artifact artifact, List<ArtifactRepository> remoteReposito
} }
File destination; File destination;
if ( Artifact.SCOPE_SYSTEM.equals( artifact.getScope() ) ) if ( Artifact.SCOPE_SYSTEM.equals( artifact.getScope() ) )
{ {
File systemFile = artifact.getFile(); File systemFile = artifact.getFile();
@ -139,8 +122,11 @@ private void resolve( Artifact artifact, List<ArtifactRepository> remoteReposito
} }
artifact.setResolved( true ); artifact.setResolved( true );
return;
} }
else if ( !artifact.isResolved() )
if ( !artifact.isResolved() )
{ {
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// Check for the existence of the artifact in the specified local // Check for the existence of the artifact in the specified local
@ -148,9 +134,21 @@ else if ( !artifact.isResolved() )
// request for resolution has been satisfied. // request for resolution has been satisfied.
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
String localPath = localRepository.pathOf( artifact ); artifact = localRepository.find( artifact );
if ( artifact.isFromAuthoritativeRepository() )
{
return;
}
if ( artifact.isSnapshot() && artifact.isResolved() )
{
return;
}
//String localPath = localRepository.pathOf( artifact );
artifact.setFile( new File( localRepository.getBasedir(), localPath ) ); //artifact.setFile( new File( localRepository.getBasedir(), localPath ) );
transformationManager.transformForResolve( artifact, remoteRepositories, localRepository ); transformationManager.transformForResolve( artifact, remoteRepositories, localRepository );
@ -160,20 +158,15 @@ else if ( !artifact.isResolved() )
boolean resolved = false; boolean resolved = false;
boolean destinationExists = destination.exists();
// There are three conditions in which we'll go after the artifact here: // There are three conditions in which we'll go after the artifact here:
// 1. the force flag is set. // 1. the force flag is set.
// 2. the artifact's file doesn't exist (this would be true for release or snapshot artifacts) // 2. the artifact's file doesn't exist (this would be true for release or snapshot artifacts)
// 3. the artifact is a snapshot and is not a locally installed snapshot // 3. the artifact is a snapshot and is not a locally installed snapshot
// TODO: Should it matter whether it's a locally installed snapshot?? if ( force || !destination.exists() || ( artifact.isSnapshot() && !localCopy ) )
if ( force || !destination.exists() || ( artifact.isSnapshot() && !localCopy && isOnline() ) )
{ {
if ( !isOnline() )
{
throw new ArtifactResolutionException( "The repository system is offline and the artifact "
+ artifact + " is not available in the local repository.", artifact );
}
try try
{ {
if ( artifact.getRepository() != null ) if ( artifact.getRepository() != null )
@ -206,18 +199,27 @@ else if ( !artifact.isResolved() )
if ( destination.exists() ) if ( destination.exists() )
{ {
// locally resolved...no need to hit the remote repo.
artifact.setResolved( true ); artifact.setResolved( true );
} }
// 1.0-SNAPSHOT
//
// 1) pom = 1.0-SoNAPSHOT
// 2) pom = 1.0-yyyymmdd.hhmmss
// 3) baseVersion = 1.0-SNAPSHOT
if ( artifact.isSnapshot() && !artifact.getBaseVersion().equals( artifact.getVersion() ) ) if ( artifact.isSnapshot() && !artifact.getBaseVersion().equals( artifact.getVersion() ) )
{ {
String version = artifact.getVersion(); String version = artifact.getVersion();
// 1.0-SNAPSHOT
artifact.selectVersion( artifact.getBaseVersion() ); artifact.selectVersion( artifact.getBaseVersion() );
// Make a file with a 1.0-SNAPSHOT format
File copy = new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) ); File copy = new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) );
// if the timestamped version was resolved or the copy doesn't exist then copy a version
// of the file like 1.0-SNAPSHOT. Even if there is a timestamped version the non-timestamped
// version will be created.
if ( resolved || !copy.exists() ) if ( resolved || !copy.exists() )
{ {
// recopy file if it was reresolved, or doesn't exist. // recopy file if it was reresolved, or doesn't exist.
@ -233,13 +235,15 @@ else if ( !artifact.isResolved() )
} }
} }
// We are only going to use the 1.0-SNAPSHOT version
artifact.setFile( copy ); artifact.setFile( copy );
// Set the version to the 1.0-SNAPSHOT version
artifact.selectVersion( version ); artifact.selectVersion( version );
} }
} }
} }
private boolean isLocalCopy( Artifact artifact ) private boolean isLocalCopy( Artifact artifact )
{ {
boolean localCopy = false; boolean localCopy = false;
@ -323,8 +327,16 @@ public ArtifactResolutionResult resolveTransitively( Set<Artifact> artifacts, Ar
List<ConflictResolver> conflictResolvers ) List<ConflictResolver> conflictResolvers )
throws ArtifactResolutionException, ArtifactNotFoundException throws ArtifactResolutionException, ArtifactNotFoundException
{ {
ArtifactResolutionRequest request = new ArtifactResolutionRequest().setArtifact( originatingArtifact ).setResolveRoot( false ).setArtifactDependencies( artifacts ).setManagedVersionMap( managedVersions ) ArtifactResolutionRequest request = new ArtifactResolutionRequest()
.setLocalRepository( localRepository ).setRemoteRepostories( remoteRepositories ).setMetadataSource( source ).setFilter( filter ).setListeners( listeners ); .setArtifact( originatingArtifact )
.setResolveRoot( false )
// This is required by the surefire plugin
.setArtifactDependencies( artifacts )
.setManagedVersionMap( managedVersions )
.setLocalRepository( localRepository )
.setRemoteRepostories( remoteRepositories )
.setFilter( filter )
.setListeners( listeners );
return resolveWithExceptions( request ); return resolveWithExceptions( request );
} }
@ -346,7 +358,7 @@ public ArtifactResolutionResult resolveWithExceptions( ArtifactResolutionRequest
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
// //
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
public ArtifactResolutionResult resolve( ArtifactResolutionRequest request ) public ArtifactResolutionResult resolve( ArtifactResolutionRequest request )
{ {
Artifact rootArtifact = request.getArtifact(); Artifact rootArtifact = request.getArtifact();
@ -354,10 +366,10 @@ public ArtifactResolutionResult resolve( ArtifactResolutionRequest request )
Map managedVersions = request.getManagedVersionMap(); Map managedVersions = request.getManagedVersionMap();
ArtifactRepository localRepository = request.getLocalRepository(); ArtifactRepository localRepository = request.getLocalRepository();
List<ArtifactRepository> remoteRepositories = request.getRemoteRepostories(); List<ArtifactRepository> remoteRepositories = request.getRemoteRepostories();
ArtifactMetadataSource source = request.getMetadataSource();
List<ResolutionListener> listeners = request.getListeners(); List<ResolutionListener> listeners = request.getListeners();
ArtifactFilter filter = request.getFilter(); ArtifactFilter filter = request.getFilter();
//TODO: hack because metadata isn't generated in m2e correctly and i want to run the maven i have in the workspace
if ( source == null ) if ( source == null )
{ {
try try
@ -366,10 +378,11 @@ public ArtifactResolutionResult resolve( ArtifactResolutionRequest request )
} }
catch ( ComponentLookupException e ) catch ( ComponentLookupException e )
{ {
// Won't happen e.printStackTrace();
// won't happen
} }
} }
if ( listeners == null ) if ( listeners == null )
{ {
listeners = new ArrayList<ResolutionListener>(); listeners = new ArrayList<ResolutionListener>();
@ -388,13 +401,12 @@ public ArtifactResolutionResult resolve( ArtifactResolutionRequest request )
// This is often an artifact like a POM that is taken from disk and we already have hold of the // This is often an artifact like a POM that is taken from disk and we already have hold of the
// file reference. But this may be a Maven Plugin that we need to resolve from a remote repository // file reference. But this may be a Maven Plugin that we need to resolve from a remote repository
// as well as its dependencies. // as well as its dependencies.
if ( request.isResolveRoot() && rootArtifact.getFile() == null ) if ( request.isResolveRoot() && rootArtifact.getFile() == null )
{ {
try try
{ {
resolve( rootArtifact, remoteRepositories, localRepository ); resolve( rootArtifact, remoteRepositories, localRepository );
result.addArtifact( rootArtifact );
} }
catch ( ArtifactResolutionException e ) catch ( ArtifactResolutionException e )
{ {
@ -407,15 +419,55 @@ public ArtifactResolutionResult resolve( ArtifactResolutionRequest request )
return result; return result;
} }
} }
if ( artifacts == null || artifacts.size() == 0 ) if ( request.isResolveTransitively() )
{ {
try
{
Set<Artifact> directArtifacts = source.retrieve( rootArtifact, localRepository, remoteRepositories ).getArtifacts();
if ( artifacts == null || artifacts.isEmpty() )
{
artifacts = directArtifacts;
}
else
{
List<Artifact> allArtifacts = new ArrayList<Artifact>();
allArtifacts.addAll( artifacts );
allArtifacts.addAll( directArtifacts );
Map<String, Artifact> mergedArtifacts = new LinkedHashMap<String, Artifact>();
for ( Artifact artifact : allArtifacts )
{
String conflictId = artifact.getDependencyConflictId();
if ( !mergedArtifacts.containsKey( conflictId ) )
{
mergedArtifacts.put( conflictId, artifact );
}
}
artifacts = new LinkedHashSet<Artifact>( mergedArtifacts.values() );
}
}
catch ( ArtifactMetadataRetrievalException e )
{
// need to add metadata resolution exception
return result;
}
}
if ( artifacts == null || artifacts.isEmpty() )
{
if ( request.isResolveRoot() )
{
result.addArtifact( rootArtifact );
}
return result; return result;
} }
// After the collection we will have the artifact object in the result but they will not be resolved yet.
result = artifactCollector.collect( artifacts, rootArtifact, managedVersions, localRepository, remoteRepositories, source, filter, listeners );
// After the collection we will have the artifact object in the result but they will not be resolved yet.
result = artifactCollector.collect( artifacts, rootArtifact, managedVersions, localRepository, remoteRepositories, source, filter, listeners, null );
// We have metadata retrieval problems, or there are cycles that have been detected // We have metadata retrieval problems, or there are cycles that have been detected
// so we give this back to the calling code and let them deal with this information // so we give this back to the calling code and let them deal with this information
// appropriately. // appropriately.
@ -424,7 +476,7 @@ public ArtifactResolutionResult resolve( ArtifactResolutionRequest request )
{ {
return result; return result;
} }
if ( result.getArtifacts() != null ) if ( result.getArtifacts() != null )
{ {
for ( Artifact artifact : result.getArtifacts() ) for ( Artifact artifact : result.getArtifacts() )
@ -449,7 +501,18 @@ public ArtifactResolutionResult resolve( ArtifactResolutionRequest request )
} }
} }
} }
// We want to send the root artifact back in the result but we need to do this after the other dependencies
// have been resolved.
if ( request.isResolveRoot() )
{
// Add the root artifact (as the first artifact to retain logical order of class path!)
Set<Artifact> allArtifacts = new LinkedHashSet<Artifact>();
allArtifacts.add( rootArtifact );
allArtifacts.addAll( result.getArtifacts() );
result.setArtifacts( allArtifacts );
}
return result; return result;
} }

View File

@ -19,12 +19,6 @@
* under the License. * under the License.
*/ */
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
@ -32,6 +26,12 @@
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
public class ResolutionNode public class ResolutionNode
{ {
private Artifact artifact; private Artifact artifact;
@ -83,7 +83,7 @@ public Object getKey()
public void addDependencies( Set<Artifact> artifacts, List<ArtifactRepository> remoteRepositories, ArtifactFilter filter ) public void addDependencies( Set<Artifact> artifacts, List<ArtifactRepository> remoteRepositories, ArtifactFilter filter )
throws CyclicDependencyException, OverConstrainedVersionException throws CyclicDependencyException, OverConstrainedVersionException
{ {
if ( !artifacts.isEmpty() ) if ( artifacts != null && !artifacts.isEmpty() )
{ {
children = new ArrayList<ResolutionNode>( artifacts.size() ); children = new ArrayList<ResolutionNode>( artifacts.size() );

View File

@ -1,10 +1,10 @@
package org.apache.maven.artifact.resolver; package org.apache.maven.artifact.resolver;
import java.util.List;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import java.util.List;
/** /**
* A simple recording of the Artifacts that could not be resolved for a given resolution request, along with * A simple recording of the Artifacts that could not be resolved for a given resolution request, along with
* the remote repositories where attempts were made to resolve the artifacts. * the remote repositories where attempts were made to resolve the artifacts.

View File

@ -23,9 +23,6 @@
import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.artifact.versioning.VersionRange;
import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.logging.Logger;
import java.util.HashSet;
import java.util.Set;
/** /**
* Send resolution warning events to the warning log. * Send resolution warning events to the warning log.
* *

View File

@ -3,7 +3,7 @@
import org.apache.maven.artifact.resolver.metadata.MetadataGraphEdge; import org.apache.maven.artifact.resolver.metadata.MetadataGraphEdge;
import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Configuration; import org.codehaus.plexus.component.annotations.Configuration;
/** /**

View File

@ -19,6 +19,10 @@
* under the License. * under the License.
*/ */
import java.util.ArrayList;
import java.util.List;
import java.util.TreeSet;
import org.apache.maven.artifact.ArtifactScopeEnum; import org.apache.maven.artifact.ArtifactScopeEnum;
import org.apache.maven.artifact.resolver.metadata.ArtifactMetadata; import org.apache.maven.artifact.resolver.metadata.ArtifactMetadata;
import org.apache.maven.artifact.resolver.metadata.MetadataGraph; import org.apache.maven.artifact.resolver.metadata.MetadataGraph;
@ -28,10 +32,6 @@
import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.component.annotations.Requirement;
import java.util.ArrayList;
import java.util.List;
import java.util.TreeSet;
/** /**
* Default conflict resolver.Implements closer newer first policy by default, but could be configured via plexus * Default conflict resolver.Implements closer newer first policy by default, but could be configured via plexus
* *

View File

@ -19,12 +19,12 @@
* under the License. * under the License.
*/ */
import org.apache.maven.artifact.Artifact;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import org.apache.maven.artifact.Artifact;
/** /**
* Apply multiple filters. * Apply multiple filters.
* *
@ -34,8 +34,17 @@
public class AndArtifactFilter public class AndArtifactFilter
implements ArtifactFilter implements ArtifactFilter
{ {
private final List<ArtifactFilter> filters = new ArrayList<ArtifactFilter>(); private List<ArtifactFilter> filters;
public AndArtifactFilter()
{
}
public AndArtifactFilter( List<ArtifactFilter> filters )
{
this.filters = filters;
}
public boolean include( Artifact artifact ) public boolean include( Artifact artifact )
{ {
boolean include = true; boolean include = true;
@ -52,6 +61,11 @@ public boolean include( Artifact artifact )
public void add( ArtifactFilter artifactFilter ) public void add( ArtifactFilter artifactFilter )
{ {
if ( filters == null )
{
filters = new ArrayList<ArtifactFilter>();
}
filters.add( artifactFilter ); filters.add( artifactFilter );
} }
} }

View File

@ -19,10 +19,10 @@
* under the License. * under the License.
*/ */
import org.apache.maven.artifact.Artifact;
import java.util.List; import java.util.List;
import org.apache.maven.artifact.Artifact;
/** /**
* Filter to exclude from a list of artifact patterns. * Filter to exclude from a list of artifact patterns.
* *

View File

@ -19,12 +19,12 @@
* under the License. * under the License.
*/ */
import org.apache.maven.artifact.Artifact;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import org.apache.maven.artifact.Artifact;
/** /**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a> * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$ * @version $Id$

View File

@ -19,11 +19,11 @@
* under the License. * under the License.
*/ */
import org.apache.maven.artifact.Artifact;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import org.apache.maven.artifact.Artifact;
/** /**
* Filter to include from a list of artifact patterns. * Filter to include from a list of artifact patterns.
* *

View File

@ -19,10 +19,10 @@
* under the License. * under the License.
*/ */
import org.apache.maven.artifact.repository.ArtifactRepository;
import java.util.List; import java.util.List;
import org.apache.maven.artifact.repository.ArtifactRepository;
/** /**
* Provides some metadata operations, like querying the remote repository for a list of versions available for an * Provides some metadata operations, like querying the remote repository for a list of versions available for an
* artifact. * artifact.
@ -34,8 +34,6 @@ public interface MetadataSource
{ {
String ROLE = MetadataSource.class.getName(); String ROLE = MetadataSource.class.getName();
MetadataResolution retrieve( ArtifactMetadata artifact, MetadataResolution retrieve( ArtifactMetadata artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories )
throws MetadataRetrievalException; throws MetadataRetrievalException;
} }

View File

@ -19,6 +19,8 @@
* under the License. * under the License.
*/ */
import java.util.List;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.manager.WagonManager;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
@ -31,9 +33,6 @@
import org.apache.maven.artifact.repository.metadata.Versioning; import org.apache.maven.artifact.repository.metadata.Versioning;
import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.component.annotations.Component;
import java.util.List;
/** /**
* Describes a version transformation during artifact resolution. * Describes a version transformation during artifact resolution.
@ -52,9 +51,7 @@ public abstract class AbstractVersionTransformation
@Requirement @Requirement
protected WagonManager wagonManager; protected WagonManager wagonManager;
protected String resolveVersion( Artifact artifact, protected String resolveVersion( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories )
throws RepositoryMetadataResolutionException throws RepositoryMetadataResolutionException
{ {
RepositoryMetadata metadata; RepositoryMetadata metadata;
@ -111,6 +108,5 @@ protected String resolveVersion( Artifact artifact,
return version; return version;
} }
protected abstract String constructVersion( Versioning versioning, protected abstract String constructVersion( Versioning versioning, String baseVersion );
String baseVersion );
} }

View File

@ -19,6 +19,8 @@
* under the License. * under the License.
*/ */
import java.util.List;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.deployer.ArtifactDeploymentException; import org.apache.maven.artifact.deployer.ArtifactDeploymentException;
import org.apache.maven.artifact.installer.ArtifactInstallationException; import org.apache.maven.artifact.installer.ArtifactInstallationException;
@ -26,8 +28,6 @@
import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import java.util.List;
/** /**
* @author <a href="mailto:jason@maven.org">Jason van Zyl </a> * @author <a href="mailto:jason@maven.org">Jason van Zyl </a>
* @version $Id: ArtifactTransformation.java,v 1.1 2005/03/03 15:37:25 * @version $Id: ArtifactTransformation.java,v 1.1 2005/03/03 15:37:25

View File

@ -19,6 +19,8 @@
* under the License. * under the License.
*/ */
import java.util.List;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.deployer.ArtifactDeploymentException; import org.apache.maven.artifact.deployer.ArtifactDeploymentException;
import org.apache.maven.artifact.installer.ArtifactInstallationException; import org.apache.maven.artifact.installer.ArtifactInstallationException;
@ -26,9 +28,6 @@
import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import java.util.List;
import java.util.Map;
/** Manages multiple ArtifactTransformation instances and applies them in succession. */ /** Manages multiple ArtifactTransformation instances and applies them in succession. */
public interface ArtifactTransformationManager public interface ArtifactTransformationManager
{ {
@ -42,9 +41,7 @@ public interface ArtifactTransformationManager
* @param remoteRepositories the repositories to check * @param remoteRepositories the repositories to check
* @param localRepository the local repository * @param localRepository the local repository
*/ */
void transformForResolve( Artifact artifact, void transformForResolve( Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository )
List<ArtifactRepository> remoteRepositories,
ArtifactRepository localRepository )
throws ArtifactResolutionException, ArtifactNotFoundException; throws ArtifactResolutionException, ArtifactNotFoundException;
/** /**
@ -54,8 +51,7 @@ void transformForResolve( Artifact artifact,
* @param artifact Artifact to be transformed. * @param artifact Artifact to be transformed.
* @param localRepository the local repository it will be stored in * @param localRepository the local repository it will be stored in
*/ */
void transformForInstall( Artifact artifact, void transformForInstall( Artifact artifact, ArtifactRepository localRepository )
ArtifactRepository localRepository )
throws ArtifactInstallationException; throws ArtifactInstallationException;
/** /**
@ -66,11 +62,8 @@ void transformForInstall( Artifact artifact,
* @param remoteRepository the repository to deploy to * @param remoteRepository the repository to deploy to
* @param localRepository the local repository the metadata is stored in * @param localRepository the local repository the metadata is stored in
*/ */
void transformForDeployment( Artifact artifact, void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository, ArtifactRepository localRepository )
ArtifactRepository remoteRepository,
ArtifactRepository localRepository )
throws ArtifactDeploymentException; throws ArtifactDeploymentException;
List getArtifactTransformations(); List getArtifactTransformations();
} }

View File

@ -19,6 +19,8 @@
* under the License. * under the License.
*/ */
import java.util.List;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.deployer.ArtifactDeploymentException; import org.apache.maven.artifact.deployer.ArtifactDeploymentException;
import org.apache.maven.artifact.installer.ArtifactInstallationException; import org.apache.maven.artifact.installer.ArtifactInstallationException;
@ -28,10 +30,6 @@
import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.component.annotations.Requirement;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/** /**
* @author Jason van Zyl * @author Jason van Zyl
*/ */

View File

@ -19,6 +19,8 @@
* under the License. * under the License.
*/ */
import java.util.List;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutionException; import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutionException;
@ -27,8 +29,6 @@
import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Component;
import java.util.List;
@Component(role=ArtifactTransformation.class, hint="latest") @Component(role=ArtifactTransformation.class, hint="latest")
public class LatestArtifactTransformation public class LatestArtifactTransformation
extends AbstractVersionTransformation extends AbstractVersionTransformation

View File

@ -19,6 +19,8 @@
* under the License. * under the License.
*/ */
import java.util.List;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
@ -29,8 +31,6 @@
import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Component;
import java.util.List;
/** /**
* Change the version <code>RELEASE</code> to the appropriate release version from the remote repository. * Change the version <code>RELEASE</code> to the appropriate release version from the remote repository.
* *

View File

@ -19,6 +19,12 @@
* under the License. * under the License.
*/ */
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.deployer.ArtifactDeploymentException; import org.apache.maven.artifact.deployer.ArtifactDeploymentException;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
@ -32,12 +38,6 @@
import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.StringUtils;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;
/** /**
* @author <a href="mailto:brett@apache.org">Brett Porter</a> * @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @author <a href="mailto:mmaczka@interia.pl">Michal Maczka</a> * @author <a href="mailto:mmaczka@interia.pl">Michal Maczka</a>
@ -54,9 +54,7 @@ public class SnapshotTransformation
private static final String UTC_TIMESTAMP_PATTERN = "yyyyMMdd.HHmmss"; private static final String UTC_TIMESTAMP_PATTERN = "yyyyMMdd.HHmmss";
public void transformForResolve( Artifact artifact, public void transformForResolve( Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository )
List<ArtifactRepository> remoteRepositories,
ArtifactRepository localRepository )
throws ArtifactResolutionException throws ArtifactResolutionException
{ {
// Only select snapshots that are unresolved (eg 1.0-SNAPSHOT, not 1.0-20050607.123456) // Only select snapshots that are unresolved (eg 1.0-SNAPSHOT, not 1.0-20050607.123456)
@ -95,10 +93,8 @@ public void transformForDeployment( Artifact artifact,
if ( artifact.isSnapshot() ) if ( artifact.isSnapshot() )
{ {
Snapshot snapshot = new Snapshot(); Snapshot snapshot = new Snapshot();
if ( remoteRepository.isUniqueVersion() )
{ snapshot.setTimestamp( getDeploymentTimestamp() );
snapshot.setTimestamp( getDeploymentTimestamp() );
}
// we update the build number anyway so that it doesn't get lost. It requires the timestamp to take effect // we update the build number anyway so that it doesn't get lost. It requires the timestamp to take effect
try try

View File

@ -20,8 +20,8 @@
*/ */
import java.util.HashMap; import java.util.HashMap;
import java.util.Map;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map;
public class ManagedVersionMap public class ManagedVersionMap
extends HashMap extends HashMap

View File

@ -19,12 +19,12 @@
* under the License. * under the License.
*/ */
import java.util.List;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import java.util.List;
/** /**
* Occurs when ranges exclude each other and no valid value remains. * Occurs when ranges exclude each other and no valid value remains.
* *

View File

@ -19,29 +19,22 @@
* under the License. * under the License.
*/ */
import org.apache.maven.model.Activation;
import org.apache.maven.model.Model;
import org.apache.maven.model.Profile;
import org.apache.maven.model.interpolator.InterpolatorProperty;
import org.apache.maven.model.interpolator.PomInterpolatorTag;
import org.apache.maven.profiles.ProfileActivationContext;
import org.apache.maven.profiles.ProfileActivationException;
import org.apache.maven.profiles.ProfileManager;
import org.apache.maven.profiles.matchers.DefaultMatcher;
import org.apache.maven.profiles.matchers.FileMatcher;
import org.apache.maven.profiles.matchers.JdkMatcher;
import org.apache.maven.profiles.matchers.ProfileMatcher;
import org.apache.maven.profiles.matchers.PropertyMatcher;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties;
import org.apache.maven.model.Activation;
import org.apache.maven.model.Model;
import org.apache.maven.model.Profile;
import org.apache.maven.model.profile.activator.FileProfileActivator;
import org.apache.maven.model.profile.activator.JdkVersionProfileActivator;
import org.apache.maven.model.profile.activator.OperatingSystemProfileActivator;
import org.apache.maven.model.profile.activator.ProfileActivator;
import org.apache.maven.model.profile.activator.PropertyProfileActivator;
@Deprecated
public class DefaultProfileManager public class DefaultProfileManager
implements ProfileManager implements ProfileManager
{ {
@ -49,11 +42,10 @@ public class DefaultProfileManager
private Map<String, Profile> profilesById = new LinkedHashMap<String, Profile>(); private Map<String, Profile> profilesById = new LinkedHashMap<String, Profile>();
private ProfileActivationContext profileActivationContext; private ProfileActivationContext profileActivationContext;
private static final ProfileMatcher defaultMatcher = new DefaultMatcher();
private static final List<ProfileMatcher> matchers = private static final List<ProfileActivator> activators =
Collections.unmodifiableList( Arrays.asList( new PropertyMatcher(), new FileMatcher(), new JdkMatcher() ) ); Arrays.asList( new PropertyProfileActivator(), new OperatingSystemProfileActivator(),
new FileProfileActivator(), new JdkVersionProfileActivator() );
/** /**
* the properties passed to the profile manager are the props that * the properties passed to the profile manager are the props that
@ -179,70 +171,6 @@ public List<Profile> getActiveProfiles( Model model )
} }
return allActive; return allActive;
} }
public static List<Profile> getActiveProfilesFrom(ProfileManager globalProfileManager, Properties properties, Model model)
throws ProfileActivationException
{
List<Profile> projectProfiles = new ArrayList<Profile>();
ProfileActivationContext profileActivationContext = (globalProfileManager == null) ? new ProfileActivationContext( new Properties(), false ):
globalProfileManager.getProfileActivationContext();
profileActivationContext.getExecutionProperties().putAll(properties);
if(globalProfileManager != null)
{
projectProfiles.addAll( globalProfileManager.getActiveProfiles() );
}
ProfileManager profileManager = new DefaultProfileManager( profileActivationContext );
profileManager.addProfiles( model.getProfiles() );
projectProfiles.addAll( profileManager.getActiveProfiles() );
return projectProfiles;
}
public static Collection<Profile> getActiveProfiles(List<Profile> profiles, ProfileManagerInfo profileContextInfo)
{
List<InterpolatorProperty> properties = profileContextInfo.getInterpolatorProperties();
Collection<String> activeProfileIds = profileContextInfo.getActiveProfileIds();
Collection<String> inactiveProfileIds = profileContextInfo.getInactiveProfileIds();
List<Profile> matchedProfiles = new ArrayList<Profile>();
List<Profile> defaultProfiles = new ArrayList<Profile>();
for ( Profile profile : profiles )
{
String profileId = profile.getId();
if ( !inactiveProfileIds.contains( profileId ) )
{
if ( activeProfileIds.contains( profileId ) )
{
matchedProfiles.add( profile );
}
else if ( defaultMatcher.isMatch( profile, properties ) )
{
defaultProfiles.add( profile );
}
else
{
for ( ProfileMatcher matcher : matchers )
{
if ( matcher.isMatch( profile, properties ) )
{
matchedProfiles.add( profile );
break;
}
}
}
}
}
if ( matchedProfiles.isEmpty() )
{
matchedProfiles = defaultProfiles;
}
return matchedProfiles;
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.apache.maven.project.ProfileManager#addProfiles(java.util.List) * @see org.apache.maven.project.ProfileManager#addProfiles(java.util.List)
@ -271,19 +199,18 @@ private static List<Profile> getDefaultProfiles(List<Profile> profiles)
private boolean isActive( Profile profile, ProfileActivationContext context ) private boolean isActive( Profile profile, ProfileActivationContext context )
throws ProfileActivationException throws ProfileActivationException
{ {
List<InterpolatorProperty> interpolatorProperties = new ArrayList<InterpolatorProperty>(); for ( ProfileActivator activator : activators )
if(context.getExecutionProperties() != null)
{ {
interpolatorProperties.addAll(InterpolatorProperty.toInterpolatorProperties( try
context.getExecutionProperties(),
PomInterpolatorTag.EXECUTION_PROPERTIES.name()));
}
for(ProfileMatcher matcher : matchers)
{
if(matcher.isMatch(profile, interpolatorProperties))
{ {
return true; if ( activator.isActive( profile, context ) )
{
return true;
}
}
catch ( org.apache.maven.model.profile.ProfileActivationException e )
{
throw new ProfileActivationException( e.getMessage(), e.getCause() );
} }
} }
return false; return false;
@ -298,4 +225,5 @@ private void activateAsDefault( String profileId )
profileActivationContext.setActiveByDefault( profileId ); profileActivationContext.setActiveByDefault( profileId );
} }
} }
} }

View File

@ -25,7 +25,9 @@
import java.util.List; import java.util.List;
import java.util.Properties; import java.util.Properties;
@Deprecated
public class ProfileActivationContext public class ProfileActivationContext
implements org.apache.maven.model.profile.ProfileActivationContext
{ {
private boolean isCustomActivatorFailureSuppressed; private boolean isCustomActivatorFailureSuppressed;
@ -148,4 +150,14 @@ public void setActiveByDefaultProfileIds( List<String> activeByDefault )
this.activeByDefault = activeByDefault; this.activeByDefault = activeByDefault;
} }
public List<String> getActiveProfileIds()
{
return getExplicitlyActiveProfileIds();
}
public List<String> getInactiveProfileIds()
{
return getExplicitlyInactiveProfileIds();
}
} }

View File

@ -19,11 +19,14 @@
* under the License. * under the License.
*/ */
@Deprecated
public class ProfileActivationException public class ProfileActivationException
extends Exception extends Exception
{ {
public ProfileActivationException( String message, Throwable cause ) private static final long serialVersionUID = -90820222109103638L;
public ProfileActivationException( String message, Throwable cause )
{ {
super( message, cause ); super( message, cause );
} }

View File

@ -15,14 +15,13 @@
* the License. * the License.
*/ */
import org.apache.maven.model.Model;
import org.apache.maven.model.Profile;
import org.apache.maven.profiles.ProfileActivationContext;
import org.apache.maven.profiles.ProfileActivationException;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.maven.model.Model;
import org.apache.maven.model.Profile;
@Deprecated
public interface ProfileManager public interface ProfileManager
{ {
void addProfile( Profile profile ); void addProfile( Profile profile );
@ -34,8 +33,7 @@ public interface ProfileManager
void addProfiles( List<Profile> profiles ); void addProfiles( List<Profile> profiles );
Map<String, Profile> getProfilesById(); Map<String, Profile> getProfilesById();
@Deprecated
List<Profile> getActiveProfiles( Model model ) List<Profile> getActiveProfiles( Model model )
throws ProfileActivationException; throws ProfileActivationException;

View File

@ -19,10 +19,19 @@
* under the License. * under the License.
*/ */
import org.apache.maven.model.*; import java.util.ArrayList;
import org.codehaus.plexus.util.xml.Xpp3Dom; import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.*; import org.apache.maven.model.Dependency;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.PluginContainer;
import org.apache.maven.model.PluginExecution;
import org.apache.maven.model.Repository;
import org.codehaus.plexus.util.xml.Xpp3Dom;
/** @deprecated */ /** @deprecated */
@Deprecated @Deprecated

View File

@ -19,12 +19,6 @@
* under the License. * under the License.
*/ */
import org.apache.maven.model.*;
import org.apache.maven.project.ModelUtils;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@ -35,6 +29,25 @@
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.TreeMap; import java.util.TreeMap;
import org.apache.maven.model.Build;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.DependencyManagement;
import org.apache.maven.model.DeploymentRepository;
import org.apache.maven.model.DistributionManagement;
import org.apache.maven.model.Extension;
import org.apache.maven.model.Model;
import org.apache.maven.model.PluginManagement;
import org.apache.maven.model.ReportPlugin;
import org.apache.maven.model.ReportSet;
import org.apache.maven.model.Reporting;
import org.apache.maven.model.Resource;
import org.apache.maven.model.Scm;
import org.apache.maven.model.Site;
import org.apache.maven.project.ModelUtils;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.Xpp3Dom;
@Component(role = ModelInheritanceAssembler.class) @Component(role = ModelInheritanceAssembler.class)
public class DefaultModelInheritanceAssembler public class DefaultModelInheritanceAssembler
implements ModelInheritanceAssembler implements ModelInheritanceAssembler

View File

@ -19,10 +19,10 @@
* under the License. * under the License.
*/ */
import org.apache.maven.model.Model;
import java.io.File; import java.io.File;
import org.apache.maven.model.Model;
/** /**
* @author Jason van Zyl * @author Jason van Zyl
* @version $Id$ * @version $Id$

View File

@ -1,4 +1,4 @@
package org.apache.maven.model.processors; package org.apache.maven.project.validation;
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
@ -9,7 +9,7 @@
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an
@ -20,29 +20,32 @@
*/ */
import org.apache.maven.model.Model; import org.apache.maven.model.Model;
import org.apache.maven.model.Parent; import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
public class ParentProcessor /**
extends BaseProcessor * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
* @version $Id$
*/
@Component(role = ModelValidator.class )
@Deprecated
public class DefaultModelValidator
implements ModelValidator
{ {
@Requirement
private org.apache.maven.model.validation.ModelValidator modelValidator;
public ParentProcessor() public ModelValidationResult validate( Model model )
{ {
} ModelValidationResult result = new ModelValidationResult();
public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized ) for ( String message : modelValidator.validateEffectiveModel( model, false ).getMessages() )
{
super.process( parent, child, target, isChildMostSpecialized );
Model t = (Model) target;
Model c = (Model) child;
if ( c.getParent() != null )
{ {
Parent p = new Parent(); result.addMessage( message );
p.setGroupId( c.getParent().getGroupId() );
p.setArtifactId( c.getParent().getArtifactId() );
p.setVersion( c.getParent().getVersion() );
p.setRelativePath( c.getParent().getRelativePath() );
t.setParent( p );
} }
return result;
} }
} }

View File

@ -1,4 +1,4 @@
package org.apache.maven.project; package org.apache.maven.project.validation;
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
@ -19,10 +19,12 @@
* under the License. * under the License.
*/ */
import org.codehaus.plexus.component.annotations.Component; /**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
@Component(role=MavenProjectBuilder.class,hint="test") * @version $Id$
public class TestProjectBuilder */
extends DefaultMavenProjectBuilder public class ModelValidationResult
extends org.apache.maven.model.validation.ModelValidationResult
{ {
} }

View File

@ -22,12 +22,17 @@
import org.apache.maven.model.Model; import org.apache.maven.model.Model;
/** /**
* Checks the model for missing or invalid values.
*
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a> * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
* @version $Id$ * @version $Id$
*/ */
@Deprecated
public interface ModelValidator public interface ModelValidator
{ {
String ROLE = ModelValidator.class.getName(); String ROLE = ModelValidator.class.getName();
ModelValidationResult validate( Model model ); ModelValidationResult validate( Model model );
} }

View File

@ -19,13 +19,6 @@
* under the License. * under the License.
*/ */
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.codehaus.plexus.PlexusTestCase;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
@ -34,6 +27,13 @@
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.codehaus.plexus.PlexusTestCase;
/** /**
* @author <a href="mailto:jason@maven.org">Jason van Zyl </a> * @author <a href="mailto:jason@maven.org">Jason van Zyl </a>
* @version $Id$ * @version $Id$
@ -71,7 +71,7 @@ protected void tearDown()
protected ArtifactRepository badLocalRepository() protected ArtifactRepository badLocalRepository()
throws Exception throws Exception
{ {
String path = "target/test-classes/repositories/" + component() + "/bad-local-repository"; String path = "target/test-repositories/" + component() + "/bad-local-repository";
File f = new File( getBasedir(), path ); File f = new File( getBasedir(), path );
@ -91,7 +91,7 @@ protected String getRepositoryLayout()
protected ArtifactRepository localRepository() protected ArtifactRepository localRepository()
throws Exception throws Exception
{ {
String path = "target/test-classes/repositories/" + component() + "/local-repository"; String path = "target/test-repositories/" + component() + "/local-repository";
File f = new File( getBasedir(), path ); File f = new File( getBasedir(), path );
@ -104,7 +104,7 @@ protected ArtifactRepository localRepository()
protected ArtifactRepository remoteRepository() protected ArtifactRepository remoteRepository()
throws Exception throws Exception
{ {
String path = "target/test-classes/repositories/" + component() + "/remote-repository"; String path = "target/test-repositories/" + component() + "/remote-repository";
File f = new File( getBasedir(), path ); File f = new File( getBasedir(), path );
@ -268,7 +268,9 @@ protected Artifact createArtifact( String artifactId, String version, String typ
protected Artifact createArtifact( String groupId, String artifactId, String version, String type ) protected Artifact createArtifact( String groupId, String artifactId, String version, String type )
throws Exception throws Exception
{ {
return artifactFactory.createBuildArtifact( groupId, artifactId, version, type ); Artifact a = artifactFactory.createBuildArtifact( groupId, artifactId, version, type );
return a;
} }
protected void deleteLocalArtifact( Artifact artifact ) protected void deleteLocalArtifact( Artifact artifact )

View File

@ -19,11 +19,11 @@
* under the License. * under the License.
*/ */
import junit.framework.TestCase;
import org.apache.maven.artifact.handler.ArtifactHandlerMock; import org.apache.maven.artifact.handler.ArtifactHandlerMock;
import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.artifact.versioning.VersionRange;
import junit.framework.TestCase;
public class DefaultArtifactTest public class DefaultArtifactTest
extends TestCase extends TestCase
{ {

View File

@ -19,13 +19,13 @@
* under the License. * under the License.
*/ */
import java.io.File;
import org.apache.maven.artifact.AbstractArtifactComponentTestCase; import org.apache.maven.artifact.AbstractArtifactComponentTestCase;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.FileUtils;
import java.io.File;
/** /**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a> * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$ * @version $Id$

View File

@ -19,17 +19,18 @@
* under the License. * under the License.
*/ */
import java.util.Collections;
import java.util.List;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
import org.apache.maven.artifact.metadata.ResolutionGroup; import org.apache.maven.artifact.metadata.ResolutionGroup;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import java.util.Collections;
import java.util.List;
/** @author Jason van Zyl */ /** @author Jason van Zyl */
public class SimpleArtifactMetadataSource public class SimpleArtifactMetadataSource
implements ArtifactMetadataSource implements ArtifactMetadataSource

View File

@ -19,11 +19,11 @@
* under the License. * under the License.
*/ */
import java.io.File;
import org.apache.maven.artifact.AbstractArtifactComponentTestCase; import org.apache.maven.artifact.AbstractArtifactComponentTestCase;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import java.io.File;
/** /**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a> * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$ * @version $Id$

View File

@ -23,6 +23,7 @@
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Set;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.DefaultArtifact;
@ -72,6 +73,20 @@ protected void setUp()
artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE ); artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
} }
@Override
protected void tearDown() throws Exception {
wagonManager = null;
artifactFactory = null;
super.tearDown();
}
public void testAvailableProtocols()
throws Exception
{
Set<String> protocols = wagonManager.getSupportProtocols();
System.out.println( protocols );
}
public void testUnnecessaryRepositoryLookup() throws Exception { public void testUnnecessaryRepositoryLookup() throws Exception {
Artifact artifact = createTestPomArtifact( "target/test-data/get-missing-pom" ); Artifact artifact = createTestPomArtifact( "target/test-data/get-missing-pom" );
@ -278,9 +293,7 @@ public void testDefaultWagonManager()
{ {
assertWagon( "a" ); assertWagon( "a" );
assertWagon( "b1" ); assertWagon( "b" );
assertWagon( "b2" );
assertWagon( "c" ); assertWagon( "c" );

View File

@ -31,10 +31,13 @@
import org.apache.maven.wagon.ResourceDoesNotExistException; import org.apache.maven.wagon.ResourceDoesNotExistException;
import org.apache.maven.wagon.StreamWagon; import org.apache.maven.wagon.StreamWagon;
import org.apache.maven.wagon.TransferFailedException; import org.apache.maven.wagon.TransferFailedException;
import org.apache.maven.wagon.Wagon;
import org.apache.maven.wagon.authentication.AuthenticationException; import org.apache.maven.wagon.authentication.AuthenticationException;
import org.apache.maven.wagon.authorization.AuthorizationException; import org.apache.maven.wagon.authorization.AuthorizationException;
import org.apache.maven.wagon.resource.Resource; import org.apache.maven.wagon.resource.Resource;
import org.codehaus.plexus.component.annotations.Component;
@Component(role=Wagon.class,hint="string")
public class StringWagon public class StringWagon
extends StreamWagon extends StreamWagon
{ {

View File

@ -1,5 +1,8 @@
package org.apache.maven.artifact.manager; package org.apache.maven.artifact.manager;
import org.apache.maven.wagon.Wagon;
import org.codehaus.plexus.component.annotations.Component;
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file
@ -26,6 +29,7 @@
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a> * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$ * @version $Id$
*/ */
@Component(role=Wagon.class,hint="a")
public class WagonA public class WagonA
extends WagonMock extends WagonMock
{ {

View File

@ -1,5 +1,8 @@
package org.apache.maven.artifact.manager; package org.apache.maven.artifact.manager;
import org.apache.maven.wagon.Wagon;
import org.codehaus.plexus.component.annotations.Component;
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file
@ -26,6 +29,7 @@
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a> * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$ * @version $Id$
*/ */
@Component(role=Wagon.class,hint="b")
public class WagonB public class WagonB
extends WagonMock extends WagonMock
{ {

View File

@ -1,5 +1,8 @@
package org.apache.maven.artifact.manager; package org.apache.maven.artifact.manager;
import org.apache.maven.wagon.Wagon;
import org.codehaus.plexus.component.annotations.Component;
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file
@ -26,6 +29,7 @@
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a> * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$ * @version $Id$
*/ */
@Component(role=Wagon.class,hint="c")
public class WagonC public class WagonC
extends WagonMock extends WagonMock
{ {

View File

@ -0,0 +1,76 @@
package org.apache.maven.artifact.metadata;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
@Component(role = ArtifactMetadataSource.class)
public class TestMetadataSource
implements ArtifactMetadataSource
{
@Requirement
private ArtifactFactory factory;
public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
throws ArtifactMetadataRetrievalException
{
Set dependencies = new HashSet();
if ( "g".equals( artifact.getArtifactId() ) )
{
Artifact a = null;
try
{
a = factory.createBuildArtifact( "org.apache.maven", "h", "1.0", "jar" );
dependencies.add( a );
}
catch ( Exception e )
{
throw new ArtifactMetadataRetrievalException( "Error retrieving metadata", e, a );
}
}
if ( "i".equals( artifact.getArtifactId() ) )
{
Artifact a = null;
try
{
a = factory.createBuildArtifact( "org.apache.maven", "j", "1.0-SNAPSHOT", "jar" );
dependencies.add( a );
}
catch ( Exception e )
{
throw new ArtifactMetadataRetrievalException( "Error retrieving metadata", e, a );
}
}
return new ResolutionGroup( artifact, dependencies, remoteRepositories );
}
public List<ArtifactVersion> retrieveAvailableVersions( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
throws ArtifactMetadataRetrievalException
{
throw new UnsupportedOperationException( "Cannot get available versions in this test case" );
}
public List<ArtifactVersion> retrieveAvailableVersionsFromDeploymentRepository( Artifact artifact, ArtifactRepository localRepository, ArtifactRepository remoteRepository )
throws ArtifactMetadataRetrievalException
{
throw new UnsupportedOperationException( "Cannot get available versions in this test case" );
}
public Artifact retrieveRelocatedArtifact( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
throws ArtifactMetadataRetrievalException
{
return artifact;
}
}

View File

@ -33,6 +33,7 @@
import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
import org.apache.maven.artifact.metadata.ResolutionGroup; import org.apache.maven.artifact.metadata.ResolutionGroup;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.ArtifactVersion;
// It would be cool if there was a hook that i could use to setup a test environment. // It would be cool if there was a hook that i could use to setup a test environment.
@ -42,8 +43,7 @@
// the layout used for a particular artifact type. // the layout used for a particular artifact type.
/** /**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a> * @author Jason van Zyl
* @version $Id$
*/ */
public class ArtifactResolverTest public class ArtifactResolverTest
extends AbstractArtifactComponentTestCase extends AbstractArtifactComponentTestCase
@ -62,6 +62,15 @@ protected void setUp()
projectArtifact = createLocalArtifact( "project", "3.0" ); projectArtifact = createLocalArtifact( "project", "3.0" );
} }
@Override
protected void tearDown()
throws Exception
{
artifactFactory = null;
projectArtifact = null;
super.tearDown();
}
@Override @Override
protected String component() protected String component()
@ -84,9 +93,7 @@ public void testResolutionOfASingleArtifactWhereTheArtifactIsNotPresentLocallyAn
{ {
Artifact b = createRemoteArtifact( "b", "1.0-SNAPSHOT" ); Artifact b = createRemoteArtifact( "b", "1.0-SNAPSHOT" );
deleteLocalArtifact( b ); deleteLocalArtifact( b );
artifactResolver.resolve( b, remoteRepositories(), localRepository() ); artifactResolver.resolve( b, remoteRepositories(), localRepository() );
assertLocalArtifactPresent( b ); assertLocalArtifactPresent( b );
} }
@ -105,59 +112,7 @@ public void testTransitiveResolutionWhereAllArtifactsArePresentInTheLocalReposit
Artifact h = createLocalArtifact( "h", "1.0" ); Artifact h = createLocalArtifact( "h", "1.0" );
ArtifactMetadataSource mds = new ArtifactMetadataSource() ArtifactResolutionResult result = artifactResolver.resolveTransitively( Collections.singleton( g ), projectArtifact, remoteRepositories(), localRepository(), null );
{
public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories )
throws ArtifactMetadataRetrievalException
{
Set dependencies = new HashSet();
if ( "g".equals( artifact.getArtifactId() ) )
{
Artifact a = null;
try
{
a = createArtifact( "org.apache.maven", "h", "1.0", "jar" );
dependencies.add( a );
}
catch ( Exception e )
{
throw new ArtifactMetadataRetrievalException( "Error retrieving metadata", e, a );
}
}
return new ResolutionGroup( artifact, dependencies, remoteRepositories );
}
public List<ArtifactVersion> retrieveAvailableVersions( Artifact artifact,
ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories )
throws ArtifactMetadataRetrievalException
{
throw new UnsupportedOperationException( "Cannot get available versions in this test case" );
}
public List<ArtifactVersion> retrieveAvailableVersionsFromDeploymentRepository(
Artifact artifact,
ArtifactRepository localRepository,
ArtifactRepository remoteRepository )
throws ArtifactMetadataRetrievalException
{
throw new UnsupportedOperationException( "Cannot get available versions in this test case" );
}
public Artifact retrieveRelocatedArtifact( Artifact artifact,
ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories )
throws ArtifactMetadataRetrievalException
{
return artifact;
}
};
ArtifactResolutionResult result =
artifactResolver.resolveTransitively( Collections.singleton( g ), projectArtifact, remoteRepositories(), localRepository(), mds );
assertEquals( 2, result.getArtifacts().size() ); assertEquals( 2, result.getArtifacts().size() );
@ -179,60 +134,7 @@ public void testTransitiveResolutionWhereAllArtifactsAreNotPresentInTheLocalRepo
Artifact j = createRemoteArtifact( "j", "1.0-SNAPSHOT" ); Artifact j = createRemoteArtifact( "j", "1.0-SNAPSHOT" );
deleteLocalArtifact( j ); deleteLocalArtifact( j );
ArtifactMetadataSource mds = new ArtifactMetadataSource() ArtifactResolutionResult result = artifactResolver.resolveTransitively( Collections.singleton( i ), projectArtifact, remoteRepositories(), localRepository(), null );
{
public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories )
throws ArtifactMetadataRetrievalException
{
Set dependencies = new HashSet();
if ( "i".equals( artifact.getArtifactId() ) )
{
Artifact a = null;
try
{
a = createArtifact( "org.apache.maven", "j", "1.0-SNAPSHOT", "jar" );
dependencies.add( a );
}
catch ( Exception e )
{
throw new ArtifactMetadataRetrievalException( "Error retrieving metadata", e, a );
}
}
return new ResolutionGroup( artifact, dependencies, remoteRepositories );
}
public List<ArtifactVersion> retrieveAvailableVersions( Artifact artifact,
ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories )
throws ArtifactMetadataRetrievalException
{
throw new UnsupportedOperationException( "Cannot get available versions in this test case" );
}
public List<ArtifactVersion> retrieveAvailableVersionsFromDeploymentRepository(
Artifact artifact,
ArtifactRepository localRepository,
ArtifactRepository remoteRepository )
throws ArtifactMetadataRetrievalException
{
throw new UnsupportedOperationException( "Cannot get available versions in this test case" );
}
public Artifact retrieveRelocatedArtifact( Artifact artifact,
ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories )
throws ArtifactMetadataRetrievalException
{
return artifact;
}
};
ArtifactResolutionResult result =
artifactResolver.resolveTransitively( Collections.singleton( i ), projectArtifact, remoteRepositories(),
localRepository(), mds );
assertEquals( 2, result.getArtifacts().size() ); assertEquals( 2, result.getArtifacts().size() );

View File

@ -19,6 +19,17 @@
* under the License. * under the License.
*/ */
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
@ -35,17 +46,6 @@
import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.artifact.versioning.VersionRange;
import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.PlexusTestCase;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
/** /**
* Test the default artifact collector. * Test the default artifact collector.
* *
@ -73,11 +73,18 @@ protected void setUp()
source = new Source(); source = new Source();
artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE ); artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
artifactCollector = (ArtifactCollector) lookup( ArtifactCollector.ROLE ); artifactCollector = (ArtifactCollector) lookup( ArtifactCollector.class );
projectArtifact = createArtifactSpec( "project", "1.0", null ); projectArtifact = createArtifactSpec( "project", "1.0", null );
} }
@Override
protected void tearDown() throws Exception {
artifactCollector = null;
artifactFactory = null;
super.tearDown();
}
// works, but we don't fail on cycles presently // works, but we don't fail on cycles presently
public void disabledtestCircularDependencyNotIncludingCurrentProject() public void disabledtestCircularDependencyNotIncludingCurrentProject()
throws ArtifactResolutionException, InvalidVersionSpecificationException throws ArtifactResolutionException, InvalidVersionSpecificationException
@ -726,23 +733,23 @@ private ArtifactResolutionResult collect( Set artifacts )
private ArtifactResolutionResult collect( Set artifacts, ArtifactFilter filter ) private ArtifactResolutionResult collect( Set artifacts, ArtifactFilter filter )
throws ArtifactResolutionException throws ArtifactResolutionException
{ {
return artifactCollector.collect( artifacts, projectArtifact.artifact, null, null, source, filter, return artifactCollector.collect( artifacts, projectArtifact.artifact, null, null, null, source, filter,
Collections.EMPTY_LIST ); Collections.EMPTY_LIST, null );
} }
private ArtifactResolutionResult collect( ArtifactSpec a ) private ArtifactResolutionResult collect( ArtifactSpec a )
throws ArtifactResolutionException throws ArtifactResolutionException
{ {
return artifactCollector.collect( Collections.singleton( a.artifact ), projectArtifact.artifact, null, null, return artifactCollector.collect( Collections.singleton( a.artifact ), projectArtifact.artifact, null, null,
source, null, Collections.EMPTY_LIST ); null, source, null, Collections.EMPTY_LIST, null );
} }
private ArtifactResolutionResult collect( ArtifactSpec a, ArtifactFilter filter ) private ArtifactResolutionResult collect( ArtifactSpec a, ArtifactFilter filter )
throws ArtifactResolutionException throws ArtifactResolutionException
{ {
return artifactCollector.collect( Collections.singleton( a.artifact ), projectArtifact.artifact, null, null, return artifactCollector.collect( Collections.singleton( a.artifact ), projectArtifact.artifact, null, null,
source, filter, Collections.EMPTY_LIST ); null, source, filter, Collections.EMPTY_LIST, null );
} }
private ArtifactResolutionResult collect( ArtifactSpec a, Artifact managedVersion ) private ArtifactResolutionResult collect( ArtifactSpec a, Artifact managedVersion )
@ -750,7 +757,7 @@ private ArtifactResolutionResult collect( ArtifactSpec a, Artifact managedVersio
{ {
Map managedVersions = Collections.singletonMap( managedVersion.getDependencyConflictId(), managedVersion ); Map managedVersions = Collections.singletonMap( managedVersion.getDependencyConflictId(), managedVersion );
return artifactCollector.collect( Collections.singleton( a.artifact ), projectArtifact.artifact, return artifactCollector.collect( Collections.singleton( a.artifact ), projectArtifact.artifact,
managedVersions, null, null, source, null, Collections.EMPTY_LIST ); managedVersions, null, null, source, null, Collections.EMPTY_LIST, null );
} }
private ArtifactSpec createArtifactSpec( String id, String version ) private ArtifactSpec createArtifactSpec( String id, String version )

View File

@ -19,12 +19,12 @@
* under the License. * under the License.
*/ */
import org.easymock.MockControl;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import org.easymock.MockControl;
public class MockManager public class MockManager
{ {

View File

@ -38,15 +38,16 @@
* under the License. * under the License.
*/ */
import junit.framework.Assert;
import org.codehaus.plexus.util.FileUtils;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import junit.framework.Assert;
import org.codehaus.plexus.util.FileUtils;
public class TestFileManager public class TestFileManager
{ {

View File

@ -1,11 +1,5 @@
package org.apache.maven.artifact.transform; package org.apache.maven.artifact.transform;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.TreeSet;
import org.apache.maven.artifact.ArtifactScopeEnum; import org.apache.maven.artifact.ArtifactScopeEnum;
import org.apache.maven.artifact.resolver.metadata.ArtifactMetadata; import org.apache.maven.artifact.resolver.metadata.ArtifactMetadata;
import org.apache.maven.artifact.resolver.metadata.MetadataGraph; import org.apache.maven.artifact.resolver.metadata.MetadataGraph;

View File

@ -1,9 +1,9 @@
package org.apache.maven.artifact.transform; package org.apache.maven.artifact.transform;
import org.codehaus.plexus.PlexusTestCase;
import java.util.List; import java.util.List;
import org.codehaus.plexus.PlexusTestCase;
/** @author Jason van Zyl */ /** @author Jason van Zyl */
public class TransformationManagerTest public class TransformationManagerTest
extends PlexusTestCase extends PlexusTestCase

View File

@ -19,10 +19,10 @@
* under the License. * under the License.
*/ */
import junit.framework.TestCase;
import java.util.List; import java.util.List;
import junit.framework.TestCase;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
/** /**

View File

@ -19,13 +19,9 @@ under the License.
<plexus> <plexus>
<components> <components>
<component>
<role>org.apache.maven.artifact.repository.authentication.AuthenticationInfoProvider</role>
<implementation>org.apache.maven.artifact.repository.authentication.DummyAuthenticationInfoProvider</implementation>
</component>
<component> <component>
<role>org.apache.maven.artifact.metadata.ArtifactMetadataSource</role> <role>org.apache.maven.artifact.metadata.ArtifactMetadataSource</role>
<implementation>org.apache.maven.artifact.deployer.SimpleArtifactMetadataSource</implementation> <implementation>org.apache.maven.artifact.deployer.SimpleArtifactMetadataSource</implementation>
</component> </component>
</components> </components>
</plexus> </plexus>

View File

@ -19,9 +19,5 @@ under the License.
<plexus> <plexus>
<components> <components>
<component>
<role>org.apache.maven.artifact.repository.authentication.AuthenticationInfoProvider</role>
<implementation>org.apache.maven.artifact.repository.authentication.DummyAuthenticationInfoProvider</implementation>
</component>
</components> </components>
</plexus> </plexus>

View File

@ -44,9 +44,5 @@ under the License.
<role-hint>string</role-hint> <role-hint>string</role-hint>
<implementation>org.apache.maven.artifact.manager.StringWagon</implementation> <implementation>org.apache.maven.artifact.manager.StringWagon</implementation>
</component> </component>
<component>
<role>org.apache.maven.artifact.repository.authentication.AuthenticationInfoProvider</role>
<implementation>org.apache.maven.artifact.repository.authentication.DummyAuthenticationInfoProvider</implementation>
</component>
</components> </components>
</plexus> </plexus>

View File

@ -19,9 +19,5 @@ under the License.
<plexus> <plexus>
<components> <components>
<component>
<role>org.apache.maven.artifact.repository.authentication.AuthenticationInfoProvider</role>
<implementation>org.apache.maven.artifact.repository.authentication.DummyAuthenticationInfoProvider</implementation>
</component>
</components> </components>
</plexus> </plexus>

View File

@ -0,0 +1,217 @@
We have a lifecycle mapping for the packaging of *jar* below. You see that for this packaging we have a *default* lifecycle and a list of phases where each phase is a comma separated list of goals to run and they are in the form groupId:artifactId:version.
<configuration>
<lifecycles>
<lifecycle>
<id>default</id>
<phases>
<process-resources>org.apache.maven.plugins:maven-resources-plugin:resources</process-resources>
<compile>org.apache.maven.plugins:maven-compiler-plugin:compile</compile>
<process-test-resources>org.apache.maven.plugins:maven-resources-plugin:testResources</process-test-resources>
<test-compile>org.apache.maven.plugins:maven-compiler-plugin:testCompile</test-compile>
<test>org.apache.maven.plugins:maven-surefire-plugin:test</test>
<package>org.apache.maven.plugins:maven-jar-plugin:jar</package>
<install>org.apache.maven.plugins:maven-install-plugin:install</install>
<deploy>org.apache.maven.plugins:maven-deploy-plugin:deploy</deploy>
</phases>
</lifecycle>
</lifecycles>
</configuration>
We need to turn this list of phases into a set of plugin objects that have an xml representation like the following:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>process</goal>
</goals>
</execution>
</executions>
</plugin>
.
.
.
</plugins>
We need this form so that the model builder can make the first pass at merging. Full merging cannot be done because we don't know what the version of the plugin is yet that the user has requested. For plugins in the default lifecycle they are typically defined in the plugin management section of the parent POM. When the merging is complete we are going to have something that looks like the following:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>1.0</version</version>
<executions>
<execution>
<goals>
<goal>process</goal>
</goals>
</execution>
</executions>
</plugin>
.
.
.
</plugins>
Once we have the version of the plugins the appropriate call to the plugin manager can be made to get the MojoDescriptor for the goal that needs to be run. In the MojoDescriptor we are interested in the <configuration/> element and <parameters/> element. From these elements we need to make a component configuration for the MojoExecution. The actual DOM like structure we create is of type PlexusConfiguration and is the type we use with the ComponentConfigurator to initialize fields in a Plexus component. Typically this is done within Plexus with the configuration supplied with component configuration, but in Maven we take configuration values from the POM. So we have to use the ComponentConfigurator outside of Plexus in order to configurure the Maven Mojo which is just a Plexus component. We can use the information from the MojoDescriptor along with the merged configuration information that is now present in the POM to create the complete PlexusConfiguration used to populate values in the Maven Mojo.
foreach configuration element:
- if read only and being set squawk
- find the parameter
- get value from expression or default
- if required and null squawk
<configuration>
<attached implementation="boolean" default-value="true"/>
<localRepository implementation="org.apache.maven.artifact.repository.ArtifactRepository">${localRepository}</localRepository>
<resources implementation="java.util.List">${project.resources}</resources>
<repositories implementation="java.util.List">${project.repositories}</repositories>
<remoteArtifactRepositories implementation="java.util.List">${project.remoteArtifactRepositories}</remoteArtifactRepositories>
<appendedResourcesDirectory implementation="java.io.File">${basedir}/src/main/appended-resources</appendedResourcesDirectory>
<excludeScope implementation="java.lang.String" default-value="">${excludeScope}</excludeScope>
<includeScope implementation="java.lang.String" default-value="runtime">${includeScope}</includeScope>
<excludeGroupIds implementation="java.lang.String" default-value="">${excludeGroupIds}</excludeGroupIds>
<skip implementation="boolean" default-value="false">${remoteresources.skip}</skip>
<outputDirectory implementation="java.io.File">${project.build.directory}/maven-shared-archive-resources</outputDirectory>
<excludeArtifactIds implementation="java.lang.String" default-value="">${excludeArtifactIds}</excludeArtifactIds>
<excludeTransitive implementation="boolean" default-value="false">${excludeTransitive}</excludeTransitive>
<includeGroupIds implementation="java.lang.String" default-value="">${includeGroupIds}</includeGroupIds>
<mavenSession implementation="org.apache.maven.execution.MavenSession">${session}</mavenSession>
<project implementation="org.apache.maven.project.MavenProject">${project}</project>
<includeArtifactIds implementation="java.lang.String" default-value="">${includeArtifactIds}</includeArtifactIds>
</configuration>
<parameters>
<parameter>
<name>appendedResourcesDirectory</name>
<type>java.io.File</type>
<required>false</required>
<editable>true</editable>
</parameter>
<parameter>
<name>attached</name>
<type>boolean</type>
<required>false</required>
<editable>true</editable>
</parameter>
<parameter>
<name>excludeArtifactIds</name>
<type>java.lang.String</type>
<required>false</required>
<editable>true</editable>
</parameter>
<parameter>
<name>excludeGroupIds</name>
<type>java.lang.String</type>
<required>false</required>
<editable>true</editable>
</parameter>
<parameter>
<name>excludeScope</name>
<type>java.lang.String</type>
<required>false</required>
<editable>true</editable>
</parameter>
<parameter>
<name>excludeTransitive</name>
<type>boolean</type>
<required>false</required>
<editable>true</editable>
</parameter>
<parameter>
<name>includeArtifactIds</name>
<type>java.lang.String</type>
<required>false</required>
<editable>true</editable>
</parameter>
<parameter>
<name>includeGroupIds</name>
<type>java.lang.String</type>
<required>false</required>
<editable>true</editable>
</parameter>
<parameter>
<name>includeScope</name>
<type>java.lang.String</type>
<required>false</required>
<editable>true</editable>
</parameter>
<parameter>
<name>localRepository</name>
<type>org.apache.maven.artifact.repository.ArtifactRepository</type>
<required>true</required>
<editable>false</editable>
</parameter>
<parameter>
<name>mavenSession</name>
<type>org.apache.maven.execution.MavenSession</type>
<required>true</required>
<editable>false</editable>
<description>The Maven session.</description>
</parameter>
<parameter>
<name>outputDirectory</name>
<type>java.io.File</type>
<required>false</required>
<editable>true</editable>
</parameter>
<parameter>
<name>project</name>
<type>org.apache.maven.project.MavenProject</type>
<required>true</required>
<editable>false</editable>
</parameter>
<parameter>
<name>properties</name>
<type>java.util.Map</type>
<required>false</required>
<editable>true</editable>
</parameter>
<parameter>
<name>remoteArtifactRepositories</name>
<type>java.util.List</type>
<required>true</required>
<editable>false</editable>
</parameter>
<parameter>
<name>repositories</name>
<type>java.util.List</type>
<required>true</required>
<editable>false</editable>
</parameter>
<parameter>
<name>resourceBundles</name>
<type>java.util.List</type>
<required>true</required>
<editable>true</editable>
</parameter>
<parameter>
<name>resources</name>
<type>java.util.List</type>
<required>true</required>
<editable>false</editable>
</parameter>
<parameter>
<name>skip</name>
<type>boolean</type>
<required>false</required>
<editable>true</editable>
</parameter>
<parameter>
<name>supplementalModels</name>
<type>java.lang.String[]</type>
<required>false</required>
<editable>true</editable>
</parameter>
</parameters>
- we need to know what came from the POM, and validate those
- plugin in any default values
- check to see if anything is missing
In the case of something like Modello where it is common to specify the configuration for all the goals outside the execution block we need to account for creating the right configuration element which includes only those configuration elements for a particular goal that that particular goal understands. We need to walk through the parameters of the Mojo in question and only take the configuration options that apply.

View File

@ -0,0 +1,185 @@
h3. Plugins
* Execution model
* Metadata model
* Metadata tooling
** Metadata extractor
** Metadata reader
** Metadata writer
** Metadata adapter (if required for the target system)
* Maven packaging and lifecycle
* Maven test harness for plugin execution model
* Eclipse IDE tooling for plugin execution model and metadata model
- we also seem to have information like the plugin lifecycle model that's burried inside the maven execution model
- we also seem to have artifact information tangled inside the plugin model
- we have to deal with scripting implementations (groovy, beanshell, ruby)
- we need to deal with a shared context for plugins, like the guarded mojos
- we need to deal with plugins as core application logic which can also interact with plugins
* Along with this comes the testing strategies that make this work
* The repository model where plugins can be stored and cataloged
* Bridging this into an OSGi system: if this could be done then we can basically take over p2
TODO
- dealing with processing of input and adapting GAVs before searching i.e. plugin groups in Maven and default searching
- how to deal with resolution from different places like local/remote/workspace
- how to incorporate the metadata processor to start with
- create a hook to programmatically configure the test
- create a plugin processor
- directory
- jar
- hooks for loading
- i could make an annotation that marked another class as its plugin discoverer, i could just add it to the
the component descriptor and when it's loaded we can add the discoverer, that would be simpler. i could
also do this with the lister as well
i'l
// 1 the metadata -> model plugin/mojo descriptor
// 2 tools for doing the mapping
// 3 the component model -> interfaces for the plugin
// The plugin manager should load up a directory structure of plugins.
// - a plugin per directory where the plugin is present with its deps
// - a plugin that has its dependencies packaged up with it
// - implement filters and create a test where a plugin fails if the right classes are not filtered
// - plugins with a dependency the same as the core but different versions, make it fail then fix it
/*
*
* h2. Concerns for the plugin manager
*
* h3. resolving the dependencies of a plugin - these could be resolved remotely at runtime or, -
* they could be resolved from a local repository - i think we need a simple dependency model here
* that is more mercury related and not Maven related i.e no POMs - workspace resolver - we need
* tools to pre-populate this repository
*
* h3. create an isolated classloader
*
* h3. lookup the plugin with a configuration
*
* h3. execute the plugin
*
* h3. plugins may have to deal with particular actions when a plugin is - installed - loaded -
* unloaded - update - uninstalled
*
* h3. plugins should be able to have specific metadata for a plugin model and that be translated -
* dependencies - resources - configuration - extension points of plugins
*
* For a particular application plugin there will be a declarative descriptor for that plugin type.
*
* - nexus - the plugin class - UI to contribute - what JS to hook into the UI - what resources to
* load into the UI - having packed or unpacked plugins, and positioning resources if necessary -
* maven can work out of the classloader, nexus plugins probably couldn't given the js and image
* resources
*
* We need to look at Maven, and Nexus as use cases and figure out what each of them needs to be
* able to do
*
* - now what is really the difference between this and loading a component in plexus - custom
* classloading capability - remote resolution of dependencies - do we want a model for sharing
* information among plugins, is this more like an extension point - do we need a sort of bus for
* application data - do we need a dictionary for our applications like Apple does. We could easily
* hook into this and this is the model we need to follow - how many of our REST services do not map
* directory to a method in the application interface?
*
* - research extension points versus plugins
*
* from igor: two plugins A and B, both depend on the same library but use different versions, say
* lib 1.0 and lib 2.0 when debugger hits a breakpoint inside a class from the library, IDE needs to
* know which version of library the class comes from
*/
This document outlines the concerns of a general plugin manager that would be used in conjunction with any Plexus-based application. The following outlined concerns are an attempt to describe what a plugin manager would need to do for Maven and for Nexus.
h2. Concerns for the plugin manager
h3. Resolving the dependencies of a plugin
A plugin manager would need to know how to find the dependencies of a plugin whether that be from a workspace of an IDE, a local Maven repository, or a remote Maven repository. During development in an IDE we would need layered resolution approach that would allow resolution from the workspace, then the local Maven repository and then from any number of remote Maven repositories. During development from the command line we would need a layered resolution approach that would allow resolution from the local Maven repository and then from any number of remote Maven repositories. In production the resolution for the dependencies could also be layered but would depend on the preferred model for the given application. In the case of Maven no plugin dependencies are shipped with a Maven plugin, but in the case of Nexus we would probably want to include the dependencies for self-containment.
h4. Working with POMs during development
During the development of a plugin we would want to make it easy for a developer to create a plugin which means we would allow the direct use of a POM to state the dependencies of a given plugin and any tooling we created would be responsible for turning the dependency information in the POM into plugin metadata which described the dependencies of the plugin.
We are looking at using Mercury for the resolution and retrieval of the plugin dependencies so during development we would translate the POMs into dependency information that Mercury can understand, and in production we would have the pre-digested format that Mercury could utilize to resolve and retrieve dependencies. We need to be careful that we are using Mercury during development and production so that we dont get in the situation where Maven 2.x is resolving different then Mercury is. We can still leverage POMs during development but we need to make sure Mercury is doing the work.
With respect to development inside an IDE the workspace from which we would like to resolve and retrieve dependencies is a read-only local repository to Mercury which is put at the front-end of the search order of any repository that Mercury will consult for artifacts.
h4. Generation of plugin metadata and packaging
To create the packaging for a plugin a special Maven packaging would be created with an accompanying life-cycle in order to create the plugin metadata required and create an archive of the plugin that can be consumed at runtime.
h3. Creation of an isolated classloader
The plugin artifact and its dependency artifacts will be loaded in an isolated ClassRealm which is simply an extension of the standard URLClassLoader. Mercury would be responsible for resolving and retrieving the dependencies which would then be used to populate a ClassRealm where there would be a connection to the host applications ClassRealm as the parent but the search order would be child first, and the parent ClassRealm can optionally choose to limit the searching to particular classes. The application ClassRealm, or parent ClassRealm, should only expose the API in the form of and application interface and model classes that may be required by plugins.
For debugging purposes we also need to keep track of what versions of artifacts are being used so that when we are debugging in the IDE we can find the specific sources for a given version of a library so that the developer can debug the correct version of a library being used for a plugin.
h3. Discovery all Plexus components
Once the ClassRealm is populated with the plugin artifact and its dependency artifacts a discovery operation must be performed on the plugin ClassRealm in order to discover any Plexus components that may be present in any of the artifacts required for the plugins execution.
h3. Looking up the plugin with a configuration
Once the ClassRealm has been populated and all Plexus components have been discovered a lookup can be performed to retrieve the primary plugin component. Currently the component would need to be looked up and then the BasicComponentConfigurator would need to configure the component with a given Plexus configuration. We will discuss later how we would retrieve the Plexus configuration required for a given plugin.
When a plugin has a complete and valid configuration, the plugin would be looked up in the Plexus container and be ready to perform any operations requested of it.
h3. Execution of the plugin
I still need to do some work here to figure out how a dispatching to a particular plugin would occur because everything needs to be mediated through the host application. For a given action that is possible for a user to perform in the UI we need to know the URI that is to be used with its given parameters. That URI in turn must map internally to a method in a given component which belongs to a plugin. This mapping should actually be more generalized and it shouldnt matter internally whether this maps to the core application or extension of the application in the form of plugins.
In the short term we are working with the model where the URI maps to a resource, and the resource itself is a Plexus component which can itself have a reference to the host application in order to perform its work. This may not occur in the first versions of the plugin API but a resource needs to simply become the mapping mechanism by which parameters are taken from the REST side of the application and mapped into a method call within a given Plexus component. Whether that be the core Nexus application or a component provided by a plugin.
At the very least in the short term the resource needs to know how to lookup the component that is required to perform the work. This needs to be made simple, for the time being we can write and test plugins working in the same realm until we get complete isolation working.
h3. Plugins need a specific metadata model
Each application will have its own model for plugins. Much of this model will be common across applications but there will always be issues specific to a particular applicationss plugins. Some of the issues that need to be taken into consideration:
* Plugin dependencies
* Plugin resources like Javascript files or images
* Configuration metadata and default configuration values
* Extension points that plugins might expose
h3. The plugin manager may have to deal with particular actions when a plugin is
* installation
* activation
* update
* deactivation
* un-installation
When a plugin is installed we may want to check the license and make users agree. We may also want to unpack the given plugin in a particular location.
We might want to separate between installation and activation, it might be nice to allow a user to activate/deactivate a plugin instead of having to uninstall and reinstall a plugin in particular cases. This would prevent having to reconfigure the plugin again. For example it might be nice to turn off LDAP authentication without having to uninstall the plugin.
These particular phases in a plugins lifecycle can probably be generalized to all plugins so could be something implemented in all plugins. Here we could have the descriptor either point to methods for each of these phases to execute or we could create a lifecycle in Plexus for these phases.
For a particular application plugin there will be a declarative descriptor for that plugin type.
h3. Some general notes on Nexus
The plugin metadata:
* the plugin class
* UI to contribute
* what JS to hook into the UI
* what resources to load into the UI
* having packed or unpacked plugins, and positioning resources if necessary
* maven can work out of the classloader, nexus plugins probably couldn't given the js and image resources
h3. Other issues
We need to look at Maven, and Nexus as use cases and figure out what each of them needs to be able to do
* now what is really the difference between this and loading a component in plexus
* do we want a model for sharing information among plugins, is this more like an extension point
* do we need a sort of bus for application data
* do we need a dictionary for our applications like Apple does. We could easily hook into this and this is the model we need to follow. Following the model of apple applications the dictionary is what the REST URI should attach to. Not creating custom logic in the resource code.
* how many of our REST services do not map directory to a method in the application interface?
- an example of adding js
- an example of adding a URI

View File

@ -21,42 +21,38 @@
<artifactId>maven-core</artifactId> <artifactId>maven-core</artifactId>
<name>Maven Core</name> <name>Maven Core</name>
<dependencies> <dependencies>
<!-- Maven -->
<dependency> <dependency>
<groupId>org.apache.maven</groupId> <groupId>org.apache.maven</groupId>
<artifactId>maven-lifecycle</artifactId> <artifactId>maven-model</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-reporting-api</artifactId>
</dependency>
<!-- Required for Maven Artifact mediator as we phase it out. -->
<dependency> <dependency>
<groupId>org.apache.maven</groupId> <groupId>org.apache.maven</groupId>
<artifactId>maven-compat</artifactId> <artifactId>maven-compat</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.maven</groupId> <groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId> <artifactId>maven-repository</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-container-default</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.apache.maven</groupId> <groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId> <artifactId>maven-plugin-api</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.maven</groupId> <groupId>org.apache.maven</groupId>
<artifactId>maven-model-builder</artifactId> <artifactId>maven-model-builder</artifactId>
</dependency> </dependency>
<!--
<dependency> <dependency>
<groupId>commons-cli</groupId> <groupId>org.apache.maven</groupId>
<artifactId>commons-cli</artifactId> <artifactId>maven-toolchain</artifactId>
<scope>test</scope>
</dependency> </dependency>
-->
<!-- Plexus -->
<dependency> <dependency>
<groupId>org.codehaus.plexus</groupId> <groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-interactivity-api</artifactId> <artifactId>plexus-container-default</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.codehaus.plexus</groupId> <groupId>org.codehaus.plexus</groupId>
@ -70,22 +66,6 @@
<groupId>org.codehaus.plexus</groupId> <groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-classworlds</artifactId> <artifactId>plexus-classworlds</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-file</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>easymock</groupId>
<artifactId>easymock</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-test-tools</artifactId>
<version>1.0-alpha-1</version>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>org.codehaus.plexus</groupId> <groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-annotations</artifactId> <artifactId>plexus-component-annotations</artifactId>
@ -118,13 +98,14 @@
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<configuration> <configuration>
<excludes> <excludes>
<exclude>**/testutils/**</exclude> <exclude>**/ProjectClasspathTest.java</exclude>
</excludes> </excludes>
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
</project> </project>

View File

@ -0,0 +1 @@
Maven Project Builder and Maven Model Builder

View File

@ -1,50 +0,0 @@
package org.apache.maven;
import org.apache.maven.lifecycle.MojoBindingUtils;
import org.apache.maven.lifecycle.model.MojoBinding;
import org.apache.maven.plugin.MojoFailureException;
/**
* Exception which occurs when an @aggregator plugin fails to execute. This
* exception is meant to wrap a {@link MojoFailureException}, and provide
* additional details about the mojo that failed, via {@link MojoBinding} and
* the root directory in which the build executes.
*
* @author jdcasey
*
*/
public class AggregatedBuildFailureException
extends BuildFailureException
{
private final String executionRootDirectory;
private final MojoBinding binding;
public AggregatedBuildFailureException( String executionRootDirectory,
MojoBinding binding,
MojoFailureException cause )
{
super( "Build in root directory: " + executionRootDirectory
+ " failed during execution of aggregator mojo: "
+ MojoBindingUtils.toString( binding ), cause );
this.executionRootDirectory = executionRootDirectory;
this.binding = binding;
}
public MojoFailureException getMojoFailureException()
{
return (MojoFailureException) getCause();
}
public String getExecutionRootDirectory()
{
return executionRootDirectory;
}
public MojoBinding getBinding()
{
return binding;
}
}

View File

@ -26,15 +26,15 @@
* @author <a href="mailto:brett@apache.org">Brett Porter</a> * @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id$ * @version $Id$
*/ */
public abstract class BuildFailureException public class BuildFailureException
extends Exception extends Exception
{ {
protected BuildFailureException( String message ) public BuildFailureException( String message )
{ {
super( message ); super( message );
} }
protected BuildFailureException( String message, Throwable cause ) public BuildFailureException( String message, Throwable cause )
{ {
super( message, cause ); super( message, cause );
} }

View File

@ -19,13 +19,13 @@
* under the License. * under the License.
*/ */
import java.util.HashSet;
import java.util.Set;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.resolver.filter.ExclusionSetFilter; import org.apache.maven.artifact.resolver.filter.ExclusionSetFilter;
import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Component;
import java.util.HashSet;
import java.util.Set;
/** /**
* @author Jason van Zyl * @author Jason van Zyl
* @version $Id$ * @version $Id$
@ -36,7 +36,7 @@ public class DefaultArtifactFilterManager
implements ArtifactFilterManager implements ArtifactFilterManager
{ {
private static final Set DEFAULT_EXCLUSIONS; private static final Set<String> DEFAULT_EXCLUSIONS;
static static
{ {
@ -59,17 +59,15 @@ public class DefaultArtifactFilterManager
artifacts.add( "maven-plugin-api" ); artifacts.add( "maven-plugin-api" );
artifacts.add( "maven-plugin-descriptor" ); artifacts.add( "maven-plugin-descriptor" );
artifacts.add( "maven-plugin-parameter-documenter" ); artifacts.add( "maven-plugin-parameter-documenter" );
artifacts.add( "maven-plugin-registry" );
artifacts.add( "maven-profile" ); artifacts.add( "maven-profile" );
artifacts.add( "maven-project" ); artifacts.add( "maven-project" );
artifacts.add( "maven-reporting-api" );
artifacts.add( "maven-repository-metadata" ); artifacts.add( "maven-repository-metadata" );
artifacts.add( "maven-settings" ); artifacts.add( "maven-settings" );
//adding shared/maven-toolchain project here, even though not part of the default
//distro yet.
artifacts.add( "maven-toolchain" );
artifacts.add( "plexus-component-api" ); artifacts.add( "plexus-component-api" );
artifacts.add( "plexus-container-default" ); artifacts.add( "plexus-container-default" );
artifacts.add( "plexus-interactivity-api" ); artifacts.add( "plexus-interactivity-api" );
//artifacts.add( "plexus-interpolation" );
artifacts.add( "wagon-provider-api" ); artifacts.add( "wagon-provider-api" );
artifacts.add( "wagon-file" ); artifacts.add( "wagon-file" );
artifacts.add( "wagon-http-lightweight" ); artifacts.add( "wagon-http-lightweight" );
@ -80,7 +78,7 @@ public class DefaultArtifactFilterManager
DEFAULT_EXCLUSIONS = artifacts; DEFAULT_EXCLUSIONS = artifacts;
} }
protected Set excludedArtifacts = new HashSet( DEFAULT_EXCLUSIONS ); protected Set<String> excludedArtifacts = new HashSet<String>( DEFAULT_EXCLUSIONS );
/** /**
* @deprecated Use this class as a component instead, and then use getArtifactFilter(). * @deprecated Use this class as a component instead, and then use getArtifactFilter().

Some files were not shown because too many files have changed in this diff Show More