Skip to content

Instantly share code, notes, and snippets.

@sgillespie
Created February 21, 2013 16:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sgillespie/5006107 to your computer and use it in GitHub Desktop.
Save sgillespie/5006107 to your computer and use it in GitHub Desktop.
apply plugin: DocumentationPlugin
authors {
gradle {
quickStart {
sourceFile = file('src/docs/quick-start')
}
userGuide {
}
developerGuide {
}
}
sean_gillespie {
greatMysteryNovel {
}
}
}
task books << {
authors.each { author ->
author.each { book ->
println "$book.name -> $book.sourceFile"
}
}
}
class DocumentationPlugin implements Plugin<Project> {
void apply(Project project) {
def authors = project.container(Author)
authors.all { author ->
books = project.container(Book) // This doesn't quite work
books.all { book ->
book.sourceFile = project.file("src/docs/$name")
}
}
project.extensions.authors = authors
}
}
class Book {
final String name
File sourceFile
Book(String name) {
this.name = name
}
}
class Author {
final String name
NamedDomainObjectContainer<Book> books
Author(String name) {
this.name = name
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment