mirror of https://github.com/apache/maven.git
CHANGES
------------------------ o Factored the layout for a repository into a separate set of components in o.a.m.a.repository.layout o Added new DefaultRepositoryLayout that uses the repo layout in http://docs.codehaus.org/pages/viewpage.action?pageId=22230 (it is not used by default until we get the repo1 conversion done) o Added command-line switches to force legacy local-repo or new format (-a/-A, I know, but try to find something that makes more sense!) o Added path formatting to the repository itself, which is now constructed with a ArtifactRepositoryLayout instance (since layout should be tied to the repository) o Removed path formatting altogether from the DefaultArtifactHandlerManager. o Changed the AbstractArtifactBasedComponent (or whatever it's called) to use the repository formatting in the path() and localPath() methods. o Moved the plugin repo construction (still intact as a hard-coded singleton list) into the DefaultMavenProjectBuilder, where it will eventually build from POM info. o Added a new method to build an artifact repository for a <distributionManagement/> section, if possible. This reduced the strain on mojos to construct an ArtifactRepository on demand. o Refactored all *DeployMojo to use #project.distributionManagementArtifactRepository instead of the #settings, #component..ArtifactRepositoryFactory, ... that it used to require. This is a big simplifying step. o Removed remote artifact repository construction from DefaultMaven, and changed the MavenSession to delegate to MavenProject for remoteArtifactRepositories, just as it does for pluginRepositories. o Added remoteArtifactRepositories, pluginArtifactRepositories, distributionManagementArtifactRepository to MavenProject as a cache for the higher-level repos used throughout the system. This is project info, so it belongs here. o Fixed all the tests in maven-core and maven-artifact which I broke. :) o Dropped what is probably a big format-bomb, since the Eclipse formatter doesn't really handle 'throws Exception' wrapping the right way. o Added MavenProject to the MavenSession constructor, since there should always be a MavenProject associated with a build, even if it's just the super-pom. TODO: -------------------------- - Write an integration/unit test to ensure that the new repo format works with $classifier (was: $extra) and $groupId[0]/../$groupId[n]. This is a simple adaptation of the old layout, but still needs testing. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163638 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e1f51a9ad4
commit
590e952f02
|
@ -20,6 +20,7 @@ import org.apache.maven.artifact.handler.ArtifactHandler;
|
||||||
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
|
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
|
||||||
import org.apache.maven.artifact.handler.manager.ArtifactHandlerNotFoundException;
|
import org.apache.maven.artifact.handler.manager.ArtifactHandlerNotFoundException;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
|
||||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,15 +39,21 @@ public class AbstractArtifactComponent
|
||||||
return artifactHandlerManager.getArtifactHandler( type );
|
return artifactHandlerManager.getArtifactHandler( type );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String path( Artifact artifact ) throws ArtifactHandlerNotFoundException
|
protected String path( Artifact artifact, ArtifactRepository remoteRepository ) throws ArtifactPathFormatException
|
||||||
{
|
{
|
||||||
return artifactHandlerManager.path( artifact );
|
return remoteRepository.pathOf( artifact );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String localPath( Artifact artifact, ArtifactRepository localRepository )
|
||||||
|
throws ArtifactPathFormatException
|
||||||
|
{
|
||||||
|
return localRepository.getBasedir() + "/" + localRepository.pathOf( artifact );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setLocalRepositoryPath( Artifact artifact, ArtifactRepository localRepository )
|
protected void setLocalRepositoryPath( Artifact artifact, ArtifactRepository localRepository )
|
||||||
throws ArtifactHandlerNotFoundException
|
throws ArtifactPathFormatException
|
||||||
{
|
{
|
||||||
String artifactPath = artifactHandlerManager.localRepositoryPath( artifact, localRepository );
|
String artifactPath = localPath( artifact, localRepository );
|
||||||
|
|
||||||
artifact.setPath( artifactPath );
|
artifact.setPath( artifactPath );
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,9 @@ public interface Artifact
|
||||||
{
|
{
|
||||||
// TODO: into scope handler
|
// TODO: into scope handler
|
||||||
String SCOPE_COMPILE = "compile";
|
String SCOPE_COMPILE = "compile";
|
||||||
|
|
||||||
String SCOPE_TEST = "test";
|
String SCOPE_TEST = "test";
|
||||||
|
|
||||||
String SCOPE_RUNTIME = "runtime";
|
String SCOPE_RUNTIME = "runtime";
|
||||||
|
|
||||||
String getGroupId();
|
String getGroupId();
|
||||||
|
@ -35,6 +37,11 @@ public interface Artifact
|
||||||
|
|
||||||
String getType();
|
String getType();
|
||||||
|
|
||||||
|
String getClassifier();
|
||||||
|
|
||||||
|
// only providing this since classifier is *very* optional...
|
||||||
|
boolean hasClassifier();
|
||||||
|
|
||||||
String getExtension();
|
String getExtension();
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
|
@ -16,6 +16,8 @@ package org.apache.maven.artifact;
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import org.codehaus.plexus.util.StringUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,6 +40,8 @@ public class DefaultArtifact
|
||||||
|
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
|
private String classifier;
|
||||||
|
|
||||||
private String scope;
|
private String scope;
|
||||||
|
|
||||||
private String extension;
|
private String extension;
|
||||||
|
@ -47,11 +51,22 @@ public class DefaultArtifact
|
||||||
/**
|
/**
|
||||||
* @todo this should be replaced by type handler
|
* @todo this should be replaced by type handler
|
||||||
*/
|
*/
|
||||||
public DefaultArtifact( String groupId, String artifactId, String version, String scope, String type, String extension )
|
public DefaultArtifact( String groupId, String artifactId, String version, String scope, String type,
|
||||||
|
String extension )
|
||||||
{
|
{
|
||||||
if(type == null)
|
this( groupId, artifactId, version, scope, type, null, extension );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* !!! WARNING !!! Never put <classifier/> in the POM. It is for mojo use
|
||||||
|
* only. Classifier is for specifying derived artifacts, like ejb-client.
|
||||||
|
*/
|
||||||
|
public DefaultArtifact( String groupId, String artifactId, String version, String scope, String type,
|
||||||
|
String classifier, String extension )
|
||||||
{
|
{
|
||||||
throw new NullPointerException("Artifact type cannot be null.");
|
if ( type == null )
|
||||||
|
{
|
||||||
|
throw new NullPointerException( "Artifact type cannot be null." );
|
||||||
}
|
}
|
||||||
|
|
||||||
this.groupId = groupId;
|
this.groupId = groupId;
|
||||||
|
@ -64,12 +79,24 @@ public class DefaultArtifact
|
||||||
|
|
||||||
this.scope = scope;
|
this.scope = scope;
|
||||||
|
|
||||||
|
this.classifier = classifier;
|
||||||
|
|
||||||
this.extension = extension;
|
this.extension = extension;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DefaultArtifact( String groupId, String artifactId, String version, String type )
|
public DefaultArtifact( String groupId, String artifactId, String version, String type )
|
||||||
{
|
{
|
||||||
this( groupId, artifactId, version, null, type, type );
|
this( groupId, artifactId, version, null, type, null, type );
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getClassifier()
|
||||||
|
{
|
||||||
|
return classifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasClassifier()
|
||||||
|
{
|
||||||
|
return StringUtils.isNotEmpty( classifier );
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getScope()
|
public String getScope()
|
||||||
|
@ -142,12 +169,13 @@ public class DefaultArtifact
|
||||||
|
|
||||||
public String getId()
|
public String getId()
|
||||||
{
|
{
|
||||||
return getGroupId() + ":" + getArtifactId() + ":" + getType() + ":" + getVersion();
|
return getConflictId() + ":" + getVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getConflictId()
|
public String getConflictId()
|
||||||
{
|
{
|
||||||
return getGroupId() + ":" + getArtifactId() + ":" + getType();
|
return getGroupId() + ":" + getArtifactId() + ":" + getType()
|
||||||
|
+ ( hasClassifier() ? ( ":" + getClassifier() ) : "" );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
@ -168,7 +196,6 @@ public class DefaultArtifact
|
||||||
{
|
{
|
||||||
Artifact other = (Artifact) o;
|
Artifact other = (Artifact) o;
|
||||||
|
|
||||||
return this.groupId.equals( other.getGroupId() ) && this.artifactId.equals( other.getArtifactId() ) && this.version.equals(
|
return getId().equals( other.getId() );
|
||||||
other.getVersion() ) && this.type.equals( other.getType() );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,8 +1,6 @@
|
||||||
package org.apache.maven.artifact.handler.manager;
|
package org.apache.maven.artifact.handler.manager;
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
|
||||||
import org.apache.maven.artifact.handler.ArtifactHandler;
|
import org.apache.maven.artifact.handler.ArtifactHandler;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@ -30,14 +28,13 @@ public interface ArtifactHandlerManager
|
||||||
{
|
{
|
||||||
String ROLE = ArtifactHandlerManager.class.getName();
|
String ROLE = ArtifactHandlerManager.class.getName();
|
||||||
|
|
||||||
ArtifactHandler getArtifactHandler( String type )
|
ArtifactHandler getArtifactHandler( String type ) throws ArtifactHandlerNotFoundException;
|
||||||
throws ArtifactHandlerNotFoundException;
|
|
||||||
|
|
||||||
String localRepositoryPath( Artifact artifact, ArtifactRepository localRepository )
|
// String localRepositoryPath( Artifact artifact, ArtifactRepository localRepository )
|
||||||
throws ArtifactHandlerNotFoundException;
|
// throws ArtifactHandlerNotFoundException;
|
||||||
|
//
|
||||||
String path( Artifact artifact )
|
// String path( Artifact artifact )
|
||||||
throws ArtifactHandlerNotFoundException;
|
// throws ArtifactHandlerNotFoundException;
|
||||||
|
|
||||||
Set getHandlerTypes();
|
Set getHandlerTypes();
|
||||||
|
|
||||||
|
|
|
@ -16,10 +16,8 @@ package org.apache.maven.artifact.handler.manager;
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
|
||||||
import org.apache.maven.artifact.handler.ArtifactHandler;
|
import org.apache.maven.artifact.handler.ArtifactHandler;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||||
import org.codehaus.plexus.util.StringUtils;
|
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -34,8 +32,9 @@ public class DefaultArtifactHandlerManager
|
||||||
{
|
{
|
||||||
private Map artifactHandlers;
|
private Map artifactHandlers;
|
||||||
|
|
||||||
public ArtifactHandler getArtifactHandler( String type )
|
private ArtifactRepositoryLayout artifactRepositoryLayout;
|
||||||
throws ArtifactHandlerNotFoundException
|
|
||||||
|
public ArtifactHandler getArtifactHandler( String type ) throws ArtifactHandlerNotFoundException
|
||||||
{
|
{
|
||||||
ArtifactHandler handler = (ArtifactHandler) artifactHandlers.get( type );
|
ArtifactHandler handler = (ArtifactHandler) artifactHandlers.get( type );
|
||||||
|
|
||||||
|
@ -56,58 +55,29 @@ public class DefaultArtifactHandlerManager
|
||||||
//
|
//
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
private String layout;
|
// public String localRepositoryPath( Artifact artifact, ArtifactRepository localRepository )
|
||||||
|
// throws ArtifactHandlerNotFoundException
|
||||||
|
// {
|
||||||
|
// return localRepository.getBasedir() + "/" + path( artifact );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public String artifactUrl( Artifact artifact, ArtifactRepository remoteRepository )
|
||||||
|
// throws ArtifactHandlerNotFoundException
|
||||||
|
// {
|
||||||
|
// return remoteRepository.getUrl() + "/" + path( artifact );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public String path( Artifact artifact )
|
||||||
|
// throws ArtifactHandlerNotFoundException
|
||||||
|
// {
|
||||||
|
// if ( artifact.getType() == null )
|
||||||
|
// {
|
||||||
|
// throw new ArtifactHandlerNotFoundException( "Artifact handler is null for artifact " + artifact );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// ArtifactHandler handler = getArtifactHandler( artifact.getType() );
|
||||||
|
//
|
||||||
|
// return artifactRepositoryLayout.pathOf( artifact, handler );
|
||||||
|
// }
|
||||||
|
|
||||||
public String getLayout()
|
|
||||||
{
|
|
||||||
if ( layout == null )
|
|
||||||
{
|
|
||||||
return "${groupId}/${directory}/${artifactId}-${version}.${extension}";
|
|
||||||
}
|
|
||||||
|
|
||||||
return layout;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String localRepositoryPath( Artifact artifact, ArtifactRepository localRepository )
|
|
||||||
throws ArtifactHandlerNotFoundException
|
|
||||||
{
|
|
||||||
return localRepository.getBasedir() + "/" + path( artifact );
|
|
||||||
}
|
|
||||||
|
|
||||||
public String artifactUrl( Artifact artifact, ArtifactRepository remoteRepository )
|
|
||||||
throws ArtifactHandlerNotFoundException
|
|
||||||
{
|
|
||||||
return remoteRepository.getUrl() + "/" + path( artifact );
|
|
||||||
}
|
|
||||||
|
|
||||||
public String path( Artifact artifact )
|
|
||||||
throws ArtifactHandlerNotFoundException
|
|
||||||
{
|
|
||||||
if ( artifact.getType() == null )
|
|
||||||
{
|
|
||||||
throw new ArtifactHandlerNotFoundException( "Artifact handler is null for artifact " + artifact );
|
|
||||||
}
|
|
||||||
|
|
||||||
ArtifactHandler handler = getArtifactHandler( artifact.getType() );
|
|
||||||
|
|
||||||
return interpolateLayout( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), handler.directory(), handler.extension() );
|
|
||||||
}
|
|
||||||
|
|
||||||
private String interpolateLayout( String groupId, String artifactId, String version, String directory,
|
|
||||||
String extension )
|
|
||||||
{
|
|
||||||
String layout = getLayout();
|
|
||||||
|
|
||||||
layout = StringUtils.replace( layout, "${groupId}", groupId );
|
|
||||||
|
|
||||||
layout = StringUtils.replace( layout, "${artifactId}", artifactId );
|
|
||||||
|
|
||||||
layout = StringUtils.replace( layout, "${directory}", directory );
|
|
||||||
|
|
||||||
layout = StringUtils.replace( layout, "${version}", version );
|
|
||||||
|
|
||||||
layout = StringUtils.replace( layout, "${extension}", extension );
|
|
||||||
|
|
||||||
return layout;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -20,6 +20,7 @@ import org.apache.maven.artifact.AbstractArtifactComponent;
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.handler.manager.ArtifactHandlerNotFoundException;
|
import org.apache.maven.artifact.handler.manager.ArtifactHandlerNotFoundException;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
|
||||||
import org.codehaus.plexus.util.FileUtils;
|
import org.codehaus.plexus.util.FileUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -69,7 +70,7 @@ public class DefaultArtifactInstaller
|
||||||
{
|
{
|
||||||
throw new ArtifactInstallationException( "Error installing artifact: ", e );
|
throw new ArtifactInstallationException( "Error installing artifact: ", e );
|
||||||
}
|
}
|
||||||
catch ( ArtifactHandlerNotFoundException e )
|
catch ( ArtifactPathFormatException e )
|
||||||
{
|
{
|
||||||
throw new ArtifactInstallationException( "Error installing artifact: ", e );
|
throw new ArtifactInstallationException( "Error installing artifact: ", e );
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ public class DefaultWagonManager
|
||||||
|
|
||||||
wagon.connect( repository, getProxy( repository.getProtocol() ) );
|
wagon.connect( repository, getProxy( repository.getProtocol() ) );
|
||||||
|
|
||||||
wagon.put( source, path( artifact ) );
|
wagon.put( source, path( artifact, repository ) );
|
||||||
|
|
||||||
wagon.disconnect();
|
wagon.disconnect();
|
||||||
|
|
||||||
|
@ -148,7 +148,9 @@ public class DefaultWagonManager
|
||||||
|
|
||||||
wagon.connect( repository, getProxy( repository.getProtocol() ) );
|
wagon.connect( repository, getProxy( repository.getProtocol() ) );
|
||||||
|
|
||||||
wagon.get( path( artifact ), temp );
|
String remotePath = path( artifact, repository );
|
||||||
|
|
||||||
|
wagon.get( remotePath, temp );
|
||||||
|
|
||||||
// TODO [BP]: put all disconnects in finally
|
// TODO [BP]: put all disconnects in finally
|
||||||
wagon.disconnect();
|
wagon.disconnect();
|
||||||
|
|
|
@ -16,6 +16,9 @@ package org.apache.maven.artifact.repository;
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import org.apache.maven.artifact.Artifact;
|
||||||
|
import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
|
||||||
|
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||||
import org.apache.maven.wagon.authentication.AuthenticationInfo;
|
import org.apache.maven.wagon.authentication.AuthenticationInfo;
|
||||||
import org.apache.maven.wagon.repository.Repository;
|
import org.apache.maven.wagon.repository.Repository;
|
||||||
|
|
||||||
|
@ -30,13 +33,25 @@ public class ArtifactRepository
|
||||||
extends Repository
|
extends Repository
|
||||||
{
|
{
|
||||||
|
|
||||||
public ArtifactRepository( String id, String url )
|
private final ArtifactRepositoryLayout layout;
|
||||||
|
|
||||||
|
public ArtifactRepository( String id, String url, ArtifactRepositoryLayout layout )
|
||||||
{
|
{
|
||||||
super( id, url );
|
super( id, url );
|
||||||
|
|
||||||
|
this.layout = layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArtifactRepository( String id, String url, AuthenticationInfo authInfo )
|
public ArtifactRepository( String id, String url, AuthenticationInfo authInfo, ArtifactRepositoryLayout layout )
|
||||||
{
|
{
|
||||||
super( id, url, authInfo );
|
super( id, url, authInfo );
|
||||||
|
|
||||||
|
this.layout = layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String pathOf( Artifact artifact ) throws ArtifactPathFormatException
|
||||||
|
{
|
||||||
|
return layout.pathOf( artifact );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,78 @@
|
||||||
|
package org.apache.maven.artifact.repository.layout;
|
||||||
|
|
||||||
|
import org.apache.maven.artifact.Artifact;
|
||||||
|
import org.apache.maven.artifact.handler.ArtifactHandler;
|
||||||
|
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
|
||||||
|
import org.apache.maven.artifact.handler.manager.ArtifactHandlerNotFoundException;
|
||||||
|
import org.codehaus.plexus.util.StringUtils;
|
||||||
|
|
||||||
|
/* ====================================================================
|
||||||
|
* Copyright 2001-2004 The Apache Software Foundation.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jdcasey
|
||||||
|
*/
|
||||||
|
public abstract class AbstractArtifactRepositoryLayout
|
||||||
|
implements ArtifactRepositoryLayout
|
||||||
|
{
|
||||||
|
|
||||||
|
private ArtifactHandlerManager artifactHandlerManager;
|
||||||
|
|
||||||
|
protected abstract String layoutPattern();
|
||||||
|
|
||||||
|
protected abstract String groupIdAsPath( String groupId );
|
||||||
|
|
||||||
|
public String pathOf( Artifact artifact ) throws ArtifactPathFormatException
|
||||||
|
{
|
||||||
|
String path = layoutPattern();
|
||||||
|
|
||||||
|
String groupPath = groupIdAsPath( artifact.getGroupId() );
|
||||||
|
|
||||||
|
path = StringUtils.replace( path, "${groupPath}", groupPath );
|
||||||
|
|
||||||
|
path = StringUtils.replace( path, "${artifactId}", artifact.getArtifactId() );
|
||||||
|
|
||||||
|
path = StringUtils.replace( path, "${version}", artifact.getVersion() );
|
||||||
|
|
||||||
|
if ( artifact.hasClassifier() )
|
||||||
|
{
|
||||||
|
path = StringUtils.replace( path, "${classifier}", artifact.getClassifier() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
path = StringUtils.replace( path, "-${classifier}", "" );
|
||||||
|
}
|
||||||
|
|
||||||
|
ArtifactHandler artifactHandler = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
artifactHandler = artifactHandlerManager.getArtifactHandler( artifact.getType() );
|
||||||
|
}
|
||||||
|
catch ( ArtifactHandlerNotFoundException e )
|
||||||
|
{
|
||||||
|
throw new ArtifactPathFormatException( "Cannot find ArtifactHandler for artifact: \'" + artifact.getId()
|
||||||
|
+ "\'.", e );
|
||||||
|
}
|
||||||
|
|
||||||
|
path = StringUtils.replace( path, "${directory}", artifactHandler.directory() );
|
||||||
|
|
||||||
|
path = StringUtils.replace( path, "${extension}", artifact.getExtension() );
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package org.apache.maven.artifact.repository.layout;
|
||||||
|
|
||||||
|
/* ====================================================================
|
||||||
|
* Copyright 2001-2004 The Apache Software Foundation.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jdcasey
|
||||||
|
*/
|
||||||
|
public class ArtifactPathFormatException
|
||||||
|
extends Exception
|
||||||
|
{
|
||||||
|
|
||||||
|
public ArtifactPathFormatException( String message, Throwable cause )
|
||||||
|
{
|
||||||
|
super( message, cause );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package org.apache.maven.artifact.repository.layout;
|
||||||
|
|
||||||
|
/* ====================================================================
|
||||||
|
* Copyright 2001-2004 The Apache Software Foundation.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
import org.apache.maven.artifact.Artifact;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jdcasey
|
||||||
|
*/
|
||||||
|
public interface ArtifactRepositoryLayout
|
||||||
|
{
|
||||||
|
|
||||||
|
String ROLE = ArtifactRepositoryLayout.class.getName();
|
||||||
|
|
||||||
|
String pathOf( Artifact artifact ) throws ArtifactPathFormatException;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
package org.apache.maven.artifact.repository.layout;
|
||||||
|
|
||||||
|
/* ====================================================================
|
||||||
|
* Copyright 2001-2004 The Apache Software Foundation.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jdcasey
|
||||||
|
*/
|
||||||
|
public class DefaultRepositoryLayout
|
||||||
|
extends AbstractArtifactRepositoryLayout
|
||||||
|
{
|
||||||
|
|
||||||
|
protected String layoutPattern()
|
||||||
|
{
|
||||||
|
return "${groupId}/${artifactId}/${version}/${artifactId}-${version}-${classifier}.${extension}";
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String groupIdAsPath( String groupId )
|
||||||
|
{
|
||||||
|
return groupId.replace( '.', '/' );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
package org.apache.maven.artifact.repository.layout;
|
||||||
|
|
||||||
|
/* ====================================================================
|
||||||
|
* Copyright 2001-2004 The Apache Software Foundation.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jdcasey
|
||||||
|
*/
|
||||||
|
public class LegacyRepositoryLayout
|
||||||
|
extends AbstractArtifactRepositoryLayout
|
||||||
|
{
|
||||||
|
|
||||||
|
protected String layoutPattern()
|
||||||
|
{
|
||||||
|
return "${groupPath}/${directory}/${artifactId}-${version}-${classifier}.${extension}";
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String groupIdAsPath( String groupId )
|
||||||
|
{
|
||||||
|
return groupId;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -3,11 +3,11 @@ package org.apache.maven.artifact.resolver;
|
||||||
import org.apache.maven.artifact.AbstractArtifactComponent;
|
import org.apache.maven.artifact.AbstractArtifactComponent;
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.construction.ArtifactConstructionSupport;
|
import org.apache.maven.artifact.construction.ArtifactConstructionSupport;
|
||||||
import org.apache.maven.artifact.handler.manager.ArtifactHandlerNotFoundException;
|
|
||||||
import org.apache.maven.artifact.manager.WagonManager;
|
import org.apache.maven.artifact.manager.WagonManager;
|
||||||
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.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
|
||||||
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
|
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
|
||||||
import org.apache.maven.artifact.resolver.transform.ArtifactRequestTransformation;
|
import org.apache.maven.artifact.resolver.transform.ArtifactRequestTransformation;
|
||||||
import org.apache.maven.wagon.TransferFailedException;
|
import org.apache.maven.wagon.TransferFailedException;
|
||||||
|
@ -65,8 +65,8 @@ public class DefaultArtifactResolver
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Logger logger = getLogger();
|
Logger logger = getLogger();
|
||||||
logger.debug( "Resolving: " + artifact.getId() + " from:\n" + "{localRepository: " + localRepository +
|
logger.debug( "Resolving: " + artifact.getId() + " from:\n" + "{localRepository: " + localRepository
|
||||||
"}\n" + "{remoteRepositories: " + remoteRepositories + "}" );
|
+ "}\n" + "{remoteRepositories: " + remoteRepositories + "}" );
|
||||||
|
|
||||||
setLocalRepositoryPath( artifact, localRepository );
|
setLocalRepositoryPath( artifact, localRepository );
|
||||||
|
|
||||||
|
@ -77,14 +77,14 @@ public class DefaultArtifactResolver
|
||||||
|
|
||||||
wagonManager.get( artifact, remoteRepositories, localRepository );
|
wagonManager.get( artifact, remoteRepositories, localRepository );
|
||||||
}
|
}
|
||||||
catch ( ArtifactHandlerNotFoundException e )
|
|
||||||
{
|
|
||||||
throw new ArtifactResolutionException( "Error resolving artifact: ", e );
|
|
||||||
}
|
|
||||||
catch ( TransferFailedException e )
|
catch ( TransferFailedException e )
|
||||||
{
|
{
|
||||||
throw new ArtifactResolutionException( artifactNotFound( artifact, remoteRepositories ), e );
|
throw new ArtifactResolutionException( artifactNotFound( artifact, remoteRepositories ), e );
|
||||||
}
|
}
|
||||||
|
catch ( ArtifactPathFormatException e )
|
||||||
|
{
|
||||||
|
throw new ArtifactResolutionException( "Error resolving artifact: ", e );
|
||||||
|
}
|
||||||
|
|
||||||
return artifact;
|
return artifact;
|
||||||
}
|
}
|
||||||
|
@ -95,8 +95,9 @@ public class DefaultArtifactResolver
|
||||||
{
|
{
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuffer sb = new StringBuffer();
|
||||||
|
|
||||||
sb.append( "The artifact is not present locally as:" ).append( LS ).append( LS ).append( artifact.getPath() ).append(
|
sb.append( "The artifact is not present locally as:" ).append( LS ).append( LS ).append( artifact.getPath() )
|
||||||
LS ).append( LS ).append( "or in any of the specified remote repositories:" ).append( LS ).append( LS );
|
.append( LS ).append( LS ).append( "or in any of the specified remote repositories:" ).append( LS )
|
||||||
|
.append( LS );
|
||||||
|
|
||||||
for ( Iterator i = remoteRepositories.iterator(); i.hasNext(); )
|
for ( Iterator i = remoteRepositories.iterator(); i.hasNext(); )
|
||||||
{
|
{
|
||||||
|
@ -179,8 +180,7 @@ public class DefaultArtifactResolver
|
||||||
|
|
||||||
private ArtifactResolutionResult collect( Set artifacts, ArtifactRepository localRepository,
|
private ArtifactResolutionResult collect( Set artifacts, ArtifactRepository localRepository,
|
||||||
List remoteRepositories, ArtifactMetadataSource source,
|
List remoteRepositories, ArtifactMetadataSource source,
|
||||||
ArtifactFilter filter )
|
ArtifactFilter filter ) throws TransitiveArtifactResolutionException
|
||||||
throws TransitiveArtifactResolutionException
|
|
||||||
{
|
{
|
||||||
ArtifactResolutionResult result = new ArtifactResolutionResult();
|
ArtifactResolutionResult result = new ArtifactResolutionResult();
|
||||||
|
|
||||||
|
@ -215,14 +215,14 @@ public class DefaultArtifactResolver
|
||||||
|
|
||||||
// TODO: scope handler
|
// TODO: scope handler
|
||||||
boolean updateScope = false;
|
boolean updateScope = false;
|
||||||
if ( Artifact.SCOPE_RUNTIME.equals( newArtifact.getScope() ) &&
|
if ( Artifact.SCOPE_RUNTIME.equals( newArtifact.getScope() )
|
||||||
Artifact.SCOPE_TEST.equals( knownArtifact.getScope() ) )
|
&& Artifact.SCOPE_TEST.equals( knownArtifact.getScope() ) )
|
||||||
{
|
{
|
||||||
updateScope = true;
|
updateScope = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Artifact.SCOPE_COMPILE.equals( newArtifact.getScope() ) &&
|
if ( Artifact.SCOPE_COMPILE.equals( newArtifact.getScope() )
|
||||||
!Artifact.SCOPE_COMPILE.equals( knownArtifact.getScope() ) )
|
&& !Artifact.SCOPE_COMPILE.equals( knownArtifact.getScope() ) )
|
||||||
{
|
{
|
||||||
updateScope = true;
|
updateScope = true;
|
||||||
}
|
}
|
||||||
|
@ -233,7 +233,8 @@ public class DefaultArtifactResolver
|
||||||
// TODO: [jc] Is this a better way to centralize artifact construction here?
|
// TODO: [jc] Is this a better way to centralize artifact construction here?
|
||||||
Artifact artifact = artifactConstructionSupport.createArtifact( knownArtifact.getGroupId(),
|
Artifact artifact = artifactConstructionSupport.createArtifact( knownArtifact.getGroupId(),
|
||||||
knownArtifact.getArtifactId(),
|
knownArtifact.getArtifactId(),
|
||||||
knownVersion, newArtifact.getScope(),
|
knownVersion,
|
||||||
|
newArtifact.getScope(),
|
||||||
knownArtifact.getType(),
|
knownArtifact.getType(),
|
||||||
knownArtifact.getExtension() );
|
knownArtifact.getExtension() );
|
||||||
resolvedArtifacts.put( artifact.getConflictId(), artifact );
|
resolvedArtifacts.put( artifact.getConflictId(), artifact );
|
||||||
|
@ -260,8 +261,8 @@ public class DefaultArtifactResolver
|
||||||
}
|
}
|
||||||
catch ( ArtifactMetadataRetrievalException e )
|
catch ( ArtifactMetadataRetrievalException e )
|
||||||
{
|
{
|
||||||
throw new TransitiveArtifactResolutionException( "Error retrieving metadata [" + newArtifact +
|
throw new TransitiveArtifactResolutionException( "Error retrieving metadata [" + newArtifact
|
||||||
"] : ", e );
|
+ "] : ", e );
|
||||||
}
|
}
|
||||||
|
|
||||||
// the pom for given dependency exisit we will add it to the
|
// the pom for given dependency exisit we will add it to the
|
||||||
|
@ -287,7 +288,7 @@ public class DefaultArtifactResolver
|
||||||
{
|
{
|
||||||
setLocalRepositoryPath( artifact, localRepository );
|
setLocalRepositoryPath( artifact, localRepository );
|
||||||
}
|
}
|
||||||
catch ( ArtifactHandlerNotFoundException e )
|
catch ( ArtifactPathFormatException e )
|
||||||
{
|
{
|
||||||
throw new TransitiveArtifactResolutionException( "Error collecting artifact: ", e );
|
throw new TransitiveArtifactResolutionException( "Error collecting artifact: ", e );
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,23 @@
|
||||||
</requirements>
|
</requirements>
|
||||||
</component>
|
</component>
|
||||||
|
|
||||||
|
<component>
|
||||||
|
<role>org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout</role>
|
||||||
|
<role-hint>default</role-hint>
|
||||||
|
<implementation>org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout</implementation>
|
||||||
|
</component>
|
||||||
|
|
||||||
|
<component>
|
||||||
|
<role>org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout</role>
|
||||||
|
<role-hint>legacy</role-hint>
|
||||||
|
<implementation>org.apache.maven.artifact.repository.layout.LegacyRepositoryLayout</implementation>
|
||||||
|
<requirements>
|
||||||
|
<requirement>
|
||||||
|
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
|
||||||
|
</requirement>
|
||||||
|
</requirements>
|
||||||
|
</component>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
|
|
|
|
||||||
| ArtifactHandlerManager
|
| ArtifactHandlerManager
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
package org.apache.maven.artifact;
|
package org.apache.maven.artifact;
|
||||||
|
|
||||||
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
|
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
|
||||||
import org.apache.maven.artifact.handler.manager.ArtifactHandlerNotFoundException;
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||||
import org.codehaus.plexus.PlexusTestCase;
|
import org.codehaus.plexus.PlexusTestCase;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -47,8 +47,9 @@ public abstract class ArtifactComponentTestCase
|
||||||
|
|
||||||
protected abstract String component();
|
protected abstract String component();
|
||||||
|
|
||||||
/** Return an existing file, not a directory - causes creation to fail. */
|
/** Return an existing file, not a directory - causes creation to fail.
|
||||||
protected ArtifactRepository badLocalRepository() throws IOException
|
* @throws Exception*/
|
||||||
|
protected ArtifactRepository badLocalRepository() throws Exception
|
||||||
{
|
{
|
||||||
String path = "target/test-classes/repositories/" + component() + "/bad-local-repository";
|
String path = "target/test-classes/repositories/" + component() + "/bad-local-repository";
|
||||||
|
|
||||||
|
@ -56,45 +57,59 @@ public abstract class ArtifactComponentTestCase
|
||||||
|
|
||||||
f.createNewFile();
|
f.createNewFile();
|
||||||
|
|
||||||
ArtifactRepository localRepository = new ArtifactRepository( "test", "file://" + f.getPath() );
|
ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE,
|
||||||
|
"legacy" );
|
||||||
|
|
||||||
|
ArtifactRepository localRepository = new ArtifactRepository( "test", "file://" + f.getPath(), repoLayout );
|
||||||
|
|
||||||
return localRepository;
|
return localRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ArtifactRepository localRepository()
|
protected ArtifactRepository localRepository() throws Exception
|
||||||
{
|
{
|
||||||
String path = "target/test-classes/repositories/" + component() + "/local-repository";
|
String path = "target/test-classes/repositories/" + component() + "/local-repository";
|
||||||
|
|
||||||
File f = new File( getBasedir(), path );
|
File f = new File( getBasedir(), path );
|
||||||
|
|
||||||
ArtifactRepository localRepository = new ArtifactRepository( "local", "file://" + f.getPath() );
|
ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE,
|
||||||
|
"legacy" );
|
||||||
|
|
||||||
|
ArtifactRepository localRepository = new ArtifactRepository( "local", "file://" + f.getPath(), repoLayout );
|
||||||
|
|
||||||
return localRepository;
|
return localRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ArtifactRepository remoteRepository()
|
protected ArtifactRepository remoteRepository() throws Exception
|
||||||
{
|
{
|
||||||
String path = "target/test-classes/repositories/" + component() + "/remote-repository";
|
String path = "target/test-classes/repositories/" + component() + "/remote-repository";
|
||||||
|
|
||||||
File f = new File( getBasedir(), path );
|
File f = new File( getBasedir(), path );
|
||||||
|
|
||||||
ArtifactRepository repository = new ArtifactRepository( "test", "file://" + f.getPath() );
|
ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE,
|
||||||
|
"legacy" );
|
||||||
|
|
||||||
|
ArtifactRepository repository = new ArtifactRepository( "test", "file://" + f.getPath(), repoLayout );
|
||||||
|
|
||||||
return repository;
|
return repository;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ArtifactRepository badRemoteRepository()
|
protected ArtifactRepository badRemoteRepository() throws Exception
|
||||||
{
|
{
|
||||||
ArtifactRepository repository = new ArtifactRepository( "test", "http://foo.bar/repository" );
|
ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE,
|
||||||
|
"legacy" );
|
||||||
|
|
||||||
|
ArtifactRepository repository = new ArtifactRepository( "test", "http://foo.bar/repository", repoLayout );
|
||||||
|
|
||||||
return repository;
|
return repository;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void assertRemoteArtifactPresent( Artifact artifact ) throws ArtifactHandlerNotFoundException
|
protected void assertRemoteArtifactPresent( Artifact artifact ) throws Exception
|
||||||
{
|
{
|
||||||
String path = artifactHandlerManager.path( artifact );
|
ArtifactRepository remoteRepo = remoteRepository();
|
||||||
|
|
||||||
File file = new File( remoteRepository().getBasedir(), path );
|
String path = remoteRepo.pathOf( artifact );
|
||||||
|
|
||||||
|
File file = new File( remoteRepo.getBasedir(), path );
|
||||||
|
|
||||||
if ( !file.exists() )
|
if ( !file.exists() )
|
||||||
{
|
{
|
||||||
|
@ -102,11 +117,13 @@ public abstract class ArtifactComponentTestCase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void assertLocalArtifactPresent( Artifact artifact ) throws ArtifactHandlerNotFoundException
|
protected void assertLocalArtifactPresent( Artifact artifact ) throws Exception
|
||||||
{
|
{
|
||||||
String path = artifactHandlerManager.path( artifact );
|
ArtifactRepository localRepo = localRepository();
|
||||||
|
|
||||||
File file = new File( localRepository().getBasedir(), path );
|
String path = localRepo.pathOf( artifact );
|
||||||
|
|
||||||
|
File file = new File( localRepo.getBasedir(), path );
|
||||||
|
|
||||||
if ( !file.exists() )
|
if ( !file.exists() )
|
||||||
{
|
{
|
||||||
|
@ -114,11 +131,13 @@ public abstract class ArtifactComponentTestCase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void assertRemoteArtifactNotPresent( Artifact artifact ) throws ArtifactHandlerNotFoundException
|
protected void assertRemoteArtifactNotPresent( Artifact artifact ) throws Exception
|
||||||
{
|
{
|
||||||
String path = artifactHandlerManager.path( artifact );
|
ArtifactRepository remoteRepo = remoteRepository();
|
||||||
|
|
||||||
File file = new File( remoteRepository().getBasedir(), path );
|
String path = remoteRepo.pathOf( artifact );
|
||||||
|
|
||||||
|
File file = new File( remoteRepo.getBasedir(), path );
|
||||||
|
|
||||||
if ( file.exists() )
|
if ( file.exists() )
|
||||||
{
|
{
|
||||||
|
@ -126,11 +145,13 @@ public abstract class ArtifactComponentTestCase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void assertLocalArtifactNotPresent( Artifact artifact ) throws ArtifactHandlerNotFoundException
|
protected void assertLocalArtifactNotPresent( Artifact artifact ) throws Exception
|
||||||
{
|
{
|
||||||
String path = artifactHandlerManager.path( artifact );
|
ArtifactRepository localRepo = localRepository();
|
||||||
|
|
||||||
File file = new File( localRepository().getBasedir(), path );
|
String path = localRepo.pathOf( artifact );
|
||||||
|
|
||||||
|
File file = new File( localRepo.getBasedir(), path );
|
||||||
|
|
||||||
if ( file.exists() )
|
if ( file.exists() )
|
||||||
{
|
{
|
||||||
|
@ -142,7 +163,7 @@ public abstract class ArtifactComponentTestCase
|
||||||
//
|
//
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
protected List remoteRepositories()
|
protected List remoteRepositories() throws Exception
|
||||||
{
|
{
|
||||||
List remoteRepositories = new ArrayList();
|
List remoteRepositories = new ArrayList();
|
||||||
|
|
||||||
|
@ -185,7 +206,7 @@ public abstract class ArtifactComponentTestCase
|
||||||
|
|
||||||
protected void createArtifact( Artifact artifact, ArtifactRepository repository ) throws Exception
|
protected void createArtifact( Artifact artifact, ArtifactRepository repository ) throws Exception
|
||||||
{
|
{
|
||||||
String path = artifactHandlerManager.path( artifact );
|
String path = repository.pathOf( artifact );
|
||||||
|
|
||||||
File artifactFile = new File( repository.getBasedir(), path );
|
File artifactFile = new File( repository.getBasedir(), path );
|
||||||
|
|
||||||
|
@ -223,7 +244,7 @@ public abstract class ArtifactComponentTestCase
|
||||||
|
|
||||||
protected void deleteArtifact( Artifact artifact, ArtifactRepository repository ) throws Exception
|
protected void deleteArtifact( Artifact artifact, ArtifactRepository repository ) throws Exception
|
||||||
{
|
{
|
||||||
String path = artifactHandlerManager.path( artifact );
|
String path = repository.pathOf( artifact );
|
||||||
|
|
||||||
File artifactFile = new File( repository.getBasedir(), path );
|
File artifactFile = new File( repository.getBasedir(), path );
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,6 @@ import java.util.Set;
|
||||||
// to change them when i change the layout of the repositories. So i want to generate
|
// to change them when i change the layout of the repositories. So i want to generate
|
||||||
// the structure i want to test by using the artifact handler manager which dictates
|
// the structure i want to test by using the artifact handler manager which dictates
|
||||||
// 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 <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
|
@ -135,15 +134,13 @@ public class ArtifactResolverTest
|
||||||
return super.createArtifact( groupId, artifactId, version, type );
|
return super.createArtifact( groupId, artifactId, version, type );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testTransitiveResolutionWhereAllArtifactsArePresentInTheLocalRepository()
|
public void testTransitiveResolutionWhereAllArtifactsArePresentInTheLocalRepository() throws Exception
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
Artifact g = createLocalArtifact( "g", "1.0" );
|
Artifact g = createLocalArtifact( "g", "1.0" );
|
||||||
|
|
||||||
Artifact h = createLocalArtifact( "h", "1.0" );
|
Artifact h = createLocalArtifact( "h", "1.0" );
|
||||||
|
|
||||||
ArtifactMetadataSource mds = new ArtifactMetadataSource()
|
ArtifactMetadataSource mds = new ArtifactMetadataSource() {
|
||||||
{
|
|
||||||
public Set retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories )
|
public Set retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories )
|
||||||
{
|
{
|
||||||
Set dependencies = new HashSet();
|
Set dependencies = new HashSet();
|
||||||
|
@ -180,8 +177,7 @@ public class ArtifactResolverTest
|
||||||
Artifact j = createRemoteArtifact( "j", "1.0" );
|
Artifact j = createRemoteArtifact( "j", "1.0" );
|
||||||
deleteLocalArtifact( j );
|
deleteLocalArtifact( j );
|
||||||
|
|
||||||
ArtifactMetadataSource mds = new ArtifactMetadataSource()
|
ArtifactMetadataSource mds = new ArtifactMetadataSource() {
|
||||||
{
|
|
||||||
public Set retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories )
|
public Set retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories )
|
||||||
{
|
{
|
||||||
Set dependencies = new HashSet();
|
Set dependencies = new HashSet();
|
||||||
|
@ -209,7 +205,7 @@ public class ArtifactResolverTest
|
||||||
assertLocalArtifactPresent( j );
|
assertLocalArtifactPresent( j );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testResolutionFailureWhenArtifactNotPresentInRemoteRepository()
|
public void testResolutionFailureWhenArtifactNotPresentInRemoteRepository() throws Exception
|
||||||
{
|
{
|
||||||
Artifact k = createArtifact( "k", "1.0" );
|
Artifact k = createArtifact( "k", "1.0" );
|
||||||
|
|
||||||
|
@ -224,8 +220,7 @@ public class ArtifactResolverTest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testResolutionOfAnArtifactWhereOneRemoteRepositoryIsBadButOneIsGood()
|
public void testResolutionOfAnArtifactWhereOneRemoteRepositoryIsBadButOneIsGood() throws Exception
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
Artifact l = createRemoteArtifact( "l", "1.0" );
|
Artifact l = createRemoteArtifact( "l", "1.0" );
|
||||||
deleteLocalArtifact( l );
|
deleteLocalArtifact( l );
|
||||||
|
@ -239,7 +234,7 @@ public class ArtifactResolverTest
|
||||||
assertLocalArtifactPresent( l );
|
assertLocalArtifactPresent( l );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
public void testResolutionOfASingleArtifactWhereTheArtifactIsNotPresentLocallyAndMustBeRetrievedFromTheRemoteRepositoryAndLocalCannotBeCreated()
|
public void testResolutionOfASingleArtifactWhereTheArtifactIsNotPresentLocallyAndMustBeRetrievedFromTheRemoteRepositoryAndLocalCannotBeCreated()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
@ -249,7 +244,7 @@ public class ArtifactResolverTest
|
||||||
|
|
||||||
// TODO [failing test case]: throw and handle a more informative exception
|
// TODO [failing test case]: throw and handle a more informative exception
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@ import org.apache.maven.execution.MavenExecutionRequest;
|
||||||
import org.apache.maven.execution.MavenExecutionResponse;
|
import org.apache.maven.execution.MavenExecutionResponse;
|
||||||
import org.apache.maven.execution.MavenSession;
|
import org.apache.maven.execution.MavenSession;
|
||||||
import org.apache.maven.lifecycle.LifecycleExecutor;
|
import org.apache.maven.lifecycle.LifecycleExecutor;
|
||||||
import org.apache.maven.model.Repository;
|
|
||||||
import org.apache.maven.monitor.event.EventDispatcher;
|
import org.apache.maven.monitor.event.EventDispatcher;
|
||||||
import org.apache.maven.monitor.event.MavenEvents;
|
import org.apache.maven.monitor.event.MavenEvents;
|
||||||
import org.apache.maven.plugin.PluginExecutionException;
|
import org.apache.maven.plugin.PluginExecutionException;
|
||||||
|
@ -82,8 +81,7 @@ public class DefaultMaven
|
||||||
// Project execution
|
// Project execution
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
public MavenExecutionResponse execute( MavenExecutionRequest request )
|
public MavenExecutionResponse execute( MavenExecutionRequest request ) throws ReactorException
|
||||||
throws ReactorException
|
|
||||||
{
|
{
|
||||||
EventDispatcher dispatcher = request.getEventDispatcher();
|
EventDispatcher dispatcher = request.getEventDispatcher();
|
||||||
String event = MavenEvents.REACTOR_EXECUTION;
|
String event = MavenEvents.REACTOR_EXECUTION;
|
||||||
|
@ -189,14 +187,9 @@ public class DefaultMaven
|
||||||
}
|
}
|
||||||
|
|
||||||
private MavenExecutionResponse processProject( MavenExecutionRequest request, MavenProject project,
|
private MavenExecutionResponse processProject( MavenExecutionRequest request, MavenProject project,
|
||||||
EventDispatcher dispatcher, List goals )
|
EventDispatcher dispatcher, List goals ) throws Exception
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
MavenSession session = createSession( request );
|
MavenSession session = createSession( request, project );
|
||||||
|
|
||||||
session.setProject( project );
|
|
||||||
|
|
||||||
session.setRemoteRepositories( getArtifactRepositories( project, request.getSettings() ) );
|
|
||||||
|
|
||||||
resolveParameters( request );
|
resolveParameters( request );
|
||||||
|
|
||||||
|
@ -254,20 +247,7 @@ public class DefaultMaven
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List getArtifactRepositories( MavenProject project, MavenSettings settings )
|
public MavenProject getProject( File pom, ArtifactRepository localRepository ) throws ProjectBuildingException
|
||||||
{
|
|
||||||
List remoteRepos = new ArrayList();
|
|
||||||
for ( Iterator it = project.getRepositories().iterator(); it.hasNext(); )
|
|
||||||
{
|
|
||||||
Repository modelRepo = (Repository) it.next();
|
|
||||||
remoteRepos.add( artifactRepositoryFactory.createArtifactRepository( modelRepo, settings ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
return remoteRepos;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MavenProject getProject( File pom, ArtifactRepository localRepository )
|
|
||||||
throws ProjectBuildingException
|
|
||||||
{
|
{
|
||||||
if ( pom.exists() )
|
if ( pom.exists() )
|
||||||
{
|
{
|
||||||
|
@ -289,18 +269,18 @@ public class DefaultMaven
|
||||||
// the session type would be specific to the request i.e. having a project
|
// the session type would be specific to the request i.e. having a project
|
||||||
// or not.
|
// or not.
|
||||||
|
|
||||||
protected MavenSession createSession( MavenExecutionRequest request )
|
protected MavenSession createSession( MavenExecutionRequest request, MavenProject project )
|
||||||
{
|
{
|
||||||
return new MavenSession( container, pluginManager, request.getSettings(), request.getLocalRepository(),
|
return new MavenSession( project, container, pluginManager, request.getSettings(),
|
||||||
request.getEventDispatcher(), request.getLog(), request.getGoals() );
|
request.getLocalRepository(), request.getEventDispatcher(), request.getLog(),
|
||||||
|
request.getGoals() );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo [BP] this might not be required if there is a better way to pass
|
* @todo [BP] this might not be required if there is a better way to pass
|
||||||
* them in. It doesn't feel quite right.
|
* them in. It doesn't feel quite right.
|
||||||
*/
|
*/
|
||||||
private void resolveParameters( MavenExecutionRequest request )
|
private void resolveParameters( MavenExecutionRequest request ) throws ComponentLookupException
|
||||||
throws ComponentLookupException
|
|
||||||
{
|
{
|
||||||
WagonManager wagonManager = (WagonManager) container.lookup( WagonManager.ROLE );
|
WagonManager wagonManager = (WagonManager) container.lookup( WagonManager.ROLE );
|
||||||
|
|
||||||
|
@ -320,8 +300,7 @@ public class DefaultMaven
|
||||||
// Lifecylce Management
|
// Lifecylce Management
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
public void contextualize( Context context )
|
public void contextualize( Context context ) throws ContextException
|
||||||
throws ContextException
|
|
||||||
{
|
{
|
||||||
container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
|
container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
|
||||||
}
|
}
|
||||||
|
@ -398,8 +377,9 @@ public class DefaultMaven
|
||||||
|
|
||||||
Runtime r = Runtime.getRuntime();
|
Runtime r = Runtime.getRuntime();
|
||||||
|
|
||||||
getLogger().info( "Final Memory: " + ( ( r.totalMemory() - r.freeMemory() ) / mb ) + "M/" +
|
getLogger().info(
|
||||||
( r.totalMemory() / mb ) + "M" );
|
"Final Memory: " + ( ( r.totalMemory() - r.freeMemory() ) / mb ) + "M/"
|
||||||
|
+ ( r.totalMemory() / mb ) + "M" );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void line()
|
protected void line()
|
||||||
|
|
|
@ -17,6 +17,7 @@ package org.apache.maven.artifact.repository;
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||||
import org.apache.maven.model.Repository;
|
import org.apache.maven.model.Repository;
|
||||||
import org.apache.maven.settings.MavenSettings;
|
import org.apache.maven.settings.MavenSettings;
|
||||||
|
|
||||||
|
@ -28,6 +29,7 @@ public interface ArtifactRepositoryFactory
|
||||||
|
|
||||||
public static final String ROLE = ArtifactRepositoryFactory.class.getName();
|
public static final String ROLE = ArtifactRepositoryFactory.class.getName();
|
||||||
|
|
||||||
public ArtifactRepository createArtifactRepository( Repository modelRepository, MavenSettings settings );
|
public ArtifactRepository createArtifactRepository( Repository modelRepository, MavenSettings settings,
|
||||||
|
ArtifactRepositoryLayout repositoryLayout );
|
||||||
|
|
||||||
}
|
}
|
|
@ -17,6 +17,7 @@ package org.apache.maven.artifact.repository;
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||||
import org.apache.maven.model.Repository;
|
import org.apache.maven.model.Repository;
|
||||||
import org.apache.maven.settings.MavenSettings;
|
import org.apache.maven.settings.MavenSettings;
|
||||||
import org.apache.maven.settings.Server;
|
import org.apache.maven.settings.Server;
|
||||||
|
@ -32,7 +33,8 @@ public class DefaultArtifactRepositoryFactory
|
||||||
implements ArtifactRepositoryFactory
|
implements ArtifactRepositoryFactory
|
||||||
{
|
{
|
||||||
|
|
||||||
public ArtifactRepository createArtifactRepository( Repository modelRepository, MavenSettings settings )
|
public ArtifactRepository createArtifactRepository( Repository modelRepository, MavenSettings settings,
|
||||||
|
ArtifactRepositoryLayout repositoryLayout )
|
||||||
{
|
{
|
||||||
Server repoProfile = null;
|
Server repoProfile = null;
|
||||||
|
|
||||||
|
@ -47,7 +49,8 @@ public class DefaultArtifactRepositoryFactory
|
||||||
Logger logger = getLogger();
|
Logger logger = getLogger();
|
||||||
if ( logger != null )
|
if ( logger != null )
|
||||||
{
|
{
|
||||||
logger.warn( "Cannot associate authentication to repository with null id. The offending repository's URL is: "
|
logger
|
||||||
|
.warn( "Cannot associate authentication to repository with null id. The offending repository's URL is: "
|
||||||
+ modelRepository.getUrl() );
|
+ modelRepository.getUrl() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,11 +69,12 @@ public class DefaultArtifactRepositoryFactory
|
||||||
|
|
||||||
authInfo.setPassphrase( repoProfile.getPassphrase() );
|
authInfo.setPassphrase( repoProfile.getPassphrase() );
|
||||||
|
|
||||||
repo = new ArtifactRepository( modelRepository.getId(), modelRepository.getUrl(), authInfo );
|
repo = new ArtifactRepository( modelRepository.getId(), modelRepository.getUrl(), authInfo,
|
||||||
|
repositoryLayout );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
repo = new ArtifactRepository( modelRepository.getId(), modelRepository.getUrl() );
|
repo = new ArtifactRepository( modelRepository.getId(), modelRepository.getUrl(), repositoryLayout );
|
||||||
}
|
}
|
||||||
|
|
||||||
return repo;
|
return repo;
|
||||||
|
|
|
@ -29,6 +29,7 @@ import org.apache.maven.MavenConstants;
|
||||||
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;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
|
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
|
||||||
|
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||||
import org.apache.maven.execution.DefaultMavenExecutionRequest;
|
import org.apache.maven.execution.DefaultMavenExecutionRequest;
|
||||||
import org.apache.maven.execution.MavenExecutionRequest;
|
import org.apache.maven.execution.MavenExecutionRequest;
|
||||||
import org.apache.maven.execution.MavenExecutionResponse;
|
import org.apache.maven.execution.MavenExecutionResponse;
|
||||||
|
@ -66,8 +67,7 @@ public class MavenCli
|
||||||
|
|
||||||
public static File userDir = new File( System.getProperty( "user.dir" ) );
|
public static File userDir = new File( System.getProperty( "user.dir" ) );
|
||||||
|
|
||||||
public static int main( String[] args, ClassWorld classWorld )
|
public static int main( String[] args, ClassWorld classWorld ) throws Exception
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Setup the command line parser
|
// Setup the command line parser
|
||||||
|
@ -135,9 +135,29 @@ public class MavenCli
|
||||||
|
|
||||||
MavenSettings settings = settingsBuilder.buildSettings();
|
MavenSettings settings = settingsBuilder.buildSettings();
|
||||||
|
|
||||||
ArtifactRepositoryFactory artifactRepositoryFactory = (ArtifactRepositoryFactory) embedder.lookup( ArtifactRepositoryFactory.ROLE );
|
ArtifactRepositoryFactory artifactRepositoryFactory = (ArtifactRepositoryFactory) embedder
|
||||||
|
.lookup( ArtifactRepositoryFactory.ROLE );
|
||||||
|
|
||||||
ArtifactRepository localRepository = getLocalRepository( settings, artifactRepositoryFactory );
|
// TODO: Switch the default repository layout id to "default" when the
|
||||||
|
// conversion is done.
|
||||||
|
String repoLayoutId = "legacy";
|
||||||
|
|
||||||
|
if ( commandLine.hasOption( CLIManager.VERSION_1_REPO ) )
|
||||||
|
{
|
||||||
|
repoLayoutId = "legacy";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( commandLine.hasOption( CLIManager.VERSION_2_REPO ) )
|
||||||
|
{
|
||||||
|
repoLayoutId = "default";
|
||||||
|
}
|
||||||
|
|
||||||
|
ArtifactRepositoryLayout repositoryLayout = (ArtifactRepositoryLayout) embedder
|
||||||
|
.lookup(
|
||||||
|
ArtifactRepositoryLayout.ROLE,
|
||||||
|
repoLayoutId );
|
||||||
|
|
||||||
|
ArtifactRepository localRepository = getLocalRepository( settings, artifactRepositoryFactory, repositoryLayout );
|
||||||
|
|
||||||
if ( commandLine.hasOption( CLIManager.REACTOR ) )
|
if ( commandLine.hasOption( CLIManager.REACTOR ) )
|
||||||
{
|
{
|
||||||
|
@ -146,10 +166,11 @@ public class MavenCli
|
||||||
|
|
||||||
String excludes = System.getProperty( "maven.reactor.excludes", POMv4 );
|
String excludes = System.getProperty( "maven.reactor.excludes", POMv4 );
|
||||||
|
|
||||||
request =
|
request = new DefaultMavenExecutionRequest( localRepository, settings, eventDispatcher,
|
||||||
new DefaultMavenExecutionRequest( localRepository, settings, eventDispatcher,
|
commandLine.getArgList(), FileUtils.getFiles( userDir,
|
||||||
commandLine.getArgList(),
|
includes,
|
||||||
FileUtils.getFiles( userDir, includes, excludes ), userDir.getPath() );
|
excludes ),
|
||||||
|
userDir.getPath() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -204,9 +225,9 @@ public class MavenCli
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// System properties handling
|
// System properties handling
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
private static void initializeSystemProperties( CommandLine commandLine )
|
private static void initializeSystemProperties( CommandLine commandLine )
|
||||||
{
|
{
|
||||||
|
@ -250,9 +271,9 @@ public class MavenCli
|
||||||
System.setProperty( name, value );
|
System.setProperty( name, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Command line manager
|
// Command line manager
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
static class CLIManager
|
static class CLIManager
|
||||||
{
|
{
|
||||||
|
@ -276,33 +297,48 @@ public class MavenCli
|
||||||
|
|
||||||
public static final char NON_RECURSIVE = 'N';
|
public static final char NON_RECURSIVE = 'N';
|
||||||
|
|
||||||
|
public static final char VERSION_1_REPO = 'A';
|
||||||
|
|
||||||
|
// TODO: this is a hack until we can get the main repo converted...
|
||||||
|
public static final char VERSION_2_REPO = 'a';
|
||||||
|
|
||||||
public CLIManager()
|
public CLIManager()
|
||||||
{
|
{
|
||||||
options = new Options();
|
options = new Options();
|
||||||
options.addOption( OptionBuilder.withLongOpt( "nobanner" ).withDescription( "Suppress logo banner" ).create(
|
options.addOption( OptionBuilder.withLongOpt( "nobanner" ).withDescription( "Suppress logo banner" )
|
||||||
NO_BANNER ) );
|
.create( NO_BANNER ) );
|
||||||
options.addOption( OptionBuilder.withLongOpt( "define" ).hasArg().withDescription(
|
options
|
||||||
"Define a system property" ).create( SET_SYSTEM_PROPERTY ) );
|
.addOption( OptionBuilder.withLongOpt( "define" ).hasArg()
|
||||||
options.addOption( OptionBuilder.withLongOpt( "offline" ).hasArg().withDescription( "Work offline" ).create(
|
.withDescription( "Define a system property" ).create( SET_SYSTEM_PROPERTY ) );
|
||||||
WORK_OFFLINE ) );
|
options.addOption( OptionBuilder.withLongOpt( "offline" ).hasArg().withDescription( "Work offline" )
|
||||||
options.addOption( OptionBuilder.withLongOpt( "mojoDescriptors" ).withDescription(
|
.create( WORK_OFFLINE ) );
|
||||||
"Display available mojoDescriptors" ).create( LIST_GOALS ) );
|
options
|
||||||
options.addOption( OptionBuilder.withLongOpt( "help" ).withDescription( "Display help information" ).create(
|
.addOption( OptionBuilder.withLongOpt( "mojoDescriptors" )
|
||||||
HELP ) );
|
.withDescription( "Display available mojoDescriptors" ).create( LIST_GOALS ) );
|
||||||
options.addOption( OptionBuilder.withLongOpt( "offline" ).withDescription( "Build is happening offline" ).create(
|
options.addOption( OptionBuilder.withLongOpt( "help" ).withDescription( "Display help information" )
|
||||||
WORK_OFFLINE ) );
|
.create( HELP ) );
|
||||||
options.addOption( OptionBuilder.withLongOpt( "version" ).withDescription( "Display version information" ).create(
|
options.addOption( OptionBuilder.withLongOpt( "offline" ).withDescription( "Build is happening offline" )
|
||||||
VERSION ) );
|
.create( WORK_OFFLINE ) );
|
||||||
options.addOption( OptionBuilder.withLongOpt( "debug" ).withDescription( "Produce execution debug output" ).create(
|
options.addOption( OptionBuilder.withLongOpt( "version" ).withDescription( "Display version information" )
|
||||||
DEBUG ) );
|
.create( VERSION ) );
|
||||||
options.addOption( OptionBuilder.withLongOpt( "reactor" ).withDescription(
|
options.addOption( OptionBuilder.withLongOpt( "debug" ).withDescription( "Produce execution debug output" )
|
||||||
"Execute goals for project found in the reactor" ).create( REACTOR ) );
|
.create( DEBUG ) );
|
||||||
options.addOption( OptionBuilder.withLongOpt( "non-recursive" ).withDescription(
|
options.addOption( OptionBuilder.withLongOpt( "reactor" )
|
||||||
"Do not recurse into sub-projects" ).create( NON_RECURSIVE ) );
|
.withDescription( "Execute goals for project found in the reactor" )
|
||||||
|
.create( REACTOR ) );
|
||||||
|
options.addOption( OptionBuilder.withLongOpt( "non-recursive" )
|
||||||
|
.withDescription( "Do not recurse into sub-projects" )
|
||||||
|
.create( NON_RECURSIVE ) );
|
||||||
|
options.addOption( OptionBuilder.withLongOpt( "v1-local-repository" )
|
||||||
|
.withDescription( "Use legacy layout for local artifact repository" )
|
||||||
|
.create( VERSION_1_REPO ) );
|
||||||
|
|
||||||
|
options.addOption( OptionBuilder.withLongOpt( "v2-local-repository" )
|
||||||
|
.withDescription( "Use new layout for local artifact repository" )
|
||||||
|
.create( VERSION_2_REPO ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandLine parse( String[] args )
|
public CommandLine parse( String[] args ) throws ParseException
|
||||||
throws ParseException
|
|
||||||
{
|
{
|
||||||
CommandLineParser parser = new PosixParser();
|
CommandLineParser parser = new PosixParser();
|
||||||
return parser.parse( options, args );
|
return parser.parse( options, args );
|
||||||
|
@ -315,9 +351,9 @@ public class MavenCli
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
protected static File getUserConfigurationDirectory()
|
protected static File getUserConfigurationDirectory()
|
||||||
{
|
{
|
||||||
|
@ -326,7 +362,7 @@ public class MavenCli
|
||||||
{
|
{
|
||||||
if ( !mavenUserConfigurationDirectory.mkdirs() )
|
if ( !mavenUserConfigurationDirectory.mkdirs() )
|
||||||
{
|
{
|
||||||
//throw a configuration exception
|
//throw a configuration exception
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return mavenUserConfigurationDirectory;
|
return mavenUserConfigurationDirectory;
|
||||||
|
@ -347,8 +383,9 @@ public class MavenCli
|
||||||
return mavenProperties;
|
return mavenProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static ArtifactRepository getLocalRepository( MavenSettings settings, ArtifactRepositoryFactory repoFactory )
|
protected static ArtifactRepository getLocalRepository( MavenSettings settings,
|
||||||
throws Exception
|
ArtifactRepositoryFactory repoFactory,
|
||||||
|
ArtifactRepositoryLayout repositoryLayout ) throws Exception
|
||||||
{
|
{
|
||||||
Profile profile = settings.getActiveProfile();
|
Profile profile = settings.getActiveProfile();
|
||||||
|
|
||||||
|
@ -361,11 +398,10 @@ public class MavenCli
|
||||||
if ( localRepository == null )
|
if ( localRepository == null )
|
||||||
{
|
{
|
||||||
String userConfigurationDirectory = System.getProperty( "user.home" ) + "/.m2";
|
String userConfigurationDirectory = System.getProperty( "user.home" ) + "/.m2";
|
||||||
localRepository =
|
localRepository = new File( userConfigurationDirectory, MavenConstants.MAVEN_REPOSITORY ).getAbsolutePath();
|
||||||
new File( userConfigurationDirectory, MavenConstants.MAVEN_REPOSITORY ).getAbsolutePath();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO [BP]: this should not be necessary - grep for and remove
|
// TODO [BP]: this should not be necessary - grep for and remove
|
||||||
System.setProperty( MavenConstants.MAVEN_REPO_LOCAL, localRepository );
|
System.setProperty( MavenConstants.MAVEN_REPO_LOCAL, localRepository );
|
||||||
|
|
||||||
Repository repo = new Repository();
|
Repository repo = new Repository();
|
||||||
|
@ -374,6 +410,6 @@ public class MavenCli
|
||||||
|
|
||||||
repo.setUrl( "file://" + localRepository );
|
repo.setUrl( "file://" + localRepository );
|
||||||
|
|
||||||
return repoFactory.createArtifactRepository( repo, settings );
|
return repoFactory.createArtifactRepository( repo, settings, repositoryLayout );
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -30,10 +30,8 @@ import org.codehaus.plexus.util.dag.DAG;
|
||||||
import org.codehaus.plexus.util.dag.TopologicalSorter;
|
import org.codehaus.plexus.util.dag.TopologicalSorter;
|
||||||
import org.codehaus.plexus.util.dag.Vertex;
|
import org.codehaus.plexus.util.dag.Vertex;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl </a>
|
* @author <a href="mailto:jason@maven.org">Jason van Zyl </a>
|
||||||
|
@ -49,8 +47,6 @@ public class MavenSession
|
||||||
|
|
||||||
private PluginManager pluginManager;
|
private PluginManager pluginManager;
|
||||||
|
|
||||||
private Set remoteRepositories;
|
|
||||||
|
|
||||||
private DAG dag;
|
private DAG dag;
|
||||||
|
|
||||||
private List goals;
|
private List goals;
|
||||||
|
@ -65,11 +61,12 @@ public class MavenSession
|
||||||
|
|
||||||
private final MavenSettings settings;
|
private final MavenSettings settings;
|
||||||
|
|
||||||
private List remoteArtifactRepos = Collections.EMPTY_LIST;
|
public MavenSession( MavenProject project, PlexusContainer container, PluginManager pluginManager,
|
||||||
|
MavenSettings settings, ArtifactRepository localRepository, EventDispatcher eventDispatcher,
|
||||||
public MavenSession( PlexusContainer container, PluginManager pluginManager, MavenSettings settings,
|
Log log, List goals )
|
||||||
ArtifactRepository localRepository, EventDispatcher eventDispatcher, Log log, List goals )
|
|
||||||
{
|
{
|
||||||
|
this.project = project;
|
||||||
|
|
||||||
this.container = container;
|
this.container = container;
|
||||||
|
|
||||||
this.pluginManager = pluginManager;
|
this.pluginManager = pluginManager;
|
||||||
|
@ -102,24 +99,14 @@ public class MavenSession
|
||||||
return project;
|
return project;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProject( MavenProject project )
|
|
||||||
{
|
|
||||||
this.project = project;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArtifactRepository getLocalRepository()
|
public ArtifactRepository getLocalRepository()
|
||||||
{
|
{
|
||||||
return localRepository;
|
return localRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRemoteRepositories(List remoteArtifactRepos)
|
|
||||||
{
|
|
||||||
this.remoteArtifactRepos = remoteArtifactRepos;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List getRemoteRepositories()
|
public List getRemoteRepositories()
|
||||||
{
|
{
|
||||||
return remoteArtifactRepos;
|
return project.getRemoteArtifactRepositories();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List getGoals()
|
public List getGoals()
|
||||||
|
@ -179,4 +166,9 @@ public class MavenSession
|
||||||
return chainToHere;
|
return chainToHere;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List getPluginRepositories()
|
||||||
|
{
|
||||||
|
return project.getPluginArtifactRepositories();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -75,8 +75,7 @@ public class DefaultLifecycleExecutor
|
||||||
* @param tasks
|
* @param tasks
|
||||||
* @param session
|
* @param session
|
||||||
*/
|
*/
|
||||||
public MavenExecutionResponse execute( List tasks, MavenSession session )
|
public MavenExecutionResponse execute( List tasks, MavenSession session ) throws LifecycleExecutionException
|
||||||
throws LifecycleExecutionException
|
|
||||||
{
|
{
|
||||||
MavenExecutionResponse response = new MavenExecutionResponse();
|
MavenExecutionResponse response = new MavenExecutionResponse();
|
||||||
|
|
||||||
|
@ -206,8 +205,7 @@ public class DefaultLifecycleExecutor
|
||||||
* @param mavenSession
|
* @param mavenSession
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private void processPluginPhases( Plugin plugin, MavenSession mavenSession, Map phaseMap )
|
private void processPluginPhases( Plugin plugin, MavenSession mavenSession, Map phaseMap ) throws Exception
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
String groupId = plugin.getGroupId();
|
String groupId = plugin.getGroupId();
|
||||||
|
|
||||||
|
@ -243,8 +241,8 @@ public class DefaultLifecycleExecutor
|
||||||
|
|
||||||
if ( mojoDescriptor == null )
|
if ( mojoDescriptor == null )
|
||||||
{
|
{
|
||||||
throw new LifecycleExecutionException(
|
throw new LifecycleExecutionException( "A goal '" + mojoId
|
||||||
"A goal '" + mojoId + "' was declared in pom.xml, but does not exist" );
|
+ "' was declared in pom.xml, but does not exist" );
|
||||||
}
|
}
|
||||||
|
|
||||||
configureMojo( mojoDescriptor, phaseMap );
|
configureMojo( mojoDescriptor, phaseMap );
|
||||||
|
@ -269,8 +267,7 @@ public class DefaultLifecycleExecutor
|
||||||
* @param mojoDescriptor
|
* @param mojoDescriptor
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private void configureMojo( MojoDescriptor mojoDescriptor, Map phaseMap )
|
private void configureMojo( MojoDescriptor mojoDescriptor, Map phaseMap ) throws Exception
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
if ( mojoDescriptor.getPhase() != null )
|
if ( mojoDescriptor.getPhase() != null )
|
||||||
{
|
{
|
||||||
|
@ -280,8 +277,7 @@ public class DefaultLifecycleExecutor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processGoalChain( String task, MavenSession session, Map phaseMap )
|
private void processGoalChain( String task, MavenSession session, Map phaseMap ) throws Exception
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
if ( phaseMap.containsKey( task ) )
|
if ( phaseMap.containsKey( task ) )
|
||||||
{
|
{
|
||||||
|
@ -312,8 +308,7 @@ public class DefaultLifecycleExecutor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyMojoPhase( String task, MavenSession session, Map phaseMap )
|
private void verifyMojoPhase( String task, MavenSession session, Map phaseMap ) throws Exception
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
MojoDescriptor mojoDescriptor = pluginManager.getMojoDescriptor( task );
|
MojoDescriptor mojoDescriptor = pluginManager.getMojoDescriptor( task );
|
||||||
|
|
||||||
|
@ -332,8 +327,7 @@ public class DefaultLifecycleExecutor
|
||||||
configureMojo( mojoDescriptor, phaseMap );
|
configureMojo( mojoDescriptor, phaseMap );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void executePhase( String phase, MavenSession session, Map phaseMap )
|
private void executePhase( String phase, MavenSession session, Map phaseMap ) throws PluginExecutionException
|
||||||
throws PluginExecutionException
|
|
||||||
{
|
{
|
||||||
// only execute up to the given phase
|
// only execute up to the given phase
|
||||||
int index = phases.indexOf( phaseMap.get( phase ) );
|
int index = phases.indexOf( phaseMap.get( phase ) );
|
||||||
|
@ -373,8 +367,7 @@ public class DefaultLifecycleExecutor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void executeMojo( String id, MavenSession session )
|
protected void executeMojo( String id, MavenSession session ) throws PluginExecutionException
|
||||||
throws PluginExecutionException
|
|
||||||
{
|
{
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// We have something of the form <pluginId>:<mojoId>, so this might be
|
// We have something of the form <pluginId>:<mojoId>, so this might be
|
||||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.maven.plugin;
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.MavenMetadataSource;
|
import org.apache.maven.artifact.MavenMetadataSource;
|
||||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
|
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
|
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
|
||||||
|
@ -28,7 +27,6 @@ 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.apache.maven.execution.MavenSession;
|
import org.apache.maven.execution.MavenSession;
|
||||||
import org.apache.maven.model.Goal;
|
import org.apache.maven.model.Goal;
|
||||||
import org.apache.maven.model.Repository;
|
|
||||||
import org.apache.maven.monitor.event.EventDispatcher;
|
import org.apache.maven.monitor.event.EventDispatcher;
|
||||||
import org.apache.maven.monitor.event.MavenEvents;
|
import org.apache.maven.monitor.event.MavenEvents;
|
||||||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||||
|
@ -38,7 +36,6 @@ import org.apache.maven.plugin.descriptor.PluginDescriptorBuilder;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
import org.apache.maven.project.MavenProjectBuilder;
|
import org.apache.maven.project.MavenProjectBuilder;
|
||||||
import org.apache.maven.project.path.PathTranslator;
|
import org.apache.maven.project.path.PathTranslator;
|
||||||
import org.apache.maven.settings.MavenSettings;
|
|
||||||
import org.apache.maven.settings.MavenSettingsBuilder;
|
import org.apache.maven.settings.MavenSettingsBuilder;
|
||||||
import org.codehaus.plexus.ArtifactEnabledContainer;
|
import org.codehaus.plexus.ArtifactEnabledContainer;
|
||||||
import org.codehaus.plexus.PlexusConstants;
|
import org.codehaus.plexus.PlexusConstants;
|
||||||
|
@ -84,8 +81,6 @@ public class DefaultPluginManager
|
||||||
|
|
||||||
protected PluginDescriptorBuilder pluginDescriptorBuilder;
|
protected PluginDescriptorBuilder pluginDescriptorBuilder;
|
||||||
|
|
||||||
protected List remotePluginRepositories;
|
|
||||||
|
|
||||||
protected ArtifactFilter artifactFilter;
|
protected ArtifactFilter artifactFilter;
|
||||||
|
|
||||||
protected PathTranslator pathTranslator;
|
protected PathTranslator pathTranslator;
|
||||||
|
@ -141,8 +136,7 @@ public class DefaultPluginManager
|
||||||
|
|
||||||
private Set pluginsInProcess = new HashSet();
|
private Set pluginsInProcess = new HashSet();
|
||||||
|
|
||||||
public void processPluginDescriptor( MavenPluginDescriptor mavenPluginDescriptor )
|
public void processPluginDescriptor( MavenPluginDescriptor mavenPluginDescriptor ) throws CycleDetectedException
|
||||||
throws CycleDetectedException
|
|
||||||
{
|
{
|
||||||
if ( pluginsInProcess.contains( mavenPluginDescriptor.getPluginId() ) )
|
if ( pluginsInProcess.contains( mavenPluginDescriptor.getPluginId() ) )
|
||||||
{
|
{
|
||||||
|
@ -213,8 +207,7 @@ public class DefaultPluginManager
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: don't throw Exception
|
// TODO: don't throw Exception
|
||||||
public void verifyPluginForGoal( String goalName, MavenSession session )
|
public void verifyPluginForGoal( String goalName, MavenSession session ) throws Exception
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
String pluginId = getPluginId( goalName );
|
String pluginId = getPluginId( goalName );
|
||||||
|
|
||||||
|
@ -223,8 +216,7 @@ public class DefaultPluginManager
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: don't throw Exception
|
// TODO: don't throw Exception
|
||||||
public void verifyPlugin( String groupId, String artifactId, MavenSession session )
|
public void verifyPlugin( String groupId, String artifactId, MavenSession session ) throws Exception
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
if ( !isPluginInstalled( groupId, artifactId ) )
|
if ( !isPluginInstalled( groupId, artifactId ) )
|
||||||
{
|
{
|
||||||
|
@ -286,8 +278,7 @@ public class DefaultPluginManager
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: don't throw Exception
|
// TODO: don't throw Exception
|
||||||
protected void addPlugin( Artifact pluginArtifact, MavenSession session )
|
protected void addPlugin( Artifact pluginArtifact, MavenSession session ) throws Exception
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
ArtifactResolver artifactResolver = null;
|
ArtifactResolver artifactResolver = null;
|
||||||
MavenProjectBuilder mavenProjectBuilder = null;
|
MavenProjectBuilder mavenProjectBuilder = null;
|
||||||
|
@ -301,7 +292,7 @@ public class DefaultPluginManager
|
||||||
MavenMetadataSource metadataSource = new MavenMetadataSource( artifactResolver, mavenProjectBuilder );
|
MavenMetadataSource metadataSource = new MavenMetadataSource( artifactResolver, mavenProjectBuilder );
|
||||||
|
|
||||||
( (ArtifactEnabledContainer) container ).addComponent( pluginArtifact, artifactResolver,
|
( (ArtifactEnabledContainer) container ).addComponent( pluginArtifact, artifactResolver,
|
||||||
remotePluginRepositories,
|
session.getPluginRepositories(),
|
||||||
session.getLocalRepository(), metadataSource,
|
session.getLocalRepository(), metadataSource,
|
||||||
artifactFilter );
|
artifactFilter );
|
||||||
}
|
}
|
||||||
|
@ -323,8 +314,7 @@ public class DefaultPluginManager
|
||||||
// Plugin execution
|
// Plugin execution
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
public void executeMojo( MavenSession session, String goalName )
|
public void executeMojo( MavenSession session, String goalName ) throws PluginExecutionException
|
||||||
throws PluginExecutionException
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -459,8 +449,7 @@ public class DefaultPluginManager
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: don't throw Exception
|
// TODO: don't throw Exception
|
||||||
private void releaseComponents( MojoDescriptor goal, PluginExecutionRequest request )
|
private void releaseComponents( MojoDescriptor goal, PluginExecutionRequest request ) throws Exception
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
if ( request != null && request.getParameters() != null )
|
if ( request != null && request.getParameters() != null )
|
||||||
{
|
{
|
||||||
|
@ -555,8 +544,7 @@ public class DefaultPluginManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map createParameters( MojoDescriptor goal, MavenSession session )
|
public Map createParameters( MojoDescriptor goal, MavenSession session ) throws PluginConfigurationException
|
||||||
throws PluginConfigurationException
|
|
||||||
{
|
{
|
||||||
List parameters = goal.getParameters();
|
List parameters = goal.getParameters();
|
||||||
|
|
||||||
|
@ -616,8 +604,8 @@ public class DefaultPluginManager
|
||||||
|
|
||||||
if ( type != null && ( type.equals( "File" ) || type.equals( "java.io.File" ) ) )
|
if ( type != null && ( type.equals( "File" ) || type.equals( "java.io.File" ) ) )
|
||||||
{
|
{
|
||||||
value = pathTranslator.alignToBaseDirectory( (String) value,
|
value = pathTranslator.alignToBaseDirectory( (String) value, session.getProject().getFile()
|
||||||
session.getProject().getFile().getParentFile() );
|
.getParentFile() );
|
||||||
map.put( key, value );
|
map.put( key, value );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -674,8 +662,8 @@ public class DefaultPluginManager
|
||||||
{
|
{
|
||||||
StringBuffer message = new StringBuffer();
|
StringBuffer message = new StringBuffer();
|
||||||
|
|
||||||
message.append( "The '" + parameter.getName() ).append( "' parameter is required for the execution of the " ).append(
|
message.append( "The '" + parameter.getName() ).append( "' parameter is required for the execution of the " )
|
||||||
mojo.getId() ).append( " mojo and cannot be null." );
|
.append( mojo.getId() ).append( " mojo and cannot be null." );
|
||||||
|
|
||||||
return message.toString();
|
return message.toString();
|
||||||
}
|
}
|
||||||
|
@ -684,8 +672,7 @@ public class DefaultPluginManager
|
||||||
// Lifecycle
|
// Lifecycle
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
public void contextualize( Context context )
|
public void contextualize( Context context ) throws ContextException
|
||||||
throws ContextException
|
|
||||||
{
|
{
|
||||||
container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
|
container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
|
||||||
}
|
}
|
||||||
|
@ -693,35 +680,19 @@ public class DefaultPluginManager
|
||||||
public void initialize()
|
public void initialize()
|
||||||
{
|
{
|
||||||
// TODO: configure this from bootstrap or scan lib
|
// TODO: configure this from bootstrap or scan lib
|
||||||
artifactFilter = new ExclusionSetFilter( new String[]{"maven-core", "maven-artifact", "maven-model",
|
artifactFilter = new ExclusionSetFilter( new String[] {
|
||||||
"maven-settings", "maven-monitor", "maven-plugin",
|
"maven-core",
|
||||||
"plexus-container-api", "plexus-container-default",
|
"maven-artifact",
|
||||||
"plexus-artifact-container", "wagon-provider-api",
|
"maven-model",
|
||||||
"classworlds"} );
|
"maven-settings",
|
||||||
|
"maven-monitor",
|
||||||
|
"maven-plugin",
|
||||||
|
"plexus-container-api",
|
||||||
|
"plexus-container-default",
|
||||||
|
"plexus-artifact-container",
|
||||||
|
"wagon-provider-api",
|
||||||
|
"classworlds" } );
|
||||||
|
|
||||||
// TODO: move this to be configurable from the Maven component
|
|
||||||
remotePluginRepositories = new ArrayList();
|
|
||||||
|
|
||||||
// TODO: needs to be configured from the POM element
|
|
||||||
|
|
||||||
MavenSettings settings = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
settings = mavenSettingsBuilder.buildSettings();
|
|
||||||
}
|
|
||||||
catch ( Exception e )
|
|
||||||
{
|
|
||||||
getLogger().error( "Failed to build MavenSettings from xml file. Using defaults.", e );
|
|
||||||
settings = new MavenSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
Repository pluginRepo = new Repository();
|
|
||||||
pluginRepo.setId( "plugin-repository" );
|
|
||||||
pluginRepo.setUrl( "http://repo1.maven.org" );
|
|
||||||
|
|
||||||
ArtifactRepository pluginRepository = artifactRepositoryFactory.createArtifactRepository( pluginRepo, settings );
|
|
||||||
|
|
||||||
remotePluginRepositories.add( pluginRepository );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
|
@ -22,9 +22,11 @@ import org.apache.maven.artifact.MavenMetadataSource;
|
||||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||||
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.ArtifactRepositoryFactory;
|
||||||
|
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
|
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolver;
|
import org.apache.maven.artifact.resolver.ArtifactResolver;
|
||||||
|
import org.apache.maven.model.DistributionManagement;
|
||||||
import org.apache.maven.model.Model;
|
import org.apache.maven.model.Model;
|
||||||
import org.apache.maven.model.Parent;
|
import org.apache.maven.model.Parent;
|
||||||
import org.apache.maven.model.Repository;
|
import org.apache.maven.model.Repository;
|
||||||
|
@ -38,7 +40,12 @@ import org.apache.maven.project.validation.ModelValidationResult;
|
||||||
import org.apache.maven.project.validation.ModelValidator;
|
import org.apache.maven.project.validation.ModelValidator;
|
||||||
import org.apache.maven.settings.MavenSettings;
|
import org.apache.maven.settings.MavenSettings;
|
||||||
import org.apache.maven.settings.MavenSettingsBuilder;
|
import org.apache.maven.settings.MavenSettingsBuilder;
|
||||||
|
import org.codehaus.plexus.PlexusConstants;
|
||||||
|
import org.codehaus.plexus.PlexusContainer;
|
||||||
|
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
|
||||||
|
import org.codehaus.plexus.context.Context;
|
||||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||||
|
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
|
||||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
|
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
|
||||||
import org.codehaus.plexus.util.StringUtils;
|
import org.codehaus.plexus.util.StringUtils;
|
||||||
|
|
||||||
|
@ -61,8 +68,10 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
public class DefaultMavenProjectBuilder
|
public class DefaultMavenProjectBuilder
|
||||||
extends AbstractLogEnabled
|
extends AbstractLogEnabled
|
||||||
implements MavenProjectBuilder, Initializable
|
implements MavenProjectBuilder, Initializable, Contextualizable
|
||||||
{
|
{
|
||||||
|
private PlexusContainer container;
|
||||||
|
|
||||||
private ArtifactResolver artifactResolver;
|
private ArtifactResolver artifactResolver;
|
||||||
|
|
||||||
private ArtifactFactory artifactFactory;
|
private ArtifactFactory artifactFactory;
|
||||||
|
@ -100,8 +109,7 @@ public class DefaultMavenProjectBuilder
|
||||||
return build( project, localRepository, true, true );
|
return build( project, localRepository, true, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
public MavenProject build( File project, ArtifactRepository localRepository )
|
public MavenProject build( File project, ArtifactRepository localRepository ) throws ProjectBuildingException
|
||||||
throws ProjectBuildingException
|
|
||||||
{
|
{
|
||||||
return build( project, localRepository, false, true );
|
return build( project, localRepository, false, true );
|
||||||
}
|
}
|
||||||
|
@ -113,8 +121,7 @@ public class DefaultMavenProjectBuilder
|
||||||
}
|
}
|
||||||
|
|
||||||
private MavenProject build( File projectDescriptor, ArtifactRepository localRepository,
|
private MavenProject build( File projectDescriptor, ArtifactRepository localRepository,
|
||||||
boolean resolveDependencies, boolean sourceProject )
|
boolean resolveDependencies, boolean sourceProject ) throws ProjectBuildingException
|
||||||
throws ProjectBuildingException
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -137,7 +144,8 @@ public class DefaultMavenProjectBuilder
|
||||||
previous = current;
|
previous = current;
|
||||||
}
|
}
|
||||||
|
|
||||||
project = processProjectLogic( project, localRepository, resolveDependencies, sourceProject );
|
project = processProjectLogic( project, localRepository, aggregatedRemoteWagonRepositories,
|
||||||
|
resolveDependencies, sourceProject );
|
||||||
|
|
||||||
return project;
|
return project;
|
||||||
}
|
}
|
||||||
|
@ -148,7 +156,7 @@ public class DefaultMavenProjectBuilder
|
||||||
}
|
}
|
||||||
|
|
||||||
private MavenProject processProjectLogic( MavenProject project, ArtifactRepository localRepository,
|
private MavenProject processProjectLogic( MavenProject project, ArtifactRepository localRepository,
|
||||||
boolean resolveDependencies, boolean sourceProject )
|
List remoteRepositories, boolean resolveDependencies, boolean sourceProject )
|
||||||
throws ProjectBuildingException, ModelInterpolationException, ArtifactResolutionException
|
throws ProjectBuildingException, ModelInterpolationException, ArtifactResolutionException
|
||||||
{
|
{
|
||||||
Model model = project.getModel();
|
Model model = project.getModel();
|
||||||
|
@ -173,8 +181,34 @@ public class DefaultMavenProjectBuilder
|
||||||
}
|
}
|
||||||
|
|
||||||
project = new MavenProject( model );
|
project = new MavenProject( model );
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
project.setPluginArtifactRepositories( buildPluginRepositories( model.getPluginRepositories() ) );
|
||||||
|
}
|
||||||
|
catch ( Exception e )
|
||||||
|
{
|
||||||
|
throw new ProjectBuildingException( "Error building plugin repository list.", e );
|
||||||
|
}
|
||||||
|
|
||||||
|
DistributionManagement dm = model.getDistributionManagement();
|
||||||
|
if ( dm != null )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
project
|
||||||
|
.setDistributionManagementArtifactRepository( buildDistributionManagementRepository( dm
|
||||||
|
.getRepository() ) );
|
||||||
|
}
|
||||||
|
catch ( Exception e )
|
||||||
|
{
|
||||||
|
throw new ProjectBuildingException( "Error building distribution management repository.", e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
project.setFile( projectDescriptor );
|
project.setFile( projectDescriptor );
|
||||||
project.setParent( parentProject );
|
project.setParent( parentProject );
|
||||||
|
project.setRemoteArtifactRepositories( remoteRepositories );
|
||||||
project.setArtifacts( artifactFactory.createArtifacts( project.getDependencies(), localRepository, null ) );
|
project.setArtifacts( artifactFactory.createArtifacts( project.getDependencies(), localRepository, null ) );
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
@ -191,11 +225,10 @@ public class DefaultMavenProjectBuilder
|
||||||
|
|
||||||
if ( resolveDependencies )
|
if ( resolveDependencies )
|
||||||
{
|
{
|
||||||
List repos = buildArtifactRepositories( project.getRepositories() );
|
|
||||||
|
|
||||||
MavenMetadataSource sourceReader = new MavenMetadataSource( artifactResolver, this );
|
MavenMetadataSource sourceReader = new MavenMetadataSource( artifactResolver, this );
|
||||||
|
|
||||||
ArtifactResolutionResult result = artifactResolver.resolveTransitively( project.getArtifacts(), repos,
|
ArtifactResolutionResult result = artifactResolver.resolveTransitively( project.getArtifacts(),
|
||||||
|
remoteRepositories,
|
||||||
localRepository, sourceReader );
|
localRepository, sourceReader );
|
||||||
|
|
||||||
project.addArtifacts( result.getArtifacts().values() );
|
project.addArtifacts( result.getArtifacts().values() );
|
||||||
|
@ -228,8 +261,7 @@ public class DefaultMavenProjectBuilder
|
||||||
}
|
}
|
||||||
|
|
||||||
private MavenProject assembleLineage( Model model, ArtifactRepository localRepository, LinkedList lineage,
|
private MavenProject assembleLineage( Model model, ArtifactRepository localRepository, LinkedList lineage,
|
||||||
List aggregatedRemoteWagonRepositories )
|
List aggregatedRemoteWagonRepositories ) throws ProjectBuildingException
|
||||||
throws ProjectBuildingException
|
|
||||||
{
|
{
|
||||||
MavenProject project = new MavenProject( model );
|
MavenProject project = new MavenProject( model );
|
||||||
|
|
||||||
|
@ -261,8 +293,8 @@ public class DefaultMavenProjectBuilder
|
||||||
// as we go in order to do this.
|
// as we go in order to do this.
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
aggregatedRemoteWagonRepositories.addAll(
|
aggregatedRemoteWagonRepositories
|
||||||
buildArtifactRepositories( project.getModel().getRepositories() ) );
|
.addAll( buildArtifactRepositories( project.getModel().getRepositories() ) );
|
||||||
|
|
||||||
MavenProject parent;
|
MavenProject parent;
|
||||||
Model cachedModel = getCachedModel( parentModel.getGroupId(), parentModel.getArtifactId(),
|
Model cachedModel = getCachedModel( parentModel.getGroupId(), parentModel.getArtifactId(),
|
||||||
|
@ -283,8 +315,7 @@ public class DefaultMavenProjectBuilder
|
||||||
return project;
|
return project;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List buildArtifactRepositories( List repositories )
|
private List buildArtifactRepositories( List repositories ) throws ProjectBuildingException
|
||||||
throws ProjectBuildingException
|
|
||||||
{
|
{
|
||||||
MavenSettings settings = null;
|
MavenSettings settings = null;
|
||||||
|
|
||||||
|
@ -298,11 +329,26 @@ public class DefaultMavenProjectBuilder
|
||||||
}
|
}
|
||||||
|
|
||||||
List repos = new ArrayList();
|
List repos = new ArrayList();
|
||||||
|
|
||||||
|
// TODO: Replace with repository layout detection. This is a nasty hack.
|
||||||
|
String remoteRepoLayoutId = "legacy";
|
||||||
|
|
||||||
|
ArtifactRepositoryLayout remoteRepoLayout = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
remoteRepoLayout = (ArtifactRepositoryLayout) container.lookup( ArtifactRepositoryLayout.ROLE,
|
||||||
|
remoteRepoLayoutId );
|
||||||
|
}
|
||||||
|
catch ( ComponentLookupException e )
|
||||||
|
{
|
||||||
|
throw new ProjectBuildingException( "Cannot find repository layout for: \'" + remoteRepoLayoutId + "\'.", e );
|
||||||
|
}
|
||||||
for ( Iterator i = repositories.iterator(); i.hasNext(); )
|
for ( Iterator i = repositories.iterator(); i.hasNext(); )
|
||||||
{
|
{
|
||||||
Repository mavenRepo = (Repository) i.next();
|
Repository mavenRepo = (Repository) i.next();
|
||||||
|
|
||||||
ArtifactRepository artifactRepo = artifactRepositoryFactory.createArtifactRepository( mavenRepo, settings );
|
ArtifactRepository artifactRepo = artifactRepositoryFactory.createArtifactRepository( mavenRepo, settings,
|
||||||
|
remoteRepoLayout );
|
||||||
|
|
||||||
if ( !repos.contains( artifactRepo ) )
|
if ( !repos.contains( artifactRepo ) )
|
||||||
{
|
{
|
||||||
|
@ -312,8 +358,55 @@ public class DefaultMavenProjectBuilder
|
||||||
return repos;
|
return repos;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Model readModel( File file )
|
private List buildPluginRepositories( List pluginRepositories ) throws Exception
|
||||||
throws ProjectBuildingException
|
{
|
||||||
|
List remotePluginRepositories = new ArrayList();
|
||||||
|
|
||||||
|
// TODO: needs to be configured from the POM element
|
||||||
|
|
||||||
|
MavenSettings settings = mavenSettingsBuilder.buildSettings();
|
||||||
|
|
||||||
|
Repository pluginRepo = new Repository();
|
||||||
|
pluginRepo.setId( "plugin-repository" );
|
||||||
|
pluginRepo.setUrl( "http://repo1.maven.org" );
|
||||||
|
|
||||||
|
// TODO: [jc] change this to detect the repository layout type somehow...
|
||||||
|
String repoLayoutId = "legacy";
|
||||||
|
|
||||||
|
ArtifactRepositoryLayout repositoryLayout = (ArtifactRepositoryLayout) container
|
||||||
|
.lookup(
|
||||||
|
ArtifactRepositoryLayout.ROLE,
|
||||||
|
repoLayoutId );
|
||||||
|
|
||||||
|
ArtifactRepository pluginRepository = artifactRepositoryFactory.createArtifactRepository( pluginRepo, settings,
|
||||||
|
repositoryLayout );
|
||||||
|
|
||||||
|
remotePluginRepositories.add( pluginRepository );
|
||||||
|
|
||||||
|
return remotePluginRepositories;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ArtifactRepository buildDistributionManagementRepository( Repository dmRepo ) throws Exception
|
||||||
|
{
|
||||||
|
// TODO: needs to be configured from the POM element
|
||||||
|
|
||||||
|
MavenSettings settings = mavenSettingsBuilder.buildSettings();
|
||||||
|
|
||||||
|
// TODO: [jc] change this to detect the repository layout type somehow...
|
||||||
|
String repoLayoutId = "legacy";
|
||||||
|
|
||||||
|
ArtifactRepositoryLayout repositoryLayout = (ArtifactRepositoryLayout) container
|
||||||
|
.lookup(
|
||||||
|
ArtifactRepositoryLayout.ROLE,
|
||||||
|
repoLayoutId );
|
||||||
|
|
||||||
|
ArtifactRepository dmArtifactRepository = artifactRepositoryFactory.createArtifactRepository( dmRepo, settings,
|
||||||
|
repositoryLayout );
|
||||||
|
|
||||||
|
return dmArtifactRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Model readModel( File file ) throws ProjectBuildingException
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -326,12 +419,12 @@ public class DefaultMavenProjectBuilder
|
||||||
catch ( Exception e )
|
catch ( Exception e )
|
||||||
{
|
{
|
||||||
throw new ProjectBuildingException(
|
throw new ProjectBuildingException(
|
||||||
"Error while reading model from file '" + file.getAbsolutePath() + "'.", e );
|
"Error while reading model from file '" + file.getAbsolutePath() + "'.",
|
||||||
|
e );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Model readModel( URL url )
|
private Model readModel( URL url ) throws ProjectBuildingException
|
||||||
throws ProjectBuildingException
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -360,8 +453,8 @@ public class DefaultMavenProjectBuilder
|
||||||
catch ( ArtifactResolutionException e )
|
catch ( ArtifactResolutionException e )
|
||||||
{
|
{
|
||||||
// @todo use parent.toString() if modello could generate it, or specify in a code segment
|
// @todo use parent.toString() if modello could generate it, or specify in a code segment
|
||||||
throw new ProjectBuildingException( "Missing parent POM: " + parent.getGroupId() + ":" +
|
throw new ProjectBuildingException( "Missing parent POM: " + parent.getGroupId() + ":"
|
||||||
parent.getArtifactId() + "-" + parent.getVersion(), e );
|
+ parent.getArtifactId() + "-" + parent.getVersion(), e );
|
||||||
}
|
}
|
||||||
|
|
||||||
return artifact.getFile();
|
return artifact.getFile();
|
||||||
|
@ -394,7 +487,9 @@ public class DefaultMavenProjectBuilder
|
||||||
{
|
{
|
||||||
project.setFile( new File( ".", "pom.xml" ) );
|
project.setFile( new File( ".", "pom.xml" ) );
|
||||||
|
|
||||||
project = processProjectLogic( project, localRepository, false, false );
|
List remoteRepositories = buildArtifactRepositories( superModel.getRepositories() );
|
||||||
|
|
||||||
|
project = processProjectLogic( project, localRepository, remoteRepositories, false, false );
|
||||||
|
|
||||||
return project;
|
return project;
|
||||||
}
|
}
|
||||||
|
@ -412,11 +507,15 @@ public class DefaultMavenProjectBuilder
|
||||||
//
|
//
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
private Model getSuperModel()
|
private Model getSuperModel() throws ProjectBuildingException
|
||||||
throws ProjectBuildingException
|
|
||||||
{
|
{
|
||||||
URL url = DefaultMavenProjectBuilder.class.getResource( "pom-" + MavenConstants.MAVEN_MODEL_VERSION + ".xml" );
|
URL url = DefaultMavenProjectBuilder.class.getResource( "pom-" + MavenConstants.MAVEN_MODEL_VERSION + ".xml" );
|
||||||
|
|
||||||
return readModel( url );
|
return readModel( url );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void contextualize( Context context ) throws Exception
|
||||||
|
{
|
||||||
|
this.container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -19,6 +19,7 @@ package org.apache.maven.project;
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.construction.ArtifactConstructionSupport;
|
import org.apache.maven.artifact.construction.ArtifactConstructionSupport;
|
||||||
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
import org.apache.maven.model.Build;
|
import org.apache.maven.model.Build;
|
||||||
import org.apache.maven.model.CiManagement;
|
import org.apache.maven.model.CiManagement;
|
||||||
import org.apache.maven.model.Contributor;
|
import org.apache.maven.model.Contributor;
|
||||||
|
@ -73,6 +74,8 @@ public class MavenProject
|
||||||
|
|
||||||
private Set artifacts;
|
private Set artifacts;
|
||||||
|
|
||||||
|
private List remoteArtifactRepositories;
|
||||||
|
|
||||||
private List collectedProjects = Collections.EMPTY_LIST;
|
private List collectedProjects = Collections.EMPTY_LIST;
|
||||||
|
|
||||||
private ArtifactConstructionSupport artifactConstructionSupport = new ArtifactConstructionSupport();
|
private ArtifactConstructionSupport artifactConstructionSupport = new ArtifactConstructionSupport();
|
||||||
|
@ -102,6 +105,16 @@ public class MavenProject
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRemoteArtifactRepositories( List remoteArtifactRepositories )
|
||||||
|
{
|
||||||
|
this.remoteArtifactRepositories = remoteArtifactRepositories;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List getRemoteArtifactRepositories()
|
||||||
|
{
|
||||||
|
return remoteArtifactRepositories;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasParent()
|
public boolean hasParent()
|
||||||
{
|
{
|
||||||
return getParent() != null;
|
return getParent() != null;
|
||||||
|
@ -147,6 +160,10 @@ public class MavenProject
|
||||||
|
|
||||||
private List scriptSourceRoots = new ArrayList();
|
private List scriptSourceRoots = new ArrayList();
|
||||||
|
|
||||||
|
private List pluginArtifactRepositories;
|
||||||
|
|
||||||
|
private ArtifactRepository distMgmtArtifactRepository;
|
||||||
|
|
||||||
public void addCompileSourceRoot( String path )
|
public void addCompileSourceRoot( String path )
|
||||||
{
|
{
|
||||||
if ( path != null )
|
if ( path != null )
|
||||||
|
@ -237,8 +254,8 @@ public class MavenProject
|
||||||
if ( isAddedToClasspath( a ) )
|
if ( isAddedToClasspath( a ) )
|
||||||
{
|
{
|
||||||
// TODO: let the scope handler deal with this
|
// TODO: let the scope handler deal with this
|
||||||
if ( Artifact.SCOPE_TEST.equals( a.getScope() ) || Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_RUNTIME.equals(
|
if ( Artifact.SCOPE_TEST.equals( a.getScope() ) || Artifact.SCOPE_COMPILE.equals( a.getScope() )
|
||||||
a.getScope() ) )
|
|| Artifact.SCOPE_RUNTIME.equals( a.getScope() ) )
|
||||||
{
|
{
|
||||||
list.add( a.getPath() );
|
list.add( a.getPath() );
|
||||||
}
|
}
|
||||||
|
@ -592,8 +609,7 @@ public class MavenProject
|
||||||
* <li>do a topo sort on the graph that remains.</li>
|
* <li>do a topo sort on the graph that remains.</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
public static List getSortedProjects( List projects )
|
public static List getSortedProjects( List projects ) throws CycleDetectedException
|
||||||
throws CycleDetectedException
|
|
||||||
{
|
{
|
||||||
DAG dag = new DAG();
|
DAG dag = new DAG();
|
||||||
|
|
||||||
|
@ -652,7 +668,7 @@ public class MavenProject
|
||||||
|
|
||||||
public void addArtifacts( Collection newArtifacts )
|
public void addArtifacts( Collection newArtifacts )
|
||||||
{
|
{
|
||||||
// project.getArtifacts().addAll( result.getArtifacts().values() );
|
// project.getArtifacts().addAll( result.getArtifacts().values() );
|
||||||
// We need to override the scope if one declared it higher
|
// We need to override the scope if one declared it higher
|
||||||
// TODO: could surely be more efficient, and use the scope handler, be part of maven-artifact...
|
// TODO: could surely be more efficient, and use the scope handler, be part of maven-artifact...
|
||||||
Map artifacts = new HashMap();
|
Map artifacts = new HashMap();
|
||||||
|
@ -669,14 +685,13 @@ public class MavenProject
|
||||||
{
|
{
|
||||||
Artifact existing = (Artifact) artifacts.get( id );
|
Artifact existing = (Artifact) artifacts.get( id );
|
||||||
boolean updateScope = false;
|
boolean updateScope = false;
|
||||||
if ( Artifact.SCOPE_RUNTIME.equals( a.getScope() ) &&
|
if ( Artifact.SCOPE_RUNTIME.equals( a.getScope() ) && Artifact.SCOPE_TEST.equals( existing.getScope() ) )
|
||||||
Artifact.SCOPE_TEST.equals( existing.getScope() ) )
|
|
||||||
{
|
{
|
||||||
updateScope = true;
|
updateScope = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) &&
|
if ( Artifact.SCOPE_COMPILE.equals( a.getScope() )
|
||||||
!Artifact.SCOPE_COMPILE.equals( existing.getScope() ) )
|
&& !Artifact.SCOPE_COMPILE.equals( existing.getScope() ) )
|
||||||
{
|
{
|
||||||
updateScope = true;
|
updateScope = true;
|
||||||
}
|
}
|
||||||
|
@ -688,8 +703,7 @@ public class MavenProject
|
||||||
Artifact artifact = artifactConstructionSupport.createArtifact( existing.getGroupId(),
|
Artifact artifact = artifactConstructionSupport.createArtifact( existing.getGroupId(),
|
||||||
existing.getArtifactId(),
|
existing.getArtifactId(),
|
||||||
existing.getVersion(),
|
existing.getVersion(),
|
||||||
a.getScope(),
|
a.getScope(), existing.getType(),
|
||||||
existing.getType(),
|
|
||||||
existing.getExtension() );
|
existing.getExtension() );
|
||||||
|
|
||||||
artifacts.put( id, artifact );
|
artifacts.put( id, artifact );
|
||||||
|
@ -702,5 +716,26 @@ public class MavenProject
|
||||||
}
|
}
|
||||||
setArtifacts( new HashSet( artifacts.values() ) );
|
setArtifacts( new HashSet( artifacts.values() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setPluginArtifactRepositories( List pluginArtifactRepositories )
|
||||||
|
{
|
||||||
|
this.pluginArtifactRepositories = pluginArtifactRepositories;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List getPluginArtifactRepositories()
|
||||||
|
{
|
||||||
|
return pluginArtifactRepositories;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDistributionManagementArtifactRepository( ArtifactRepository distMgmtArtifactRepository )
|
||||||
|
{
|
||||||
|
this.distMgmtArtifactRepository = distMgmtArtifactRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArtifactRepository getDistributionManagementArtifactRepository()
|
||||||
|
{
|
||||||
|
return distMgmtArtifactRepository;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ package org.apache.maven;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||||
import org.apache.maven.plugin.PluginManager;
|
import org.apache.maven.plugin.PluginManager;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
import org.apache.maven.project.MavenProjectBuilder;
|
import org.apache.maven.project.MavenProjectBuilder;
|
||||||
|
@ -36,8 +37,7 @@ public class MavenTestCase
|
||||||
|
|
||||||
protected MavenProjectBuilder projectBuilder;
|
protected MavenProjectBuilder projectBuilder;
|
||||||
|
|
||||||
protected void setUp()
|
protected void setUp() throws Exception
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
super.setUp();
|
super.setUp();
|
||||||
|
|
||||||
|
@ -70,9 +70,13 @@ public class MavenTestCase
|
||||||
return resourceFile;
|
return resourceFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ArtifactRepository getLocalRepository()
|
protected ArtifactRepository getLocalRepository() throws Exception
|
||||||
{
|
{
|
||||||
ArtifactRepository r = new ArtifactRepository( "local", "file://" + getLocalRepositoryPath().getAbsolutePath() );
|
ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE,
|
||||||
|
"legacy" );
|
||||||
|
|
||||||
|
ArtifactRepository r = new ArtifactRepository( "local", "file://" + getLocalRepositoryPath().getAbsolutePath(),
|
||||||
|
repoLayout );
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -81,14 +85,12 @@ public class MavenTestCase
|
||||||
// Project building
|
// Project building
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
protected MavenProject getProjectWithDependencies( File pom )
|
protected MavenProject getProjectWithDependencies( File pom ) throws Exception
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
return projectBuilder.buildWithDependencies( pom, getLocalRepository() );
|
return projectBuilder.buildWithDependencies( pom, getLocalRepository() );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected MavenProject getProject( File pom )
|
protected MavenProject getProject( File pom ) throws Exception
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
return projectBuilder.build( pom, getLocalRepository() );
|
return projectBuilder.build( pom, getLocalRepository() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package org.apache.maven.plugin;
|
||||||
|
|
||||||
import org.apache.maven.MavenTestCase;
|
import org.apache.maven.MavenTestCase;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||||
import org.apache.maven.execution.MavenSession;
|
import org.apache.maven.execution.MavenSession;
|
||||||
import org.apache.maven.model.Build;
|
import org.apache.maven.model.Build;
|
||||||
import org.apache.maven.model.Model;
|
import org.apache.maven.model.Model;
|
||||||
|
@ -37,17 +38,13 @@ public class PluginParameterExpressionEvaluatorTest
|
||||||
{
|
{
|
||||||
String expected = getTestFile( "target/test-classes/target/classes" ).getCanonicalPath();
|
String expected = getTestFile( "target/test-classes/target/classes" ).getCanonicalPath();
|
||||||
|
|
||||||
ArtifactRepository repo = new ArtifactRepository( "local", "here" );
|
ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE,
|
||||||
|
"legacy" );
|
||||||
|
|
||||||
|
ArtifactRepository repo = new ArtifactRepository( "local", "here", repoLayout );
|
||||||
PluginManager mgr = (PluginManager) lookup( PluginManager.ROLE );
|
PluginManager mgr = (PluginManager) lookup( PluginManager.ROLE );
|
||||||
|
|
||||||
PlexusContainer container = getContainer();
|
PlexusContainer container = getContainer();
|
||||||
MavenSession session = new MavenSession( container,
|
|
||||||
mgr,
|
|
||||||
new MavenSettings(),
|
|
||||||
repo,
|
|
||||||
new DefaultEventDispatcher(),
|
|
||||||
new DefaultLog( container.getLogger() ),
|
|
||||||
Collections.EMPTY_LIST );
|
|
||||||
|
|
||||||
Build build = new Build();
|
Build build = new Build();
|
||||||
build.setDirectory( expected.substring( 0, expected.length() - "/classes".length() ) );
|
build.setDirectory( expected.substring( 0, expected.length() - "/classes".length() ) );
|
||||||
|
@ -58,7 +55,9 @@ public class PluginParameterExpressionEvaluatorTest
|
||||||
MavenProject project = new MavenProject( model );
|
MavenProject project = new MavenProject( model );
|
||||||
project.setFile( new File( "pom.xml" ).getCanonicalFile() );
|
project.setFile( new File( "pom.xml" ).getCanonicalFile() );
|
||||||
|
|
||||||
session.setProject( project );
|
MavenSession session = new MavenSession( project, container, mgr, new MavenSettings(), repo,
|
||||||
|
new DefaultEventDispatcher(), new DefaultLog( container.getLogger() ),
|
||||||
|
Collections.EMPTY_LIST );
|
||||||
|
|
||||||
Object value = PluginParameterExpressionEvaluator.evaluate( "#project.build.directory/classes", session );
|
Object value = PluginParameterExpressionEvaluator.evaluate( "#project.build.directory/classes", session );
|
||||||
|
|
||||||
|
@ -74,17 +73,18 @@ public class PluginParameterExpressionEvaluatorTest
|
||||||
{
|
{
|
||||||
String role = "#component.org.apache.maven.project.MavenProjectBuilder";
|
String role = "#component.org.apache.maven.project.MavenProjectBuilder";
|
||||||
|
|
||||||
ArtifactRepository repo = new ArtifactRepository( "test", "http://www.test.com" );
|
ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE,
|
||||||
|
"legacy" );
|
||||||
|
|
||||||
|
ArtifactRepository repo = new ArtifactRepository( "test", "http://www.test.com", repoLayout );
|
||||||
PluginManager mgr = (PluginManager) lookup( PluginManager.ROLE );
|
PluginManager mgr = (PluginManager) lookup( PluginManager.ROLE );
|
||||||
|
|
||||||
PlexusContainer container = getContainer();
|
PlexusContainer container = getContainer();
|
||||||
MavenSession session = new MavenSession( container,
|
MavenSession session = new MavenSession( null, // don't need a project for this test.
|
||||||
mgr,
|
container, mgr, new MavenSettings(), repo,
|
||||||
new MavenSettings(),
|
new DefaultEventDispatcher(), new DefaultLog( container.getLogger() ),
|
||||||
repo,
|
|
||||||
new DefaultEventDispatcher(),
|
|
||||||
new DefaultLog( container.getLogger() ),
|
|
||||||
Collections.EMPTY_LIST );
|
Collections.EMPTY_LIST );
|
||||||
|
|
||||||
Object value = PluginParameterExpressionEvaluator.evaluate( role, session );
|
Object value = PluginParameterExpressionEvaluator.evaluate( role, session );
|
||||||
|
|
||||||
assertNotNull( value );
|
assertNotNull( value );
|
||||||
|
@ -92,20 +92,20 @@ public class PluginParameterExpressionEvaluatorTest
|
||||||
|
|
||||||
public void testLocalRepositoryExtraction() throws Exception
|
public void testLocalRepositoryExtraction() throws Exception
|
||||||
{
|
{
|
||||||
ArtifactRepository repo = new ArtifactRepository( "local", "target/repo" );
|
ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE,
|
||||||
|
"legacy" );
|
||||||
|
|
||||||
|
ArtifactRepository repo = new ArtifactRepository( "local", "target/repo", repoLayout );
|
||||||
PluginManager mgr = (PluginManager) lookup( PluginManager.ROLE );
|
PluginManager mgr = (PluginManager) lookup( PluginManager.ROLE );
|
||||||
|
|
||||||
PlexusContainer container = getContainer();
|
PlexusContainer container = getContainer();
|
||||||
MavenSession session = new MavenSession( container,
|
MavenSession session = new MavenSession( null, // don't need a project for this test.
|
||||||
mgr,
|
container, mgr, new MavenSettings(), repo,
|
||||||
new MavenSettings(),
|
new DefaultEventDispatcher(), new DefaultLog( container.getLogger() ),
|
||||||
repo,
|
|
||||||
new DefaultEventDispatcher(),
|
|
||||||
new DefaultLog( container.getLogger() ),
|
|
||||||
Collections.EMPTY_LIST );
|
Collections.EMPTY_LIST );
|
||||||
|
|
||||||
Object value = PluginParameterExpressionEvaluator.evaluate( "#localRepository", session );
|
Object value = PluginParameterExpressionEvaluator.evaluate( "#localRepository", session );
|
||||||
|
|
||||||
assertEquals( "local", ((ArtifactRepository) value).getId() );
|
assertEquals( "local", ( (ArtifactRepository) value ).getId() );
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -20,7 +20,6 @@ import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.MavenMetadataSource;
|
import org.apache.maven.artifact.MavenMetadataSource;
|
||||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||||
import org.apache.maven.artifact.factory.DefaultArtifactFactory;
|
import org.apache.maven.artifact.factory.DefaultArtifactFactory;
|
||||||
import org.apache.maven.artifact.handler.manager.ArtifactHandlerNotFoundException;
|
|
||||||
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.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
@ -75,25 +74,29 @@ public class ProjectClasspathArtifactResolver
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setLocalRepositoryPath( Artifact artifact, ArtifactRepository localRepository )
|
protected void setLocalRepositoryPath( Artifact artifact, ArtifactRepository localRepository )
|
||||||
throws ArtifactHandlerNotFoundException
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArtifactResolutionResult resolveTransitively( Set artifacts, List remoteRepositories,
|
public ArtifactResolutionResult resolveTransitively( Set artifacts, List remoteRepositories,
|
||||||
ArtifactRepository localRepository, ArtifactMetadataSource source, ArtifactFilter filter )
|
ArtifactRepository localRepository,
|
||||||
|
ArtifactMetadataSource source, ArtifactFilter filter )
|
||||||
throws ArtifactResolutionException
|
throws ArtifactResolutionException
|
||||||
{
|
{
|
||||||
return super.resolveTransitively( artifacts, remoteRepositories, localRepository, new Source( this ), filter );
|
return super.resolveTransitively( artifacts, remoteRepositories, localRepository, new Source( this ), filter );
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArtifactResolutionResult resolveTransitively( Set artifacts, List remoteRepositories,
|
public ArtifactResolutionResult resolveTransitively( Set artifacts, List remoteRepositories,
|
||||||
ArtifactRepository localRepository, ArtifactMetadataSource source ) throws ArtifactResolutionException
|
ArtifactRepository localRepository,
|
||||||
|
ArtifactMetadataSource source )
|
||||||
|
throws ArtifactResolutionException
|
||||||
{
|
{
|
||||||
return super.resolveTransitively( artifacts, remoteRepositories, localRepository, new Source( this ) );
|
return super.resolveTransitively( artifacts, remoteRepositories, localRepository, new Source( this ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArtifactResolutionResult resolveTransitively( Artifact artifact, List remoteRepositories,
|
public ArtifactResolutionResult resolveTransitively( Artifact artifact, List remoteRepositories,
|
||||||
ArtifactRepository localRepository, ArtifactMetadataSource source ) throws ArtifactResolutionException
|
ArtifactRepository localRepository,
|
||||||
|
ArtifactMetadataSource source )
|
||||||
|
throws ArtifactResolutionException
|
||||||
{
|
{
|
||||||
return super.resolveTransitively( artifact, remoteRepositories, localRepository, new Source( this ) );
|
return super.resolveTransitively( artifact, remoteRepositories, localRepository, new Source( this ) );
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,14 +20,10 @@ import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.DefaultArtifact;
|
import org.apache.maven.artifact.DefaultArtifact;
|
||||||
import org.apache.maven.artifact.deployer.ArtifactDeployer;
|
import org.apache.maven.artifact.deployer.ArtifactDeployer;
|
||||||
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.model.DistributionManagement;
|
|
||||||
import org.apache.maven.model.Repository;
|
|
||||||
import org.apache.maven.plugin.AbstractPlugin;
|
import org.apache.maven.plugin.AbstractPlugin;
|
||||||
import org.apache.maven.plugin.PluginExecutionRequest;
|
import org.apache.maven.plugin.PluginExecutionRequest;
|
||||||
import org.apache.maven.plugin.PluginExecutionResponse;
|
import org.apache.maven.plugin.PluginExecutionResponse;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
import org.apache.maven.settings.MavenSettings;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
@ -51,19 +47,11 @@ import java.io.File;
|
||||||
* description=""
|
* description=""
|
||||||
*
|
*
|
||||||
* @parameter
|
* @parameter
|
||||||
* name="artifactRepositoryFactory"
|
* name="deploymentRepository"
|
||||||
* type="org.apache.maven.artifact.repository.ArtifactRepositoryFactory"
|
* type="org.apache.maven.artifact.repository.ArtifactRepository"
|
||||||
* required="true"
|
* required="true"
|
||||||
* validator=""
|
* validator=""
|
||||||
* expression="#component.org.apache.maven.artifact.repository.ArtifactRepositoryFactory"
|
* expression="#project.distributionManagementArtifactRepository"
|
||||||
* description=""
|
|
||||||
*
|
|
||||||
* @parameter
|
|
||||||
* name="settings"
|
|
||||||
* type="org.apache.maven.settings.MavenSettings"
|
|
||||||
* required="true"
|
|
||||||
* validator=""
|
|
||||||
* expression="#settings"
|
|
||||||
* description=""
|
* description=""
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse </a>
|
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse </a>
|
||||||
|
@ -73,39 +61,26 @@ public abstract class AbstractDeployMojo
|
||||||
extends AbstractPlugin
|
extends AbstractPlugin
|
||||||
{
|
{
|
||||||
|
|
||||||
public void execute( PluginExecutionRequest request, PluginExecutionResponse response )
|
public void execute( PluginExecutionRequest request, PluginExecutionResponse response ) throws Exception
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
MavenProject project = (MavenProject) request.getParameter( "project" );
|
MavenProject project = (MavenProject) request.getParameter( "project" );
|
||||||
|
|
||||||
ArtifactDeployer artifactDeployer = (ArtifactDeployer) request.getParameter( "deployer" );
|
ArtifactDeployer artifactDeployer = (ArtifactDeployer) request.getParameter( "deployer" );
|
||||||
|
|
||||||
ArtifactRepositoryFactory artifactRepositoryFactory = (ArtifactRepositoryFactory) request.getParameter( "artifactRepositoryFactory" );
|
ArtifactRepository deploymentRepository = (ArtifactRepository) request.getParameter( "deploymentRepository" );
|
||||||
|
|
||||||
MavenSettings settings = (MavenSettings) request.getParameter( "settings" );
|
if ( deploymentRepository == null )
|
||||||
|
|
||||||
DistributionManagement distributionManagement = project.getDistributionManagement();
|
|
||||||
|
|
||||||
if ( distributionManagement == null )
|
|
||||||
{
|
{
|
||||||
String msg = "Deployment failed: distributionManagement element" + " was not specified in the pom";
|
String msg = "Deployment failed: repository element" + " was not specified in the pom inside"
|
||||||
|
+ " distributionManagement element";
|
||||||
throw new Exception( msg );
|
throw new Exception( msg );
|
||||||
}
|
}
|
||||||
|
|
||||||
Repository repository = distributionManagement.getRepository();
|
if ( deploymentRepository.getAuthenticationInfo() == null )
|
||||||
|
|
||||||
if ( repository == null )
|
|
||||||
{
|
{
|
||||||
String msg = "Deployment failed: repository element" + " was not specified in the pom inside" +
|
getLog().warn(
|
||||||
" distributionManagement element";
|
"Deployment repository {id: \'" + deploymentRepository.getId()
|
||||||
throw new Exception( msg );
|
+ "\'} has no associated authentication info!" );
|
||||||
}
|
|
||||||
|
|
||||||
ArtifactRepository deploymentRepository = artifactRepositoryFactory.createArtifactRepository( repository, settings );
|
|
||||||
|
|
||||||
if(deploymentRepository.getAuthenticationInfo() == null)
|
|
||||||
{
|
|
||||||
getLog().warn("Deployment repository {id: \'" + repository.getId() + "\'} has no associated authentication info!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deploy the POM
|
// Deploy the POM
|
||||||
|
|
|
@ -38,19 +38,11 @@ package org.apache.maven.plugin.deploy;
|
||||||
* description=""
|
* description=""
|
||||||
*
|
*
|
||||||
* @parameter
|
* @parameter
|
||||||
* name="artifactRepositoryFactory"
|
* name="deploymentRepository"
|
||||||
* type="org.apache.maven.artifact.repository.ArtifactRepositoryFactory"
|
* type="org.apache.maven.artifact.repository.ArtifactRepository"
|
||||||
* required="true"
|
* required="true"
|
||||||
* validator=""
|
* validator=""
|
||||||
* expression="#component.org.apache.maven.artifact.repository.ArtifactRepositoryFactory"
|
* expression="#project.distributionManagementArtifactRepository"
|
||||||
* description=""
|
|
||||||
*
|
|
||||||
* @parameter
|
|
||||||
* name="settings"
|
|
||||||
* type="org.apache.maven.settings.MavenSettings"
|
|
||||||
* required="true"
|
|
||||||
* validator=""
|
|
||||||
* expression="#settings"
|
|
||||||
* description=""
|
* description=""
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
|
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.apache.maven.plugin.jar;
|
package org.apache.maven.plugin.ejb;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2001-2005 The Apache Software Foundation.
|
* Copyright 2001-2005 The Apache Software Foundation.
|
||||||
|
@ -113,8 +113,7 @@ public class EjbMojo
|
||||||
/**
|
/**
|
||||||
* @todo Add license files in META-INF directory.
|
* @todo Add license files in META-INF directory.
|
||||||
*/
|
*/
|
||||||
public void execute( PluginExecutionRequest request, PluginExecutionResponse response )
|
public void execute( PluginExecutionRequest request, PluginExecutionResponse response ) throws Exception
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
|
@ -142,8 +141,8 @@ public class EjbMojo
|
||||||
|
|
||||||
String ejbJarXmlFile = "META-INF/ejb-jar.xml";
|
String ejbJarXmlFile = "META-INF/ejb-jar.xml";
|
||||||
|
|
||||||
archiver.getArchiver().addDirectory( new File( outputDirectory ), new String[]{"**/**"},
|
archiver.getArchiver().addDirectory( new File( outputDirectory ), new String[] { "**/**" },
|
||||||
new String[]{ejbJarXmlFile, "**/package.html"} );
|
new String[] { ejbJarXmlFile, "**/package.html" } );
|
||||||
|
|
||||||
archiver.getArchiver().addFile( new File( outputDirectory, ejbJarXmlFile ), ejbJarXmlFile );
|
archiver.getArchiver().addFile( new File( outputDirectory, ejbJarXmlFile ), ejbJarXmlFile );
|
||||||
|
|
||||||
|
@ -160,9 +159,14 @@ public class EjbMojo
|
||||||
|
|
||||||
clientArchiver.setOutputFile( jarFile );
|
clientArchiver.setOutputFile( jarFile );
|
||||||
|
|
||||||
clientArchiver.getArchiver().addDirectory( new File( outputDirectory ), new String[]{"**/**"},
|
clientArchiver.getArchiver().addDirectory(
|
||||||
new String[]{"**/*Bean.class", "**/*CMP.class",
|
new File( outputDirectory ),
|
||||||
"**/*Session.class", "**/package.html"} );
|
new String[] { "**/**" },
|
||||||
|
new String[] {
|
||||||
|
"**/*Bean.class",
|
||||||
|
"**/*CMP.class",
|
||||||
|
"**/*Session.class",
|
||||||
|
"**/package.html" } );
|
||||||
|
|
||||||
// create archive
|
// create archive
|
||||||
clientArchiver.createArchive( request );
|
clientArchiver.createArchive( request );
|
||||||
|
|
|
@ -30,46 +30,51 @@ import org.apache.maven.project.MavenProject;
|
||||||
/**
|
/**
|
||||||
* @goal deploy
|
* @goal deploy
|
||||||
* @description deploys a JAR to remote repository
|
* @description deploys a JAR to remote repository
|
||||||
* @parameter name="project" type="org.apache.maven.project.MavenProject"
|
* @parameter name="project"
|
||||||
* required="true" validator="" expression="#project" description=""
|
* type="org.apache.maven.project.MavenProject"
|
||||||
|
* required="true"
|
||||||
|
* validator=""
|
||||||
|
* expression="#project"
|
||||||
|
* description=""
|
||||||
* @parameter name="deployer"
|
* @parameter name="deployer"
|
||||||
* type="org.apache.maven.artifact.deployer.ArtifactDeployer"
|
* type="org.apache.maven.artifact.deployer.ArtifactDeployer"
|
||||||
* required="true" validator=""
|
* required="true" validator=""
|
||||||
* expression="#component.org.apache.maven.artifact.deployer.ArtifactDeployer"
|
* expression="#component.org.apache.maven.artifact.deployer.ArtifactDeployer"
|
||||||
* description=""
|
* description=""
|
||||||
|
* @parameter
|
||||||
|
* name="deploymentRepository"
|
||||||
|
* type="org.apache.maven.artifact.repository.ArtifactRepository"
|
||||||
|
* required="true"
|
||||||
|
* validator=""
|
||||||
|
* expression="#project.distributionManagementArtifactRepository"
|
||||||
|
* description=""
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public class JarDeployMojo
|
public class JarDeployMojo
|
||||||
extends AbstractPlugin
|
extends AbstractPlugin
|
||||||
{
|
{
|
||||||
public void execute( PluginExecutionRequest request, PluginExecutionResponse response )
|
public void execute( PluginExecutionRequest request, PluginExecutionResponse response ) throws Exception
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
MavenProject project = (MavenProject) request.getParameter( "project" );
|
MavenProject project = (MavenProject) request.getParameter( "project" );
|
||||||
|
|
||||||
ArtifactDeployer artifactDeployer = (ArtifactDeployer) request.getParameter( "deployer" );
|
ArtifactDeployer artifactDeployer = (ArtifactDeployer) request.getParameter( "deployer" );
|
||||||
|
|
||||||
//@todo this will be duplicated in case of every mojo which implements
|
ArtifactRepository deploymentRepository = (ArtifactRepository) request.getParameter( "deploymentRepository" );
|
||||||
// deploy goal
|
|
||||||
// this should be pushed into the ArtifactDeployer component
|
|
||||||
DistributionManagement distributionManagement = project.getDistributionManagement();
|
|
||||||
|
|
||||||
if ( distributionManagement == null )
|
if ( deploymentRepository == null )
|
||||||
{
|
{
|
||||||
String msg = "Deployment failed: distributionManagement element" + " was not specified in the pom";
|
String msg = "Deployment failed: repository element" + " was not specified in the pom inside"
|
||||||
|
+ " distributionManagement element";
|
||||||
throw new Exception( msg );
|
throw new Exception( msg );
|
||||||
}
|
}
|
||||||
|
|
||||||
Repository repository = distributionManagement.getRepository();
|
if ( deploymentRepository.getAuthenticationInfo() == null )
|
||||||
|
|
||||||
if ( repository == null )
|
|
||||||
{
|
{
|
||||||
String msg = "Deployment failed: repository element" + " was not specified in the pom inside" +
|
getLog().warn(
|
||||||
" distributionManagement element";
|
"Deployment repository {id: \'" + deploymentRepository.getId()
|
||||||
throw new Exception( msg );
|
+ "\'} has no associated authentication info!" );
|
||||||
}
|
}
|
||||||
|
|
||||||
ArtifactRepository deploymentRepository = new ArtifactRepository( repository.getId(), repository.getUrl() );
|
|
||||||
|
|
||||||
Artifact artifact = new DefaultArtifact( project.getGroupId(), project.getArtifactId(), project.getVersion(),
|
Artifact artifact = new DefaultArtifact( project.getGroupId(), project.getArtifactId(), project.getVersion(),
|
||||||
project.getPackaging() );
|
project.getPackaging() );
|
||||||
|
|
||||||
|
|
|
@ -33,11 +33,10 @@ import java.io.File;
|
||||||
/**
|
/**
|
||||||
* @goal deploy
|
* @goal deploy
|
||||||
* @description deploys a pom to remote repository
|
* @description deploys a pom to remote repository
|
||||||
* @parameter name="project" type="org.apache.maven.project.MavenProject"
|
|
||||||
* required="true" validator="" expression="#project" description=""
|
|
||||||
* @parameter name="deployer"
|
* @parameter name="deployer"
|
||||||
* type="org.apache.maven.artifact.deployer.ArtifactDeployer"
|
* type="org.apache.maven.artifact.deployer.ArtifactDeployer"
|
||||||
* required="true" validator=""
|
* required="true"
|
||||||
|
* validator=""
|
||||||
* expression="#component.org.apache.maven.artifact.deployer.ArtifactDeployer"
|
* expression="#component.org.apache.maven.artifact.deployer.ArtifactDeployer"
|
||||||
* description=""
|
* description=""
|
||||||
* @parameter name="project"
|
* @parameter name="project"
|
||||||
|
@ -52,48 +51,37 @@ import java.io.File;
|
||||||
* validator=""
|
* validator=""
|
||||||
* expression="#component.org.apache.maven.artifact.deployer.ArtifactDeployer"
|
* expression="#component.org.apache.maven.artifact.deployer.ArtifactDeployer"
|
||||||
* description=""
|
* description=""
|
||||||
* @parameter name="artifactRepositoryFactory"
|
* @parameter
|
||||||
* type="org.apache.maven.artifact.repository.ArtifactRepositoryFactory"
|
* name="deploymentRepository"
|
||||||
|
* type="org.apache.maven.artifact.repository.ArtifactRepository"
|
||||||
* required="true"
|
* required="true"
|
||||||
* validator=""
|
* validator=""
|
||||||
* expression="#component.org.apache.maven.artifact.repository.ArtifactRepositoryFactory"
|
* expression="#project.distributionManagementArtifactRepository"
|
||||||
* description=""
|
|
||||||
* @parameter name="settings"
|
|
||||||
* type="org.apache.maven.settings.MavenSettings"
|
|
||||||
* required="true"
|
|
||||||
* validator=""
|
|
||||||
* expression="#settings"
|
|
||||||
* description=""
|
* description=""
|
||||||
*/
|
*/
|
||||||
public class PomDeployMojo
|
public class PomDeployMojo
|
||||||
extends AbstractPlugin
|
extends AbstractPlugin
|
||||||
{
|
{
|
||||||
public void execute( PluginExecutionRequest request, PluginExecutionResponse response )
|
public void execute( PluginExecutionRequest request, PluginExecutionResponse response ) throws Exception
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
MavenProject project = (MavenProject) request.getParameter( "project" );
|
MavenProject project = (MavenProject) request.getParameter( "project" );
|
||||||
|
|
||||||
ArtifactDeployer artifactDeployer = (ArtifactDeployer) request.getParameter( "deployer" );
|
ArtifactDeployer artifactDeployer = (ArtifactDeployer) request.getParameter( "deployer" );
|
||||||
|
|
||||||
ArtifactRepositoryFactory artifactRepositoryFactory = (ArtifactRepositoryFactory) request.getParameter(
|
ArtifactRepository deploymentRepository = (ArtifactRepository) request.getParameter( "deploymentRepository" );
|
||||||
"artifactRepositoryFactory" );
|
|
||||||
|
|
||||||
MavenSettings settings = (MavenSettings) request.getParameter( "settings" );
|
if ( deploymentRepository == null )
|
||||||
|
|
||||||
// TODO: validation instead
|
|
||||||
if ( project.getDistributionManagement() == null )
|
|
||||||
{
|
{
|
||||||
// TODO: simple failure response
|
String msg = "Deployment failed: repository element" + " was not specified in the pom inside"
|
||||||
throw new Exception( "distributionManagement is required for deployment" );
|
+ " distributionManagement element";
|
||||||
|
throw new Exception( msg );
|
||||||
}
|
}
|
||||||
Repository repository = project.getDistributionManagement().getRepository();
|
|
||||||
ArtifactRepository deploymentRepository = artifactRepositoryFactory.createArtifactRepository( repository,
|
|
||||||
settings );
|
|
||||||
|
|
||||||
if ( deploymentRepository.getAuthenticationInfo() == null )
|
if ( deploymentRepository.getAuthenticationInfo() == null )
|
||||||
{
|
{
|
||||||
getLog().warn(
|
getLog().warn(
|
||||||
"Deployment repository {id: \'" + repository.getId() + "\'} has no associated authentication info!" );
|
"Deployment repository {id: \'" + deploymentRepository.getId()
|
||||||
|
+ "\'} has no associated authentication info!" );
|
||||||
}
|
}
|
||||||
|
|
||||||
Artifact artifact = new DefaultArtifact( project.getGroupId(), project.getArtifactId(), project.getVersion(),
|
Artifact artifact = new DefaultArtifact( project.getGroupId(), project.getArtifactId(), project.getVersion(),
|
||||||
|
|
Loading…
Reference in New Issue