From 1e84b8af48ac2316812cd2ca95ec2d72dc014f66 Mon Sep 17 00:00:00 2001
From: Marek Goldmann <goldmann@fedoraproject.org>
Date: Sat, 28 Jul 2012 13:02:58 +0200
Subject: [PATCH 14/25] Add proper codenarc dependencies

---
 .../src/main/groovy/org/gradle/api/plugins/quality/Checkstyle.groovy   | 3 ++-
 .../main/groovy/org/gradle/api/plugins/quality/CheckstylePlugin.groovy | 2 --
 .../src/main/groovy/org/gradle/api/plugins/quality/CodeNarc.groovy     | 3 ++-
 .../main/groovy/org/gradle/api/plugins/quality/CodeNarcPlugin.groovy   | 1 +
 4 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/subprojects/code-quality/src/main/groovy/org/gradle/api/plugins/quality/Checkstyle.groovy b/subprojects/code-quality/src/main/groovy/org/gradle/api/plugins/quality/Checkstyle.groovy
index 71ecb3a..4f56b7c 100644
--- a/subprojects/code-quality/src/main/groovy/org/gradle/api/plugins/quality/Checkstyle.groovy
+++ b/subprojects/code-quality/src/main/groovy/org/gradle/api/plugins/quality/Checkstyle.groovy
@@ -18,6 +18,7 @@ package org.gradle.api.plugins.quality
 import org.gradle.api.GradleException
 import org.gradle.api.file.FileCollection
 import org.gradle.api.internal.Instantiator
+import org.gradle.api.internal.ClassPathRegistry
 import org.gradle.api.internal.project.IsolatedAntBuilder
 import org.gradle.api.plugins.quality.internal.CheckstyleReportsImpl
 import org.gradle.api.reporting.Reporting
@@ -141,7 +142,7 @@ class Checkstyle extends SourceTask implements VerificationTask, Reporting<Check
     public void run() {
         def propertyName = "org.gradle.checkstyle.violations"
         def antBuilder = services.get(IsolatedAntBuilder)
-        antBuilder.withClasspath(getCheckstyleClasspath()).execute {
+        antBuilder.withGroovy(services.get(ClassPathRegistry).getClassPath("GROOVY").asFiles).withClasspath(getCheckstyleClasspath()).execute {
             ant.taskdef(name: 'checkstyle', classname: 'com.puppycrawl.tools.checkstyle.CheckStyleTask')
 
             ant.checkstyle(config: getConfigFile(), failOnViolation: false, failureProperty: propertyName) {
diff --git a/subprojects/code-quality/src/main/groovy/org/gradle/api/plugins/quality/CheckstylePlugin.groovy b/subprojects/code-quality/src/main/groovy/org/gradle/api/plugins/quality/CheckstylePlugin.groovy
index 21ef63d..2f90292 100644
--- a/subprojects/code-quality/src/main/groovy/org/gradle/api/plugins/quality/CheckstylePlugin.groovy
+++ b/subprojects/code-quality/src/main/groovy/org/gradle/api/plugins/quality/CheckstylePlugin.groovy
@@ -52,8 +52,6 @@ class CheckstylePlugin extends AbstractCodeQualityPlugin<Checkstyle> {
                     project.dependencies {
                         checkstyle "antlr:antlr:2.7.7"
                         checkstyle "com.puppycrawl.tools:checkstyle:$extension.toolVersion"
-//                        checkstyle "com.google.guava:guava:11.0.1"
-//                        checkstyle "commons-beanutils:commons-beanutils:1.8.3"
                     }
                 }
                 config
diff --git a/subprojects/code-quality/src/main/groovy/org/gradle/api/plugins/quality/CodeNarc.groovy b/subprojects/code-quality/src/main/groovy/org/gradle/api/plugins/quality/CodeNarc.groovy
index 76ab134..df38151 100644
--- a/subprojects/code-quality/src/main/groovy/org/gradle/api/plugins/quality/CodeNarc.groovy
+++ b/subprojects/code-quality/src/main/groovy/org/gradle/api/plugins/quality/CodeNarc.groovy
@@ -21,6 +21,7 @@ package org.gradle.api.plugins.quality
 import org.gradle.api.GradleException
 import org.gradle.api.file.FileCollection
 import org.gradle.api.internal.Instantiator
+import org.gradle.api.internal.ClassPathRegistry
 import org.gradle.api.internal.project.IsolatedAntBuilder
 import org.gradle.api.logging.LogLevel
 import org.gradle.api.plugins.quality.internal.CodeNarcReportsImpl
@@ -99,7 +100,7 @@ class CodeNarc extends SourceTask implements VerificationTask, Reporting<CodeNar
     void run() {
         logging.captureStandardOutput(LogLevel.INFO)
         def antBuilder = services.get(IsolatedAntBuilder)
-        antBuilder.withClasspath(getCodenarcClasspath()).execute {
+        antBuilder.withGroovy(services.get(ClassPathRegistry).getClassPath("LOCAL_GROOVY").asFiles).withClasspath(getCodenarcClasspath()).execute {
             ant.taskdef(name: 'codenarc', classname: 'org.codenarc.ant.CodeNarcTask')
             try {
                 ant.codenarc(ruleSetFiles: "file:${getConfigFile()}", maxPriority1Violations: 0, maxPriority2Violations: 0, maxPriority3Violations: 0) {
diff --git a/subprojects/code-quality/src/main/groovy/org/gradle/api/plugins/quality/CodeNarcPlugin.groovy b/subprojects/code-quality/src/main/groovy/org/gradle/api/plugins/quality/CodeNarcPlugin.groovy
index 77acf6f..8d5f555 100644
--- a/subprojects/code-quality/src/main/groovy/org/gradle/api/plugins/quality/CodeNarcPlugin.groovy
+++ b/subprojects/code-quality/src/main/groovy/org/gradle/api/plugins/quality/CodeNarcPlugin.groovy
@@ -55,6 +55,7 @@ class CodeNarcPlugin extends AbstractCodeQualityPlugin<CodeNarc> {
                 def config = project.configurations['codenarc']
                 if (config.dependencies.empty) {
                     project.dependencies {
+                        codenarc "antlr:antlr:2.7.7"
                         codenarc "org.codenarc:CodeNarc:$extension.toolVersion"
                     }
                 }
-- 
1.7.11.2

