Skip to content

Instantly share code, notes, and snippets.

@ck1125
Created February 26, 2012 00:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ck1125/1911957 to your computer and use it in GitHub Desktop.
Save ck1125/1911957 to your computer and use it in GitHub Desktop.
gradle grails plugin on grails 2.0.x
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven {
url "http://repo.grails.org/grails/core"
}
}
dependencies {
classpath "org.grails:grails-gradle-plugin:1.1.1-SNAPSHOT",
"org.grails:grails-bootstrap:2.0.0",
"javassist:javassist:3.11.0.GA"
}
}
grailsVersion = '2.0.0'
apply plugin: 'grails'
apply plugin: "project-reports"
apply plugin: "idea"
sourceCompatibility = 1.6
targetCompatibility = 1.6
version = "0.1-SNAPSHOT"
repositories {
mavenLocal()
mavenCentral()
maven {
url "http://repo.grails.org/grails/core"
}
}
configurations {
all*.exclude module: "jaxb-impl"
all*.exclude group: "stax"
all*.exclude group: "xstream"
all*.exclude group: "jtidy"
all*.exclude module: "xml-apis"
all*.exclude module: "jmxri"
all*.exclude module: "jmx-tools"
// all*.exclude module: "xercesImpl"
compile.exclude module: "commons-logging"
}
dependencies {
compile "org.grails:grails-crud:$grailsVersion"
compile "org.grails:grails-datastore-gorm:1.0.2.RELEASE"
compile "org.grails:grails-bootstrap:$grailsVersion"
compile "org.grails:grails-plugin-testing:$grailsVersion"
compile "org.grails:grails-plugin-log4j:$grailsVersion"
compile "org.grails:grails-plugin-datasource:$grailsVersion"
compile "org.spockframework:spock-grails-support:0.6-groovy-1.8-SNAPSHOT"
//compile "org.slf4j:slf4j-log4j12:1.6.4"
compile "org.grails:grails-test:$grailsVersion"
runtime "hsqldb:hsqldb:1.8.0.5",
"net.sf.ehcache:ehcache-core:1.7.1",
//"org.grails:grails-crud:$grailsVersion",
"org.aspectj:aspectjweaver:1.6.8"
}
private def getCompileDependencies() {
def depList = []
configurations.compile.resolvedConfiguration.resolvedArtifacts.each {
if (!depList.contains(it.moduleVersion.id.name)) {
depList.add([name: it.moduleVersion.id.name, file: it.file])
}
}
return depList
}
idea.project.ipr {
withXml { provider ->
def libraryTable = provider.node.component.orderEntry.find {it.@type == 'libraryTable'}
def compileDependencies = getCompileDependencies()
compileDependencies.each { dependency ->
def inXml = libraryTable?.find { it.library.@name == "${dependency.name}"}
if (!inXml) {
if (!libraryTable) {
libraryTable = provider.node.appendNode('component', [name: 'libraryTable'])
}
def newLibrary = libraryTable.appendNode('library', [name: "${dependency.name}"])
def classNode = newLibrary.appendNode('CLASSES')
classNode.appendNode('root', [url: "jar:///${dependency.file}!/"])
newLibrary.appendNode('JAVADOC')
newLibrary.appendNode('SOURCES')
}
provider.node.component.find { it.@name == 'ProjectRootManager' }.@languageLevel = 'JDK_1_6'
provider.node.component.find { it.@name == 'ProjectRootManager' }.@'project-jdk-name' = '1.6'
provider.node.component.find { it.@name == 'VcsDirectoryMappings' }.mapping.@vcs = "Git"
}
}
}
idea.module.iml {
withXml { provider ->
def component = provider.node.component.find {it.@name == "NewModuleRootManager" }
def compileDependencies = getCompileDependencies()
compileDependencies.each { dependency ->
def inXml = component.orderEntry?.find { it.@name == "${dependency.name}"}
if (!inXml) {
orderEntry = component.appendNode('orderEntry', [type: 'library', name: "${dependency.name}", level: "project"])
}
}
def content = component.find {it.name() == 'content'}
if (content) {
content.appendNode('sourceFolder',[url:"file://\$MODULE_DIR\$/test/unit",isTestSource:"true"])
content.appendNode('sourceFolder',[url:'file://\$MODULE_DIR\$/test/integration',isTestSource:"true"])
content.appendNode('sourceFolder',[url:'file://\$MODULE_DIR\$/grails-app/domain',isTestSource:"false"])
content.appendNode('sourceFolder',[url:'file://\$MODULE_DIR\$/grails-app/controllers',isTestSource:"false"])
content.appendNode('sourceFolder',[url:'file://\$MODULE_DIR\$/grails-app/service',isTestSource:"false"])
content.appendNode('sourceFolder',[url:'file://\$MODULE_DIR\$/grails-app/conf',isTestSource:"false"])
content.appendNode('sourceFolder',[url:'file://\$MODULE_DIR\$/grails-app/taglib',isTestSource:"false"])
content.appendNode('sourceFolder',[url:'file://\$MODULE_DIR\$/src/groovy',isTestSource:"false"])
content.appendNode('sourceFolder',[url:'file://\$MODULE_DIR\$/src/java',isTestSource:"false"])
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment