Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Latest commit

 

History

History
95 lines (71 loc) · 2.87 KB

README.md

File metadata and controls

95 lines (71 loc) · 2.87 KB

gradle-plugin

Gradle plugin to convert your groovy files to javascript using grooscript. Last version published is 1.3.0.

build.gradle to use the plugin with gradle 2.0+ version:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'org.grooscript:gradle-plugin:1.3.0'
    }
}

apply plugin: 'org.grooscript.conversion'

build.gradle to use the plugin with gradle 2.1+:

plugins {
  id "org.grooscript.conversion" version "1.3.0"
}

There are 4 extension, convert files, convert templates, spy changes in files and generate require.js modules.

//Convert files, you can change options
grooscript {
    source = ['src/main/groovy/presenters'] //Sources to be converted(List), default is ['src/main/groovy']
    destination = 'js' //Target directory for js files, default is 'src/main/webapp/js/app'
    classpath = ['src/main/groovy'] //Needed classpath's to compile source files(List), default is ['src/main/groovy']
    customization = null //Customization in files, it's a closure, as for example { -> ast(groovy.transform.TypeChecked) }
    initialText = '//Grooscript converted file'
    initialText = '//End converted file'
    recursive = true //Default is false
    mainContextScope = ['$'] //Variables available in main scope (List), default is null
    addGsLib = 'grooscript' //Include a grooscript js lib in the result, default is null
    includeDependencies = true //Include conversion of dependency files, default is false
}

//Templates options
templates {
    templatesPath = 'src/main/webapp/templates'
    templates = ['main.gtpl', 'little/small.tpl']
    destinationFile = 'src/main/webapp/js/lib'
    classpath = ['src/main/groovy']
}

//Spy files changes
spy {
    files = ['anyFolder', 'aFile']
    onChanges = { list ->
        println 'Changes!! ' + list
    }
}

//Require.js modules
requireJs {
    sourceFile = 'src/main/groovy/MyApp.groovy'
    destinationFolder = 'src/main/resources/web/js/app'
}

There are 9 tasks:

convert - to convert groovy files to javascript

convertThread - to run conversion daemon that detect file changes and convert the files to javascript

templatesJs - generate javascript file with groovy templates defined

templatesThread - run daemon to convert templates. Executes daemon in a thread, so is perfect to use with other task

spyChanges - listen changes in files

syncGsLibs - synchronize grooscript libraries with plugin

requireJs - to generate require.js modules from groovy code

requireJsThread - listen changes in groovy code to regenerate require.js modules

generateGrailsFiles - this task is done automatically if you are in a grails project, to generate static files needed by grooscript grails plugin

More info about tasks here

Contributors

  • Jorge Franco
  • Michal Bernhard