~/.m2/settings.xml ignored when using M2 ant task 'install-provider' --------------------------------------------------------------------
Key: MNG-2360 URL: http://jira.codehaus.org/browse/MNG-2360 Project: Maven 2 Type: Bug Components: Ant tasks Versions: 2.0.4 Environment: Windows XP SP2. Reporter: Davy Toch >From the local M2 repository I deleted the jar file junit 3.8.1 including the corresponding POM and hash files. However these files are also present in our corporate repository (currently used for simulation purposes): http://localhost:8080/maven-proxy-webapp/repository We also have a file ~/.m2/settings.xml: <settings> <mirrors> <mirror> <mirrorOf>central</mirrorOf> <id>central_mirror</id> <url>http://localhost:8080/maven-proxy-webapp/repository</url> </mirror> </mirrors> <profiles> <profile> <id>DEV</id> <repositories> <repository> <id>central</id> <url>http://localhost:8080/maven-proxy-webapp/repository</url> </repository> </repositories> <pluginRepositories> <pluginRepository> <snapshots> <enabled>false</enabled> </snapshots> <id>central</id> <url>http://localhost:8080/maven-proxy-webapp/repository</url> </pluginRepository> </pluginRepositories> <properties> <repository.id>repo_dev</repository.id> <repository.url>scp://localhost/m2demo/repo_dev</repository.url> </properties> </profile> </profiles> <activeProfiles> <activeProfile>DEV</activeProfile> </activeProfiles> <settings> This allows to always pass through the corporate repository to retrieve artifacts/plugins (instead of the default repository http://www.ibiblio.org/maven2). Remark that this corporate repository is running locally , so normally it is NOT needed to have Internet access. **Therefore the local machine isn't connected to the Internet.** We have the following ANT script build.xml that uses M2 ant tasks 2.0.4: build.xml: <project name="test" default="test" xmlns:m="antlib:org.apache.maven.artifact.ant"> <target name="test"> <m:install-provider artifactId="wagon-ssh" version="1.0-alpha-5"/> </target> </project> In the same folder as build.xml we also have a file pom.xml: <project> <modelVersion>4.0.0</modelVersion> <groupId>com.mycompany.project</groupId> <artifactId>project-model</artifactId> <version>1.0-SNAPSHOT</version> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>compile</scope> </dependency> <dependency> <groupId>commons-collections</groupId> <artifactId>commons-collections</artifactId> <version>2.0</version> <scope>provided</scope> </dependency> </dependencies> <distributionManagement> <repository> <id>repo_dev</id> <url>scp://localhost/m2demo/repo_dev</url> </repository> </distributionManagement> </project> When executing the target 'test' from the above ANT script, we get the following error message: test: [m:install-provider] An error has occurred while processing the Maven artifact tasks. [m:install-provider] Diagnosis: [m:install-provider] [m:install-provider] Error downloading wagon provider from the remote repository: Unable to get dependency information: Unable to read the metadata file for artifact 'junit:junit:jar': Error getting P OM for 'junit:junit' from the repository: Error transferring file [m:install-provider] junit:junit:pom:3.8.1 [m:install-provider] [m:install-provider] from the specified remote repositories: [m:install-provider] central (http://repo1.maven.org/maven2) [m:install-provider] [m:install-provider] junit:junit:jar:3.8.1 [m:install-provider] [m:install-provider] from the specified remote repositories: [m:install-provider] central (http://repo1.maven.org/maven2) [m:install-provider] Path to dependency: [m:install-provider] 1) unspecified:unspecified:jar:0.0 [m:install-provider] 2) org.apache.maven.wagon:wagon-ssh:jar:1.0-alpha-5 [m:install-provider] 3) org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-8 [m:install-provider] [m:install-provider] [m:install-provider] BUILD FAILED C:\tmp\build.xml:8: Error downloading wagon provider from the remote repository: Unable to get dependency information: Unable to read the metadata file for artifact 'junit:junit:jar': Error getting PO M for 'junit:junit' from the repository: Error transferring file junit:junit:pom:3.8.1 from the specified remote repositories: central (http://repo1.maven.org/maven2) junit:junit:jar:3.8.1 from the specified remote repositories: central (http://repo1.maven.org/maven2) Path to dependency: 1) unspecified:unspecified:jar:0.0 2) org.apache.maven.wagon:wagon-ssh:jar:1.0-alpha-5 3) org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-8 So it seems install-provider just ignores the central repository settings defined in ~/.m2/settings.xml and uses the settings defined in wagon-ssh-1.0-alpha-5.pom . Remark : we also tested with the following variants of the above ANT script build.xml: <project name="test" default="test" xmlns:m="antlib:org.apache.maven.artifact.ant"> <target name="test"> <m:pom id="POM" file="pom.xml"/> <m:install-provider artifactId="wagon-ssh" version="1.0-alpha-5"/> <!-- OR <m:install-provider artifactId="wagon-ssh" version="1.0-alpha-5" pomRefId="POM"/> --> </target> </project> but unfortunately the same error occurred. However, the following ANT script solves the above problem : <project name="test" default="test" xmlns:m="antlib:org.apache.maven.artifact.ant"> <target name="test"> <m:pom id="POM" file="pom.xml"/> <!-- will retrieve junit from our corporate repository (using settings from ~/.m2/settings.xml) --> <m:dependencies pomRefId="POM"/> <!-- junit already in local repository, so won't give any errors any more --> <m:install-provider artifactId="wagon-ssh" version="1.0-alpha-5"/> </target> </project> but this is because the task m:dependencies correctly uses the file ~/.m2/settings.xml to retrieve junit from the corporate repository. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira