Commits

Meikel Brandmeyer committed 5f12943

Get up to speed with Gradle 0.9

Comments (0)

Files changed (4)

-usePlugin 'java'
-usePlugin 'groovy'
-usePlugin 'maven'
+apply {
+    plugin 'java'
+    plugin 'groovy'
+    plugin 'maven'
+}
 
 group = 'clojuresque'
 version = '1.4.0-SNAPSHOT'
 
 repositories {
     flatDir name: 'gradle', dirs: new File(System.getenv('GRADLE_HOME') + '/lib')
+    flatDir name: 'plugins', dirs: new File(System.getenv('GRADLE_HOME') + '/lib/plugins')
     mavenCentral()
 }
 
 dependencies {
     groovy 'org.clojure:clojure: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'
-    groovy name: 'ivy', version:'2.1.0-rc2'
+    groovy name: 'groovy-all', version: '1.7.1'
+    groovy name: 'gradle-core', version: '0.9-preview-1'
+    groovy name: 'gradle-plugins', version: '0.9-preview-1'
+    groovy name: 'asm-all', version: '3.2'
+    groovy name: 'slf4j-api', version:'1.5.10'
+    groovy name: 'logback-core', version:'0.9.18'
+    groovy name: 'logback-classic', version:'0.9.18'
+    groovy name: 'ant', version:'1.8.0'
+    groovy name: 'ivy', version:'2.1.0'
 }
 
 File dummyRepo = new File(project.buildDir, 'deploy')

src/main/groovy/clojuresque/ClojurePlugin.groovy

 import org.gradle.api.plugins.JavaPlugin
 import org.gradle.api.plugins.JavaPluginConvention
 import org.gradle.api.plugins.MavenPlugin
-import org.gradle.api.plugins.ProjectPluginsContainer
 import org.gradle.api.tasks.ConventionValue
 import org.gradle.api.tasks.StopExecutionException
 import org.gradle.api.tasks.bundling.Jar
 
-public class ClojurePlugin implements Plugin {
+public class ClojurePlugin implements Plugin<Project> {
     public static final String UEBERJAR_TASK_NAME = 'ueberjar'
 
-    public void use(Project project, ProjectPluginsContainer handler) {
-        JavaPlugin javaPlugin = handler.usePlugin(JavaPlugin.class, project)
-        MavenPlugin mavenPlugin = handler.usePlugin(MavenPlugin.class, project)
+    public void apply(Project project) {
+        project.plugins.apply(JavaPlugin.class)
+        project.plugins.apply(MavenPlugin.class)
 
         project.convention.plugins["clojure"] =
             new ClojurePluginConvention(project)
 
         configureCompileDefaults(project)
-        configureSourceSetDefaults(project, javaPlugin)
+        configureSourceSetDefaults(project)
         configureConfigurations(project)
         configureArchives(project)
         configureUeberjar(project)
     }
 
     private configureSourceSet(DefaultSourceSet sourceSet,
-            Project project, JavaPlugin javaPlugin) {
+            Project project) {
         ProjectInternal projectInternal = (ProjectInternal)project
         String srcDir = String.format("src/%s/clojure", sourceSet.name)
 
         project.tasks[sourceSet.classesTaskName].dependsOn(compileTaskName)
     }
 
-    private void configureSourceSetDefaults(Project project,
-            JavaPlugin javaPlugin) {
+    private void configureSourceSetDefaults(Project project) {
         def action = [ execute: { SourceSet sourceSet ->
-            configureSourceSet(sourceSet, project, javaPlugin)
+            configureSourceSet(sourceSet, project)
         } ] as Action
 
         project.convention.getPlugin(JavaPluginConvention.class)
                 if (!jar.enabled)
                     throw new StopExecutionException("SKIPPED: jar not enabled")
                 project.configurations.runtime.resolve().each {
-                    ueberjar.merge it
+                    ueberjar.from zipTree(it)
                 }
-                ueberjar.merge jar.archivePath
+                ueberjar.from zipTree(jar.archivePath)
             }
         }
     }

src/main/groovy/clojuresque/ClojurePluginConvention.groovy

     public void gradleHomeRepo(RepositoryHandler repos) {
         String home = System.getenv('GRADLE_HOME')
         if (home != null) {
-            repos.flatDir name: 'gradleHome', dirs: new File(home + '/lib')
+            repos.flatDir name: 'gradleHome', dirs: new File(home + '/lib/plugins')
         }
     }
 

src/main/resources/META-INF/gradle-plugins/clojure.properties

+implementation-class=clojuresque.ClojurePlugin