You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2007/10/18 23:49:13 UTC
svn commit: r586152 - in /maven/ant-tasks/trunk: ./
src/main/java/org/apache/maven/artifact/ant/ src/test/
Author: hboutemy
Date: Thu Oct 18 14:49:12 2007
New Revision: 586152
URL: http://svn.apache.org/viewvc?rev=586152&view=rev
Log:
[MANTTASKS-85] settings config ignored for remoteRepositories not defined in pom
Added:
maven/ant-tasks/trunk/src/test/settings-mirror.xml
Modified:
maven/ant-tasks/trunk/sample.build.xml
maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java
maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactWithRepositoryTask.java
maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/DeployTask.java
Modified: maven/ant-tasks/trunk/sample.build.xml
URL: http://svn.apache.org/viewvc/maven/ant-tasks/trunk/sample.build.xml?rev=586152&r1=586151&r2=586152&view=diff
==============================================================================
--- maven/ant-tasks/trunk/sample.build.xml (original)
+++ maven/ant-tasks/trunk/sample.build.xml Thu Oct 18 14:49:12 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/trunk/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java
URL: http://svn.apache.org/viewvc/maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java?rev=586152&r1=586151&r2=586152&view=diff
==============================================================================
--- maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java (original)
+++ maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java Thu Oct 18 14:49:12 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/trunk/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactWithRepositoryTask.java
URL: http://svn.apache.org/viewvc/maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactWithRepositoryTask.java?rev=586152&r1=586151&r2=586152&view=diff
==============================================================================
--- maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactWithRepositoryTask.java (original)
+++ maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactWithRepositoryTask.java Thu Oct 18 14:49:12 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/trunk/src/main/java/org/apache/maven/artifact/ant/DeployTask.java
URL: http://svn.apache.org/viewvc/maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/DeployTask.java?rev=586152&r1=586151&r2=586152&view=diff
==============================================================================
--- maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/DeployTask.java (original)
+++ maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/DeployTask.java Thu Oct 18 14:49:12 2007
@@ -54,6 +54,8 @@
*/
protected ArtifactRepository createDeploymentArtifactRepository( RemoteRepository repository )
{
+ updateRepositoryWithSettings( repository );
+
ArtifactRepositoryLayout repositoryLayout =
(ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, repository.getLayout() );
Added: maven/ant-tasks/trunk/src/test/settings-mirror.xml
URL: http://svn.apache.org/viewvc/maven/ant-tasks/trunk/src/test/settings-mirror.xml?rev=586152&view=auto
==============================================================================
--- maven/ant-tasks/trunk/src/test/settings-mirror.xml (added)
+++ maven/ant-tasks/trunk/src/test/settings-mirror.xml Thu Oct 18 14:49:12 2007
@@ -0,0 +1,13 @@
+<?xml version="1.0"?>
+
+<settings xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
+ <mirrors>
+ <mirror>
+ <id>fake-mirror</id>
+ <url>file:./src/test/repo</url>
+ <mirrorOf>fake-repository</mirrorOf>
+ </mirror>
+ </mirrors>
+</settings>
\ No newline at end of file