2

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.

Alexey Pomelov
  • 196
  • 1
  • 9
  • 1
    Any chance you could use the [standard crypto api](https://docs.oracle.com/javase/7/docs/api/javax/crypto/package-summary.html) rather than a 3rd party library? – lance-java Nov 30 '18 at 18:36
  • Sure, I can. I will be the last chance. And will force the init script to contain code -- the main reason I started all this activity was to get rid of code in the init script. – Alexey Pomelov Dec 03 '18 at 13:49

0 Answers0