mirror of https://github.com/apache/maven.git
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:
parent
7b6c7f6ce3
commit
0bf25e64d8
|
@ -209,7 +209,6 @@ END SNIPPET: ant-bootstrap -->
|
|||
</macrodef>
|
||||
|
||||
<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-project/src/main/mdo/profiles.mdo"/>
|
||||
<modello file="maven-core/src/main/mdo/settings.mdo"/>
|
||||
|
|
|
@ -164,7 +164,6 @@ END SNIPPET: ant-bootstrap -->
|
|||
</macrodef>
|
||||
|
||||
<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-project/src/main/mdo/profiles.mdo"/>
|
||||
<modello file="maven-core/src/main/mdo/settings.mdo"/>
|
||||
|
|
|
@ -1,22 +1,18 @@
|
|||
package org.apache.maven.artifact.manager;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
|
||||
* agreements. See the NOTICE file distributed with this work for additional information regarding
|
||||
* copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* 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.
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
|
@ -60,14 +56,14 @@ import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
|
|||
import org.codehaus.plexus.logging.Logger;
|
||||
import org.codehaus.plexus.util.FileUtils;
|
||||
|
||||
@Component(role=WagonManager.class)
|
||||
@Component(role = WagonManager.class)
|
||||
public class DefaultWagonManager
|
||||
implements WagonManager
|
||||
{
|
||||
private static final String[] CHECKSUM_IDS = {"md5", "sha1"};
|
||||
private static final String[] CHECKSUM_IDS = { "md5", "sha1" };
|
||||
|
||||
/** 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
|
||||
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
|
||||
// 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.
|
||||
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 */
|
||||
private Map<String,XmlPlexusConfiguration> serverConfigurationMap = new HashMap<String,XmlPlexusConfiguration>();
|
||||
private Map<String, XmlPlexusConfiguration> serverConfigurationMap = new HashMap<String, XmlPlexusConfiguration>();
|
||||
|
||||
private RepositoryPermissions defaultRepositoryPermissions;
|
||||
|
||||
|
@ -96,7 +92,7 @@ public class DefaultWagonManager
|
|||
@Requirement
|
||||
private ArtifactRepositoryFactory repositoryFactory;
|
||||
|
||||
@Requirement(role=Wagon.class)
|
||||
@Requirement(role = Wagon.class)
|
||||
private Map wagons;
|
||||
|
||||
//@Requirement
|
||||
|
@ -125,7 +121,6 @@ public class DefaultWagonManager
|
|||
throw new UnsupportedProtocolException( "The repository " + repository + " does not specify a protocol" );
|
||||
}
|
||||
|
||||
|
||||
Wagon wagon = getWagon( protocol );
|
||||
|
||||
configureWagon( wagon, repository.getId(), protocol );
|
||||
|
@ -141,14 +136,12 @@ public class DefaultWagonManager
|
|||
throw new UnsupportedProtocolException( "Unspecified protocol" );
|
||||
}
|
||||
|
||||
|
||||
String hint = protocol.toLowerCase( java.util.Locale.ENGLISH );
|
||||
Wagon wagon = (Wagon) wagons.get( hint );
|
||||
|
||||
if ( wagon == null )
|
||||
{
|
||||
throw new UnsupportedProtocolException(
|
||||
"Cannot find wagon which supports the requested protocol: " + protocol );
|
||||
throw new UnsupportedProtocolException( "Cannot find wagon which supports the requested protocol: " + protocol );
|
||||
}
|
||||
|
||||
return wagon;
|
||||
|
@ -195,9 +188,9 @@ public class DefaultWagonManager
|
|||
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
|
||||
for ( int i = 0; i < CHECKSUM_IDS.length; i++ )
|
||||
|
@ -219,7 +212,7 @@ public class DefaultWagonManager
|
|||
{
|
||||
return getProxy( protocol );
|
||||
}
|
||||
});
|
||||
} );
|
||||
|
||||
wagon.put( source, remotePath );
|
||||
}
|
||||
|
@ -238,19 +231,21 @@ public class DefaultWagonManager
|
|||
}
|
||||
|
||||
// Pre-store the checksums as any future puts will overwrite them
|
||||
for (String extension : checksums.keySet()) {
|
||||
ChecksumObserver observer = checksums.get(extension);
|
||||
sums.put(extension, observer.getActualChecksum());
|
||||
for ( String extension : checksums.keySet() )
|
||||
{
|
||||
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
|
||||
for (String extension : checksums.keySet()) {
|
||||
for ( String extension : checksums.keySet() )
|
||||
{
|
||||
// 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();
|
||||
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 )
|
||||
|
@ -276,10 +271,12 @@ public class DefaultWagonManager
|
|||
finally
|
||||
{
|
||||
// Remove every checksum listener
|
||||
for (String aCHECKSUM_IDS : CHECKSUM_IDS) {
|
||||
TransferListener checksumListener = checksums.get(aCHECKSUM_IDS);
|
||||
if (checksumListener != null) {
|
||||
wagon.removeTransferListener(checksumListener);
|
||||
for ( String aCHECKSUM_IDS : CHECKSUM_IDS )
|
||||
{
|
||||
TransferListener checksumListener = checksums.get( aCHECKSUM_IDS );
|
||||
if ( checksumListener != null )
|
||||
{
|
||||
wagon.removeTransferListener( checksumListener );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -289,8 +286,7 @@ public class DefaultWagonManager
|
|||
}
|
||||
}
|
||||
|
||||
private ChecksumObserver addChecksumObserver( Wagon wagon,
|
||||
String algorithm )
|
||||
private ChecksumObserver addChecksumObserver( Wagon wagon, String algorithm )
|
||||
throws TransferFailedException
|
||||
{
|
||||
try
|
||||
|
@ -305,11 +301,10 @@ public class DefaultWagonManager
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// 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
|
||||
public void getArtifact( Artifact artifact, ArtifactRepository remoteRepository, boolean force )
|
||||
throws TransferFailedException, ResourceDoesNotExistException
|
||||
throws TransferFailedException, ResourceDoesNotExistException
|
||||
{
|
||||
getArtifact( artifact, remoteRepository, downloadMonitor, force );
|
||||
}
|
||||
|
@ -320,23 +315,24 @@ public class DefaultWagonManager
|
|||
getArtifact( artifact, remoteRepository, downloadMonitor, true );
|
||||
}
|
||||
|
||||
public void getArtifact( Artifact artifact, List<ArtifactRepository> remoteRepositories, TransferListener downloadMonitor )
|
||||
public void getArtifact( Artifact artifact, List<ArtifactRepository> remoteRepositories, TransferListener downloadMonitor )
|
||||
throws TransferFailedException, ResourceDoesNotExistException
|
||||
{
|
||||
getArtifact( artifact, remoteRepositories, downloadMonitor, true );
|
||||
}
|
||||
{
|
||||
getArtifact( artifact, remoteRepositories, downloadMonitor, true );
|
||||
}
|
||||
|
||||
public void getArtifact( Artifact artifact, List<ArtifactRepository> remoteRepositories, TransferListener downloadMonitor, boolean force )
|
||||
throws TransferFailedException, ResourceDoesNotExistException
|
||||
{
|
||||
for (ArtifactRepository repository : remoteRepositories) {
|
||||
for ( ArtifactRepository repository : remoteRepositories )
|
||||
{
|
||||
try
|
||||
{
|
||||
getArtifact( artifact, repository, downloadMonitor, force );
|
||||
|
||||
if (artifact.isResolved())
|
||||
if ( artifact.isResolved() )
|
||||
{
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch ( ResourceDoesNotExistException e )
|
||||
|
@ -344,13 +340,11 @@ public class DefaultWagonManager
|
|||
// This one we will eat when looking through remote repositories
|
||||
// because we want to cycle through them all before squawking.
|
||||
|
||||
logger.debug( "Unable to get resource '" + artifact.getId() + "' from repository " +
|
||||
repository.getId() + " (" + repository.getUrl() + ")", e );
|
||||
logger.debug( "Unable to get resource '" + artifact.getId() + "' from repository " + repository.getId() + " (" + repository.getUrl() + ")", e );
|
||||
}
|
||||
catch ( TransferFailedException e )
|
||||
{
|
||||
logger.debug( "Unable to get resource '" + artifact.getId() + "' from repository " +
|
||||
repository.getId() + " (" + repository.getUrl() + ")", e );
|
||||
logger.debug( "Unable to get resource '" + artifact.getId() + "' from repository " + repository.getId() + " (" + repository.getUrl() + ")", e );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -362,8 +356,7 @@ public class DefaultWagonManager
|
|||
}
|
||||
|
||||
public void getArtifact( Artifact artifact, ArtifactRepository repository, TransferListener downloadMonitor )
|
||||
throws TransferFailedException,
|
||||
ResourceDoesNotExistException
|
||||
throws TransferFailedException, ResourceDoesNotExistException
|
||||
{
|
||||
getArtifact( artifact, repository, downloadMonitor, true );
|
||||
}
|
||||
|
@ -396,7 +389,7 @@ public class DefaultWagonManager
|
|||
}
|
||||
finally
|
||||
{
|
||||
updateCheckManager.touch( artifact, repository );
|
||||
updateCheckManager.touch( artifact, repository );
|
||||
}
|
||||
|
||||
logger.debug( " Artifact resolved" );
|
||||
|
@ -457,10 +450,7 @@ public class DefaultWagonManager
|
|||
}
|
||||
}
|
||||
|
||||
public void getArtifactMetadata( ArtifactMetadata metadata,
|
||||
ArtifactRepository repository,
|
||||
File destination,
|
||||
String checksumPolicy )
|
||||
public void getArtifactMetadata( ArtifactMetadata metadata, ArtifactRepository repository, File destination, String checksumPolicy )
|
||||
throws TransferFailedException, ResourceDoesNotExistException
|
||||
{
|
||||
String remotePath = repository.pathOfRemoteRepositoryMetadata( metadata );
|
||||
|
@ -468,8 +458,7 @@ public class DefaultWagonManager
|
|||
getRemoteFile( repository, destination, remotePath, null, checksumPolicy, true );
|
||||
}
|
||||
|
||||
public void getArtifactMetadataFromDeploymentRepository( ArtifactMetadata metadata, ArtifactRepository repository,
|
||||
File destination, String checksumPolicy )
|
||||
public void getArtifactMetadataFromDeploymentRepository( ArtifactMetadata metadata, ArtifactRepository repository, File destination, String checksumPolicy )
|
||||
throws TransferFailedException, ResourceDoesNotExistException
|
||||
{
|
||||
String remotePath = repository.pathOfRemoteRepositoryMetadata( metadata );
|
||||
|
@ -477,12 +466,7 @@ public class DefaultWagonManager
|
|||
getRemoteFile( repository, destination, remotePath, null, checksumPolicy, true );
|
||||
}
|
||||
|
||||
private void getRemoteFile( ArtifactRepository repository,
|
||||
File destination,
|
||||
String remotePath,
|
||||
TransferListener downloadMonitor,
|
||||
String checksumPolicy,
|
||||
boolean force )
|
||||
private void getRemoteFile( ArtifactRepository repository, File destination, String remotePath, TransferListener downloadMonitor, String checksumPolicy, boolean force )
|
||||
throws TransferFailedException, ResourceDoesNotExistException
|
||||
{
|
||||
String protocol = repository.getProtocol();
|
||||
|
@ -513,14 +497,13 @@ public class DefaultWagonManager
|
|||
|
||||
try
|
||||
{
|
||||
wagon.connect( new Repository( repository.getId(), repository.getUrl() ),
|
||||
getAuthenticationInfo( repository.getId() ), new ProxyInfoProvider()
|
||||
wagon.connect( new Repository( repository.getId(), repository.getUrl() ), getAuthenticationInfo( repository.getId() ), new ProxyInfoProvider()
|
||||
{
|
||||
public ProxyInfo getProxyInfo( String protocol )
|
||||
{
|
||||
return getProxy( protocol );
|
||||
}
|
||||
});
|
||||
} );
|
||||
|
||||
boolean firstRun = true;
|
||||
boolean retry = true;
|
||||
|
@ -631,8 +614,7 @@ public class DefaultWagonManager
|
|||
catch ( ResourceDoesNotExistException md5TryException )
|
||||
{
|
||||
// this was a failed transfer, and we don't want to retry.
|
||||
handleChecksumFailure( checksumPolicy, "Error retrieving checksum file for " + remotePath,
|
||||
md5TryException );
|
||||
handleChecksumFailure( checksumPolicy, "Error retrieving checksum file for " + remotePath, md5TryException );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -699,16 +681,13 @@ public class DefaultWagonManager
|
|||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new TransferFailedException(
|
||||
"Error copying temporary file to the final destination: " + e.getMessage(), e );
|
||||
throw new TransferFailedException( "Error copying temporary file to the final destination: " + e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleChecksumFailure( String checksumPolicy,
|
||||
String message,
|
||||
Throwable cause )
|
||||
private void handleChecksumFailure( String checksumPolicy, String message, Throwable cause )
|
||||
throws ChecksumFailedException
|
||||
{
|
||||
if ( ArtifactRepositoryPolicy.CHECKSUM_POLICY_FAIL.equals( checksumPolicy ) )
|
||||
|
@ -723,12 +702,7 @@ public class DefaultWagonManager
|
|||
// otherwise it is ignore
|
||||
}
|
||||
|
||||
private void verifyChecksum( ChecksumObserver checksumObserver,
|
||||
File destination,
|
||||
File tempDestination,
|
||||
String remotePath,
|
||||
String checksumFileExtension,
|
||||
Wagon wagon )
|
||||
private void verifyChecksum( ChecksumObserver checksumObserver, File destination, File tempDestination, String remotePath, String checksumFileExtension, Wagon wagon )
|
||||
throws ResourceDoesNotExistException, TransferFailedException, AuthorizationException
|
||||
{
|
||||
try
|
||||
|
@ -746,8 +720,7 @@ public class DefaultWagonManager
|
|||
expectedChecksum = expectedChecksum.trim();
|
||||
|
||||
// check for 'ALGO (name) = CHECKSUM' like used by openssl
|
||||
if ( expectedChecksum.regionMatches( true, 0, "MD", 0, 2 )
|
||||
|| expectedChecksum.regionMatches( true, 0, "SHA", 0, 3 ) )
|
||||
if ( expectedChecksum.regionMatches( true, 0, "MD", 0, 2 ) || expectedChecksum.regionMatches( true, 0, "SHA", 0, 3 ) )
|
||||
{
|
||||
int lastSpacePos = expectedChecksum.lastIndexOf( ' ' );
|
||||
expectedChecksum = expectedChecksum.substring( lastSpacePos + 1 );
|
||||
|
@ -774,8 +747,7 @@ public class DefaultWagonManager
|
|||
}
|
||||
else
|
||||
{
|
||||
throw new ChecksumFailedException( "Checksum failed on download: local = '" + actualChecksum +
|
||||
"'; remote = '" + expectedChecksum + "'" );
|
||||
throw new ChecksumFailedException( "Checksum failed on download: local = '" + actualChecksum + "'; remote = '" + expectedChecksum + "'" );
|
||||
}
|
||||
}
|
||||
catch ( IOException e )
|
||||
|
@ -784,7 +756,6 @@ public class DefaultWagonManager
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private void disconnectWagon( Wagon wagon )
|
||||
{
|
||||
try
|
||||
|
@ -797,8 +768,7 @@ public class DefaultWagonManager
|
|||
}
|
||||
}
|
||||
|
||||
private void releaseWagon( String protocol,
|
||||
Wagon wagon )
|
||||
private void releaseWagon( String protocol, Wagon wagon )
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -833,7 +803,7 @@ public class DefaultWagonManager
|
|||
try
|
||||
{
|
||||
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 )
|
||||
{
|
||||
|
@ -850,16 +820,11 @@ public class DefaultWagonManager
|
|||
* @param port the proxy port (required)
|
||||
* @param username the username for the proxy, or null if there is none
|
||||
* @param password the password for the proxy, or null if there is none
|
||||
* @param nonProxyHosts the set of hosts not to use the proxy for. Follows Java system property format:
|
||||
* <code>*.foo.com|localhost</code>.
|
||||
* @param nonProxyHosts the set of hosts not to use the proxy for. Follows Java system property
|
||||
* format: <code>*.foo.com|localhost</code>.
|
||||
* @todo [BP] would be nice to configure this via plexus in some way
|
||||
*/
|
||||
public void addProxy( String protocol,
|
||||
String host,
|
||||
int port,
|
||||
String username,
|
||||
String password,
|
||||
String nonProxyHosts )
|
||||
public void addProxy( String protocol, String host, int port, String username, String password, String nonProxyHosts )
|
||||
{
|
||||
ProxyInfo proxyInfo = new ProxyInfo();
|
||||
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
|
||||
// library from the 2.0.x code so that we aren't maintaining two lines of code
|
||||
// for the artifact management.
|
||||
public void addAuthenticationInfo( String repositoryId,
|
||||
String username,
|
||||
String password,
|
||||
String privateKey,
|
||||
String passphrase
|
||||
)
|
||||
public void addAuthenticationInfo( String repositoryId, String username, String password, String privateKey, String passphrase )
|
||||
{
|
||||
AuthenticationInfo authInfo = new AuthenticationInfo();
|
||||
authInfo.setUserName( username );
|
||||
|
@ -891,9 +851,7 @@ public class DefaultWagonManager
|
|||
authenticationInfoMap.put( repositoryId, authInfo );
|
||||
}
|
||||
|
||||
public void addPermissionInfo( String repositoryId,
|
||||
String filePermissions,
|
||||
String directoryPermissions )
|
||||
public void addPermissionInfo( String repositoryId, String filePermissions, String directoryPermissions )
|
||||
{
|
||||
RepositoryPermissions permissions = new RepositoryPermissions();
|
||||
|
||||
|
@ -920,9 +878,10 @@ public class DefaultWagonManager
|
|||
/**
|
||||
* Applies the server configuration to the wagon
|
||||
*
|
||||
* @param wagon the wagon to configure
|
||||
* @param wagon the wagon to configure
|
||||
* @param repository the repository that has the configuration
|
||||
* @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 )
|
||||
throws WagonConfigurationException
|
||||
|
|
|
@ -1,22 +1,18 @@
|
|||
package org.apache.maven.artifact.repository;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
|
||||
* agreements. See the NOTICE file distributed with this work for additional information regarding
|
||||
* copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* 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.
|
||||
* 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;
|
||||
|
@ -38,6 +34,7 @@ public interface ArtifactRepository
|
|||
String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository );
|
||||
|
||||
String getUrl();
|
||||
|
||||
void setUrl( String url );
|
||||
|
||||
String getBasedir();
|
||||
|
@ -45,15 +42,19 @@ public interface ArtifactRepository
|
|||
String getProtocol();
|
||||
|
||||
String getId();
|
||||
|
||||
void setId( String id );
|
||||
|
||||
ArtifactRepositoryPolicy getSnapshots();
|
||||
|
||||
void setSnapshotUpdatePolicy( ArtifactRepositoryPolicy policy );
|
||||
|
||||
ArtifactRepositoryPolicy getReleases();
|
||||
|
||||
void setReleaseUpdatePolicy( ArtifactRepositoryPolicy policy );
|
||||
|
||||
ArtifactRepositoryLayout getLayout();
|
||||
|
||||
void setLayout( ArtifactRepositoryLayout layout );
|
||||
|
||||
String getKey();
|
||||
|
|
|
@ -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 )
|
||||
{
|
||||
Artifact rootArtifact = request.getArtifact();
|
||||
|
@ -358,6 +363,14 @@ public class DefaultArtifactResolver
|
|||
List<ResolutionListener> listeners = request.getListeners();
|
||||
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 )
|
||||
{
|
||||
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.
|
||||
result = artifactCollector.collect( artifacts, rootArtifact, managedVersions, localRepository, remoteRepositories, source, filter, listeners );
|
||||
|
||||
// Add the root artifact
|
||||
result.addArtifact( rootArtifact );
|
||||
if ( !isDummy( request ) )
|
||||
{
|
||||
// Add the root artifact
|
||||
result.addArtifact( rootArtifact );
|
||||
}
|
||||
|
||||
// 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
|
||||
|
|
|
@ -159,7 +159,7 @@ public class ArtifactResolverTest
|
|||
ArtifactResolutionResult result =
|
||||
artifactResolver.resolveTransitively( Collections.singleton( g ), projectArtifact, remoteRepositories(), localRepository(), mds );
|
||||
|
||||
assertEquals( 2, result.getArtifacts().size() );
|
||||
assertEquals( 3, result.getArtifacts().size() );
|
||||
|
||||
assertTrue( result.getArtifacts().contains( g ) );
|
||||
|
||||
|
@ -234,7 +234,7 @@ public class ArtifactResolverTest
|
|||
artifactResolver.resolveTransitively( Collections.singleton( i ), projectArtifact, remoteRepositories(),
|
||||
localRepository(), mds );
|
||||
|
||||
assertEquals( 2, result.getArtifacts().size() );
|
||||
assertEquals( 3, result.getArtifacts().size() );
|
||||
|
||||
assertTrue( result.getArtifacts().contains( i ) );
|
||||
|
||||
|
|
|
@ -382,11 +382,9 @@ public class DefaultMaven
|
|||
// the session type would be specific to the request i.e. having a project
|
||||
// or not.
|
||||
|
||||
protected MavenSession createSession( MavenExecutionRequest request,
|
||||
ReactorManager reactorManager,
|
||||
EventDispatcher dispatcher )
|
||||
protected MavenSession createSession( MavenExecutionRequest request, ReactorManager reactorManager, EventDispatcher dispatcher )
|
||||
{
|
||||
MavenSession session = new MavenSession( container, request, dispatcher, reactorManager );
|
||||
MavenSession session = new MavenSession( container, request, reactorManager, dispatcher );
|
||||
|
||||
return session;
|
||||
}
|
||||
|
|
|
@ -73,14 +73,19 @@ public class MavenSession
|
|||
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.request = request;
|
||||
this.eventDispatcher = eventDispatcher;
|
||||
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 )
|
||||
{
|
||||
if ( reactorManager == null )
|
||||
|
|
|
@ -1225,8 +1225,6 @@ public class DefaultLifecycleExecutor
|
|||
String goal;
|
||||
Plugin plugin;
|
||||
|
||||
PluginDescriptor pluginDescriptor = null;
|
||||
|
||||
StringTokenizer tok = new StringTokenizer( task, ":" );
|
||||
int numTokens = tok.countTokens();
|
||||
|
||||
|
@ -1246,14 +1244,6 @@ public class DefaultLifecycleExecutor
|
|||
|
||||
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
|
||||
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 )
|
||||
{
|
||||
|
@ -1313,10 +1295,7 @@ public class DefaultLifecycleExecutor
|
|||
project.injectPluginManagementInfo( plugin );
|
||||
}
|
||||
|
||||
if ( pluginDescriptor == null )
|
||||
{
|
||||
pluginDescriptor = loadPlugin( plugin, project, session );
|
||||
}
|
||||
PluginDescriptor pluginDescriptor = loadPlugin( plugin, project, session );
|
||||
|
||||
// this has been simplified from the old code that injected the plugin management stuff, since
|
||||
// pluginManagement injection is now handled by the project method.
|
||||
|
|
|
@ -165,6 +165,7 @@ public class DefaultPluginManager
|
|||
// TODO: this should be possibly outside
|
||||
// All version-resolution logic has been moved to DefaultPluginVersionManager.
|
||||
logger.debug( "Resolving plugin: " + plugin.getKey() + " with version: " + pluginVersion );
|
||||
|
||||
if ( ( pluginVersion == null ) || Artifact.LATEST_VERSION.equals( pluginVersion ) || Artifact.RELEASE_VERSION.equals( pluginVersion ) )
|
||||
{
|
||||
logger.debug( "Resolving version for plugin: " + plugin.getKey() );
|
||||
|
@ -310,7 +311,8 @@ public class DefaultPluginManager
|
|||
}
|
||||
|
||||
pluginDescriptor.setPluginArtifact( pluginArtifact );
|
||||
|
||||
// Make sure it's just the plugin artifacts
|
||||
pluginDescriptor.setArtifacts( new ArrayList( pluginArtifacts ) );
|
||||
pluginDescriptor.setClassRealm( pluginRealm );
|
||||
|
||||
pluginRealms.put( pluginKey( plugin ), pluginRealm );
|
||||
|
@ -561,10 +563,9 @@ public class DefaultPluginManager
|
|||
ClassRealm oldLookupRealm = container.getLookupRealm();
|
||||
ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
|
||||
|
||||
List realmActions = new ArrayList();
|
||||
try
|
||||
{
|
||||
mojo = getConfiguredMojo( session, dom, project, false, mojoExecution, realmActions );
|
||||
mojo = getConfiguredMojo( session, dom, project, false, mojoExecution );
|
||||
|
||||
//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 )
|
||||
{
|
||||
//container.setLookupRealm( oldLookupRealm );
|
||||
container.setLookupRealm( null );
|
||||
}
|
||||
|
||||
|
@ -660,7 +651,7 @@ public class DefaultPluginManager
|
|||
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 )
|
||||
|
@ -685,7 +676,7 @@ public class DefaultPluginManager
|
|||
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
|
||||
{
|
||||
MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
|
||||
|
@ -703,7 +694,6 @@ public class DefaultPluginManager
|
|||
Thread.currentThread().setContextClassLoader( pluginRealm );
|
||||
try
|
||||
{
|
||||
System.out.println( pluginDescriptor );
|
||||
logger.debug( "Looking up mojo " + mojoDescriptor.getRoleHint() + " in realm " + pluginRealm.getId() + " - descRealmId=" + mojoDescriptor.getRealm() );
|
||||
|
||||
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 )
|
||||
throws IOException
|
||||
{
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.io.File;
|
|||
import java.util.Arrays;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.maven.artifact.InvalidRepositoryException;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.execution.DefaultMavenExecutionRequest;
|
||||
import org.apache.maven.execution.MavenExecutionRequest;
|
||||
|
@ -43,7 +44,6 @@ public class LifecycleExecutorTest
|
|||
protected void setUp()
|
||||
throws Exception
|
||||
{
|
||||
//!!jvz need these injected into the test cases as this is a pita.
|
||||
projectBuilder = lookup( MavenProjectBuilder.class );
|
||||
repositorySystem = lookup( RepositorySystem.class );
|
||||
pluginManager = lookup( PluginManager.class );
|
||||
|
@ -55,7 +55,7 @@ public class LifecycleExecutorTest
|
|||
assertNotNull( lifecycleExecutor.getLifecyclePhases() );
|
||||
}
|
||||
|
||||
public void testMojoExecution()
|
||||
public void testRemoteResourcesPlugin()
|
||||
throws Exception
|
||||
{
|
||||
// - 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 targetPom = new File( getBasedir(), "target/lifecycle-executor/pom-plugin.xml" );
|
||||
FileUtils.copyFile( pom, targetPom );
|
||||
|
||||
if ( !targetPom.getParentFile().exists() )
|
||||
{
|
||||
targetPom.getParentFile().mkdirs();
|
||||
}
|
||||
|
||||
ArtifactRepository localRepository = repositorySystem.createLocalRepository( new File( "/Users/jvanzyl/.m2/repository" ) );
|
||||
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 ) ) );
|
||||
.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() );
|
||||
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, 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 );
|
||||
|
||||
String pluginArtifactId = "remote-resources";
|
||||
|
@ -105,12 +103,72 @@ public class LifecycleExecutorTest
|
|||
assertEquals( "maven-remote-resources-plugin", pd.getArtifactId() );
|
||||
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
|
||||
|
||||
// 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 )
|
||||
|
@ -118,4 +176,11 @@ public class LifecycleExecutorTest
|
|||
containerConfiguration.addComponentDiscoverer( new MavenPluginDiscoverer() );
|
||||
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" ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ public class BuildExtensionListenerTest
|
|||
ReactorManager rm = new ReactorManager( Collections.singletonList( project ), ReactorManager.FAIL_FAST );
|
||||
MavenExecutionRequest request = new DefaultMavenExecutionRequest();
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -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.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
@ -55,6 +28,35 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
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
|
||||
|
@ -350,7 +352,7 @@ public class PluginParameterExpressionEvaluatorTest
|
|||
.setBaseDirectory( new File( "" ) )
|
||||
.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()
|
||||
|
@ -470,7 +472,7 @@ public class PluginParameterExpressionEvaluatorTest
|
|||
ReactorManager rm = new ReactorManager( Collections.singletonList( project ), ReactorManager.FAIL_FAST );
|
||||
MockControl mockMavenExecutionRequest = MockControl.createControl( MavenExecutionRequest.class );
|
||||
MavenExecutionRequest req = (MavenExecutionRequest) mockMavenExecutionRequest.getMock();
|
||||
MavenSession session = new MavenSession( getContainer(), req, new DefaultEventDispatcher(), rm );
|
||||
MavenSession session = new MavenSession( getContainer(), req, rm );
|
||||
|
||||
return session;
|
||||
}
|
||||
|
|
|
@ -285,7 +285,7 @@ public class MavenEmbedder
|
|||
protected void verifyPlugin( Plugin plugin, MavenProject project )
|
||||
throws ComponentLookupException, PluginLoaderException
|
||||
{
|
||||
MavenSession session = new MavenSession( container, request, null, null );
|
||||
MavenSession session = new MavenSession( container, request, null );
|
||||
pluginManager.loadPlugin( plugin, project, session );
|
||||
}
|
||||
|
||||
|
|
|
@ -1318,7 +1318,7 @@ public class MavenProject
|
|||
}
|
||||
}
|
||||
|
||||
//TODO: remove ModelUtils
|
||||
//!!jvz remove ModelUtils
|
||||
public void injectPluginManagementInfo( Plugin plugin )
|
||||
{
|
||||
PluginManagement pm = getModelBuild().getPluginManagement();
|
||||
|
|
|
@ -1,22 +1,18 @@
|
|||
package org.apache.maven.project;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
|
||||
* agreements. See the NOTICE file distributed with this work for additional information regarding
|
||||
* copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* 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.
|
||||
* 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.repository.ArtifactRepository;
|
||||
|
@ -32,6 +28,7 @@ import java.io.FileNotFoundException;
|
|||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
|
@ -96,9 +93,7 @@ public abstract class AbstractMavenProjectTestCase
|
|||
{
|
||||
ArtifactRepositoryLayout repoLayout = lookup( ArtifactRepositoryLayout.class, "legacy" );
|
||||
|
||||
ArtifactRepository r = new DefaultArtifactRepository( "local",
|
||||
"file://" + getLocalRepositoryPath().getAbsolutePath(),
|
||||
repoLayout );
|
||||
ArtifactRepository r = new DefaultArtifactRepository( "local", "file://" + getLocalRepositoryPath().getAbsolutePath(), repoLayout );
|
||||
|
||||
return r;
|
||||
}
|
||||
|
@ -110,19 +105,20 @@ public abstract class AbstractMavenProjectTestCase
|
|||
protected MavenProject getProjectWithDependencies( File pom )
|
||||
throws Exception
|
||||
{
|
||||
ProjectBuilderConfiguration pbc = new DefaultProjectBuilderConfiguration();
|
||||
pbc.setLocalRepository( getLocalRepository() );
|
||||
ProjectBuilderConfiguration configuration = new DefaultProjectBuilderConfiguration();
|
||||
configuration.setLocalRepository( getLocalRepository() );
|
||||
configuration.setRemoteRepositories( Arrays.asList( new ArtifactRepository[]{} ) );
|
||||
|
||||
try
|
||||
{
|
||||
return projectBuilder.buildProjectWithDependencies( pom, pbc).getProject();
|
||||
return projectBuilder.buildProjectWithDependencies( pom, configuration ).getProject();
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
if ( e instanceof InvalidProjectModelException )
|
||||
{
|
||||
ModelValidationResult validationResult = ((InvalidProjectModelException)e).getValidationResult();
|
||||
String message = "In: " + pom + "(" + ((ProjectBuildingException) e).getProjectId() + ")\n\n" + validationResult.render( " " );
|
||||
ModelValidationResult validationResult = ( (InvalidProjectModelException) e ).getValidationResult();
|
||||
String message = "In: " + pom + "(" + ( (ProjectBuildingException) e ).getProjectId() + ")\n\n" + validationResult.render( " " );
|
||||
System.out.println( message );
|
||||
fail( message );
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ public class ProjectInheritanceTest
|
|||
Set set = project1.getArtifacts();
|
||||
assertNotNull("No artifacts", set);
|
||||
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();
|
||||
while (iter.hasNext()) {
|
||||
|
|
|
@ -66,7 +66,7 @@ public class ProjectInheritanceTest
|
|||
assertNotNull("No artifacts", set);
|
||||
assertTrue("No Artifacts", set.size() > 0);
|
||||
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())
|
||||
{
|
||||
|
|
|
@ -65,7 +65,7 @@ public class ProjectInheritanceTest
|
|||
Set set = project1.getArtifacts();
|
||||
assertNotNull("No artifacts", set);
|
||||
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();
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ public class ProjectInheritanceTest
|
|||
assertNotNull("No artifacts", set);
|
||||
assertTrue("No Artifacts", set.size() > 0);
|
||||
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())
|
||||
{
|
||||
|
|
|
@ -76,7 +76,7 @@ public class ProjectInheritanceTest
|
|||
|
||||
assertNotNull("No artifacts", map);
|
||||
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-b is not in the project", map.containsKey( "maven-test:t09-b" ));
|
||||
|
@ -110,7 +110,7 @@ public class ProjectInheritanceTest
|
|||
Map map = project2.getArtifactMap();
|
||||
assertNotNull( "No artifacts", map );
|
||||
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-b is not in the project", map.containsKey( "maven-test:t09-b" ) );
|
||||
|
|
|
@ -71,7 +71,7 @@ public class ProjectInheritanceTest
|
|||
Map map = project1.getArtifactMap();
|
||||
assertNotNull("No artifacts", map);
|
||||
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 b = (Artifact) map.get("maven-test:t10-b");
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -67,7 +67,7 @@ under the License.
|
|||
<mercuryMp3Version>1.0-alpha-1</mercuryMp3Version>
|
||||
<securityDispatcherVersion>1.2</securityDispatcherVersion>
|
||||
<woodstoxVersion>3.2.6</woodstoxVersion>
|
||||
<modelloVersion>1.0.1-SNAPSHOT</modelloVersion>
|
||||
<modelloVersion>1.0.1</modelloVersion>
|
||||
<jxpathVersion>1.3</jxpathVersion>
|
||||
</properties>
|
||||
<issueManagement>
|
||||
|
|
Loading…
Reference in New Issue