Skip to content

Instantly share code, notes, and snippets.

@kellyrob99
Created June 3, 2012 02:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kellyrob99/2860971 to your computer and use it in GitHub Desktop.
Save kellyrob99/2860971 to your computer and use it in GitHub Desktop.
Gradle task definition for apache rat
configurations{
rat
}
dependencies {
rat 'org.apache.rat:apache-rat-tasks:0.8'
}
task rat(type: RatTask){
ratClasspath = configurations.rat
srcDirs = files(project.sourceSets.main.allSource.srcDirs)
}
class RatTask extends DefaultTask {
@Input
FileCollection ratClasspath
@InputFiles
FileCollection srcDirs
@TaskAction
def rat() {
def antBuilder = services.get(IsolatedAntBuilder)
antBuilder.withClasspath(ratClasspath).execute {
ant.taskdef(resource: 'org/apache/rat/anttasks/antlib.xml')
ant.report {
srcDirs.each{
fileset(dir:it, includes:"**/*.java")
}
}
}
}
}
@kellyrob99
Copy link
Author

Updated to include usage of IsolatedAntBuilder to prevent possible collision with other tasks, and to limit the classpath needs for configuration of this task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment