Created
June 3, 2012 02:04
-
-
Save kellyrob99/2860971 to your computer and use it in GitHub Desktop.
Gradle task definition for apache rat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated to include usage of IsolatedAntBuilder to prevent possible collision with other tasks, and to limit the classpath needs for configuration of this task