[GRADLE-1039] Maven deployer ignores user's settings.xml Created: 18/Jul/10 Updated: 24/Jan/17 Resolved: 24/Jan/17 |
|
Status: | Resolved |
Project: | Gradle |
Affects Version/s: | 0.9 |
Fix Version/s: | None |
Type: | Bug | ||
Reporter: | John Gibson | Assignee: | Unassigned |
Resolution: | Duplicate | Votes: | 7 |
Description |
The user's Maven settings.xml is ignored during deployment. This is bad because among other things, the settings.xml provides authentication and proxy configuration for target repositories. If it is intended for users to use the Maven Ant Tasks to perform the deployment then the settings for the Maven Ant Tasks should be respected. Otherwise it is both jarring for new users and creates yet another location that needs to be updated when authentication or proxy settings change. I know that this aim conflicts with the fix for |
Comments |
Comment by Hans Dockter [ 27/Jul/10 ] |
We should provide a solution for this. |
Comment by John Gibson [ 13/Aug/10 ] |
William Wong's analysis of the problem is correct: http://jira.codehaus.org/browse/GRADLE-702?focusedCommentId=207376&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#action_207376 First of all, it's unclear to me whether or not this problem is a bug. Is this how Maven normally behaves? Or is this some peculiarity of the Maven Ant Tasks themselves? At any rate the obvious solution for the problem is to use a different id for the repository in the Gradle build file. This is what you'd have to do if you were using the Maven Ant Tasks in an Ant build file. In the worst case we'd fix this problem and then get a new complaint from some other user that their mirror settings were being disregarded. At any rate we shouldn't be throwing away the settings file entirely. The other preferences derived from the settings file (proxies and authentication) do not override the choices made in the build file and only take effect if they are omitted from the build file. The most straightforward solution is to copy the settings file and remove all of the proxy sections and hand that to the ant task instead of the empty one that we currently use. However there is a user-level settings file and a global settings file and both can live in multiple places (~/.ant/settings, ~/.m2/settings, etc.) so this fix is probably more pain that it's worth. A better solution would be to subclass DeployTask and override the updateRepositoryWithSettings() method. The implementation would be something like: if(id != null) { repo.setId(id) }} Finally this whole problem might change given this comment in updateRepositoryWithSettings() from line 422 of org.apache.maven.artifact.ant.AbstractArtifactTask: // TODO: actually, we need to not funnel this through the ant repository - we should pump settings into wagon The file in question can be found here: http://svn.apache.org/viewvc/maven/ant-tasks/tags/maven-ant-tasks-2.1.1/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java?revision=965619&view=markup |
Comment by Hans Dockter [ 15/Aug/10 ] |
We should allow the settings.xml to be reused from Gradle. I haven't thought about this in depth. You should have the options to:
I think this is an important issues for seamless integration with Maven. In particular when we allow for importing pom.xml's. |
Comment by Peter Ledbrook [ 17/Aug/10 ] |
Proxy settings seem to be completely ignored at the moment. I would personally prefer to have Gradle-specific proxy settings, but that option simply isn't available. It makes absolutely no sense to put the proxy settings in the build file. Right now, I simply can't deploy artifacts to Maven repositories from work. |
Comment by Ray Gauss II [ 04/Jun/12 ] |
This seems like something that should be resolved for a 1.0 release. It looks like some work progressed with the addition of MaybeUserMavenSettingsSupplier, but that's only called by BaseMavenInstaller. Are there plans to get this into 1.0? |
Comment by Rouillard [ 22/Dec/14 ] |
I am still experiencing this issue with the last release. |
Comment by Wolfgang Wachsmuth [ 04/Sep/15 ] |
Hello and sorry for the stupid question: btw: This is not only a problem of deplying but also for simple load dependencies |
Comment by Daz DeBoer [ 08/Sep/15 ] |
Comment by Benjamin Muschko [ 15/Nov/16 ] |
As announced on the Gradle blog we are planning to completely migrate issues from JIRA to GitHub. We intend to prioritize issues that are actionable and impactful while working more closely with the community. Many of our JIRA issues are inactionable or irrelevant. We would like to request your help to ensure we can appropriately prioritize JIRA issues you’ve contributed to. Please confirm that you still advocate for your JIRA issue before December 10th, 2016 by:
We look forward to collaborating with you more closely on GitHub. Thank you for your contribution to Gradle! |
Comment by Wolfgang Wachsmuth [ 15/Nov/16 ] |
still a blocking issue IMHO |
Comment by John Gibson [ 19/Nov/16 ] |
I concur with Wolfgang Wachsmuth. I still have to workaround this issue and end up manually reading the settings.xml and then altering the task definition just before it runs like so: uploadArchives { repositories.mavenDeployer { configuration = configurations.deployerJars repository(url: project.ext.isReleaseVersion ? "https://my.repository/artifactory/libs-release-local" : "https://my.repository/artifactory/libs-snapshot-local") { authentication(userName:"ignored") } } doFirst { def settings = new File(System.getProperty('user.home') + '/.m2/settings.xml') if (settings.exists()) { def xml = new XmlSlurper().parse(settings) def server = xml.servers.children().find({ it.id.text() == 'myMavenServerId' }) if (server) { def mavenUsername = server.username.text() def mavenPassword = server.password.text() println 'Found server definition, username: ' + mavenUsername repositories.mavenDeployer.repository.authentication.userName = mavenUsername repositories.mavenDeployer.repository.authentication.password = mavenPassword } else { println 'No server definition for artifacts was found in ' + settings } } else { println 'Maven settings file was not found: ' + settings } } } In the interest of backwards compatibility and users who would prefer to ignore their settings.xml I'd suggest that we simply provide a property on the task or the convention or something to instruct the task to use the user's settings.xml. *Expected Behavior*
uploadArchives {
repositories.mavenDeployer {
configuration = configurations.deployerJars
repository(url: "https://my.repository/artifactory/libs-release-local", id: "myMavenServerId")
}
}
*Current Behavior* |
Comment by Benjamin Muschko [ 24/Jan/17 ] |
The issue is now tracked on GitHub: https://github.com/gradle/gradle/issues/1236 |