simplicityitself / grails-gwt

New Grails GWT Plugin
Other
23 stars 18 forks source link

Grails GWT for Grails 3.2 #66

Open dap10 opened 7 years ago

dap10 commented 7 years ago

Hi,

Could you please indicate if/when a grails 3 version of grails-gwt will be released?

Thanks In Advance, David

donbeave commented 7 years ago

Hi, David!

My suggestion is switch to use GWT Gradle plugin, not need to use any Grails GWT plugin.

If u need some example how to use GWT Gradle plugin with Grails 3.2, I can share my files.

Best regards, Alexey Zhokhov.

dap10 commented 7 years ago

Hi Alexey,

Can you please share your files for an example of using the GWT Gradle plugin with Grails 3.2 as that would be greatly appreciated.

Thanks in Advance, David David Pollum.

donbeave commented 7 years ago

root build.gradle:

buildscript {
    repositories {
        mavenCentral()
        jcenter()
    }
}
allprojects {
    repositories {
        mavenCentral()
        jcenter()
    }
}

client directory (for GWT files):

gradle.properties:

gradleWrapperVersion=2.9

build.gradle:

buildscript {
    repositories {
        jcenter()
        mavenLocal()
        maven { url 'http://dl.bintray.com/steffenschaefer/maven' }
    }
    dependencies {
        classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.6'
    }
}

ext {
    appVersion = '0.1-SNAPSHOT'
    gradleWrapperVersion = project.gradleWrapperVersion
    gwtVersion = '2.8.0-beta1'
}

version appVersion
group 'com.myapp.client'

apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'war'
apply plugin: 'gwt'

sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
    jcenter()
    mavenLocal()
    mavenCentral()
    maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
    maven { url 'https://nexus.codehaus.org/content/repositories/snapshots' }
    maven { url 'https://oss.sonatype.org/content/repositories/google-snapshots' }
    // ...
}

dependencies {
    compile "com.google.gwt:gwt-user:$gwtVersion"
    compile "com.google.gwt:gwt-elemental:$gwtVersion"
    compile "com.google.gwt:gwt-dev:$gwtVersion"
    compile('com.google.gwt.inject:gin:2.1.2') {
        exclude group: 'asm', module: 'asm'
        exclude group: 'com.google.gwt', module: 'gwt-dev'
        exclude group: 'com.google.gwt', module: 'gwt-user'
        exclude group: 'com.google.gwt', module: 'gwt-elemental'
    }
    // gwtp dependencies...
    compile('com.gwtplatform:gwtp-mvp-client:1.5.3') {
        exclude group: 'asm', module: 'asm'
        exclude group: 'com.google.gwt', module: 'gwt-dev'
        exclude group: 'com.google.gwt', module: 'gwt-user'
        exclude group: 'com.google.gwt', module: 'gwt-elemental'
    }
    // .....
}

gwt {
    gwtVersion = gwtVersion
    modules = ['com.myapp.MyApp']
    incremental = false
    sourceLevel = '1.8'

    compiler {
        if (System.getenv('GWT_WORKERS')) {
            println "Setting ${System.getenv('GWT_WORKERS')} GWT workers"
            localWorkers = Integer.parseInt(System.getenv('GWT_WORKERS'))
        }
        optimize = 9
        enableClosureCompiler = true
        disableClassMetadata = true
        disableCastChecking = true
    }

    superDev {
        noPrecompile = true
    }

    minHeapSize = '512M'
    maxHeapSize = '2048M'
}

version.sh script:

#!/usr/bin/env bash

ABSOLUTE_PATH=$(cd `dirname "${BASH_SOURCE[0]}"` && pwd)
cd $ABSOLUTE_PATH

appVersion="$(grep 'appVersion =' build.gradle | egrep -v ^[[:blank:]]*\/\/)"
appVersion="${appVersion#*=}"
appVersion="${appVersion//[[:blank:]\'\"]/}"
echo $appVersion;

build.sh script:

#!/usr/bin/env bash

printf "> \e[1;37mBuilding myapp-client\e[0m\n\n"

set -e

ABSOLUTE_PATH=$(cd `dirname "${BASH_SOURCE[0]}"` && pwd)
cd $ABSOLUTE_PATH

appVersion=$(./version.sh)

printf "# Project version \e[1;37m$appVersion\e[0m\n\n"

printf "# Building Gradle project\n\n"
./gradlew build

printf "\n# Copy built project to myapp-server\n\n"
rm -rf $ABSOLUTE_PATH/../server/grails-app/assets/javascripts/gwt
mkdir -p $ABSOLUTE_PATH/../server/grails-app/assets/javascripts/gwt
cp -R $ABSOLUTE_PATH/build/gwt/out/myapp $ABSOLUTE_PATH/../server/grails-app/assets/javascripts/gwt/

server directory (for Grails app):

gradle.properties:

grailsVersion=3.1.9
gormVersion=5.0.10
gradleWrapperVersion=2.13

build.gradle:

buildscript {
    ext {
        grailsVersion = project.grailsVersion
        gormVersion = project.gormVersion
    }
    repositories {
        jcenter()
        mavenLocal()
        maven { url 'https://repo.grails.org/grails/core' }
        maven { url 'http://dl.bintray.com/steffenschaefer/maven' }
        maven { url 'https://plugins.gradle.org/m2/' }
    }
    dependencies {
        classpath "org.grails:grails-gradle-plugin:$grailsVersion"
        classpath 'com.bertramlabs.plugins:asset-pipeline-gradle:2.13.1'
        classpath "org.grails.plugins:hibernate5:$gormVersion"
    }
}

ext {
    appVersion = '0.1-SNAPSHOT'
    grailsVersion = project.grailsVersion
    gormVersion = project.gormVersion
    gradleWrapperVersion = project.gradleWrapperVersion
}

version appVersion
group 'com.myapp.server'

apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'war'
apply plugin: 'org.grails.grails-web'
apply plugin: 'org.grails.grails-gsp'
apply plugin: 'asset-pipeline'

sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
    mavenLocal()
    jcenter()
    maven { url 'https://repo.grails.org/grails/core' }
    maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}

dependencyManagement {
    imports {
        mavenBom "org.grails:grails-bom:$grailsVersion"
    }
    applyMavenExclusions false
}

configurations.all {
    exclude module: 'spring-boot-starter-jetty'
    exclude module: 'gwt-dev'
}

dependencies {
    // Grails deps
    compile 'org.springframework.boot:spring-boot-starter-logging'
    compile 'org.springframework.boot:spring-boot-autoconfigure'
    compile 'org.grails:grails-core'
    compile 'org.springframework.boot:spring-boot-starter-actuator'
    compile "org.springframework.boot:spring-boot-starter-tomcat"
    compile 'org.grails:grails-dependencies'
    compile 'org.grails:grails-web-boot'
    console 'org.grails:grails-console'
    profile "org.grails.profiles:web:$grailsVersion"
    runtime 'com.h2database:h2'
    testCompile 'org.grails:grails-plugin-testing'
    testCompile 'org.grails.plugins:geb'
    testRuntime 'org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1'
    testRuntime 'net.sourceforge.htmlunit:htmlunit:2.18'

    // plugins
    compile "org.grails.plugins:hibernate5:$gormVersion"
    compile 'org.grails.plugins:quartz:2.0.9'
    compile 'org.grails.plugins:quartz-monitor:1.2'
    runtime 'org.grails.plugins:grails-console:2.0.5'
    runtime 'com.bertramlabs.plugins:asset-pipeline-grails:2.13.1'
    assets 'com.bertramlabs.plugins:less-asset-pipeline:2.13.1'

    // libraries
    compile 'org.hibernate:hibernate-core:5.1.0.Final'
    compile 'org.hibernate:hibernate-ehcache:5.1.0.Final'
}

task wrapper(type: Wrapper) {
    gradleVersion = gradleWrapperVersion
}

assets {
    minifyJs = true
    minifyCss = true
    enableSourceMaps = false
}

version.sh script:

#!/usr/bin/env bash

ABSOLUTE_PATH=$(cd `dirname "${BASH_SOURCE[0]}"` && pwd)
cd $ABSOLUTE_PATH

appVersion="$(grep 'appVersion =' build.gradle | egrep -v ^[[:blank:]]*\/\/)"
appVersion="${appVersion#*=}"
appVersion="${appVersion//[[:blank:]\'\"]/}"
echo $appVersion;

build.sh script:

#!/usr/bin/env bash

printf "> \e[1;37mBuilding myapp-server\e[0m\n\n"

set -e

ABSOLUTE_PATH=$(cd `dirname "${BASH_SOURCE[0]}"` && pwd)
cd $ABSOLUTE_PATH

GIT_COMMIT_SHORTHASH=$(git log --pretty=format:'%h' -n 1)

appVersion=$(./version.sh)

printf "# Project version \e[1;37m$appVersion\e[0m\n\n"

printf "# Building Gradle project\n\n"
./gradlew -Dgrails.env=production build

Usage:

For running SuperDev mode do:

cd client
./gradlew gwtSuperDev
dap10 commented 7 years ago

Thank you @donbeave for providing those example files, it is much clearer now! Kind Regards, David