diff --git a/.gitignore b/.gitignore index 862ef23..32372d3 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,9 @@ /*.ipr /*.iml /*.iws -/.gradletasknamecache \ No newline at end of file +/.gradletasknamecache +/bin/ + +.classpath +.project +.settings/* diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..d33e9e6 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,7 @@ +language: java +jdk: + - openjdk7 + - oraclejdk7 + - oraclejdk8 +install: /bin/true +script: "./gradlew clean build -Pbintray_username=abc -Pbintray_api_key=42 --info" diff --git a/README.md b/README.md index 967965f..b42c5d9 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Gradle Compass plugin +[![Build Status](https://travis-ci.org/holisticon/gradle-compass.svg?branch=master)](https://travis-ci.org/holisticon/gradle-compass) + A [SASS][sass] / [Compass][compass] plugin for [Gradle][gradle]. The plugin uses JRuby to install and run Compass. ## Tasks @@ -20,18 +22,16 @@ Installs the Compass Ruby gem and any additional gems you specify. This is execu ## Installation -Add the plugin's Bintray repository to your `buildscript` and apply the plugin: +Add the [JAR](https://github.com/holisticon/gradle-compass/releases/latest) to your nexus and apply the plugin: + ```groovy apply plugin: 'compass' buildscript { - repositories { - mavenCentral() - maven { url 'http://dl.bintray.com/robfletcher/gradle-plugins' } - } + ... dependencies { - classpath 'org.gradle.plugins:gradle-compass:1.0.7' + classpath 'org.gradle.plugins:gradle-compass:1.0.15' } } @@ -46,6 +46,7 @@ General configuration for the plugin goes inside a `compass` block in your build ```groovy compass { + sourcesMirror = 'http://nexus.example.com:8080/content/repositories/rubygems/' cssDir = file('public/styles') sassDir = file('src/main/sass') } @@ -64,7 +65,7 @@ The full set of parameters supported by the plugin is… * `jvmArgs`: additional arguments to pass to the JVM when running JRuby. The default is blank. #### Paths - +* `sourcesMirror`: the ruby gem mirror to use * `cssDir` **required**: the target directory where compiled CSS is output. Equivalent to `--css-dir`. * `sassDir` **required**: the source directory where you keep *.scss* and/or *.sass* files. Equivalent to `--sass-dir`. * `imagesDir`: the source directory where you keep image files. Equivalent to `--images-dir`. diff --git a/build.gradle b/build.gradle index 3ef219c..ec2c021 100644 --- a/build.gradle +++ b/build.gradle @@ -1,45 +1,46 @@ +apply plugin: "idea" +apply plugin: "eclipse" apply plugin: "groovy" apply plugin: "maven-publish" group = "org.gradle.plugins" -version = "1.0.10" +version = "1.0.15" repositories { - mavenCentral() + mavenCentral() } dependencies { - compile gradleApi() - compile localGroovy() + compile gradleApi() + compile localGroovy() } task sourceJar(type: Jar) { - from sourceSets.main.allGroovy, sourceSets.main.resources + from sourceSets.main.allGroovy, sourceSets.main.resources } publishing { - publications { - mavenJava(MavenPublication) { - from components.java - - artifact sourceJar { - classifier "sources" - } - } - } - repositories { - maven { - url "https://api.bintray.com/maven/robfletcher/gradle-plugins/gradle-compass" - credentials { - username = bintray_username - password = bintray_api_key - } - } - } + publications { + mavenJava(MavenPublication) { + from components.java + artifact sourceJar { + classifier "sources" + } + } + } + repositories { + maven { + url "https://api.bintray.com/maven/robfletcher/gradle-plugins/gradle-compass" + credentials { + username = bintray_username + password = bintray_api_key + } + } + } } task wrapper(type: Wrapper) { - gradleVersion = "1.9" + gradleVersion = "1.9" } apply from: "gradle/integration-tests.gradle" diff --git a/src/main/groovy/org/gradle/plugins/compass/CompassExtension.groovy b/src/main/groovy/org/gradle/plugins/compass/CompassExtension.groovy index b331e17..f62a173 100644 --- a/src/main/groovy/org/gradle/plugins/compass/CompassExtension.groovy +++ b/src/main/groovy/org/gradle/plugins/compass/CompassExtension.groovy @@ -31,5 +31,5 @@ class CompassExtension { String environment String outputStyle String projectType - + String sourcesMirror } diff --git a/src/main/groovy/org/gradle/plugins/compass/CompassPlugin.groovy b/src/main/groovy/org/gradle/plugins/compass/CompassPlugin.groovy index 0ab47de..fd720e6 100644 --- a/src/main/groovy/org/gradle/plugins/compass/CompassPlugin.groovy +++ b/src/main/groovy/org/gradle/plugins/compass/CompassPlugin.groovy @@ -16,7 +16,9 @@ class CompassPlugin implements Plugin { createConfiguration() - def installCompass = project.task('installCompass', type: DependenciesResolver) + def installCompass = project.task('installCompass', type: DependenciesResolver) { + sourcesMirror = sourcesMirror + } def compileSass = project.task('compileSass', type: CompassTask) { group "Build" @@ -33,6 +35,12 @@ class CompassPlugin implements Plugin { outputs.upToDateWhen { false } } + def cleanCompileTask = project.task('cleanCompileTask') << { + fileTree(dir: extension.cssDir, include: '**/*.css').each { + delete it + } + } + compileSass.dependsOn(installCompass) watchSass.dependsOn(installCompass) @@ -51,7 +59,7 @@ class CompassPlugin implements Plugin { } } - private void createExtension() { + private void createExtension() { extension = project.extensions.create('compass', CompassExtension) extension.with { encoding = Charset.defaultCharset().name() @@ -61,7 +69,7 @@ class CompassPlugin implements Plugin { cssDir = project.file('build/css') sassDir = project.file('src/main/sass') jvmArgs = '' - jrubyVersion = '1.7.10' + jrubyVersion = '1.7.20' def defaultImagesDir = new File('src/main/images') if (defaultImagesDir.isDirectory()) { @@ -105,6 +113,7 @@ class CompassPlugin implements Plugin { importPath = { extension.importPath } projectType = { extension.projectType } environment = { extension.environment } + sourcesMirror = { extension.sourcesMirror } outputStyle = { extension.outputStyle } fontsDir = { extension.fontsDir } noLineComments = { extension.noLineComments } diff --git a/src/main/groovy/org/gradle/plugins/compass/CompassTask.groovy b/src/main/groovy/org/gradle/plugins/compass/CompassTask.groovy index efb39cd..c013de1 100644 --- a/src/main/groovy/org/gradle/plugins/compass/CompassTask.groovy +++ b/src/main/groovy/org/gradle/plugins/compass/CompassTask.groovy @@ -17,6 +17,8 @@ class CompassTask extends JRubyTask { boolean quiet boolean trace + String sourcesMirror + String environment String outputStyle String projectType @@ -97,12 +99,25 @@ class CompassTask extends JRubyTask { @TaskAction void runCompassTask() { - if (background) { - Thread.start { - jrubyexec(getJRubyArguments()) + if (getSourcesMirror()){ + logger.info('Adding source mirror.') + def args = [] + args << '-S' << 'gem' << 'sources' << '--add' << getSourcesMirror() + jrubyexec(args) } - } else { + if (background) { + Thread.start { + jrubyexec(getJRubyArguments()) + } + } else { jrubyexec(getJRubyArguments()) + + if (getSourcesMirror()){ + logger.info('Remove source mirror.') + def args = [] + args << '-S' << 'gem' << 'sources' << '--remove' << getSourcesMirror() + jrubyexec(args) + } } } } \ No newline at end of file diff --git a/src/main/groovy/org/gradle/plugins/compass/DependenciesResolver.groovy b/src/main/groovy/org/gradle/plugins/compass/DependenciesResolver.groovy index fe99f0a..4df71dc 100644 --- a/src/main/groovy/org/gradle/plugins/compass/DependenciesResolver.groovy +++ b/src/main/groovy/org/gradle/plugins/compass/DependenciesResolver.groovy @@ -4,6 +4,8 @@ import org.gradle.api.tasks.* class DependenciesResolver extends JRubyTask { + String sourcesMirror + @OutputDirectory File gemPath @@ -15,6 +17,12 @@ class DependenciesResolver extends JRubyTask { @TaskAction void install() { + if (sourcesMirror){ + logger.info('Adding source mirror.') + def args = [] + args << '-S' << 'gem' << 'sources' << '--add' << sourcesMirror + jrubyexec(args) + } if (gemJars?.empty) { for (gem in getRubyGems()) { jrubyexec(getJRubyArguments(gem))