Skip to content

Instantly share code, notes, and snippets.

@rbellamy
Last active July 25, 2016 13:28
Show Gist options
  • Save rbellamy/152d3e10ef5177b36fbe to your computer and use it in GitHub Desktop.
Save rbellamy/152d3e10ef5177b36fbe to your computer and use it in GitHub Desktop.
apply plugin:EnterpriseRepositoryPlugin
class EnterpriseRepositoryPlugin implements Plugin<Gradle> {
private static String TERRADATUM_REPOSITORY_URL = "https://nexus.terradatum.com/content/groups/public"
void apply(Gradle gradle) {
// ONLY USE ENTERPRISE REPO FOR DEPENDENCIES
gradle.allprojects{ project ->
project.repositories {
// Remove all repositories not pointing to the enterprise repository url
all { ArtifactRepository repo ->
if (!(repo instanceof MavenArtifactRepository) ||
repo.url.toString() != TERRADATUM_REPOSITORY_URL) {
project.logger.lifecycle "Repository ${repo.url} removed. Only $TERRADATUM_REPOSITORY_URL is allowed"
remove repo
}
}
// add the enterprise repository
maven {
name "Terradatum Nexus Repository"
url TERRADATUM_REPOSITORY_URL
}
}
}
}
}
allprojects { project ->
apply plugin: 'maven'
afterEvaluate {
task checkSonatypeProperties(overwrite: true) << {
project.logger.lifecycle "Overwrite checkSonatypeProperties"
}
uploadArchives {
repositories {
mavenDeployer {
snapshotRepository(url: 'https://nexus.terradatum.com/content/repositories/snapshots/') {
authentication(userName: 'deployment', password: 'password')
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment