Skip to content
This repository has been archived by the owner on Nov 19, 2020. It is now read-only.

Commit

Permalink
added init.gradle doc
Browse files Browse the repository at this point in the history
  • Loading branch information
mosabua committed Mar 6, 2015
1 parent 579ae45 commit 9c7330f
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions chapter-maven.asciidoc
Expand Up @@ -354,6 +354,66 @@ allprojects {
repositories RepoConfigurator
----

Other setup could be an expansion of the following example allowing
file system based repostories:

----
/**
* init.gradle file for development using Nexus as proxy repository
*
* @author Manfred Moser <manfred@simpligility.com
*/
apply plugin:NexusRepositoryPlugin
class NexusRepositoryPlugin implements Plugin<Gradle> {
final static String LOG_PREFIX = "init.gradle/NexusRepositoryPlugin:"
final Closure NexusConfig = {
maven {
name = 'standard-nexus'
url = 'http://localhost:8081/nexus/content/groups/public'
}
// if required you can add further repositories or groups here and they will
// be left intact if the name starts with standard-
// although it is better to just add those repositories in Nexus
// and expose them via the public group
}
final Closure RepoHandler = {
all { ArtifactRepository repo ->
if (repo.name.toString().startsWith("standard-") ) {
println "$LOG_PREFIX $repo.name at $repo.url activated as repository."
} else {
if (repo instanceof MavenArtifactRepository) {
remove repo
println "$LOG_PREFIX $repo.name at $repo.url removed."
} else {
println "$LOG_PREFIX $repo.name kept (not a Maven repository)."
}
}
}
}
void apply(Gradle gradle) {
// Override all project specified Maven repos with standard defined in here
gradle.allprojects{ project ->
println "$LOG_PREFIX Reconfiguring repositories and buildscript repositories."
project.repositories RepoHandler
project.buildscript.repositories RepoHandler
project.repositories NexusConfig
project.buildscript.repositories NexusConfig
}
}
}
----




Gradle init scripts can be much more powerful and customized and are
explained with more examples in the
http://gradle.org/docs/current/userguide/init_scripts.html[official Gradle documentation].
Expand Down

0 comments on commit 9c7330f

Please sign in to comment.