Declare plugin repository in settings.gradle.kts:
pluginManagement {
repositories {
// ...
maven("https://jitpack.io")
}
// ...
}Add plugin to build.gradle.kts:
plugins {
// ...
id("com.github.BoBkiNN.RepoSecrets") version "1.0.0" // replace 1.0.0 with latest release
}Use extension functions to add your repository:
import xyz.bobkinn.repoSecrets.credRepository
// ...
repositories {
// ...
credRepository("REPO_ID", rootProject.properties)
}
Replace REPO_ID with your custom repository id.
Example:
REPO_ID_URL = https://user:password@repo.example.com/You can replace REPO_ID with any other repository name to reference it.
Also you can use _LOGIN and _PASSWORD suffixes after repository name to specify credentials
Example use of _LOGIN and _PASSWORD:
REPO_ID_URL = https://repo.example.com/
REPO_ID_LOGIN = user
REPO_ID_PASSWORD = passwordWhen plugin is applied it loads cred.properties file in project directory.
If no file is found then no exception is loaded
Project.loadCredProperties(file: String = DEFAULT_CRED_PROPERTIES): loads file, can be called manually if plugin not appliedPublishingExtension.printPublishResults(pubName: String): prints pretty list of artifacts and repositories (without credentials) where artifacts was uploadedMavenArtifactRepository.authFromSettings: Loads repository credentials from.m2/settings.xmlfile
- Ability to throw exception when no file is found or no repo is found, or it requires auth
- Plugin settings
- Lazy-loaded file to apply settings
- Move to ini or toml or other format to set repositories options