diff --git a/build-mercury.xml b/build-mercury.xml
index fda4fa3c3a..354a9a5cb9 100644
--- a/build-mercury.xml
+++ b/build-mercury.xml
@@ -209,7 +209,6 @@ END SNIPPET: ant-bootstrap -->
-
diff --git a/build.xml b/build.xml
index f88f0f66c3..50562cf004 100644
--- a/build.xml
+++ b/build.xml
@@ -164,7 +164,6 @@ END SNIPPET: ant-bootstrap -->
-
diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java b/maven-compat/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java
index a69e7c7700..3bce207c9a 100644
--- a/maven-compat/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java
+++ b/maven-compat/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java
@@ -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
- *
- * 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.
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
*/
import java.io.File;
@@ -60,34 +56,34 @@
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;
-
+
@Requirement
private PlexusContainer container;
// TODO: proxies, authentication and mirrors are via settings, and should come in via an alternate method - perhaps
// attached to ArtifactRepository before the method is called (so AR would be composed of WR, not inherit it)
- private Map proxies = new HashMap();
+ private Map proxies = new HashMap();
- private static Map authenticationInfoMap = new HashMap();
+ private static Map authenticationInfoMap = new HashMap();
- private Map serverPermissionsMap = new HashMap();
+ private Map serverPermissionsMap = new HashMap();
//used LinkedMap to preserve the order.
- private Map mirrors = new LinkedHashMap();
+ private Map mirrors = new LinkedHashMap();
/** Map( String, XmlPlexusConfiguration ) with the repository id and the wagon configuration */
- private Map serverConfigurationMap = new HashMap();
+ private Map serverConfigurationMap = new HashMap();
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
@@ -108,12 +104,12 @@ public class DefaultWagonManager
private String httpUserAgent = "Apache-Maven/3.0-alpha-1";
private TransferListener downloadMonitor;
-
+
public void setDownloadMonitor( TransferListener downloadMonitor )
{
- this.downloadMonitor = downloadMonitor;
+ this.downloadMonitor = downloadMonitor;
}
-
+
// TODO: this leaks the component in the public api - it is never released back to the container
public Wagon getWagon( Repository repository )
throws UnsupportedProtocolException, WagonConfigurationException
@@ -125,7 +121,6 @@ public Wagon getWagon( Repository repository )
throw new UnsupportedProtocolException( "The repository " + repository + " does not specify a protocol" );
}
-
Wagon wagon = getWagon( protocol );
configureWagon( wagon, repository.getId(), protocol );
@@ -140,15 +135,13 @@ public Wagon getWagon( String protocol )
{
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;
@@ -159,7 +152,7 @@ public void putArtifact( File source, Artifact artifact, ArtifactRepository depl
{
putRemoteFile( deploymentRepository, source, deploymentRepository.pathOf( artifact ), downloadMonitor );
}
-
+
public void putArtifact( File source, Artifact artifact, ArtifactRepository deploymentRepository, TransferListener downloadMonitor )
throws TransferFailedException
{
@@ -195,9 +188,9 @@ private void putRemoteFile( ArtifactRepository repository, File source, String r
wagon.addTransferListener( downloadMonitor );
}
- Map checksums = new HashMap( 2 );
+ Map checksums = new HashMap( 2 );
- Map sums = new HashMap( 2 );
+ Map sums = new HashMap( 2 );
// TODO: configure these on the repository
for ( int i = 0; i < CHECKSUM_IDS.length; i++ )
@@ -211,15 +204,15 @@ private void putRemoteFile( ArtifactRepository repository, File source, String r
{
Repository artifactRepository = new Repository( repository.getId(), repository.getUrl() );
- AuthenticationInfo authenticationInfo = getAuthenticationInfo( repository.getId() );
-
+ AuthenticationInfo authenticationInfo = getAuthenticationInfo( repository.getId() );
+
wagon.connect( artifactRepository, authenticationInfo, new ProxyInfoProvider()
{
public ProxyInfo getProxyInfo( String protocol )
{
return getProxy( protocol );
}
- });
+ } );
wagon.put( source, remotePath );
}
@@ -238,19 +231,21 @@ public ProxyInfo getProxyInfo( String protocol )
}
// 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 ProxyInfo getProxyInfo( String protocol )
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 ProxyInfo getProxyInfo( String protocol )
}
}
- private ChecksumObserver addChecksumObserver( Wagon wagon,
- String algorithm )
+ private ChecksumObserver addChecksumObserver( Wagon wagon, String algorithm )
throws TransferFailedException
{
try
@@ -305,38 +301,38 @@ private ChecksumObserver addChecksumObserver( Wagon wagon,
}
}
-
// 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 );
}
-
+
public void getArtifact( Artifact artifact, ArtifactRepository remoteRepository )
throws TransferFailedException, ResourceDoesNotExistException
{
getArtifact( artifact, remoteRepository, downloadMonitor, true );
}
-
- public void getArtifact( Artifact artifact, List remoteRepositories, TransferListener downloadMonitor )
+
+ public void getArtifact( Artifact artifact, List remoteRepositories, TransferListener downloadMonitor )
throws TransferFailedException, ResourceDoesNotExistException
- {
- getArtifact( artifact, remoteRepositories, downloadMonitor, true );
- }
+ {
+ getArtifact( artifact, remoteRepositories, downloadMonitor, true );
+ }
public void getArtifact( Artifact artifact, List 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 void getArtifact( Artifact artifact, List remoteRepos
// 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 void getArtifact( Artifact artifact, List remoteRepos
}
public void getArtifact( Artifact artifact, ArtifactRepository repository, TransferListener downloadMonitor )
- throws TransferFailedException,
- ResourceDoesNotExistException
+ throws TransferFailedException, ResourceDoesNotExistException
{
getArtifact( artifact, repository, downloadMonitor, true );
}
@@ -396,7 +389,7 @@ else if ( artifact.isSnapshot() && ( force || updateCheckManager.isUpdateRequire
}
finally
{
- updateCheckManager.touch( artifact, repository );
+ updateCheckManager.touch( artifact, repository );
}
logger.debug( " Artifact resolved" );
@@ -423,7 +416,7 @@ else if ( "pom".equals( artifact.getType() ) && !artifact.getFile().exists() )
{
// cache the POM failure
updateCheckManager.touch( artifact, repository );
-
+
throw e;
}
@@ -437,7 +430,7 @@ else if ( "pom".equals( artifact.getType() ) && !artifact.getFile().exists() )
throw new ResourceDoesNotExistException( "Failure was cached in the local repository" );
}
}
-
+
// If it's not a snapshot artifact, then we don't care what the force flag says. If it's on the local
// system, it's resolved. Releases are presumed to be immutable, so release artifacts are not ever updated.
// NOTE: This is NOT the case for metadata files on relese-only repositories. This metadata may contain information
@@ -457,10 +450,7 @@ else if ( !artifact.isSnapshot() )
}
}
- 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 void getArtifactMetadata( ArtifactMetadata metadata,
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 void getArtifactMetadataFromDeploymentRepository( ArtifactMetadata metada
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 @@ private void getRemoteFile( ArtifactRepository repository,
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 ProxyInfo getProxyInfo( String protocol )
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 ProxyInfo getProxyInfo( String protocol )
}
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 @@ else if ( !ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE.equals( checksumPolic
// 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 @@ private void verifyChecksum( ChecksumObserver checksumObserver,
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 @@ private void verifyChecksum( ChecksumObserver checksumObserver,
}
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 @@ private void verifyChecksum( ChecksumObserver checksumObserver,
}
}
-
private void disconnectWagon( Wagon wagon )
{
try
@@ -797,8 +768,7 @@ private void disconnectWagon( Wagon wagon )
}
}
- private void releaseWagon( String protocol,
- Wagon wagon )
+ private void releaseWagon( String protocol, Wagon wagon )
{
try
{
@@ -810,7 +780,7 @@ private void releaseWagon( String protocol,
logger.debug( "", e );
}
}
-
+
public ProxyInfo getProxy( String protocol )
{
return proxies.get( protocol );
@@ -824,7 +794,7 @@ public AuthenticationInfo getAuthenticationInfo( String id )
/**
* Checks the URL to see if this repository refers to an external repository
- *
+ *
* @param originalRepository
* @return true if external.
*/
@@ -833,7 +803,7 @@ public boolean isExternalRepo( ArtifactRepository originalRepository )
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 )
{
@@ -844,22 +814,17 @@ public boolean isExternalRepo( ArtifactRepository originalRepository )
/**
* Set the proxy used for a particular protocol.
- *
+ *
* @param protocol the protocol (required)
* @param host the proxy host name (required)
* @param port the proxy port (required)
* @param username the username for the proxy, or null if there is none
* @param password the password for the proxy, or null if there is none
- * @param nonProxyHosts the set of hosts not to use the proxy for. Follows Java system property format:
- * *.foo.com|localhost
.
+ * @param nonProxyHosts the set of hosts not to use the proxy for. Follows Java system property
+ * format: *.foo.com|localhost
.
* @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 void addProxy( String protocol,
// 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 void addAuthenticationInfo( String repositoryId,
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();
@@ -919,10 +877,11 @@ public void addPermissionInfo( String repositoryId,
/**
* 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
@@ -933,8 +892,8 @@ private void configureWagon( Wagon wagon, ArtifactRepository repository )
private void configureWagon( Wagon wagon, String repositoryId, String protocol )
throws WagonConfigurationException
{
- PlexusConfiguration config = (PlexusConfiguration) serverConfigurationMap.get( repositoryId );
-
+ PlexusConfiguration config = (PlexusConfiguration) serverConfigurationMap.get( repositoryId );
+
if ( config != null )
{
ComponentConfigurator componentConfigurator = null;
@@ -966,7 +925,7 @@ private void configureWagon( Wagon wagon, String repositoryId, String protocol )
}
}
}
-
+
/**
* {@inheritDoc}
*/
@@ -974,7 +933,7 @@ public void setHttpUserAgent( String userAgent )
{
this.httpUserAgent = userAgent;
}
-
+
/**
* {@inheritDoc}
*/
diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/repository/ArtifactRepository.java b/maven-compat/src/main/java/org/apache/maven/artifact/repository/ArtifactRepository.java
index c5160ea7e5..8ad2d02737 100644
--- a/maven-compat/src/main/java/org/apache/maven/artifact/repository/ArtifactRepository.java
+++ b/maven-compat/src/main/java/org/apache/maven/artifact/repository/ArtifactRepository.java
@@ -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
- *
- * 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.
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
*/
import org.apache.maven.artifact.Artifact;
@@ -25,7 +21,7 @@
/**
* Specifies the repository used for artifact handling.
- *
+ *
* @author Brett Porter
* @version $Id$
*/
@@ -38,6 +34,7 @@ public interface ArtifactRepository
String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository );
String getUrl();
+
void setUrl( String url );
String getBasedir();
@@ -45,17 +42,21 @@ 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();
boolean isUniqueVersion();
diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java b/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java
index db7d25c2b6..3313773674 100644
--- a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java
+++ b/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java
@@ -347,6 +347,11 @@ public ArtifactResolutionResult resolveWithExceptions( ArtifactResolutionRequest
//
// ------------------------------------------------------------------------
+ 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();
@@ -356,7 +361,15 @@ public ArtifactResolutionResult resolve( ArtifactResolutionRequest request )
List remoteRepositories = request.getRemoteRepostories();
ArtifactMetadataSource source = request.getMetadataSource();
List 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 )
{
@@ -388,7 +401,7 @@ public ArtifactResolutionResult resolve( ArtifactResolutionRequest request )
// This is often an artifact like a POM that is taken from disk and we already have hold of the
// file reference. But this may be a Maven Plugin that we need to resolve from a remote repository
// as well as its dependencies.
-
+
if ( request.isResolveRoot() && rootArtifact.getFile() == null )
{
try
@@ -406,18 +419,21 @@ public ArtifactResolutionResult resolve( ArtifactResolutionRequest request )
return result;
}
}
-
+
if ( artifacts == null || artifacts.size() == 0 )
{
result.addArtifact( rootArtifact );
return result;
}
-
+
// After the collection we will have the artifact object in the result but they will not be resolved yet.
result = artifactCollector.collect( artifacts, rootArtifact, managedVersions, localRepository, remoteRepositories, source, filter, listeners );
-
- // 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
@@ -427,7 +443,7 @@ public ArtifactResolutionResult resolve( ArtifactResolutionRequest request )
{
return result;
}
-
+
if ( result.getArtifacts() != null )
{
for ( Artifact artifact : result.getArtifacts() )
@@ -452,7 +468,7 @@ public ArtifactResolutionResult resolve( ArtifactResolutionRequest request )
}
}
}
-
+
return result;
}
diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java
index a0ab7d2de4..f60aeeb3bb 100644
--- a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java
@@ -159,7 +159,7 @@ public Artifact retrieveRelocatedArtifact( Artifact artifact,
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 Artifact retrieveRelocatedArtifact( Artifact artifact,
artifactResolver.resolveTransitively( Collections.singleton( i ), projectArtifact, remoteRepositories(),
localRepository(), mds );
- assertEquals( 2, result.getArtifacts().size() );
+ assertEquals( 3, result.getArtifacts().size() );
assertTrue( result.getArtifacts().contains( i ) );
diff --git a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
index 4565629518..12221a9989 100644
--- a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
+++ b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
@@ -382,11 +382,9 @@ else if ( moduleFile.isDirectory() )
// 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;
}
diff --git a/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java b/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java
index 6dc6f1e372..ebece38db1 100644
--- a/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java
+++ b/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java
@@ -73,13 +73,18 @@ public MavenSession( ArtifactRepository localRepository, List pluginGrou
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 )
{
diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java b/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
index b41be6c794..5e8f4bb43f 100644
--- a/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
+++ b/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
@@ -1225,8 +1225,6 @@ MojoDescriptor getMojoDescriptor( String task, MavenSession session, MavenProjec
String goal;
Plugin plugin;
- PluginDescriptor pluginDescriptor = null;
-
StringTokenizer tok = new StringTokenizer( task, ":" );
int numTokens = tok.countTokens();
@@ -1245,15 +1243,7 @@ MojoDescriptor getMojoDescriptor( String task, MavenSession session, MavenProjec
// repository.
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 @@ MojoDescriptor getMojoDescriptor( String task, MavenSession session, MavenProjec
}
}
}
-
- // Default to o.a.m.plugins and maven--plugin
- if ( plugin == null )
- {
- plugin = new Plugin();
- plugin.setGroupId( PluginDescriptor.getDefaultPluginGroupId() );
- plugin.setArtifactId( PluginDescriptor.getDefaultPluginArtifactId( prefix ) );
- }
}
else if ( numTokens == 3 || numTokens == 4 )
{
@@ -1298,32 +1280,29 @@ else if ( numTokens == 3 || numTokens == 4 )
}
if ( plugin.getVersion() == null )
- {
+ {
for ( Iterator i = project.getBuildPlugins().iterator(); i.hasNext(); )
{
Plugin buildPlugin = (Plugin) i.next();
-
+
if ( buildPlugin.getKey().equals( plugin.getKey() ) )
{
plugin = buildPlugin;
break;
}
}
-
- project.injectPluginManagementInfo( plugin );
- }
-
- if ( pluginDescriptor == null )
- {
- pluginDescriptor = loadPlugin( plugin, project, session );
+
+ project.injectPluginManagementInfo( plugin );
}
+ 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.
project.addPlugin( plugin );
MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( goal );
-
+
return mojoDescriptor;
}
diff --git a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
index afeb374b54..0268182c88 100644
--- a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
+++ b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
@@ -165,6 +165,7 @@ public PluginDescriptor verifyPlugin( Plugin plugin, MavenProject project, Maven
// 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() );
@@ -173,7 +174,7 @@ public PluginDescriptor verifyPlugin( Plugin plugin, MavenProject project, Maven
logger.debug( "Resolved to version: " + pluginVersion );
}
-
+
return verifyVersionedPlugin( plugin, project, session );
}
@@ -309,8 +310,9 @@ else if ( projectPlugin.getVersion() == null || Artifact.RELEASE_VERSION.equals(
+ " Please verify that the plugin JAR " + pluginArtifact.getFile() + " is intact.", project );
}
- pluginDescriptor.setPluginArtifact( pluginArtifact );
-
+ 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 void executeMojo( MavenProject project, MojoExecution mojoExecution, Mave
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 void executeMojo( MavenProject project, MojoExecution mojoExecution, Mave
}
}
- 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 MavenReport getReport( MavenProject project, MojoExecution mojoExecution,
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 PluginDescriptor verifyReportPlugin( ReportPlugin reportPlugin, MavenProj
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 @@ private Mojo getConfiguredMojo( MavenSession session, Xpp3Dom dom, MavenProject
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 static void checkPlexusUtils( ResolutionGroup resolutionGroup, ArtifactFa
}
}
- 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 interpolatorProperties )
throws IOException
{
diff --git a/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java b/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java
index 634587a388..e728e78cfb 100644
--- a/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java
+++ b/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java
@@ -4,6 +4,7 @@
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;
@@ -30,23 +31,22 @@ public class LifecycleExecutorTest
{
@Requirement
private MavenProjectBuilder projectBuilder;
-
+
@Requirement
private RepositorySystem repositorySystem;
-
+
@Requirement
private PluginManager pluginManager;
-
+
@Requirement
private DefaultLifecycleExecutor lifecycleExecutor;
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 );
+ projectBuilder = lookup( MavenProjectBuilder.class );
+ repositorySystem = lookup( RepositorySystem.class );
+ pluginManager = lookup( PluginManager.class );
lifecycleExecutor = (DefaultLifecycleExecutor) lookup( LifecycleExecutor.class );
}
@@ -54,68 +54,133 @@ public void testLifecyclePhases()
{
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]
// - 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 = 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 ) ) );
-
- MavenProject project = projectBuilder.build( targetPom, configuration );
+ .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, null );
+
+ 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 = "remote-resources";
String goal = "process";
- MojoDescriptor mojoDescriptor = lifecycleExecutor.getMojoDescriptor( pluginArtifactId + ":" + goal, session, project );
-
+ MojoDescriptor mojoDescriptor = lifecycleExecutor.getMojoDescriptor( pluginArtifactId + ":" + goal, session, project );
+
PluginDescriptor pd = mojoDescriptor.getPluginDescriptor();
assertNotNull( pd );
assertEquals( "org.apache.maven.plugins", pd.getGroupId() );
assertEquals( "maven-remote-resources-plugin", pd.getArtifactId() );
- assertEquals( "1.0", pd.getVersion() );
-
- MojoExecution me = new MojoExecution( mojoDescriptor );
-
+ assertEquals( "1.0", 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, 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 )
{
- containerConfiguration.addComponentDiscoverer( new MavenPluginDiscoverer() );
+ 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" ) );
+ }
}
diff --git a/maven-core/src/test/java/org/apache/maven/listeners/BuildExtensionListenerTest.java b/maven-core/src/test/java/org/apache/maven/listeners/BuildExtensionListenerTest.java
index 1e77e65a13..15373957ee 100644
--- a/maven-core/src/test/java/org/apache/maven/listeners/BuildExtensionListenerTest.java
+++ b/maven-core/src/test/java/org/apache/maven/listeners/BuildExtensionListenerTest.java
@@ -70,7 +70,7 @@ private MavenSession newMavenSession()
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;
}
diff --git a/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java b/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java
index 4407731b33..e7a77fdfc3 100644
--- a/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java
+++ b/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java
@@ -20,33 +20,6 @@
*/
-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.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 @@ private static MavenSession createSession( PlexusContainer container,
.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 @@ private MavenSession newMavenSession()
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;
}
diff --git a/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java b/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java
index 4f6a6826fb..3bec1784e1 100644
--- a/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java
+++ b/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java
@@ -285,7 +285,7 @@ public static Settings readSettings( File file )
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 );
}
diff --git a/maven-project/src/main/java/org/apache/maven/project/MavenProject.java b/maven-project/src/main/java/org/apache/maven/project/MavenProject.java
index e3640e6496..6860a55d19 100644
--- a/maven-project/src/main/java/org/apache/maven/project/MavenProject.java
+++ b/maven-project/src/main/java/org/apache/maven/project/MavenProject.java
@@ -1318,7 +1318,7 @@ public void addPlugin( Plugin plugin )
}
}
- //TODO: remove ModelUtils
+ //!!jvz remove ModelUtils
public void injectPluginManagementInfo( Plugin plugin )
{
PluginManagement pm = getModelBuild().getPluginManagement();
diff --git a/maven-project/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java b/maven-project/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java
index cd6a862c2f..6ae14389b1 100644
--- a/maven-project/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java
+++ b/maven-project/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java
@@ -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
- *
- * 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.
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
*/
import org.apache.maven.artifact.repository.ArtifactRepository;
@@ -32,6 +28,7 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
+import java.util.Arrays;
import java.util.Properties;
/**
@@ -96,9 +93,7 @@ protected ArtifactRepository getLocalRepository()
{
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 @@ protected ArtifactRepository getLocalRepository()
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 );
}
diff --git a/maven-project/src/test/java/org/apache/maven/project/inheritance/t04/ProjectInheritanceTest.java b/maven-project/src/test/java/org/apache/maven/project/inheritance/t04/ProjectInheritanceTest.java
index d87db4f991..3dfe113c3d 100644
--- a/maven-project/src/test/java/org/apache/maven/project/inheritance/t04/ProjectInheritanceTest.java
+++ b/maven-project/src/test/java/org/apache/maven/project/inheritance/t04/ProjectInheritanceTest.java
@@ -69,7 +69,7 @@ public void testDependencyManagementOverridesTransitiveDependencyVersion()
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()) {
diff --git a/maven-project/src/test/java/org/apache/maven/project/inheritance/t06/ProjectInheritanceTest.java b/maven-project/src/test/java/org/apache/maven/project/inheritance/t06/ProjectInheritanceTest.java
index 75e8ed46b6..6338a001a1 100644
--- a/maven-project/src/test/java/org/apache/maven/project/inheritance/t06/ProjectInheritanceTest.java
+++ b/maven-project/src/test/java/org/apache/maven/project/inheritance/t06/ProjectInheritanceTest.java
@@ -66,7 +66,7 @@ public void testDependencyManagement()
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())
{
diff --git a/maven-project/src/test/java/org/apache/maven/project/inheritance/t07/ProjectInheritanceTest.java b/maven-project/src/test/java/org/apache/maven/project/inheritance/t07/ProjectInheritanceTest.java
index b7d36edd35..d2da37e17b 100644
--- a/maven-project/src/test/java/org/apache/maven/project/inheritance/t07/ProjectInheritanceTest.java
+++ b/maven-project/src/test/java/org/apache/maven/project/inheritance/t07/ProjectInheritanceTest.java
@@ -65,7 +65,7 @@ public void testDependencyManagement()
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();
diff --git a/maven-project/src/test/java/org/apache/maven/project/inheritance/t08/ProjectInheritanceTest.java b/maven-project/src/test/java/org/apache/maven/project/inheritance/t08/ProjectInheritanceTest.java
index 722ab40953..953048840c 100644
--- a/maven-project/src/test/java/org/apache/maven/project/inheritance/t08/ProjectInheritanceTest.java
+++ b/maven-project/src/test/java/org/apache/maven/project/inheritance/t08/ProjectInheritanceTest.java
@@ -67,7 +67,7 @@ public void testDependencyManagement()
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())
{
diff --git a/maven-project/src/test/java/org/apache/maven/project/inheritance/t09/ProjectInheritanceTest.java b/maven-project/src/test/java/org/apache/maven/project/inheritance/t09/ProjectInheritanceTest.java
index 352bb7b8fc..ff385fc2f3 100644
--- a/maven-project/src/test/java/org/apache/maven/project/inheritance/t09/ProjectInheritanceTest.java
+++ b/maven-project/src/test/java/org/apache/maven/project/inheritance/t09/ProjectInheritanceTest.java
@@ -76,7 +76,7 @@ public void testDependencyManagementExclusionsExcludeTransitively()
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 void testDependencyManagementExclusionDoesNotOverrideGloballyForTransitiv
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" ) );
diff --git a/maven-project/src/test/java/org/apache/maven/project/inheritance/t10/ProjectInheritanceTest.java b/maven-project/src/test/java/org/apache/maven/project/inheritance/t10/ProjectInheritanceTest.java
index a41ffc26fa..5da9a35f26 100644
--- a/maven-project/src/test/java/org/apache/maven/project/inheritance/t10/ProjectInheritanceTest.java
+++ b/maven-project/src/test/java/org/apache/maven/project/inheritance/t10/ProjectInheritanceTest.java
@@ -71,7 +71,7 @@ public void testDependencyManagementOverridesTransitiveDependencyVersion()
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");
diff --git a/pom.xml b/pom.xml
index 48dadc2295..3b77527cce 100644
--- a/pom.xml
+++ b/pom.xml
@@ -67,7 +67,7 @@ under the License.
1.0-alpha-1
1.2
3.2.6
- 1.0.1-SNAPSHOT
+ 1.0.1
1.3