Hi there!
as of version 4.10 Gradle supports token authentication via HTTP headers which has to be configured in the following manner:
maven {
url = “https://gitlab.com/api/…”
credentials(HttpHeaderCredentials) {
name = credentials_name
value = credentials_value
}
authentication {
header(HttpHeaderAuthentication)
}
}
So far, so good. My goal, however, is to configure such a maven repository by using a function
repository = {String name -> ...}
I managed to configure url and credentials but I am not able to configure the Authenatication correctly. What I get is an Action
of an AuthenaticationContainer
. I tried to create a HttpHeaderAuthentication and add it to the container without any success.
Does anybody know how to replace the (domain-specific) header(HttpHeaderAuthentication)
using an Action
of an AuthenticationContainer
instead?
Thanks in advance.
For reference see my code below:
getRepository = {String id →
return new Action() {
@Override
void execute(MavenArtifactRepository repository){
repository.setUrl(“https://gitlab.com/api/v4/projects/“+id+”/packages/maven”)
repository.credentials(HttpHeaderCredentials, newAction(){
@Override
void execute(HttpHeaderCredentialscredentials){
credentials.name=“Private Token”
credentials.value = value
}
})
repository.authentication(newAction() {
@Override
voidexecute(AuthenticationContainer authentications) {
// does not work
authentications.register(“header”,HttpHeaderAuthentication)
printlnauthentications
}
})
}
}
}