Meikel  Brandmeyer avatar Meikel Brandmeyer committed a9fbbf6

Initial check-in: project skeleton

Comments (0)

Files changed (4)

+syntax: glob
+
+build/*
+lib/*
+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.
+# clj-gradle – a Clojure plugin for Gradle
+
+## What is Gradle?
+
+[Gradle][] is a build system written in Java and [Groovy][]. One advantage
+of [Gradle][] is, that the build script itself is also a [Groovy][] script.
+That means whatever can be done in [Groovy][] can be done in the build
+script. This is useful to abstract away common patterns in the build like
+repetition or conditional decisions.
+
+On top of that [Gradle][] provides a convenient build system which comes
+in form of different plugins. Each plugin defines certain conventions which
+(if followed) automasie 95% of the build completely. Still the conventions
+are freely configurable to be adapted to different project structures.
+
+## What is clj-gradle?
+
+[clj-gradle][cg] is now a plugin for [Gradle][], which adds [Clojure][clj]
+support. It allows compilation with automatic namespace recognition. The
+plugin is based on the Java plugin and hooks into the standard configurations
+and archives.
+
+Contrary to the [Groovy][] plugin, there is no special `groovy` configuration.
+Java code in the same project might want to hook into [Clojure][] as well. So
+the [Clojure][] jar must be available also to the Java portion of the project.
+
+## Caveats
+
+* Sitting between the chairs of [Clojure][clj]'s namespace based and the
+  other languages file based compilation, you have to include or exclude
+  namespaces based on filenames for now.
+
+* Automatic recognition of namespaces only works if the `ns` form is the
+  first in the file. Comments may precede the form. The symbol is allowed
+  to be fully qualified: `clojure.core/ns`.
+
+## Getting started
+
+Create a sandbox directory. Add a subdirectory `lib` and put the `clojure.jar`
+as well as the `clj-gradle.jar` there. Create some test namespace in
+`src/main/clojure/test/example.clj`:
+
+    (ns test.example
+      (:gen-class))
+    
+    (defn -main
+      []
+      (println "Hello, World!"))
+
+Now create the `build.gradle` script:
+
+    buildscript {
+        repositories {
+            flatDir name: 'lib', dirs: 'lib'
+        }
+        dependencies {
+            classpath name: 'clj-gradle'
+        }
+    }
+    
+    usePlugin(de.kotka.gradle.ClojurePlugin)
+    
+    repositories {
+        flatDir name: 'lib', dirs: 'lib'
+    }
+    
+    configurations {
+        compileOnly {
+            setVisible(false)
+            setTransitive(false)
+        }
+        compile.extendsFrom(compileOnly)
+    }
+    
+    dependencies {
+        compileOnly name: 'clj-gradle'
+        compile name: 'clojure'
+    }
+
+This looks rather verbose, but I hope to simplify it later on. First we
+declare a dependency (and where to find it) for the build script itself.
+This is necessary, since the we need the plugin already to define the build
+logic itself.
+
+Next we define the repositories and dependencies for the project being
+build. Since we need the `ClojureCompile` class from the `clj-gradle.jar`
+in the classpath for compilation we introduce a special `compileOnly`
+configuration. It's private the finally deployed archives of the project
+won't depend on it at runtime. Additionally we add a dependency on the
+new configuration to the pre-defined `compile` configuration.
+
+Now build the project with `gradle build` and test the result:
+
+    ceres:..gradle-plugin/test% java -cp lib/clojure.jar:build/libs/test-unspecified.jar test.example
+    Hello, World!
+    ceres:..gradle-plugin/test%
+
+Please note, that the name of the generated jar depends on how you named
+the sandbox directory.
+
+## Issues
+
+This is **alpha** software! Expect problems! Please report issues in the
+bugtracker at [bitbucket in the 'Issues' tab][cg].
+
+-- 
+Meikel Brandmeyer <mb@kotka.de>
+Frankfurt am Main, October 2009
+
+[Gradle]: http://www.gradle.org
+[Groovy]: http://groovy.codehaus.org
+[clj]:    http://clojure.org
+[cg]:     http://bitbucket.org/kotarak/clj-gradle
+usePlugin 'java'
+usePlugin 'groovy'
+
+version = '1.0.0'
+
+def gradle_home = new File(System.getenv()['GRADLE_HOME'])
+def gradle_lib = new File(gradle_home, "lib")
+
+repositories {
+    flatDir name: 'lib', dirs: 'lib'
+    flatDir name: 'gradle', dirs: gradle_lib
+}
+
+dependencies {
+    compile name: 'clojure', version: '1.0.0'
+
+    groovy name: 'groovy', version: '1.6.4'
+    groovy name: 'gradle-core', version: '0.8'
+    groovy name: 'asm-all', version: '2.2.3'
+    groovy name: 'slf4j-api', version:'1.5.3'
+    groovy name: 'logback-core', version:'0.9.9'
+    groovy name: 'logback-classic', version:'0.9.9'
+    groovy name: 'antlr', version:'2.7.7'
+    groovy name: 'ant', version:'1.7.0'
+}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.