Author: hboutemy Date: Thu Oct 18 14:51:22 2007 New Revision: 586153 URL: http://svn.apache.org/viewvc?rev=586153&view=rev Log: [MANTTASKS-85] settings config ignored for remoteRepositories not defined in pom
Added: maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/test/settings-mirror.xml - copied unchanged from r586152, maven/ant-tasks/trunk/src/test/settings-mirror.xml Modified: maven/ant-tasks/branches/maven-ant-tasks-2.0.x/sample.build.xml maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactWithRepositoryTask.java maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/DeployTask.java Modified: maven/ant-tasks/branches/maven-ant-tasks-2.0.x/sample.build.xml URL: http://svn.apache.org/viewvc/maven/ant-tasks/branches/maven-ant-tasks-2.0.x/sample.build.xml?rev=586153&r1=586152&r2=586153&view=diff ============================================================================== --- maven/ant-tasks/branches/maven-ant-tasks-2.0.x/sample.build.xml (original) +++ maven/ant-tasks/branches/maven-ant-tasks-2.0.x/sample.build.xml Thu Oct 18 14:51:22 2007 @@ -40,7 +40,7 @@ </target> <target name="test-all-deps" description="All dependencies tests" - depends="test-pom,test-pom-with-parent,test-no-deps,test-pom-deps,test-deps,test-legacy-pom"> + depends="test-pom,test-pom-with-parent,test-no-deps,test-pom-deps,test-deps,test-legacy-pom,test-deps-mirror"> <echo>test-bad-dep and test-invalid-pom-ref must be run manually, since they are intended to fail</echo> </target> @@ -152,6 +152,16 @@ <fileset refid="maven-ant-tasks.compile.dependency.fileset"/> <mapper type="flatten"/> </copy> + </target> + + <target name="test-deps-mirror" depends="initTaskDefs"> + <delete dir="${basedir}/target/tmp"/> + <!-- the remoteRepository specified doesn't really exist, but settings declares an existing mirror--> + <artifact:dependencies filesetId="mirror.fileset" settingsFile="${basedir}/src/test/settings-mirror.xml" verbose="true"> + <dependency groupId="it.ant-tasks" artifactId="snapshotUniqueFalse" version="2.0.7-SNAPSHOT"/> + <localRepository path="${basedir}/target/tmp"/> + <remoteRepository url="file://${basedir}/target/fake/repository" id="fake-repository" /> + </artifact:dependencies> </target> <target name="test-deploy-spaces" depends="initTaskDefs,installSshProvider"> Modified: maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java URL: http://svn.apache.org/viewvc/maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java?rev=586153&r1=586152&r2=586153&view=diff ============================================================================== --- maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java (original) +++ maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java Thu Oct 18 14:51:22 2007 @@ -299,35 +299,46 @@ protected RemoteRepository createAntRemoteRepositoryBase( org.apache.maven.model.RepositoryBase pomRepository ) { - // TODO: actually, we need to not funnel this through the ant repository - we should pump settings into wagon - // manager at the start like m2 does, and then match up by repository id - // As is, this could potentially cause a problem with 2 remote repositories with different authentication info - RemoteRepository r = new RemoteRepository(); r.setId( pomRepository.getId() ); r.setUrl( pomRepository.getUrl() ); r.setLayout( pomRepository.getLayout() ); - Server server = getSettings().getServer( pomRepository.getId() ); - if ( server != null ) - { - r.addAuthentication( new Authentication( server ) ); - } + updateRepositoryWithSettings( r ); + return r; + } - org.apache.maven.settings.Proxy proxy = getSettings().getActiveProxy(); - if ( proxy != null ) + protected void updateRepositoryWithSettings( RemoteRepository repository ) + { + // TODO: actually, we need to not funnel this through the ant repository - we should pump settings into wagon + // manager at the start like m2 does, and then match up by repository id + // As is, this could potentially cause a problem with 2 remote repositories with different authentication info + + if ( repository.getAuthentication() == null ) + { + Server server = getSettings().getServer( repository.getId() ); + if ( server != null ) + { + repository.addAuthentication( new Authentication( server ) ); + } + } + + if ( repository.getProxy() == null ) { - r.addProxy( new Proxy( proxy ) ); + org.apache.maven.settings.Proxy proxy = getSettings().getActiveProxy(); + if ( proxy != null ) + { + repository.addProxy( new Proxy( proxy ) ); + } } - - Mirror mirror = getSettings().getMirrorOf( pomRepository.getId() ); + + Mirror mirror = getSettings().getMirrorOf( repository.getId() ); if ( mirror != null ) { - r.setUrl( mirror.getUrl() ); + repository.setUrl( mirror.getUrl() ); } - return r; } - + protected Object lookup( String role ) { try @@ -436,7 +447,7 @@ { Pom pom = createDummyPom(); ArtifactFactory factory = (ArtifactFactory) lookup( ArtifactFactory.ROLE ); - // TODO: maybe not strictly correct, while we should enfore that packaging has a type handler of the same id, we don't + // TODO: maybe not strictly correct, while we should enforce that packaging has a type handler of the same id, we don't return factory.createBuildArtifact( pom.getGroupId(), pom.getArtifactId(), pom.getVersion(), pom.getPackaging() ); } Modified: maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactWithRepositoryTask.java URL: http://svn.apache.org/viewvc/maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactWithRepositoryTask.java?rev=586153&r1=586152&r2=586153&view=diff ============================================================================== --- maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactWithRepositoryTask.java (original) +++ maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactWithRepositoryTask.java Thu Oct 18 14:51:22 2007 @@ -27,7 +27,7 @@ /** * Base class for atifact tasks that are able to download artifact from repote repositories. - * @version $Id:$ + * @version $Id$ */ public abstract class AbstractArtifactWithRepositoryTask extends AbstractArtifactTask @@ -43,7 +43,7 @@ */ private static RemoteRepository getDefaultRemoteRepository() { - // TODO: could we utilise the super POM for this? + // TODO: could we utilize the super POM for this? RemoteRepository remoteRepository = new RemoteRepository(); remoteRepository.setId( "central" ); remoteRepository.setUrl( "http://repo1.maven.org/maven2" ); @@ -76,6 +76,7 @@ for ( Iterator i = remoteRepositories.iterator(); i.hasNext(); ) { RemoteRepository remoteRepository = (RemoteRepository) i.next(); + updateRepositoryWithSettings( remoteRepository ); StringBuffer msg = new StringBuffer(); msg.append( " - id=" + remoteRepository.getId() ); Modified: maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/DeployTask.java URL: http://svn.apache.org/viewvc/maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/DeployTask.java?rev=586153&r1=586152&r2=586153&view=diff ============================================================================== --- maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/DeployTask.java (original) +++ maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/DeployTask.java Thu Oct 18 14:51:22 2007 @@ -54,6 +54,8 @@ */ protected ArtifactRepository createDeploymentArtifactRepository( RemoteRepository repository ) { + updateRepositoryWithSettings( repository ); + ArtifactRepositoryLayout repositoryLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, repository.getLayout() );