question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add support for custom maven repositories with credentials

See original GitHub issue

In our custom instance we would like to add a maven repository which requires credentials.

For maven projects, this works because the user can define the credentials in ~/.m2/settings.xml while referencing the maven repository-id.

For gradle projects this doesn’t work. The gradle-way to accomplish this, looks like this:

maven {
       url 'https://artifacts.mycompany.com/snapshots'
       credentials {
                username property("com.mycompany.artifacts.username")
                password property("com.mycompany.artifacts.password")
        }
}

This is currently not supported by Initializr.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:2
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
tgeenscommented, Sep 5, 2019

My proposal:

  1. Add a credentials field to the MavenRepository model. The type would be a MavenRepositoryCredentials object with username & password fields. (Or a key-value map-like object, which would facilitate extending this to non-basic-auth later on.)

2a. The maven-build-writer can ignore the credentials field - just like the gradle-build-writer is ignoring the name and snapshotsEnabled fields from MavenRepository

2b. The gradle-build-writer can check if there are (non-default) credentials provided and write those to the build.gradle if necessary. Currently the gradle-build-writer can only write repositories on a single line (like maven { url 'https://repo.spring.io/snapshot' }).

To support a representation which includes credentials info, the implementation of GradleBuildWriter#writeRepositories should be updated and the method signature

protected abstract String repositoryAsString(MavenRepository repository)

should change into something that can (optionally) write multi-line repository information, like

protected void writeRepository(IndentingWriter writer, MavenRepository repository)
0reactions
wilkinsonacommented, Jun 14, 2022

We hope to address it at some point, that’s why the issue has not be closed. We don’t have any firm plans or a date in mind at the moment, however.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to specify credentials for custom maven private repo
You can set in .m2/settings.xml file. Like This: <settings> <servers> <server> <id>private-repo</id> <username>xyz</username> ...
Read more >
Guide to using Multiple Repositories - Apache Maven
The first way is to specify in a POM which repositories you want to use. That is supported both inside and outside of...
Read more >
Declaring repositories - Gradle User Manual
Accessing authenticated Maven repositories. You can specify credentials for Maven repositories secured by different type of authentication. See Supported ...
Read more >
Your private maven repository - myMavenRepo.com
There is difference between repository credentials and service credentials. Don't mess them up. Help / Configuring Maven pom.xml file for HTTP Basic Auth ......
Read more >
How to use Enterprise Maven Repository credentials with ...
To configure your Enterprise Maven Repository credentials with embedded Maven to allow you to reference and use dependencies only available from the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found