2

When I do a ./gradlew publishToMavenLocal it publishes to my default maven home directory of: ~/.m2.

I would instead like to publish to a custom maven repository path.

To do with with mvn command line, you can specify the command line -Dmaven.repo.local=$HOME/.my/other/repository (See: https://stackoverflow.com/a/7071791/1174024)

But what about when publishing with Gradle? Is there a way to publish to a custom path by using an environment variable, or something similar?

Nicholas DiPiazza
  • 10,029
  • 11
  • 83
  • 152

1 Answers1

2

You can add a system property maven.repo.local with the path.

Example:

./gradlew -Dmaven.repo.local=/path/to/local/repo publishToMavenLocal

Source: https://github.com/gradle/gradle/blob/0cb6116e150ec397f2e6c935ab4a851b48d2cf67/subprojects/dependency-management/src/main/java/org/gradle/api/internal/artifacts/mvnsettings/DefaultLocalMavenRepositoryLocator.java#L46

Note that the same thing does NOT work if you specify as a gradle project -P property. Only reads system properties.

Nicholas DiPiazza
  • 10,029
  • 11
  • 83
  • 152