Commits

Meikel Brandmeyer committed c1819cd

Added ClojurePluginConvention and moved warnOnReflection flag

Fixes #3

Comments (0)

Files changed (5)

src/main/groovy/clojuresque/ClojureCompileTask.groovy

 
     private void initialise() {
         def action = [ execute: { ClojureCompileTask task ->
-            boolean warnOnReflection = task.sourceSet.warnOnReflection
+            boolean warnOnReflection = task.project.warnOnReflection
             Set<File> sourceDirs = task.sourceSet.srcDirs
             File destDir = task.destinationDir
             FileTree source = task.source

src/main/groovy/clojuresque/ClojurePlugin.groovy

 public class ClojurePlugin implements Plugin {
     public void use(Project project, ProjectPluginsContainer handler) {
         JavaPlugin javaPlugin = handler.usePlugin(JavaPlugin.class, project)
+
+        project.convention.plugins["clojure"] =
+            new ClojurePluginConvention(project)
+
         configureCompileDefaults(project)
         configureSourceSetDefaults(project, javaPlugin)
         configureConfigurations(project)

src/main/groovy/clojuresque/ClojurePluginConvention.groovy

+/*-
+ * Copyright 2009 © Meikel Brandmeyer.
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+package clojuresque
+
+import org.gradle.api.Project
+
+class ClojurePluginConvention {
+    Project project
+    boolean warnOnReflection
+
+    public ClojurePluginConvention(Project project) {
+        this.project = project
+        this.warnOnReflection = false
+    }
+
+    public boolean getWarnOnReflection() {
+        return this.warnOnReflection
+    }
+
+    public void setWarnOnReflection(boolean flag) {
+        this.warnOnReflection = flag
+    }
+}

src/main/groovy/clojuresque/ClojureSourceSet.groovy

     public ClojureSourceSet clojure(Closure closure)
     public FileTree getAllClojure()
     public Set<File> getSrcDirs()
-    public boolean getWarnOnReflection()
-    public void setWarnOnReflection(boolean flag)
 }

src/main/groovy/clojuresque/DefaultClojureSourceSet.groovy

     private DefaultSourceDirectorySet clojure
     private PatternSet clojurePatterns
     private UnionFileTree allClojure
-    private boolean warnOnReflection
 
     public DefaultClojureSourceSet(String displayName,
             FileResolver fileResolver) {
         clojurePatterns.include("**/*.clj")
 
         allClojure = new UnionFileTree(desc, clojure.matching(clojurePatterns))
-
-        warnOnReflection = false
     }
 
     public DefaultSourceDirectorySet getClojure() {
     public Set<File> getSrcDirs() {
         return clojure.srcDirs
     }
-
-    public boolean getWarnOnReflection() {
-        return warnOnReflection
-    }
-
-    public void setWarnOnReflection(boolean flag) {
-        warnOnReflection = flag
-    }
 }