Skip to content

Instantly share code, notes, and snippets.

View robfletcher's full-sized avatar

Rob Fletcher robfletcher

View GitHub Profile
@robfletcher
robfletcher / CheckPluginVersions.groovy
Created June 15, 2009 10:19
Grails script that checks the versions of plugins you have installed and notifies you when newer versions are available
import groovy.xml.dom.DOMCategory
includeTargets << grailsScript("_GrailsInit")
includeTargets << grailsScript("_GrailsPlugins")
def getAvailablePluginVersions = {
def plugins = [:]
eachRepository {repo, url ->
use(DOMCategory) {
pluginsList.'plugin'.each {plugin ->
includeTargets << grailsScript("_GrailsInit")
includeTargets << grailsScript("_PluginDependencies")
target('default': "Prepares development environment") {
depends(installPlugins, installDependencies)
event("StatusFinal", ["Done"])
}
target(installPlugins: "Installs all plugins") {
depends(resolveDependencies)
package com.energizedwork.grails.plugins.jodatime;
import grails.converters.JSON;
import org.codehaus.groovy.grails.web.converters.exceptions.ConverterException;
import org.codehaus.groovy.grails.web.converters.marshaller.ObjectMarshaller;
import org.codehaus.groovy.grails.web.json.JSONException;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
@robfletcher
robfletcher / build.gradle
Created January 17, 2010 20:05
Example of using a Gradle multi-project build to test a Grails plugin and all its test-apps
allprojects {
task clean << { task ->
ant.exec(executable: "grails", dir: "$task.project.projectDir", failonerror: true) {
arg line: "clean"
}
}
}
task test << {
ant.exec(executable: "grails", dir: "$projectDir", failonerror: true) {
@robfletcher
robfletcher / DomainClassLookupPropertyEditor.groovy
Created February 26, 2010 13:25
PropertyEditor implementation used for binding to Grails domain objects by unique property value
import java.beans.PropertyEditorSupport
import org.apache.commons.lang.StringUtils
class DomainClassLookupPropertyEditor extends PropertyEditorSupport {
Class domainClass
String property
String getAsText() {
value."$property"
class TagListEditor extends PropertyEditorSupport {
void setAsText(String text) {
value = text.split(/,\s*/) as Set
}
String getAsText() {
value?.join(", ")
}
}
class TagListEditor extends PropertyEditorSupport {
void setAsText(String text) {
value = text.split(/,\s*/).collect {
Tag.findByName(it) ?: new Tag(name: it)
} as Set
}
String getAsText() {
value?.name?.join(", ")
}
@artifact.package@import grails.test.*
import org.junit.*
import static org.junit.Assert.*
import static org.hamcrest.CoreMatchers.*
import static org.junit.matchers.JUnitMatchers.*
class @artifact.name@ {
@Before void setUp() {
}
package com.github.robfletcher.grails.validation
import org.codehaus.groovy.grails.validation.AbstractConstraint
import org.springframework.validation.Errors
class AcyclicConstraint extends AbstractConstraint {
static final String DEFAULT_MESSAGE_CODE = "default.acyclic.violation.message"
static final String NAME = "acyclic"
@artifact.package@import spock.lang.*
import grails.plugin.spock.*
class @artifact.name@ extends @artifact.superclass@ {
def "feature method"() {
}
}