Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,9 @@
/*.ipr
/*.iml
/*.iws
/.gradletasknamecache
/.gradletasknamecache
/bin/

.classpath
.project
.settings/*
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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"
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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'
}
}

Expand All @@ -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')
}
Expand All @@ -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`.
Expand Down
49 changes: 25 additions & 24 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ class CompassExtension {
String environment
String outputStyle
String projectType

String sourcesMirror
}
15 changes: 12 additions & 3 deletions src/main/groovy/org/gradle/plugins/compass/CompassPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ class CompassPlugin implements Plugin<Project> {

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"
Expand All @@ -33,6 +35,12 @@ class CompassPlugin implements Plugin<Project> {
outputs.upToDateWhen { false }
}

def cleanCompileTask = project.task('cleanCompileTask') << {
fileTree(dir: extension.cssDir, include: '**/*.css').each {
delete it
}
}

compileSass.dependsOn(installCompass)
watchSass.dependsOn(installCompass)

Expand All @@ -51,7 +59,7 @@ class CompassPlugin implements Plugin<Project> {
}
}

private void createExtension() {
private void createExtension() {
extension = project.extensions.create('compass', CompassExtension)
extension.with {
encoding = Charset.defaultCharset().name()
Expand All @@ -61,7 +69,7 @@ class CompassPlugin implements Plugin<Project> {
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()) {
Expand Down Expand Up @@ -105,6 +113,7 @@ class CompassPlugin implements Plugin<Project> {
importPath = { extension.importPath }
projectType = { extension.projectType }
environment = { extension.environment }
sourcesMirror = { extension.sourcesMirror }
outputStyle = { extension.outputStyle }
fontsDir = { extension.fontsDir }
noLineComments = { extension.noLineComments }
Expand Down
23 changes: 19 additions & 4 deletions src/main/groovy/org/gradle/plugins/compass/CompassTask.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class CompassTask extends JRubyTask {
boolean quiet
boolean trace

String sourcesMirror

String environment
String outputStyle
String projectType
Expand Down Expand Up @@ -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)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import org.gradle.api.tasks.*

class DependenciesResolver extends JRubyTask {

String sourcesMirror

@OutputDirectory
File gemPath

Expand All @@ -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))
Expand Down