-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Hi There. We use an internal Sonatype Nexus artifact repository for managing internal and third party dependencies. I'd like to be able to provide credentials in the URL returned from the rootUrlMapper so the download can leverage authentication. See proposed change below.
private static void download(Project project, String fromUrl, File toFile) {
def url = new URL(fromUrl)
def urlConnection = url.openConnection();
if (url.getUserInfo() != null) {
def basicAuth = "Basic " + new String(new Base64().encode(url.getUserInfo().getBytes()));
urlConnection.setRequestProperty("Authorization", basicAuth);
}
def from = Channels.newChannel(urlConnection.getInputStream())
project.logger.lifecycle("About to download a gradle distribution from $fromUrl to $toFile.absolutePath")
new FileOutputStream(toFile).withCloseable {
it.channel.transferFrom(from, 0, Long.MAX_VALUE)
}
project.logger.lifecycle("Downloaded a gradle distribution from $fromUrl to $toFile.absolutePath")
}
Metadata
Metadata
Assignees
Labels
No labels