o adjusting the internals to deal with root-based resolution

o gross hack to work around someone hardcoding a dummy:dummy root artifact in the surefire plugin



git-svn-id: https://svn.apache.org/repos/asf/maven/components/branches/MNG-2766@756885 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2009-03-21 07:28:59 +00:00
parent 7b6c7f6ce3
commit 0bf25e64d8
23 changed files with 333 additions and 353 deletions

View File

@ -209,7 +209,6 @@ END SNIPPET: ant-bootstrap -->
</macrodef> </macrodef>
<modello file="maven-model/src/main/mdo/maven.mdo" version="4.0.0"/> <modello file="maven-model/src/main/mdo/maven.mdo" version="4.0.0"/>
<modello file="maven-lifecycle/src/main/mdo/maven-lifecycle.mdo"/>
<modello file="maven-plugin-api/src/main/mdo/lifecycle.mdo"/> <modello file="maven-plugin-api/src/main/mdo/lifecycle.mdo"/>
<modello file="maven-project/src/main/mdo/profiles.mdo"/> <modello file="maven-project/src/main/mdo/profiles.mdo"/>
<modello file="maven-core/src/main/mdo/settings.mdo"/> <modello file="maven-core/src/main/mdo/settings.mdo"/>

View File

@ -164,7 +164,6 @@ END SNIPPET: ant-bootstrap -->
</macrodef> </macrodef>
<modello file="maven-model/src/main/mdo/maven.mdo" version="4.0.0"/> <modello file="maven-model/src/main/mdo/maven.mdo" version="4.0.0"/>
<modello file="maven-lifecycle/src/main/mdo/maven-lifecycle.mdo"/>
<modello file="maven-plugin-api/src/main/mdo/lifecycle.mdo"/> <modello file="maven-plugin-api/src/main/mdo/lifecycle.mdo"/>
<modello file="maven-project/src/main/mdo/profiles.mdo"/> <modello file="maven-project/src/main/mdo/profiles.mdo"/>
<modello file="maven-core/src/main/mdo/settings.mdo"/> <modello file="maven-core/src/main/mdo/settings.mdo"/>

View File

@ -1,22 +1,18 @@
package org.apache.maven.artifact.manager; package org.apache.maven.artifact.manager;
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
* or more contributor license agreements. See the NOTICE file * agreements. See the NOTICE file distributed with this work for additional information regarding
* distributed with this work for additional information * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
* regarding copyright ownership. The ASF licenses this file * "License"); you may not use this file except in compliance with the License. You may obtain a
* to you under the Apache License, Version 2.0 (the * copy of the License at
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing, software distributed under the License
* software distributed under the License is distributed on an * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * or implied. See the License for the specific language governing permissions and limitations under
* KIND, either express or implied. See the License for the * the License.
* specific language governing permissions and limitations
* under the License.
*/ */
import java.io.File; import java.io.File;
@ -60,14 +56,14 @@ import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.FileUtils;
@Component(role=WagonManager.class) @Component(role = WagonManager.class)
public class DefaultWagonManager public class DefaultWagonManager
implements WagonManager implements WagonManager
{ {
private static final String[] CHECKSUM_IDS = {"md5", "sha1"}; private static final String[] CHECKSUM_IDS = { "md5", "sha1" };
/** have to match the CHECKSUM_IDS */ /** have to match the CHECKSUM_IDS */
private static final String[] CHECKSUM_ALGORITHMS = {"MD5", "SHA-1"}; private static final String[] CHECKSUM_ALGORITHMS = { "MD5", "SHA-1" };
@Requirement @Requirement
private Logger logger; private Logger logger;
@ -77,17 +73,17 @@ public class DefaultWagonManager
// TODO: proxies, authentication and mirrors are via settings, and should come in via an alternate method - perhaps // TODO: proxies, authentication and mirrors are via settings, and should come in via an alternate method - perhaps
// attached to ArtifactRepository before the method is called (so AR would be composed of WR, not inherit it) // attached to ArtifactRepository before the method is called (so AR would be composed of WR, not inherit it)
private Map<String,ProxyInfo> proxies = new HashMap<String,ProxyInfo>(); private Map<String, ProxyInfo> proxies = new HashMap<String, ProxyInfo>();
private static Map<String,AuthenticationInfo> authenticationInfoMap = new HashMap<String,AuthenticationInfo>(); private static Map<String, AuthenticationInfo> authenticationInfoMap = new HashMap<String, AuthenticationInfo>();
private Map<String,RepositoryPermissions> serverPermissionsMap = new HashMap<String,RepositoryPermissions>(); private Map<String, RepositoryPermissions> serverPermissionsMap = new HashMap<String, RepositoryPermissions>();
//used LinkedMap to preserve the order. //used LinkedMap to preserve the order.
private Map<String,ArtifactRepository> mirrors = new LinkedHashMap<String,ArtifactRepository>(); private Map<String, ArtifactRepository> mirrors = new LinkedHashMap<String, ArtifactRepository>();
/** Map( String, XmlPlexusConfiguration ) with the repository id and the wagon configuration */ /** Map( String, XmlPlexusConfiguration ) with the repository id and the wagon configuration */
private Map<String,XmlPlexusConfiguration> serverConfigurationMap = new HashMap<String,XmlPlexusConfiguration>(); private Map<String, XmlPlexusConfiguration> serverConfigurationMap = new HashMap<String, XmlPlexusConfiguration>();
private RepositoryPermissions defaultRepositoryPermissions; private RepositoryPermissions defaultRepositoryPermissions;
@ -96,7 +92,7 @@ public class DefaultWagonManager
@Requirement @Requirement
private ArtifactRepositoryFactory repositoryFactory; private ArtifactRepositoryFactory repositoryFactory;
@Requirement(role=Wagon.class) @Requirement(role = Wagon.class)
private Map wagons; private Map wagons;
//@Requirement //@Requirement
@ -125,7 +121,6 @@ public class DefaultWagonManager
throw new UnsupportedProtocolException( "The repository " + repository + " does not specify a protocol" ); throw new UnsupportedProtocolException( "The repository " + repository + " does not specify a protocol" );
} }
Wagon wagon = getWagon( protocol ); Wagon wagon = getWagon( protocol );
configureWagon( wagon, repository.getId(), protocol ); configureWagon( wagon, repository.getId(), protocol );
@ -141,14 +136,12 @@ public class DefaultWagonManager
throw new UnsupportedProtocolException( "Unspecified protocol" ); throw new UnsupportedProtocolException( "Unspecified protocol" );
} }
String hint = protocol.toLowerCase( java.util.Locale.ENGLISH ); String hint = protocol.toLowerCase( java.util.Locale.ENGLISH );
Wagon wagon = (Wagon) wagons.get( hint ); Wagon wagon = (Wagon) wagons.get( hint );
if ( wagon == null ) if ( wagon == null )
{ {
throw new UnsupportedProtocolException( throw new UnsupportedProtocolException( "Cannot find wagon which supports the requested protocol: " + protocol );
"Cannot find wagon which supports the requested protocol: " + protocol );
} }
return wagon; return wagon;
@ -195,9 +188,9 @@ public class DefaultWagonManager
wagon.addTransferListener( downloadMonitor ); wagon.addTransferListener( downloadMonitor );
} }
Map<String,ChecksumObserver> checksums = new HashMap<String,ChecksumObserver>( 2 ); Map<String, ChecksumObserver> checksums = new HashMap<String, ChecksumObserver>( 2 );
Map<String,String> sums = new HashMap<String,String>( 2 ); Map<String, String> sums = new HashMap<String, String>( 2 );
// TODO: configure these on the repository // TODO: configure these on the repository
for ( int i = 0; i < CHECKSUM_IDS.length; i++ ) for ( int i = 0; i < CHECKSUM_IDS.length; i++ )
@ -219,7 +212,7 @@ public class DefaultWagonManager
{ {
return getProxy( protocol ); return getProxy( protocol );
} }
}); } );
wagon.put( source, remotePath ); wagon.put( source, remotePath );
} }
@ -238,19 +231,21 @@ public class DefaultWagonManager
} }
// Pre-store the checksums as any future puts will overwrite them // Pre-store the checksums as any future puts will overwrite them
for (String extension : checksums.keySet()) { for ( String extension : checksums.keySet() )
ChecksumObserver observer = checksums.get(extension); {
sums.put(extension, observer.getActualChecksum()); ChecksumObserver observer = checksums.get( extension );
sums.put( extension, observer.getActualChecksum() );
} }
// We do this in here so we can checksum the artifact metadata too, otherwise it could be metadata itself // We do this in here so we can checksum the artifact metadata too, otherwise it could be metadata itself
for (String extension : checksums.keySet()) { for ( String extension : checksums.keySet() )
{
// TODO: shouldn't need a file intermediatary - improve wagon to take a stream // TODO: shouldn't need a file intermediatary - improve wagon to take a stream
File temp = File.createTempFile("maven-artifact", null); File temp = File.createTempFile( "maven-artifact", null );
temp.deleteOnExit(); temp.deleteOnExit();
FileUtils.fileWrite(temp.getAbsolutePath(), "UTF-8", sums.get(extension)); FileUtils.fileWrite( temp.getAbsolutePath(), "UTF-8", sums.get( extension ) );
wagon.put(temp, remotePath + "." + extension); wagon.put( temp, remotePath + "." + extension );
} }
} }
catch ( ConnectionException e ) catch ( ConnectionException e )
@ -276,10 +271,12 @@ public class DefaultWagonManager
finally finally
{ {
// Remove every checksum listener // Remove every checksum listener
for (String aCHECKSUM_IDS : CHECKSUM_IDS) { for ( String aCHECKSUM_IDS : CHECKSUM_IDS )
TransferListener checksumListener = checksums.get(aCHECKSUM_IDS); {
if (checksumListener != null) { TransferListener checksumListener = checksums.get( aCHECKSUM_IDS );
wagon.removeTransferListener(checksumListener); if ( checksumListener != null )
{
wagon.removeTransferListener( checksumListener );
} }
} }
@ -289,8 +286,7 @@ public class DefaultWagonManager
} }
} }
private ChecksumObserver addChecksumObserver( Wagon wagon, private ChecksumObserver addChecksumObserver( Wagon wagon, String algorithm )
String algorithm )
throws TransferFailedException throws TransferFailedException
{ {
try try
@ -305,7 +301,6 @@ public class DefaultWagonManager
} }
} }
// NOTE: It is not possible that this method throws TransferFailedException under current conditions. // NOTE: It is not possible that this method throws TransferFailedException under current conditions.
// FIXME: Change the throws clause to reflect the fact that we're never throwing TransferFailedException // FIXME: Change the throws clause to reflect the fact that we're never throwing TransferFailedException
public void getArtifact( Artifact artifact, ArtifactRepository remoteRepository, boolean force ) public void getArtifact( Artifact artifact, ArtifactRepository remoteRepository, boolean force )
@ -329,12 +324,13 @@ public class DefaultWagonManager
public void getArtifact( Artifact artifact, List<ArtifactRepository> remoteRepositories, TransferListener downloadMonitor, boolean force ) public void getArtifact( Artifact artifact, List<ArtifactRepository> remoteRepositories, TransferListener downloadMonitor, boolean force )
throws TransferFailedException, ResourceDoesNotExistException throws TransferFailedException, ResourceDoesNotExistException
{ {
for (ArtifactRepository repository : remoteRepositories) { for ( ArtifactRepository repository : remoteRepositories )
{
try try
{ {
getArtifact( artifact, repository, downloadMonitor, force ); getArtifact( artifact, repository, downloadMonitor, force );
if (artifact.isResolved()) if ( artifact.isResolved() )
{ {
break; break;
} }
@ -344,13 +340,11 @@ public class DefaultWagonManager
// This one we will eat when looking through remote repositories // This one we will eat when looking through remote repositories
// because we want to cycle through them all before squawking. // because we want to cycle through them all before squawking.
logger.debug( "Unable to get resource '" + artifact.getId() + "' from repository " + logger.debug( "Unable to get resource '" + artifact.getId() + "' from repository " + repository.getId() + " (" + repository.getUrl() + ")", e );
repository.getId() + " (" + repository.getUrl() + ")", e );
} }
catch ( TransferFailedException e ) catch ( TransferFailedException e )
{ {
logger.debug( "Unable to get resource '" + artifact.getId() + "' from repository " + logger.debug( "Unable to get resource '" + artifact.getId() + "' from repository " + repository.getId() + " (" + repository.getUrl() + ")", e );
repository.getId() + " (" + repository.getUrl() + ")", e );
} }
} }
@ -362,8 +356,7 @@ public class DefaultWagonManager
} }
public void getArtifact( Artifact artifact, ArtifactRepository repository, TransferListener downloadMonitor ) public void getArtifact( Artifact artifact, ArtifactRepository repository, TransferListener downloadMonitor )
throws TransferFailedException, throws TransferFailedException, ResourceDoesNotExistException
ResourceDoesNotExistException
{ {
getArtifact( artifact, repository, downloadMonitor, true ); getArtifact( artifact, repository, downloadMonitor, true );
} }
@ -457,10 +450,7 @@ public class DefaultWagonManager
} }
} }
public void getArtifactMetadata( ArtifactMetadata metadata, public void getArtifactMetadata( ArtifactMetadata metadata, ArtifactRepository repository, File destination, String checksumPolicy )
ArtifactRepository repository,
File destination,
String checksumPolicy )
throws TransferFailedException, ResourceDoesNotExistException throws TransferFailedException, ResourceDoesNotExistException
{ {
String remotePath = repository.pathOfRemoteRepositoryMetadata( metadata ); String remotePath = repository.pathOfRemoteRepositoryMetadata( metadata );
@ -468,8 +458,7 @@ public class DefaultWagonManager
getRemoteFile( repository, destination, remotePath, null, checksumPolicy, true ); getRemoteFile( repository, destination, remotePath, null, checksumPolicy, true );
} }
public void getArtifactMetadataFromDeploymentRepository( ArtifactMetadata metadata, ArtifactRepository repository, public void getArtifactMetadataFromDeploymentRepository( ArtifactMetadata metadata, ArtifactRepository repository, File destination, String checksumPolicy )
File destination, String checksumPolicy )
throws TransferFailedException, ResourceDoesNotExistException throws TransferFailedException, ResourceDoesNotExistException
{ {
String remotePath = repository.pathOfRemoteRepositoryMetadata( metadata ); String remotePath = repository.pathOfRemoteRepositoryMetadata( metadata );
@ -477,12 +466,7 @@ public class DefaultWagonManager
getRemoteFile( repository, destination, remotePath, null, checksumPolicy, true ); getRemoteFile( repository, destination, remotePath, null, checksumPolicy, true );
} }
private void getRemoteFile( ArtifactRepository repository, private void getRemoteFile( ArtifactRepository repository, File destination, String remotePath, TransferListener downloadMonitor, String checksumPolicy, boolean force )
File destination,
String remotePath,
TransferListener downloadMonitor,
String checksumPolicy,
boolean force )
throws TransferFailedException, ResourceDoesNotExistException throws TransferFailedException, ResourceDoesNotExistException
{ {
String protocol = repository.getProtocol(); String protocol = repository.getProtocol();
@ -513,14 +497,13 @@ public class DefaultWagonManager
try try
{ {
wagon.connect( new Repository( repository.getId(), repository.getUrl() ), wagon.connect( new Repository( repository.getId(), repository.getUrl() ), getAuthenticationInfo( repository.getId() ), new ProxyInfoProvider()
getAuthenticationInfo( repository.getId() ), new ProxyInfoProvider()
{ {
public ProxyInfo getProxyInfo( String protocol ) public ProxyInfo getProxyInfo( String protocol )
{ {
return getProxy( protocol ); return getProxy( protocol );
} }
}); } );
boolean firstRun = true; boolean firstRun = true;
boolean retry = true; boolean retry = true;
@ -631,8 +614,7 @@ public class DefaultWagonManager
catch ( ResourceDoesNotExistException md5TryException ) catch ( ResourceDoesNotExistException md5TryException )
{ {
// this was a failed transfer, and we don't want to retry. // this was a failed transfer, and we don't want to retry.
handleChecksumFailure( checksumPolicy, "Error retrieving checksum file for " + remotePath, handleChecksumFailure( checksumPolicy, "Error retrieving checksum file for " + remotePath, md5TryException );
md5TryException );
} }
} }
@ -699,16 +681,13 @@ public class DefaultWagonManager
} }
catch ( IOException e ) catch ( IOException e )
{ {
throw new TransferFailedException( throw new TransferFailedException( "Error copying temporary file to the final destination: " + e.getMessage(), e );
"Error copying temporary file to the final destination: " + e.getMessage(), e );
} }
} }
} }
} }
private void handleChecksumFailure( String checksumPolicy, private void handleChecksumFailure( String checksumPolicy, String message, Throwable cause )
String message,
Throwable cause )
throws ChecksumFailedException throws ChecksumFailedException
{ {
if ( ArtifactRepositoryPolicy.CHECKSUM_POLICY_FAIL.equals( checksumPolicy ) ) if ( ArtifactRepositoryPolicy.CHECKSUM_POLICY_FAIL.equals( checksumPolicy ) )
@ -723,12 +702,7 @@ public class DefaultWagonManager
// otherwise it is ignore // otherwise it is ignore
} }
private void verifyChecksum( ChecksumObserver checksumObserver, private void verifyChecksum( ChecksumObserver checksumObserver, File destination, File tempDestination, String remotePath, String checksumFileExtension, Wagon wagon )
File destination,
File tempDestination,
String remotePath,
String checksumFileExtension,
Wagon wagon )
throws ResourceDoesNotExistException, TransferFailedException, AuthorizationException throws ResourceDoesNotExistException, TransferFailedException, AuthorizationException
{ {
try try
@ -746,8 +720,7 @@ public class DefaultWagonManager
expectedChecksum = expectedChecksum.trim(); expectedChecksum = expectedChecksum.trim();
// check for 'ALGO (name) = CHECKSUM' like used by openssl // check for 'ALGO (name) = CHECKSUM' like used by openssl
if ( expectedChecksum.regionMatches( true, 0, "MD", 0, 2 ) if ( expectedChecksum.regionMatches( true, 0, "MD", 0, 2 ) || expectedChecksum.regionMatches( true, 0, "SHA", 0, 3 ) )
|| expectedChecksum.regionMatches( true, 0, "SHA", 0, 3 ) )
{ {
int lastSpacePos = expectedChecksum.lastIndexOf( ' ' ); int lastSpacePos = expectedChecksum.lastIndexOf( ' ' );
expectedChecksum = expectedChecksum.substring( lastSpacePos + 1 ); expectedChecksum = expectedChecksum.substring( lastSpacePos + 1 );
@ -774,8 +747,7 @@ public class DefaultWagonManager
} }
else else
{ {
throw new ChecksumFailedException( "Checksum failed on download: local = '" + actualChecksum + throw new ChecksumFailedException( "Checksum failed on download: local = '" + actualChecksum + "'; remote = '" + expectedChecksum + "'" );
"'; remote = '" + expectedChecksum + "'" );
} }
} }
catch ( IOException e ) catch ( IOException e )
@ -784,7 +756,6 @@ public class DefaultWagonManager
} }
} }
private void disconnectWagon( Wagon wagon ) private void disconnectWagon( Wagon wagon )
{ {
try try
@ -797,8 +768,7 @@ public class DefaultWagonManager
} }
} }
private void releaseWagon( String protocol, private void releaseWagon( String protocol, Wagon wagon )
Wagon wagon )
{ {
try try
{ {
@ -833,7 +803,7 @@ public class DefaultWagonManager
try try
{ {
URL url = new URL( originalRepository.getUrl() ); URL url = new URL( originalRepository.getUrl() );
return !( url.getHost().equals( "localhost" ) || url.getHost().equals( "127.0.0.1" ) || url.getProtocol().equals("file" ) ); return !( url.getHost().equals( "localhost" ) || url.getHost().equals( "127.0.0.1" ) || url.getProtocol().equals( "file" ) );
} }
catch ( MalformedURLException e ) catch ( MalformedURLException e )
{ {
@ -850,16 +820,11 @@ public class DefaultWagonManager
* @param port the proxy port (required) * @param port the proxy port (required)
* @param username the username for the proxy, or null if there is none * @param username the username for the proxy, or null if there is none
* @param password the password for the proxy, or null if there is none * @param password the password for the proxy, or null if there is none
* @param nonProxyHosts the set of hosts not to use the proxy for. Follows Java system property format: * @param nonProxyHosts the set of hosts not to use the proxy for. Follows Java system property
* <code>*.foo.com|localhost</code>. * format: <code>*.foo.com|localhost</code>.
* @todo [BP] would be nice to configure this via plexus in some way * @todo [BP] would be nice to configure this via plexus in some way
*/ */
public void addProxy( String protocol, public void addProxy( String protocol, String host, int port, String username, String password, String nonProxyHosts )
String host,
int port,
String username,
String password,
String nonProxyHosts )
{ {
ProxyInfo proxyInfo = new ProxyInfo(); ProxyInfo proxyInfo = new ProxyInfo();
proxyInfo.setHost( host ); proxyInfo.setHost( host );
@ -875,12 +840,7 @@ public class DefaultWagonManager
// We are leaving this method here so that we can attempt to use the new maven-artifact // We are leaving this method here so that we can attempt to use the new maven-artifact
// library from the 2.0.x code so that we aren't maintaining two lines of code // library from the 2.0.x code so that we aren't maintaining two lines of code
// for the artifact management. // for the artifact management.
public void addAuthenticationInfo( String repositoryId, public void addAuthenticationInfo( String repositoryId, String username, String password, String privateKey, String passphrase )
String username,
String password,
String privateKey,
String passphrase
)
{ {
AuthenticationInfo authInfo = new AuthenticationInfo(); AuthenticationInfo authInfo = new AuthenticationInfo();
authInfo.setUserName( username ); authInfo.setUserName( username );
@ -891,9 +851,7 @@ public class DefaultWagonManager
authenticationInfoMap.put( repositoryId, authInfo ); authenticationInfoMap.put( repositoryId, authInfo );
} }
public void addPermissionInfo( String repositoryId, public void addPermissionInfo( String repositoryId, String filePermissions, String directoryPermissions )
String filePermissions,
String directoryPermissions )
{ {
RepositoryPermissions permissions = new RepositoryPermissions(); RepositoryPermissions permissions = new RepositoryPermissions();
@ -922,7 +880,8 @@ public class DefaultWagonManager
* *
* @param wagon the wagon to configure * @param wagon the wagon to configure
* @param repository the repository that has the configuration * @param repository the repository that has the configuration
* @throws WagonConfigurationException wraps any error given during configuration of the wagon instance * @throws WagonConfigurationException wraps any error given during configuration of the wagon
* instance
*/ */
private void configureWagon( Wagon wagon, ArtifactRepository repository ) private void configureWagon( Wagon wagon, ArtifactRepository repository )
throws WagonConfigurationException throws WagonConfigurationException

View File

@ -1,22 +1,18 @@
package org.apache.maven.artifact.repository; package org.apache.maven.artifact.repository;
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
* or more contributor license agreements. See the NOTICE file * agreements. See the NOTICE file distributed with this work for additional information regarding
* distributed with this work for additional information * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
* regarding copyright ownership. The ASF licenses this file * "License"); you may not use this file except in compliance with the License. You may obtain a
* to you under the Apache License, Version 2.0 (the * copy of the License at
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing, software distributed under the License
* software distributed under the License is distributed on an * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * or implied. See the License for the specific language governing permissions and limitations under
* KIND, either express or implied. See the License for the * the License.
* specific language governing permissions and limitations
* under the License.
*/ */
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
@ -38,6 +34,7 @@ public interface ArtifactRepository
String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository ); String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository );
String getUrl(); String getUrl();
void setUrl( String url ); void setUrl( String url );
String getBasedir(); String getBasedir();
@ -45,15 +42,19 @@ public interface ArtifactRepository
String getProtocol(); String getProtocol();
String getId(); String getId();
void setId( String id ); void setId( String id );
ArtifactRepositoryPolicy getSnapshots(); ArtifactRepositoryPolicy getSnapshots();
void setSnapshotUpdatePolicy( ArtifactRepositoryPolicy policy ); void setSnapshotUpdatePolicy( ArtifactRepositoryPolicy policy );
ArtifactRepositoryPolicy getReleases(); ArtifactRepositoryPolicy getReleases();
void setReleaseUpdatePolicy( ArtifactRepositoryPolicy policy ); void setReleaseUpdatePolicy( ArtifactRepositoryPolicy policy );
ArtifactRepositoryLayout getLayout(); ArtifactRepositoryLayout getLayout();
void setLayout( ArtifactRepositoryLayout layout ); void setLayout( ArtifactRepositoryLayout layout );
String getKey(); String getKey();

View File

@ -347,6 +347,11 @@ public class DefaultArtifactResolver
// //
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
private boolean isDummy( ArtifactResolutionRequest request )
{
return request.getArtifact().getArtifactId().equals( "dummy" ) && request.getArtifact().getGroupId().equals( "dummy" );
}
public ArtifactResolutionResult resolve( ArtifactResolutionRequest request ) public ArtifactResolutionResult resolve( ArtifactResolutionRequest request )
{ {
Artifact rootArtifact = request.getArtifact(); Artifact rootArtifact = request.getArtifact();
@ -358,6 +363,14 @@ public class DefaultArtifactResolver
List<ResolutionListener> listeners = request.getListeners(); List<ResolutionListener> listeners = request.getListeners();
ArtifactFilter filter = request.getFilter(); ArtifactFilter filter = request.getFilter();
// This is an extreme hack because of the ridiculous APIs we have a root that is disconnected and
// useless. The SureFire plugin passes in a dummy root artifact that is actually used in the production
// plugin ... We have no choice but to put this hack in the core.
if ( isDummy( request ) )
{
request.setResolveRoot( false );
}
if ( source == null ) if ( source == null )
{ {
try try
@ -416,8 +429,11 @@ public class DefaultArtifactResolver
// After the collection we will have the artifact object in the result but they will not be resolved yet. // After the collection we will have the artifact object in the result but they will not be resolved yet.
result = artifactCollector.collect( artifacts, rootArtifact, managedVersions, localRepository, remoteRepositories, source, filter, listeners ); result = artifactCollector.collect( artifacts, rootArtifact, managedVersions, localRepository, remoteRepositories, source, filter, listeners );
if ( !isDummy( request ) )
{
// Add the root artifact // Add the root artifact
result.addArtifact( rootArtifact ); result.addArtifact( rootArtifact );
}
// We have metadata retrieval problems, or there are cycles that have been detected // We have metadata retrieval problems, or there are cycles that have been detected
// so we give this back to the calling code and let them deal with this information // so we give this back to the calling code and let them deal with this information

View File

@ -159,7 +159,7 @@ public class ArtifactResolverTest
ArtifactResolutionResult result = ArtifactResolutionResult result =
artifactResolver.resolveTransitively( Collections.singleton( g ), projectArtifact, remoteRepositories(), localRepository(), mds ); artifactResolver.resolveTransitively( Collections.singleton( g ), projectArtifact, remoteRepositories(), localRepository(), mds );
assertEquals( 2, result.getArtifacts().size() ); assertEquals( 3, result.getArtifacts().size() );
assertTrue( result.getArtifacts().contains( g ) ); assertTrue( result.getArtifacts().contains( g ) );
@ -234,7 +234,7 @@ public class ArtifactResolverTest
artifactResolver.resolveTransitively( Collections.singleton( i ), projectArtifact, remoteRepositories(), artifactResolver.resolveTransitively( Collections.singleton( i ), projectArtifact, remoteRepositories(),
localRepository(), mds ); localRepository(), mds );
assertEquals( 2, result.getArtifacts().size() ); assertEquals( 3, result.getArtifacts().size() );
assertTrue( result.getArtifacts().contains( i ) ); assertTrue( result.getArtifacts().contains( i ) );

View File

@ -382,11 +382,9 @@ 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, ReactorManager reactorManager, EventDispatcher dispatcher )
ReactorManager reactorManager,
EventDispatcher dispatcher )
{ {
MavenSession session = new MavenSession( container, request, dispatcher, reactorManager ); MavenSession session = new MavenSession( container, request, reactorManager, dispatcher );
return session; return session;
} }

View File

@ -73,14 +73,19 @@ public class MavenSession
this.pluginGroups = pluginGroups; this.pluginGroups = pluginGroups;
} }
public MavenSession( PlexusContainer container, MavenExecutionRequest request, EventDispatcher eventDispatcher, ReactorManager reactorManager ) public MavenSession( PlexusContainer container, MavenExecutionRequest request, ReactorManager reactorManager )
{ {
this.container = container; this.container = container;
this.request = request; this.request = request;
this.eventDispatcher = eventDispatcher;
this.reactorManager = reactorManager; this.reactorManager = reactorManager;
} }
public MavenSession( PlexusContainer container, MavenExecutionRequest request, ReactorManager reactorManager, EventDispatcher Eventdispatcher )
{
this( container, request, reactorManager );
this.eventDispatcher = Eventdispatcher;
}
public Map getPluginContext( PluginDescriptor pluginDescriptor, MavenProject project ) public Map getPluginContext( PluginDescriptor pluginDescriptor, MavenProject project )
{ {
if ( reactorManager == null ) if ( reactorManager == null )

View File

@ -1225,8 +1225,6 @@ public class DefaultLifecycleExecutor
String goal; String goal;
Plugin plugin; Plugin plugin;
PluginDescriptor pluginDescriptor = null;
StringTokenizer tok = new StringTokenizer( task, ":" ); StringTokenizer tok = new StringTokenizer( task, ":" );
int numTokens = tok.countTokens(); int numTokens = tok.countTokens();
@ -1246,14 +1244,6 @@ public class DefaultLifecycleExecutor
plugin = pluginManager.findPluginForPrefix( prefix, project, session ); plugin = pluginManager.findPluginForPrefix( prefix, project, session );
if ( plugin == null )
{
plugin = new Plugin();
plugin.setGroupId( pluginDescriptor.getGroupId() );
plugin.setArtifactId( pluginDescriptor.getArtifactId() );
plugin.setVersion( pluginDescriptor.getVersion() );
}
// Search plugin in the current POM // Search plugin in the current POM
if ( plugin == null ) if ( plugin == null )
{ {
@ -1269,14 +1259,6 @@ public class DefaultLifecycleExecutor
} }
} }
} }
// Default to o.a.m.plugins and maven-<prefix>-plugin
if ( plugin == null )
{
plugin = new Plugin();
plugin.setGroupId( PluginDescriptor.getDefaultPluginGroupId() );
plugin.setArtifactId( PluginDescriptor.getDefaultPluginArtifactId( prefix ) );
}
} }
else if ( numTokens == 3 || numTokens == 4 ) else if ( numTokens == 3 || numTokens == 4 )
{ {
@ -1313,10 +1295,7 @@ public class DefaultLifecycleExecutor
project.injectPluginManagementInfo( plugin ); project.injectPluginManagementInfo( plugin );
} }
if ( pluginDescriptor == null ) PluginDescriptor pluginDescriptor = loadPlugin( plugin, project, session );
{
pluginDescriptor = loadPlugin( plugin, project, session );
}
// this has been simplified from the old code that injected the plugin management stuff, since // this has been simplified from the old code that injected the plugin management stuff, since
// pluginManagement injection is now handled by the project method. // pluginManagement injection is now handled by the project method.

View File

@ -165,6 +165,7 @@ public class DefaultPluginManager
// TODO: this should be possibly outside // TODO: this should be possibly outside
// All version-resolution logic has been moved to DefaultPluginVersionManager. // All version-resolution logic has been moved to DefaultPluginVersionManager.
logger.debug( "Resolving plugin: " + plugin.getKey() + " with version: " + pluginVersion ); logger.debug( "Resolving plugin: " + plugin.getKey() + " with version: " + pluginVersion );
if ( ( pluginVersion == null ) || Artifact.LATEST_VERSION.equals( pluginVersion ) || Artifact.RELEASE_VERSION.equals( pluginVersion ) ) if ( ( pluginVersion == null ) || Artifact.LATEST_VERSION.equals( pluginVersion ) || Artifact.RELEASE_VERSION.equals( pluginVersion ) )
{ {
logger.debug( "Resolving version for plugin: " + plugin.getKey() ); logger.debug( "Resolving version for plugin: " + plugin.getKey() );
@ -310,7 +311,8 @@ public class DefaultPluginManager
} }
pluginDescriptor.setPluginArtifact( pluginArtifact ); pluginDescriptor.setPluginArtifact( pluginArtifact );
// Make sure it's just the plugin artifacts
pluginDescriptor.setArtifacts( new ArrayList( pluginArtifacts ) );
pluginDescriptor.setClassRealm( pluginRealm ); pluginDescriptor.setClassRealm( pluginRealm );
pluginRealms.put( pluginKey( plugin ), pluginRealm ); pluginRealms.put( pluginKey( plugin ), pluginRealm );
@ -561,10 +563,9 @@ public class DefaultPluginManager
ClassRealm oldLookupRealm = container.getLookupRealm(); ClassRealm oldLookupRealm = container.getLookupRealm();
ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader(); ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
List realmActions = new ArrayList();
try try
{ {
mojo = getConfiguredMojo( session, dom, project, false, mojoExecution, realmActions ); mojo = getConfiguredMojo( session, dom, project, false, mojoExecution );
//dispatcher.dispatchStart( event, goalExecId ); //dispatcher.dispatchStart( event, goalExecId );
@ -630,18 +631,8 @@ public class DefaultPluginManager
} }
} }
pluginDescriptor.setClassRealm( null );
pluginDescriptor.setArtifacts( null );
for ( Iterator it = realmActions.iterator(); it.hasNext(); )
{
PluginRealmAction action = (PluginRealmAction) it.next();
action.undo();
}
if ( oldLookupRealm != null ) if ( oldLookupRealm != null )
{ {
//container.setLookupRealm( oldLookupRealm );
container.setLookupRealm( null ); container.setLookupRealm( null );
} }
@ -660,7 +651,7 @@ public class DefaultPluginManager
dom = Xpp3Dom.mergeXpp3Dom( dom, mojoExecution.getConfiguration() ); dom = Xpp3Dom.mergeXpp3Dom( dom, mojoExecution.getConfiguration() );
} }
return (MavenReport) getConfiguredMojo( session, dom, project, true, mojoExecution, new ArrayList() ); return (MavenReport) getConfiguredMojo( session, dom, project, true, mojoExecution );
} }
public PluginDescriptor verifyReportPlugin( ReportPlugin reportPlugin, MavenProject project, MavenSession session ) public PluginDescriptor verifyReportPlugin( ReportPlugin reportPlugin, MavenProject project, MavenSession session )
@ -685,7 +676,7 @@ public class DefaultPluginManager
return verifyVersionedPlugin( forLookup, project, session ); return verifyVersionedPlugin( forLookup, project, session );
} }
private Mojo getConfiguredMojo( MavenSession session, Xpp3Dom dom, MavenProject project, boolean report, MojoExecution mojoExecution, List realmActions ) private Mojo getConfiguredMojo( MavenSession session, Xpp3Dom dom, MavenProject project, boolean report, MojoExecution mojoExecution )
throws PluginConfigurationException, PluginManagerException throws PluginConfigurationException, PluginManagerException
{ {
MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
@ -703,7 +694,6 @@ public class DefaultPluginManager
Thread.currentThread().setContextClassLoader( pluginRealm ); Thread.currentThread().setContextClassLoader( pluginRealm );
try try
{ {
System.out.println( pluginDescriptor );
logger.debug( "Looking up mojo " + mojoDescriptor.getRoleHint() + " in realm " + pluginRealm.getId() + " - descRealmId=" + mojoDescriptor.getRealm() ); logger.debug( "Looking up mojo " + mojoDescriptor.getRoleHint() + " in realm " + pluginRealm.getId() + " - descRealmId=" + mojoDescriptor.getRealm() );
Mojo mojo; Mojo mojo;
@ -1429,35 +1419,6 @@ public class DefaultPluginManager
} }
} }
private static final class PluginRealmAction
{
private final PluginDescriptor pluginDescriptor;
private final ClassRealm realmWithTransientParent;
PluginRealmAction( PluginDescriptor pluginDescriptor )
{
this.pluginDescriptor = pluginDescriptor;
realmWithTransientParent = null;
}
PluginRealmAction( PluginDescriptor pluginDescriptor, ClassRealm realmWithTransientParent )
{
this.pluginDescriptor = pluginDescriptor;
this.realmWithTransientParent = realmWithTransientParent;
}
void undo()
{
pluginDescriptor.setArtifacts( null );
pluginDescriptor.setClassRealm( null );
if ( realmWithTransientParent != null )
{
realmWithTransientParent.setParentRealm( null );
}
}
}
private static String interpolateXmlString( String xml, List<InterpolatorProperty> interpolatorProperties ) private static String interpolateXmlString( String xml, List<InterpolatorProperty> interpolatorProperties )
throws IOException throws IOException
{ {

View File

@ -4,6 +4,7 @@ import java.io.File;
import java.util.Arrays; import java.util.Arrays;
import java.util.Properties; import java.util.Properties;
import org.apache.maven.artifact.InvalidRepositoryException;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.execution.DefaultMavenExecutionRequest; import org.apache.maven.execution.DefaultMavenExecutionRequest;
import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.execution.MavenExecutionRequest;
@ -43,7 +44,6 @@ public class LifecycleExecutorTest
protected void setUp() protected void setUp()
throws Exception throws Exception
{ {
//!!jvz need these injected into the test cases as this is a pita.
projectBuilder = lookup( MavenProjectBuilder.class ); projectBuilder = lookup( MavenProjectBuilder.class );
repositorySystem = lookup( RepositorySystem.class ); repositorySystem = lookup( RepositorySystem.class );
pluginManager = lookup( PluginManager.class ); pluginManager = lookup( PluginManager.class );
@ -55,7 +55,7 @@ public class LifecycleExecutorTest
assertNotNull( lifecycleExecutor.getLifecyclePhases() ); assertNotNull( lifecycleExecutor.getLifecyclePhases() );
} }
public void testMojoExecution() public void testRemoteResourcesPlugin()
throws Exception throws Exception
{ {
// - find the plugin [extension point: any client may wish to do whatever they choose] // - find the plugin [extension point: any client may wish to do whatever they choose]
@ -67,32 +67,30 @@ public class LifecycleExecutorTest
File pom = new File( getBasedir(), "src/test/pom.xml" ); File pom = new File( getBasedir(), "src/test/pom.xml" );
File targetPom = new File( getBasedir(), "target/lifecycle-executor/pom-plugin.xml" ); File targetPom = new File( getBasedir(), "target/lifecycle-executor/pom-plugin.xml" );
FileUtils.copyFile( pom, targetPom ); FileUtils.copyFile( pom, targetPom );
if ( !targetPom.getParentFile().exists() ) if ( !targetPom.getParentFile().exists() )
{ {
targetPom.getParentFile().mkdirs(); targetPom.getParentFile().mkdirs();
} }
ArtifactRepository localRepository = repositorySystem.createLocalRepository( new File( "/Users/jvanzyl/.m2/repository" ) ); ArtifactRepository localRepository = getLocalRepository();
Repository repository = new Repository(); Repository repository = new Repository();
repository.setUrl( "http://repo1.maven.org/maven2" ); repository.setUrl( "http://repo1.maven.org/maven2" );
repository.setId( "central" ); repository.setId( "central" );
ProjectBuilderConfiguration configuration = new DefaultProjectBuilderConfiguration() ProjectBuilderConfiguration configuration = new DefaultProjectBuilderConfiguration()
.setLocalRepository( localRepository ) .setLocalRepository( localRepository ).setRemoteRepositories( Arrays.asList( repositorySystem.buildArtifactRepository( repository ) ) );
.setRemoteRepositories( Arrays.asList( repositorySystem.buildArtifactRepository( repository ) ) );
MavenProject project = projectBuilder.build( targetPom, configuration ); MavenProject project = projectBuilder.build( targetPom, configuration );
assertEquals( "maven", project.getArtifactId() ); assertEquals( "maven", project.getArtifactId() );
assertEquals( "3.0-SNAPSHOT", project.getVersion() ); assertEquals( "3.0-SNAPSHOT", project.getVersion() );
MavenExecutionRequest request = new DefaultMavenExecutionRequest() MavenExecutionRequest request = new DefaultMavenExecutionRequest().setProjectPresent( true ).setPluginGroups( Arrays.asList( new String[] { "org.apache.maven.plugins" } ) )
.setProjectPresent( true ) .setLocalRepository( localRepository ).setRemoteRepositories( Arrays.asList( repositorySystem.buildArtifactRepository( repository ) ) ).setProperties( new Properties() );
.setPluginGroups( Arrays.asList( new String[]{ "org.apache.maven.plugins"} ) )
.setLocalRepository( localRepository )
.setRemoteRepositories( Arrays.asList( repositorySystem.buildArtifactRepository( repository ) ) )
.setProperties( new Properties() );
MavenSession session = new MavenSession( getContainer(), request, null, null ); MavenSession session = new MavenSession( getContainer(), request, null );
//!!jvz This is not really quite right, take a look at how this actually works.
session.setCurrentProject( project ); session.setCurrentProject( project );
String pluginArtifactId = "remote-resources"; String pluginArtifactId = "remote-resources";
@ -105,12 +103,72 @@ public class LifecycleExecutorTest
assertEquals( "maven-remote-resources-plugin", pd.getArtifactId() ); assertEquals( "maven-remote-resources-plugin", pd.getArtifactId() );
assertEquals( "1.0", pd.getVersion() ); assertEquals( "1.0", pd.getVersion() );
MojoExecution me = new MojoExecution( mojoDescriptor ); MojoExecution mojoExecution = new MojoExecution( mojoDescriptor );
// Need some xpath action in here. Make sure the mojoExecution configuration is intact // Need some xpath action in here. Make sure the mojoExecution configuration is intact
// Now the magical mojo descriptor is complete and I can execute the mojo. // Now the magical mojo descriptor is complete and I can execute the mojo.
pluginManager.executeMojo( project, me, session ); pluginManager.executeMojo( project, mojoExecution, session );
}
public void testSurefirePlugin()
throws Exception
{
// - find the plugin [extension point: any client may wish to do whatever they choose]
// - load the plugin into a classloader [extension point: we want to take them from a repository, some may take from disk or whatever]
// - configure the plugin [extension point]
// - execute the plugin
// Our test POM and this is actually the Maven POM so not the best idea.
File pom = new File( getBasedir(), "src/test/pom.xml" );
File targetPom = new File( getBasedir(), "target/lifecycle-executor/pom-plugin.xml" );
FileUtils.copyFile( pom, targetPom );
if ( !targetPom.getParentFile().exists() )
{
targetPom.getParentFile().mkdirs();
}
ArtifactRepository localRepository = getLocalRepository();
Repository repository = new Repository();
repository.setUrl( "http://repo1.maven.org/maven2" );
repository.setId( "central" );
ProjectBuilderConfiguration configuration = new DefaultProjectBuilderConfiguration()
.setLocalRepository( localRepository )
.setRemoteRepositories( Arrays.asList( repositorySystem.buildArtifactRepository( repository ) ) );
MavenProject project = projectBuilder.build( targetPom, configuration );
assertEquals( "maven", project.getArtifactId() );
assertEquals( "3.0-SNAPSHOT", project.getVersion() );
MavenExecutionRequest request = new DefaultMavenExecutionRequest().setProjectPresent( true ).setPluginGroups( Arrays.asList( new String[] { "org.apache.maven.plugins" } ) )
.setLocalRepository( localRepository )
.setRemoteRepositories( Arrays.asList( repositorySystem.buildArtifactRepository( repository ) ) )
.setProperties( new Properties() );
MavenSession session = new MavenSession( getContainer(), request, null );
//!!jvz This is not really quite right, take a look at how this actually works.
session.setCurrentProject( project );
String pluginArtifactId = "surefire";
String goal = "test";
MojoDescriptor mojoDescriptor = lifecycleExecutor.getMojoDescriptor( pluginArtifactId + ":" + goal, session, project );
assertNotNull( mojoDescriptor );
PluginDescriptor pd = mojoDescriptor.getPluginDescriptor();
assertNotNull( pd );
assertEquals( "org.apache.maven.plugins", pd.getGroupId() );
assertEquals( "maven-surefire-plugin", pd.getArtifactId() );
assertEquals( "2.4.2", pd.getVersion() );
MojoExecution mojoExecution = new MojoExecution( mojoDescriptor );
// Need some xpath action in here. Make sure the mojoExecution configuration is intact
// Now the magical mojo descriptor is complete and I can execute the mojo.
pluginManager.executeMojo( project, mojoExecution, session );
} }
protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration ) protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration )
@ -118,4 +176,11 @@ public class LifecycleExecutorTest
containerConfiguration.addComponentDiscoverer( new MavenPluginDiscoverer() ); containerConfiguration.addComponentDiscoverer( new MavenPluginDiscoverer() );
containerConfiguration.addComponentDiscoveryListener( new MavenPluginCollector() ); containerConfiguration.addComponentDiscoveryListener( new MavenPluginCollector() );
} }
//!!jvz The repository system needs to know about the defaults for Maven, it's tied up in the embedder right now.
protected ArtifactRepository getLocalRepository()
throws InvalidRepositoryException
{
return repositorySystem.createLocalRepository( new File( "/Users/jvanzyl/.m2/repository" ) );
}
} }

View File

@ -70,7 +70,7 @@ public class BuildExtensionListenerTest
ReactorManager rm = new ReactorManager( Collections.singletonList( project ), ReactorManager.FAIL_FAST ); ReactorManager rm = new ReactorManager( Collections.singletonList( project ), ReactorManager.FAIL_FAST );
MavenExecutionRequest request = new DefaultMavenExecutionRequest(); MavenExecutionRequest request = new DefaultMavenExecutionRequest();
request.setLocalRepositoryPath( new File( System.getProperty( "user.home" ), ".m2/repository" ) ); request.setLocalRepositoryPath( new File( System.getProperty( "user.home" ), ".m2/repository" ) );
MavenSession session = new MavenSession( getContainer(), request, new DefaultEventDispatcher(), rm ); MavenSession session = new MavenSession( getContainer(), request, rm );
return session; return session;
} }

View File

@ -20,33 +20,6 @@ package org.apache.maven.plugin;
*/ */
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.ArtifactUtils;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.execution.*;
import org.apache.maven.model.Build;
import org.apache.maven.model.Model;
import org.apache.maven.monitor.event.DefaultEventDispatcher;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.execution.DuplicateProjectException;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.path.PathTranslator;
import org.apache.maven.settings.Settings;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.MutablePlexusContainer;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.logging.console.ConsoleLogger;
import org.codehaus.plexus.util.dag.CycleDetectedException;
import org.easymock.MockControl;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -55,6 +28,35 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.ArtifactUtils;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.execution.DefaultMavenExecutionRequest;
import org.apache.maven.execution.DuplicateProjectException;
import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.execution.ReactorManager;
import org.apache.maven.model.Build;
import org.apache.maven.model.Model;
import org.apache.maven.monitor.event.DefaultEventDispatcher;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.path.PathTranslator;
import org.codehaus.plexus.MutablePlexusContainer;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.logging.console.ConsoleLogger;
import org.codehaus.plexus.util.dag.CycleDetectedException;
import org.easymock.MockControl;
/** /**
* @author Jason van Zyl * @author Jason van Zyl
@ -350,7 +352,7 @@ public class PluginParameterExpressionEvaluatorTest
.setBaseDirectory( new File( "" ) ) .setBaseDirectory( new File( "" ) )
.setLocalRepository( repo ); .setLocalRepository( repo );
return new MavenSession( container, request, new DefaultEventDispatcher(), new ReactorManager( Collections.EMPTY_LIST, ReactorManager.FAIL_FAST ) ); return new MavenSession( container, request, null );
} }
public void testLocalRepositoryExtraction() public void testLocalRepositoryExtraction()
@ -470,7 +472,7 @@ public class PluginParameterExpressionEvaluatorTest
ReactorManager rm = new ReactorManager( Collections.singletonList( project ), ReactorManager.FAIL_FAST ); ReactorManager rm = new ReactorManager( Collections.singletonList( project ), ReactorManager.FAIL_FAST );
MockControl mockMavenExecutionRequest = MockControl.createControl( MavenExecutionRequest.class ); MockControl mockMavenExecutionRequest = MockControl.createControl( MavenExecutionRequest.class );
MavenExecutionRequest req = (MavenExecutionRequest) mockMavenExecutionRequest.getMock(); MavenExecutionRequest req = (MavenExecutionRequest) mockMavenExecutionRequest.getMock();
MavenSession session = new MavenSession( getContainer(), req, new DefaultEventDispatcher(), rm ); MavenSession session = new MavenSession( getContainer(), req, rm );
return session; return session;
} }

View File

@ -285,7 +285,7 @@ public class MavenEmbedder
protected void verifyPlugin( Plugin plugin, MavenProject project ) protected void verifyPlugin( Plugin plugin, MavenProject project )
throws ComponentLookupException, PluginLoaderException throws ComponentLookupException, PluginLoaderException
{ {
MavenSession session = new MavenSession( container, request, null, null ); MavenSession session = new MavenSession( container, request, null );
pluginManager.loadPlugin( plugin, project, session ); pluginManager.loadPlugin( plugin, project, session );
} }

View File

@ -1318,7 +1318,7 @@ public class MavenProject
} }
} }
//TODO: remove ModelUtils //!!jvz remove ModelUtils
public void injectPluginManagementInfo( Plugin plugin ) public void injectPluginManagementInfo( Plugin plugin )
{ {
PluginManagement pm = getModelBuild().getPluginManagement(); PluginManagement pm = getModelBuild().getPluginManagement();

View File

@ -1,22 +1,18 @@
package org.apache.maven.project; package org.apache.maven.project;
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
* or more contributor license agreements. See the NOTICE file * agreements. See the NOTICE file distributed with this work for additional information regarding
* distributed with this work for additional information * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
* regarding copyright ownership. The ASF licenses this file * "License"); you may not use this file except in compliance with the License. You may obtain a
* to you under the Apache License, Version 2.0 (the * copy of the License at
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing, software distributed under the License
* software distributed under the License is distributed on an * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * or implied. See the License for the specific language governing permissions and limitations under
* KIND, either express or implied. See the License for the * the License.
* specific language governing permissions and limitations
* under the License.
*/ */
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
@ -32,6 +28,7 @@ import java.io.FileNotFoundException;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
import java.util.Arrays;
import java.util.Properties; import java.util.Properties;
/** /**
@ -96,9 +93,7 @@ public abstract class AbstractMavenProjectTestCase
{ {
ArtifactRepositoryLayout repoLayout = lookup( ArtifactRepositoryLayout.class, "legacy" ); ArtifactRepositoryLayout repoLayout = lookup( ArtifactRepositoryLayout.class, "legacy" );
ArtifactRepository r = new DefaultArtifactRepository( "local", ArtifactRepository r = new DefaultArtifactRepository( "local", "file://" + getLocalRepositoryPath().getAbsolutePath(), repoLayout );
"file://" + getLocalRepositoryPath().getAbsolutePath(),
repoLayout );
return r; return r;
} }
@ -110,19 +105,20 @@ public abstract class AbstractMavenProjectTestCase
protected MavenProject getProjectWithDependencies( File pom ) protected MavenProject getProjectWithDependencies( File pom )
throws Exception throws Exception
{ {
ProjectBuilderConfiguration pbc = new DefaultProjectBuilderConfiguration(); ProjectBuilderConfiguration configuration = new DefaultProjectBuilderConfiguration();
pbc.setLocalRepository( getLocalRepository() ); configuration.setLocalRepository( getLocalRepository() );
configuration.setRemoteRepositories( Arrays.asList( new ArtifactRepository[]{} ) );
try try
{ {
return projectBuilder.buildProjectWithDependencies( pom, pbc).getProject(); return projectBuilder.buildProjectWithDependencies( pom, configuration ).getProject();
} }
catch ( Exception e ) catch ( Exception e )
{ {
if ( e instanceof InvalidProjectModelException ) if ( e instanceof InvalidProjectModelException )
{ {
ModelValidationResult validationResult = ((InvalidProjectModelException)e).getValidationResult(); ModelValidationResult validationResult = ( (InvalidProjectModelException) e ).getValidationResult();
String message = "In: " + pom + "(" + ((ProjectBuildingException) e).getProjectId() + ")\n\n" + validationResult.render( " " ); String message = "In: " + pom + "(" + ( (ProjectBuildingException) e ).getProjectId() + ")\n\n" + validationResult.render( " " );
System.out.println( message ); System.out.println( message );
fail( message ); fail( message );
} }

View File

@ -69,7 +69,7 @@ public class ProjectInheritanceTest
Set set = project1.getArtifacts(); Set set = project1.getArtifacts();
assertNotNull("No artifacts", set); assertNotNull("No artifacts", set);
assertTrue("No Artifacts", set.size() > 0); assertTrue("No Artifacts", set.size() > 0);
assertTrue("Set size should be 3, is " + set.size(), set.size() == 3); assertTrue("Set size should be 4, is " + set.size(), set.size() == 4);
Iterator iter = set.iterator(); Iterator iter = set.iterator();
while (iter.hasNext()) { while (iter.hasNext()) {

View File

@ -66,7 +66,7 @@ public class ProjectInheritanceTest
assertNotNull("No artifacts", set); assertNotNull("No artifacts", set);
assertTrue("No Artifacts", set.size() > 0); assertTrue("No Artifacts", set.size() > 0);
Iterator iter = set.iterator(); Iterator iter = set.iterator();
assertTrue("Set size should be 4, is " + set.size(), set.size() == 4); assertTrue("Set size should be 5, is " + set.size(), set.size() == 5);
while (iter.hasNext()) while (iter.hasNext())
{ {

View File

@ -65,7 +65,7 @@ public class ProjectInheritanceTest
Set set = project1.getArtifacts(); Set set = project1.getArtifacts();
assertNotNull("No artifacts", set); assertNotNull("No artifacts", set);
assertTrue("No Artifacts", set.size() > 0); assertTrue("No Artifacts", set.size() > 0);
assertTrue("Set size should be 3, is " + set.size(), set.size() == 3); assertTrue("Set size should be 4, is " + set.size(), set.size() == 4 );
Iterator iter = set.iterator(); Iterator iter = set.iterator();

View File

@ -67,7 +67,7 @@ public class ProjectInheritanceTest
assertNotNull("No artifacts", set); assertNotNull("No artifacts", set);
assertTrue("No Artifacts", set.size() > 0); assertTrue("No Artifacts", set.size() > 0);
Iterator iter = set.iterator(); Iterator iter = set.iterator();
assertTrue("Set size should be 4, is " + set.size(), set.size() == 4); assertTrue("Set size should be 5, is " + set.size(), set.size() == 5);
while (iter.hasNext()) while (iter.hasNext())
{ {

View File

@ -76,7 +76,7 @@ public class ProjectInheritanceTest
assertNotNull("No artifacts", map); assertNotNull("No artifacts", map);
assertTrue("No Artifacts", map.size() > 0); assertTrue("No Artifacts", map.size() > 0);
assertTrue("Set size should be 2, is " + map.size(), map.size() == 2); assertTrue("Set size should be 3, is " + map.size(), map.size() == 3);
assertTrue("maven-test:t09-a is not in the project", map.containsKey( "maven-test:t09-a" )); assertTrue("maven-test:t09-a is not in the project", map.containsKey( "maven-test:t09-a" ));
assertTrue("maven-test:t09-b is not in the project", map.containsKey( "maven-test:t09-b" )); assertTrue("maven-test:t09-b is not in the project", map.containsKey( "maven-test:t09-b" ));
@ -110,7 +110,7 @@ public class ProjectInheritanceTest
Map map = project2.getArtifactMap(); Map map = project2.getArtifactMap();
assertNotNull( "No artifacts", map ); assertNotNull( "No artifacts", map );
assertTrue( "No Artifacts", map.size() > 0 ); assertTrue( "No Artifacts", map.size() > 0 );
assertTrue( "Set size should be 4, is " + map.size(), map.size() == 4 ); assertTrue( "Set size should be 5, is " + map.size(), map.size() == 5 );
assertTrue( "maven-test:t09-a is not in the project", map.containsKey( "maven-test:t09-a" ) ); assertTrue( "maven-test:t09-a is not in the project", map.containsKey( "maven-test:t09-a" ) );
assertTrue( "maven-test:t09-b is not in the project", map.containsKey( "maven-test:t09-b" ) ); assertTrue( "maven-test:t09-b is not in the project", map.containsKey( "maven-test:t09-b" ) );

View File

@ -71,7 +71,7 @@ public class ProjectInheritanceTest
Map map = project1.getArtifactMap(); Map map = project1.getArtifactMap();
assertNotNull("No artifacts", map); assertNotNull("No artifacts", map);
assertTrue("No Artifacts", map.size() > 0); assertTrue("No Artifacts", map.size() > 0);
assertTrue("Set size should be 3, is " + map.size(), map.size() == 3); assertTrue("Set size should be 4, is " + map.size(), map.size() == 4);
Artifact a = (Artifact) map.get("maven-test:t10-a"); Artifact a = (Artifact) map.get("maven-test:t10-a");
Artifact b = (Artifact) map.get("maven-test:t10-b"); Artifact b = (Artifact) map.get("maven-test:t10-b");

View File

@ -67,7 +67,7 @@ under the License.
<mercuryMp3Version>1.0-alpha-1</mercuryMp3Version> <mercuryMp3Version>1.0-alpha-1</mercuryMp3Version>
<securityDispatcherVersion>1.2</securityDispatcherVersion> <securityDispatcherVersion>1.2</securityDispatcherVersion>
<woodstoxVersion>3.2.6</woodstoxVersion> <woodstoxVersion>3.2.6</woodstoxVersion>
<modelloVersion>1.0.1-SNAPSHOT</modelloVersion> <modelloVersion>1.0.1</modelloVersion>
<jxpathVersion>1.3</jxpathVersion> <jxpathVersion>1.3</jxpathVersion>
</properties> </properties>
<issueManagement> <issueManagement>