Grails assets not work in deployed .WAR - grails

I am running an application through Intellij Idea 2016.3 and everything is working correctly, when I generate the .WAR (gradlew assemble) file the assets are not loaded in the running application and the application not working.
Grails 3.1.14
JDK 1.8.121
That is my build.gradle
buildscript {
ext {
grailsVersion = project.grailsVersion
}
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencies {
classpath "org.grails:grails-gradle-plugin:$grailsVersion"
classpath "gradle.plugin.com.craigburke.gradle:bower-installer-gradle:2.5.1"
classpath "org.grails.plugins:hibernate4:5.0.5"
classpath "com.bertramlabs.plugins:asset-pipeline-gradle:2.8.2"
classpath "org.grails.plugins:views-gradle:1.0.12"
}
}
version "1.0.18"
group "veedy"
apply plugin:"eclipse"
apply plugin:"idea"
apply plugin:"war"
apply plugin:"org.grails.grails-web"
apply plugin:"org.grails.grails-gsp"
apply plugin:"com.craigburke.bower-installer"
apply plugin:"asset-pipeline"
apply plugin:"org.grails.plugins.views-json"
apply plugin: 'spring-boot'
springBoot {
executable = true
}
ext {
grailsVersion = project.grailsVersion
gradleWrapperVersion = project.gradleWrapperVersion
}
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencyManagement {
imports {
mavenBom "org.grails:grails-bom:$grailsVersion"
}
applyMavenExclusions false
}
dependencies {
assets "com.craigburke.angular:angular-template-asset-pipeline:2.2.6"
assets "com.craigburke.angular:angular-annotate-asset-pipeline:2.4.0"
assets "com.craigburke:js-closure-wrap-asset-pipeline:1.2.0"
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-plugin-url-mappings"
compile "org.grails:grails-plugin-rest"
compile "org.grails:grails-plugin-codecs"
compile "org.grails:grails-plugin-interceptors"
compile "org.grails:grails-plugin-services"
compile "org.grails:grails-plugin-datasource"
compile "org.grails:grails-plugin-databinding"
compile "org.grails:grails-plugin-async"
compile "org.grails:grails-web-boot"
compile "org.grails:grails-logging"
compile "org.grails.plugins:cache"
compile "org.grails:grails-plugin-gsp"
compile "org.grails.plugins:hibernate4"
compile "org.hibernate:hibernate-ehcache"
compile "org.grails.plugins:views-json:1.0.12"
console "org.grails:grails-console"
profile "org.grails.profiles:angular:3.1.6"
runtime "com.h2database:h2"
runtime "com.bertramlabs.plugins:asset-pipeline-grails:2.8.2"
testCompile "org.grails:grails-plugin-testing"
testCompile "org.grails.plugins:geb"
testCompile "org.grails:grails-datastore-rest-client"
testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"
//custom
compile 'org.grails.plugins:spring-security-core:3.0.3'
compile "org.grails.plugins:mail:2.0.0.RC4"
compile "org.grails.plugins:grails-spring-websocket:2.3.0"
runtime 'mysql:mysql-connector-java:5.1.36'
}
task wrapper(type: Wrapper) {
gradleVersion = gradleWrapperVersion
}
bower {
'angular'('1.4.x') {
source 'angular.js'
}
'angular-resource'('1.4.x') {
source 'angular-resource.js' >> '/angular/'
}
'angular-mocks'('1.4.x') {
source 'angular-mocks.js' >> '/angular/'
}
'angular-bootstrap'('1.1.x') {
source 'ui-bootstrap-tpls.js' >> '/angular/'
}
'bootstrap'('3.x.x') {
source 'dist/css/bootstrap.css' >> '/bootstrap/'
}
}
assets {
minifyJs = true
minifyCss = true
}
bootRun {
// local.config.location is just a random name. You can use yours.
jvmArgs = ['-Dlocal.config.location=app-config.yml']
}
and my

On my end, with or without war, its working fine with below snippets in build.gradle.
Basically, gradle plugin for asset-pipeline needs to be mentioned. And also, in dependencies change it to compile instead of runtime
buildscript {
ext {
...
}
repositories {
...
}
dependencies {
...
classpath "com.bertramlabs.plugins:asset-pipeline-gradle:2.10.2"
...
}
}
apply plugin:"asset-pipeline"
UPDATE
In my Grails application, i have the below codes:
... \grails-app\assets\javascripts\app\app.js
//= require_self
//= require /angular/angular.js
//= require /angular/lodash.js
//= require /angular/ui-bootstrap-tpls-2.3.1.js
//= require /app/directives/directives.js
'use strict';
var app = angular
.module('myapp', [
'ui.bootstrap', 'directives'
]);
... \grails-app\assets\javascripts\app\directives\directives.js
//= require_self
angular.module("directives",[])
.directive('bindUnsafeHtml',['$compile', function($compile) {...}]);
index.gsp
<asset:javascript src="app/app.js" />
Please note: the comments like lines //= require_self are important for module dependency.
Gradle Angular Asset Pipeline has this points mentioned in the examples.

The problem was solved deleting the Bower calls in gradle.build.

Related

Can't load resources in a gradle project

I am using gradle 4.10.2 & IntelliJ IDEA Community Edition 2018.2
Note that this is a jenkins shared library project, hence, deviates from the standard gradle project structure.
The project shown in the image is an existing Gradle project. I am simply trying to load a properties file viz. mailTemplate.properties in a Groovy class EmailTemplate but the problem is that irrespective of where I keep it(like shown in the image), it's not loaded. I created a separate test gradle project and placed it in the default (src/main/resources) dir. and it works like a breeze.
I tried creating 'resources' at two places but in vain.
The build.gradle is:
buildscript {
repositories {
ivy {
url "$repositoryURL/$resolveRepository"
}
maven {
url "$repositoryURL/$resolveRepository"
}
}
dependencies {
classpath "tools.gradle.plugin:ReleasePlugin:1.10.0"
classpath "tools.gradle.plugin:qualityreport:v1.14.4"
}
}
group 'tools'
apply plugin: 'groovy'
apply plugin: 'tools.gradle.plugin.releaseplugin'
apply plugin: 'tools.gradle.plugin.qualityreport'
sourceSets {
main {
groovy {
srcDirs = ['src']
}
}
test {
groovy {
srcDirs = ['test/groovy']
}
}
}
repositories {
addAll(buildscript.repositories)
}
dependencies {
compile 'org.codehaus.groovy:groovy-all:2.4.15'
compile 'org.codehaus.groovy:groovy-json:2.4.9'
compile 'com.cloudbees:groovy-cps:1.1'
compile 'org.slf4j:slf4j-api:1.7.21'
testCompile 'junit:junit:4.12'
testCompile 'org.hamcrest:hamcrest-core:1.3'
testCompile 'net.bytebuddy:byte-buddy:1.6.4'
testCompile ('org.spockframework:spock-core:1.1-groovy-2.4') {
exclude group: 'org.codehaus.groovy'
}
testCompile gradleTestKit()
testCompile group: 'com.lesfurets', name: 'jenkins-pipeline-unit', version: '1.1'
testCompile group: 'org.mockito', name: 'mockito-core', version: '2.23.4'
testCompile group: 'tools.gradle.plugin', name: 'jenkins-shared-stages', version: 'v2.48.0'
// jenkins dependencies
testCompile 'org.jenkins-ci.plugins:script-security:1.34#jar'
}
task copySharedLibs(type: Copy, group: "PipelineTest") {
from '.'
into 'build/libs/jenkins-shared-pipelines#master'
include 'src/**'
include 'vars/**'
}
test.dependsOn(copySharedLibs)
Gradle groovy plugin expects resources to be at src/main/resources by default. In case the resources are located some other folder then it should be configured in the sourceSets. You can try the below assuming your resource file are also withing your src folder.
sourceSets {
main {
groovy {
srcDirs = ['src']
}
resources {
srcDirs = ['src']
}
}
test {
groovy {
srcDirs = ['test/groovy']
}
resources {
srcDirs = ['test/groovy']
}
}
}

ROBOVM + robopods + admob ios binding

I tried to bind my project using this but however i failed to achieve so i am getting errors like
noClassDefFoundFor NSObject
i also tried to add the older version
ie this but here i am not able to link admob module to my ios module error which i an getting in this case is:
no Configuration found for 'default'
i am using latest version of LibGDX.
log snippet:
ava.lang.NoClassDefFoundError: org/robovm/apple/foundation/NSObject$Handle
at org.robovm.pods.google.mobileads.GADRequest.<init>(GADRequest.java)
at com.blurpixel.arcpop.ViewController.createAndLoadBanner(ViewController.java)
at com.blurpixel.arcpop.ViewController.intializeAds(ViewController.java)
at com.blurpixel.arcpop.ViewController.showAds(ViewController.java)
at com.blurpixel.arcpop.Menu.show(Menu.java)
at com.badlogic.gdx.Game.setScreen(Game.java)
at com.blurpixel.arcpop.GameClass.create(GameClass.java)
at com.badlogic.gdx.backends.iosrobovm.IOSGraphics.draw(IOSGraphics.java)
at com.badlogic.gdx.backends.iosrobovm.IOSGraphics$1.draw(IOSGraphics.java)
at com.badlogic.gdx.backends.iosrobovm.IOSGraphics$1.$cb$drawRect$(IOSGraphics.java)
at org.robovm.apple.uikit.UIApplication.main(Native Method)
at org.robovm.apple.uikit.UIApplication.main(UIApplication.java)
at com.blurpixel.arcpop.IOSLauncher.main(IOSLauncher.java)
and what i am doing in my code is:
adView = new GADBannerView(GADAdSize.SmartBannerPortrait());
adView.setAdUnitID("xxxxxxxxxxxxxxx");
adView.setRootViewController(UIApplication.getSharedApplication().getKeyWindow().getRootViewController());
UIApplication.getSharedApplication().getKeyWindow().getRootViewController().getView().addSubview(adView);
GADRequest request = new GADRequest();//this line is creating this error if i am commenting this line + the adview.loadAd line i am getting my game running without ads.
request.setTestDevices(Arrays.asList(GADRequest.getSimulatorID()));
adView.setDelegate(new GADBannerViewDelegateAdapter() {
#Override
public void didReceiveAd(GADBannerView view) {
super.didReceiveAd(view);
}
#Override
public void didFailToReceiveAd(GADBannerView view, GADRequestError error) {
super.didFailToReceiveAd(view, error);
System.out.println("Failed to recieve ");
}
});
adView.loadRequest(request);
Gradle files:
ios gradle:
sourceSets.main.java.srcDirs = ["src/"]
sourceCompatibility = '1.7'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
ext {
mainClassName = "com.blurpixel.arcpop.IOSLauncher"
}
launchIPhoneSimulator.dependsOn build
launchIPadSimulator.dependsOn build
launchIOSDevice.dependsOn build
createIPA.dependsOn build
eclipse.project {
name = appName + "-ios"
natures 'org.robovm.eclipse.RoboVMNature'
}
dependencies {
compile "org.robovm:robopods-google-mobile-ads-ios:1.13.1-SNAPSHOT"
compile "org.robovm:robopods-google-apis-ios:1.13.1-SNAPSHOT"
}
build.gradle:
buildscript {
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
jcenter()
}
dependencies {
classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.6'
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.2.0-SNAPSHOT'
}
}
allprojects {
apply plugin: "eclipse"
apply plugin: "idea"
version = '1.2'
ext {
appName = "ArcPOP"
gdxVersion = '1.9.2'
roboVMVersion = '1.14.0'
robopodsVersion = '1.13.1'
box2DLightsVersion = '1.4'
ashleyVersion = '1.7.0'
aiVersion = '1.8.0'
admobVersion = '9.0.1'
}
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
}
project(":desktop") {
apply plugin: "java"
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
}
}
project(":android") {
apply plugin: "android"
configurations { natives }
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86_64"
compile 'com.google.android.gms:play-services-ads:9.0.1'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
}
}
project(":ios") {
apply plugin: "java"
apply plugin: "robovm"
dependencies {
compile project(":core")
compile "org.robovm:robovm-rt:$roboVMVersion"
compile "org.robovm:robovm-cocoatouch:$roboVMVersion"
compile "org.robovm:robopods-google-mobile-ads-ios:$robopodsVersion-SNAPSHOT"
compile "org.robovm:robopods-google-apis-ios:$robopodsVersion-SNAPSHOT"
compile "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-ios"
compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-ios"
}
}
project(":html") {
apply plugin: "gwt"
apply plugin: "war"
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion"
compile "com.badlogicgames.gdx:gdx:$gdxVersion:sources"
compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion:sources"
compile "com.badlogicgames.gdx:gdx-box2d-gwt:$gdxVersion:sources"
}
}
project(":core") {
apply plugin: "java"
dependencies {
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
}
}
tasks.eclipse.doLast {
delete ".project"
}
dependencies {
}
Please Help and thanks in advance.
The problem is in your gradle files. First of all you are using the mobidevelop plugin with the official robovm. This might give problems.
then you are adding dependencies in 2 places. This should not do anything bad, but it is not needed and might cause problems if you change one of them.
Apply the following changes, rebuild gradle (dont forget to --refresh-dependencies) and rebuild your project. If it still fails clear cache again.
change:
classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.2.0-SNAPSHOT'
to
classpath 'org.robovm:robovm-gradle-plugin:1.14.0'
and
robopodsVersion = '1.13.1'
to
robopodsVersion = '1.14.0'
might also need to change:
gdxVersion = '1.9.2'
to
gdxVersion = '1.9.0'
You might also need to remove the "-SNAPSHOT" from the robopod version. not 100% sure it they exist (and if you would want those)
remove:
dependencies {
compile "org.robovm:robopods-google-mobile-ads-ios:1.13.1-SNAPSHOT"
compile "org.robovm:robopods-google-apis-ios:1.13.1-SNAPSHOT"
}
from ios build.gradle (these area already defined in you main build.gradle)

DebuggingClassWriter overrides final method visit

I have a grails 3 project where I had to write a regular Spring MVC #RestfulController (for Chunk json response reasons). Anyway I tried to write a simple Spock unit test for the simple controller actions. They run fine inside IDEA but out on the command line they fail with strange errors related to asm/cglib from what i have read. Anyone know how I can get around this ?
Test the advanced search action returns a page of results
java.lang.NoClassDefFoundError: Could not initialize class org.spockframework.mock.runtime.ProxyBasedMockFactory$CglibMockFactory$ConstructorFriendlyEnhancer
at org.spockframework.mock.runtime.ProxyBasedMockFactory$CglibMockFactory.createMock(ProxyBasedMockFactory.java:80)
at org.spockframework.mock.runtime.ProxyBasedMockFactory.create(ProxyBasedMockFactory.java:49)
at org.spockframework.mock.runtime.JavaMockFactory.create(JavaMockFactory.java:51)
at org.spockframework.mock.runtime.CompositeMockFactory.create(CompositeMockFactory.java:44)
at org.spockframework.lang.SpecInternals.createMock(SpecInternals.java:45)
at org.spockframework.lang.SpecInternals.createMockImpl(SpecInternals.java:281)
at org.spockframework.lang.SpecInternals.MockImpl(SpecInternals.java:83)
at uk.ac.xxx.coursefinder.controller.SearchControllerSpec.setup(SearchControllerSpec.groovy:27)
Test the basic search action returns a page of results
java.lang.VerifyError: class net.sf.cglib.core.DebuggingClassWriter overrides final method visit.(IILjava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)V
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at net.sf.cglib.core.AbstractClassGenerator.<init>(AbstractClassGenerator.java:38)
at net.sf.cglib.core.KeyFactory$Generator.<init>(KeyFactory.java:127)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:112)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:104)
at net.sf.cglib.proxy.Enhancer.<clinit>(Enhancer.java:69)
at org.spockframework.mock.runtime.ProxyBasedMockFactory$CglibMockFactory.createMock(ProxyBasedMockFactory.java:80)
at org.spockframework.mock.runtime.ProxyBasedMockFactory.create(ProxyBasedMockFactory.java:49)
at org.spockframework.mock.runtime.JavaMockFactory.create(JavaMockFactory.java:51)
at org.spockframework.mock.runtime.CompositeMockFactory.create(CompositeMockFactory.java:44)
at org.spockframework.lang.SpecInternals.createMock(SpecInternals.java:45)
at org.spockframework.lang.SpecInternals.createMockImpl(SpecInternals.java:281)
at org.spockframework.lang.SpecInternals.MockImpl(SpecInternals.java:83)
at uk.ac.xxx.coursefinder.controller.SearchControllerSpec.setup(SearchControllerSpec.groovy:27)
Here is my test:
package uk.ac.xxx.coursefinder.controller
import org.springframework.data.domain.Page
import org.springframework.data.domain.PageImpl
import org.springframework.data.domain.PageRequest
import spock.lang.Specification
import uk.ac.xxx.coursefinder.command.AdvancedSearchCommand
import uk.ac.xxx.coursefinder.command.BasicSearchCommand
import uk.ac.xxx.coursefinder.search.SearchService
import uk.ac.xxx.coursefinder.solr.domain.CourseGuide
/**
* Pure unit test
*/
class SearchControllerSpec extends Specification {
SearchController searchController = new SearchController()
SearchService searchService
def setup() {
searchService = Mock()
searchController.searchService = searchService
}
def cleanup() {
}
def "Test the basic search action returns a page of results"() {
given:
print "1"
Page expectedPage = new PageImpl<CourseGuide>([new CourseGuide()])
BasicSearchCommand basicSearchCommand = new BasicSearchCommand()
PageRequest pageRequest = new PageRequest(0, 20)
when: "The basic search action is executed with a BasicSearchCommand"
Page page = searchController.basic(basicSearchCommand, pageRequest)
then: "The correct search service was called with the appropriate arguments and returned expected results"
1 * searchService.basic(basicSearchCommand, pageRequest) >> expectedPage
page == expectedPage
}
def "Test the advanced search action returns a page of results"() {
given:
print "2"
Page expectedPage = new PageImpl<CourseGuide>([new CourseGuide()])
AdvancedSearchCommand advancedSearchCommand = new AdvancedSearchCommand()
PageRequest pageRequest = new PageRequest(0, 20)
when: "The advanced search action is executed with a AdvancedSearchCommand"
Page page = searchController.advanced(advancedSearchCommand, pageRequest)
then: "The correct search service was called with the appropriate arguments and returned expected results"
1 * searchService.advanced(advancedSearchCommand, pageRequest) >> expectedPage
page == expectedPage
}
}
and my build.gradle file:
buildscript {
ext {
grailsVersion = project.grailsVersion
}
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencies {
classpath "org.grails:grails-gradle-plugin:$grailsVersion"
classpath "com.bertramlabs.plugins:asset-pipeline-gradle:2.6.4"
classpath "gradle.plugin.com.craigburke.gradle:karma-gradle:1.4.3"
classpath "gradle.plugin.com.craigburke.gradle:bower-installer-gradle:2.5.1"
classpath "org.grails.plugins:hibernate4:5.0.2"
classpath "com.bertramlabs.plugins:asset-pipeline-gradle:2.5.0"
classpath "org.grails.plugins:views-gradle:1.0.4"
classpath "net.saliman:gradle-cobertura-plugin:2.3.1"
}
}
version "0.1"
group "coursefinder.grails.angular"
apply plugin:"eclipse"
apply plugin:"idea"
apply plugin:"war"
apply plugin:"org.grails.grails-web"
apply plugin:"org.grails.grails-gsp"
apply plugin:"com.craigburke.karma"
apply plugin:"com.craigburke.bower-installer"
apply plugin:"asset-pipeline"
apply plugin:"org.grails.plugins.views-json"
apply plugin:"net.saliman.cobertura"
ext {
grailsVersion = project.grailsVersion
gradleWrapperVersion = project.gradleWrapperVersion
}
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
maven { url "http://maven.restlet.org" } //needed for solr core lib
}
dependencyManagement {
imports {
mavenBom "org.grails:grails-bom:$grailsVersion"
}
applyMavenExclusions false
}
dependencies {
assets "com.craigburke.angular:angular-template-asset-pipeline:2.2.6"
assets "com.craigburke.angular:angular-annotate-asset-pipeline:2.4.0"
assets "com.craigburke:js-closure-wrap-asset-pipeline:1.2.0"
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-plugin-url-mappings"
compile "org.grails:grails-plugin-rest"
compile "org.grails:grails-plugin-codecs"
compile "org.grails:grails-plugin-interceptors"
compile "org.grails:grails-plugin-services"
compile "org.grails:grails-plugin-datasource"
compile "org.grails:grails-plugin-databinding"
compile "org.grails:grails-plugin-async"
compile "org.grails:grails-web-boot"
compile "org.grails:grails-logging"
compile "org.grails.plugins:cache"
compile "org.grails:grails-plugin-gsp"
compile "org.grails.plugins:hibernate4"
compile "org.hibernate:hibernate-ehcache"
compile "org.grails.plugins:views-json"
console "org.grails:grails-console"
//solr and rest stuff
compile('org.springframework.boot:spring-boot-starter-data-rest')
compile('org.springframework.boot:spring-boot-starter-data-solr')
//for embedded server
compile ('org.apache.solr:solr-core:4.10.4') {
exclude(group: "org.slf4j", module: "slf4j-jdk14")
exclude(group: "ch.qos.logback", module: "logback-classic")
}
compile "org.grails.plugins:grails3-cas-client:3.0"
compile "org.ccil.cowan.tagsoup:tagsoup:1.2"
profile "org.grails.profiles:angular:3.1.3"
runtime "com.h2database:h2"
runtime "org.grails.plugins:asset-pipeline"
testCompile "org.grails:grails-plugin-testing"
//testCompile "org.grails.plugins:geb"
testCompile "org.grails:grails-datastore-rest-client"
//testCompile 'org.mockito:mockito-all:1.10.19'
//testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
//testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"
runtime 'org.grails.plugins:grails-console:2.0.4'
//testRuntime "org.slf4j:slf4j-api:1.7.10" //stop cobertura class not found exception
}
task wrapper(type: Wrapper) {
gradleVersion = gradleWrapperVersion
}
bower {
'angular'('1.4.x') {
source 'angular.js'
}
'angular-resource'('1.4.x') {
source 'angular-resource.js' >> '/angular/'
}
'angular-route'('1.4.x') {
source 'angular-route.js' >> '/angular/'
}
'angular-mocks'('1.4.x') {
source 'angular-mocks.js' >> '/angular/'
}
'angular-bootstrap'('1.1.x') {
source 'ui-bootstrap-tpls.js' >> '/angular/'
}
'bootstrap'('3.x.x') {
source 'dist/css/bootstrap.css' >> '/bootstrap/'
}
}
karma {
dependencies(['karma-wrap-preprocessor'])
profile 'angularJS'
preprocessors = [
'grails-app/assets/javascripts/**/*.js': ['wrap']
]
wrapPreprocessor = [
template: "(function () { 'use strict'; <%= contents %> })()"
]
}
assets {
minifyJs = true
minifyCss = true
}
I just had a similar problem.
It seems that the cglib:cglib-nodep:2.2.2 lib needs to be available at compile time. It is pulled in by the org.grails:grails-plugin-testing plugin.
I was able to solve it in two ways; both involving the dependencies {...} block in build.gradle:
1) Add compile 'cglib:cglib-nodep:2.2.2'
Or
2) Changing testCompile "org.grails:grails-plugin-testing" to compile "org.grails:grails-plugin-testing"
Hope it helps.

Grails 3 asset-pipeline / coffee-asset pipeline

I am using asset-pipeline to manage my front end resources for my Grails 3.0 application. However it seems that source-maps for CoffeeScript files are not created. Is there any way to enable this?
My build.gradle is as follows:
buildscript {
ext {
grailsVersion = project.grailsVersion
}
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencies {
classpath "org.grails:grails-gradle-plugin:$grailsVersion"
classpath 'com.bertramlabs.plugins:asset-pipeline-gradle:2.6.2'
classpath 'com.bertramlabs.plugins:coffee-asset-pipeline:2.6.2'
classpath "org.grails.plugins:hibernate:4.3.10.5"
}
}
plugins {
id "io.spring.dependency-management" version "0.5.2.RELEASE"
}
version "0.1"
group "grails2"
apply plugin: "spring-boot"
apply plugin: "war"
apply plugin: "asset-pipeline"
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: "org.grails.grails-web"
apply plugin: "org.grails.grails-gsp"
ext {
grailsVersion = project.grailsVersion
gradleWrapperVersion = project.gradleWrapperVersion
}
assets {
minifyJs = true
minifyCss = true
enableSourceMaps = true
}
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencyManagement {
imports {
mavenBom "org.grails:grails-bom:$grailsVersion"
}
applyMavenExclusions false
}
dependencies {
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-autoconfigure"
compile "org.springframework.boot:spring-boot-starter-tomcat"
compile "org.grails:grails-dependencies"
compile "org.grails:grails-web-boot"
compile "org.grails.plugins:hibernate"
compile "org.grails.plugins:cache"
compile "org.hibernate:hibernate-ehcache"
compile "org.grails.plugins:scaffolding"
runtime "org.grails.plugins:asset-pipeline"
runtime 'com.bertramlabs.plugins:coffee-asset-pipeline:2.6.2'
testCompile "org.grails:grails-plugin-testing"
testCompile "org.grails.plugins:geb"
// Note: It is recommended to update to a more robust driver (Chrome, Firefox etc.)
testRuntime 'org.seleniumhq.selenium:selenium-htmlunit-driver:2.44.0'
console "org.grails:grails-console"
}
task wrapper(type: Wrapper) {
gradleVersion = gradleWrapperVersion
}
This is my application.coffee
#= require test
#= require_tree .
#= require_self
console.log "This is my manifest"
$ ->
$("#spinner")
.ajaxStart -> $(this).fadeIn()
.ajaxStop -> $(this).fadeOut()
And have included the following tag in my main.gsp:
<asset:javascript src="application.coffee"/>
However, the source I get in the Chrome Browser Developer tools is the following:
// Generated by CoffeeScript 1.9.2
(function() {
console.log("This is my manifest");
$(function() {
return $("#spinner").ajaxStart(function() {
return $(this).fadeIn();
}).ajaxStop(function() {
return $(this).fadeOut();
});
});
}).call(this);
source, what you see, is actually coffee script "translated" into pure JS. From main page of Coffescript
"CoffeeScript is a little language that compiles into JavaScript."
(http://coffeescript.org)

Spring Data Neo4j how to aggregate

Im trying to do what I think should be a very basic task but I'm getting steam rolled. My code is as follows:
#Query("match (x:Package) where x.houseAirwayBill = {self}.houseAirwayBill return count(x)")
#JsonIgnore
Long pieces
#JsonProperty("total_pieces")
Long getPieces(){
return pieces
}
However, it just throws a stack strace saying that it gets a '1' when it wants to get a map... I've been looking at other ways to do this, but I can't get the repository to autowire in the Domain object either... I'm at a loss. Did no one forecee that you'd want to do an aggregate in a domain object?
My build.gradle
buildscript {
repositories {
maven { url "https://repo.spring.io/libs-release" }
mavenLocal()
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.1.10.RELEASE")
}
}
apply plugin: "groovy"
apply plugin: 'spring-boot'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
version = "1.4.38"
repositories {
mavenLocal()
mavenCentral()
jcenter()
maven { url "http://m2.neo4j.org/content/repositories/releases/"}
maven { url "https://repo.spring.io/libs-release" }
maven { url "https://repo.spring.io/libs-milestone" }
maven { url 'http://repo.spring.io/snapshot' }
}
defaultTasks "clean", "processResources", "build"
dependencies {
//groovy
compile 'org.codehaus.groovy:groovy-all:2.4.0-rc-2'
//spring
compile("org.springframework.boot:spring-boot-starter-web"){
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat'
}
compile("org.springframework.boot:spring-boot-starter-jetty")
compile 'org.eclipse.jetty:jetty-servlet:9.3.0.M1'
compile 'org.springframework.boot:spring-boot-actuator:1.2.3.RELEASE'
//compile 'org.springframework.data:spring-data-rest-webmvc:2.3.0.RELEASE'
//compile 'org.springframework.hateoas:spring-hateoas:0.17.0.RELEASE'
compile('org.springframework.boot:spring-boot-starter-data-rest:1.2.3.RELEASE')
//compile 'org.springframework.data:spring-data-neo4j:3.3.0.RELEASE'
compile 'org.springframework.data:spring-data-neo4j-aspects:3.3.0.RELEASE'
//compile "org.neo4j:neo4j-rest-graphdb:2.0.1"
compile("org.hibernate:hibernate-validator")
compile 'javax.persistence:persistence-api:1.0.2'
compile 'org.springframework.data:spring-data-neo4j-rest:3.4.0.BUILD-SNAPSHOT'
compile 'org.springframework.data:spring-data-jpa:1.8.0.RELEASE'
//Jersey
compile 'org.glassfish.jersey.core:jersey-client:2.17'
//JsonSchema stuff
// Required if generating equals, hashCode, or toString methods
compile 'commons-lang:commons-lang:2.6'
// Required if generating JSR-303 annotations
compile 'javax.validation:validation-api:1.1.0.CR2'
// Required if generating Jackson 2 annotations
compile 'com.fasterxml.jackson.core:jackson-databind:2.5.0'
compile 'com.fasterxml.jackson.datatype:jackson-datatype-joda:2.5.0'
// Required if generating JodaTime data types
compile 'joda-time:joda-time:2.2'
//Retrofit
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.retrofit:converter-jackson:1.2.2'
//logging
compile 'ch.qos.logback:logback-classic:1.1.2'
}
task wrapper(type: Wrapper) {
gradleVersion = '2.2.1'
}
processResources {
expand(project.properties)
}
So, after sleeping over the problem and looking over the documentation, I did this:
#Query("start item=node({self}) match (x:Package) where x.houseAirwayBill= item.houseAirwayBill return count(x)")
#JsonIgnore
def pieces
#JsonProperty("total_pieces")
#Transactional
Long getPieces(){
return pieces.get("count(x)") as Long
}
the start item=node({self}) is really important as it binds the self reference to a parameter which I called Item in this case. The getter NEEDS to be in a transaction as well. I hope this helps because I could not find an specific example on how to do this anywhere.
Code is in groovy btw.

Resources