Created
September 14, 2012 16:03
-
-
Save gpike/3722887 to your computer and use it in GitHub Desktop.
Gradle build file for GWT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.event.ItemEvent; | |
apply plugin: 'java' | |
apply plugin: 'eclipse' | |
apply plugin: 'maven' | |
apply plugin: 'war' | |
task wrapper(type: Wrapper) { gradleVersion = '1.1' } | |
def spring_version = '3.1.1.RELEASE' | |
def version = '1.0' | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
// Compile GWT libs, needed for gwtCompile and the javaCompile | |
// Also includes the servlet-api | |
providedCompile 'com.google.gwt:gwt-user:2.4.0' | |
providedCompile 'com.google.gwt:gwt-dev:2.4.0' | |
// Needed for GWT compile and at runtime for RequestBuilder | |
// Specify two artifacts as workaround for GRADLE-1934 | |
compile('javax.validation:validation-api:1.0.0.GA') { | |
artifact { | |
name = 'validation-api' | |
type = 'jar' | |
} | |
artifact { | |
name = 'validation-api' | |
type = 'jar' | |
classifier = 'sources' | |
} | |
} | |
// Runtime GWT libraries, should be included in WAR | |
runtime 'com.google.gwt:gwt-servlet:2.4.0' | |
//runtime 'org.json:json:20090211' | |
//Logging | |
compile 'org.slf4j:slf4j-api:1.6.2' | |
compile 'org.slf4j:jcl-over-slf4j:1.6.2' | |
compile 'org.slf4j:jul-to-slf4j:1.6.2' | |
compile 'ch.qos.logback:logback-classic:1.0.3' | |
compile 'ch.qos.logback:logback-core:1.0.3' | |
compile 'log4j:log4j:1.2.16' | |
compile 'com.google.gwt:gwt-user:2.4.0' | |
compile 'com.google.gwt:gwt-servlet:2.4.0' | |
compile 'com.google.gwt:gwt-dev:2.4.0' | |
compile 'com.google.gwt.inject:gin:1.5.0' | |
compile 'com.google.inject:guice:3.0-rc2' | |
compile 'com.google.inject.extensions:guice-assistedinject:3.0-rc2' | |
testCompile group: 'junit', name: 'junit', version: '4.+' | |
testCompile "org.springframework:spring-test:${spring_version}" | |
testCompile 'org.mockito:mockito-all:1.9.5-rc1+' | |
} | |
task createDirs << { | |
sourceSets*.java.srcDirs*.each { it.mkdirs() } | |
sourceSets*.resources.srcDirs*.each { it.mkdirs() } | |
webAppDir.mkdirs() | |
} | |
task initProject << { | |
File oldSource = file("./src") | |
File tmpSource = file("./tmp") | |
tmpSource.mkdirs() | |
oldSource.listFiles().each {File f -> f.renameTo new File(tmpSource, f.name)} | |
sourceSets*.java.srcDirs*.each { it.mkdirs() } | |
sourceSets*.resources.srcDirs*.each { it.mkdirs() } | |
webAppDir.mkdirs() | |
File newSource = file(sourceSets.main.java.srcDirs.iterator().next()) | |
tmpSource.listFiles().each {File f -> f.renameTo new File(newSource, f.name)} | |
tmpSource.delete() | |
} | |
task compileGwt (dependsOn: classes, type: JavaExec) { | |
ext.buildDir = "${project.buildDir}/gwt" | |
ext.extraDir = "${project.buildDir}/extra" | |
inputs.source sourceSets.main.java.srcDirs | |
inputs.dir sourceSets.main.output.resourcesDir | |
outputs.dir buildDir | |
// Workaround for incremental build (GRADLE-1483) | |
outputs.upToDateSpec = new org.gradle.api.specs.AndSpec() | |
doFirst { | |
file(buildDir).mkdirs() | |
//classpath.each { println it.name} | |
} | |
main = 'com.google.gwt.dev.Compiler' | |
classpath { | |
[ | |
sourceSets.main.java.srcDirs, // Java source | |
sourceSets.main.output.resourcesDir, // Generated resources | |
sourceSets.main.output.classesDir, // Generated classes | |
sourceSets.main.compileClasspath, // Deps | |
] | |
} | |
args = | |
[ | |
'com.gwtcasts.MyProject', // Your GWT module | |
'-war', buildDir, | |
'-logLevel', 'INFO', | |
'-localWorkers', '2', | |
'-compileReport', | |
'-extra', extraDir, | |
// '-draftCompile' // Speeds up compile with 25% | |
] | |
maxHeapSize = '256M' | |
} | |
war.dependsOn compileGwt | |
war { | |
from compileGwt.buildDir | |
} | |
war.doLast { | |
ant.unzip(src: war.archivePath, dest: "./war") | |
} | |
eclipse { | |
project { | |
natures 'com.google.gwt.eclipse.core.gwtNature' | |
buildCommand 'com.google.gdt.eclipse.core.webAppProjectValidator' | |
buildCommand 'com.google.gwt.eclipse.core.gwtProjectValidator' | |
} | |
classpath { | |
containers 'com.google.gwt.eclipse.core.GWT_CONTAINER' | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you're using SLF4J - why are you including log4j instead of log4j-over-slf4j ? An oversight?
Regards