Allow user to specify the path to Maven settings (or provide repo credentials directly)

Description

Support for Maven repository credentials was added in https://dev.clojure.org/jira/browse/TDEPS-9 but only permits a settings.xml in the default location (~/.m2/settings.xml or the one bundled with the Maven install).

Allowing user to specify the path to an alternative Maven settings would help in shared environments (e.g. CI servers where builds should be isolated). This could perhaps be done with a new optional key `:mvn/settings`. I'd be happy to propose a patch if you're interested.

Alternatively supporting Thomas Spellman's suggestion in TDEPS-9 (allowing user to specify repo credentials in deps.edn) would solve the same problem and has the benefit of not requiring a separate settings file.

Environment

None

Activity

Show:
import
October 12, 2018, 8:24 AM

Comment made by: cbowdon

Thanks for looking at this. Maven allows passing an alternative path to settings.xml with a command line argument, so perhaps an additional `-Smaven-settings` option for clj would be appropriate.

import
November 6, 2018, 10:10 PM

Comment made by: tsachev

I think maven settings builder used by tools.deps also supports custom settings.xml file location with system property org.apache.maven.user-settings

import
November 9, 2018, 10:16 AM

Comment made by: cbowdon

Thanks for the suggestion Vladimir. Unfortunately it seems this system property isn't supported with Maven 3: https://issues.apache.org/jira/browse/MNG-5199 . I tested it myself anyway, both with clj and mvn, but had no luck.

tcrawley
November 19, 2018, 2:12 PM

The org.apache.maven.user-settings sysprop is supported by the maven lib version that tools.deps is using (currently 3.5.2). The reason specifying it does not work is the clojure script does not pass the -J options ($java_opts within the script) to the java invocation that resolves dependencies. If you modify the script to set that sysprop directly or pass the JVM options, you can see the sysprop working. I'm not advocating that passing all of the JVM opts to the resolution invocation is a solution, just a way to confirm that this sysprop does indeed work.

Alex Miller
November 20, 2018, 6:49 PM

Yeah, don't want to pass all JVM options to the classpath generation invocation. Will need to either create a way to do that specifically or pass this as a prop a different way.

Assignee

Alex Miller

Reporter

import

Labels

None

Approval

None

Patch

None

Priority

Minor
Configure