To use a third-party library in a gradle script I have to declare the dependency in a special buildscript
block.
But can I use a library in the buildscript
block?
The case is the following (maybe I'm doing something wrong here). I'm developing a plugin to collect all company-wide settings and would like to apply it from the init script. Plugin will be published to an internal Nexus repository, everybody will take a small init script.
In future I'll be able to add new stuff to the plugin and redeploy it without disturbing others.
The problem is our nexus has authentication, user and password are stored in $USER_HOME/.gradle
, password is encrypted. I'd like to use some library to decrypt it. But how?
I thought init script to be like this:
initscript {
repositories {
val nexusUsername = ....
val nexusPassword = ....
maven {
url = uri("https://some.company.nexus/maven-public/")
credentials {
username = nexusUsername
password = nexusPassword
}
}
}
dependencies {
classpath("company:gradle-plugin:1.0-SNAPSHOT")
}
}
allprojects {
apply<CompanyGradlePlugin>()
}
I have no project instance in initscript
section, so I'll read properties manually with java.util.Properties
. But password decryption is still a problem.