ROBOVM + robopods + admob ios binding - ios

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)

Related

Adding jcenter() in rootlevel repositories breaks my build

I have a project with a Gradle buildscript and I added the bmuschko/gradle-docker-plugin to create and push image on new builds.
However I cant use the plugin if I don't specify jcenter() in root level repositories, but that breaks my build, so im kinda lost.
If I add the root level jcenter() it fails the build with:
Could not resolve all dependencies for configuration ':compileClasspath'.
Could not find com.sleepycat:je:7.0.6. Searched in the following locations:
https://jcenter.bintray.com/com/sleepycat/je/7.0.6/je-7.0.6.pom
https://jcenter.bintray.com/com/sleepycat/je/7.0.6/je-7.0.6.jar
https://repo1.maven.org/maven2/com/sleepycat/je/7.0.6/je-7.0.6.pom
https://repo1.maven.org/maven2/com/sleepycat/je/7.0.6/je-7.0.6.jar
https://nexus.company.com/content/groups/public/com/sleepycat/je/7.0.6/je-7.0.6.pom
https://nexus.company.com/content/groups/public/com/sleepycat/je/7.0.6/je-7.0.6.jar
Required by: project : > org.jpos:jpos:2.1.1
However if I don't add it i get this:
Could not resolve all dependencies for configuration ':dockerJava'.
Could not find com.aries:docker-java-shaded:3.1.0-rc-3. Searched in the following locations:
https://nexus.company.com/content/groups/public/com/aries/docker-java-shaded/3.1.0-rc-3/docker-java-shaded-3.1.0-rc-3.pom
https://nexus.company.com/content/groups/public/com/aries/docker-java-shaded/3.1.0-rc-3/docker-java-shaded-3.1.0-rc-3-cglib.jar
Required by: project :
Should I perhaps build Java shaded and include in our local Maven repo?
Here is the script:
buildscript {
repositories {
jcenter()
mavenCentral()
maven {
url = 'https://nexus.company.com/content/repositories/snapshots/'
credentials {
username 'na'
password 'na'
}
}
}
dependencies {
classpath group: 'com.company.gradle', name: 'cpmgradle', version: '0.1-SNAPSHOT'
classpath 'com.bmuschko:gradle-docker-plugin:3.4.4'
}
}
// ADDING THIS BREAKS MY BUILD BUT IS NECESSARY FOR DOCKER PLUGIN TO WORK
repositories {
jcenter()
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'com.company.gradle.java'
apply plugin: 'com.bmuschko.docker-remote-api'
projectinfo {
group = 'com.company.mesb'
artifact = 'MESB'
version = '1.29.DEV-SNAPSHOT'
description = 'MESB'
packaging = 'jar'
}
dependencies {
compile 'org.jpos:jpos:2.1.1'
compile 'org.jdom:jdom2:2.0.6'
compile 'org.json:json:20140107'
compile 'com.company.javasdk:JavaSDK:1.1.JDOM2-SNAPSHOT'
compile 'com.company.javasdk:Base64:1.0'
compile 'org.apache.wss4j:wss4j-ws-security-dom:2.0.3'
compile 'org.apache.santuario:xmlsec:2.0.3'
compile 'org.slf4j:slf4j-log4j12:1.7.10'
compile 'com.google.code.gson:gson:2.3.1'
compile 'org.bouncycastle:bcprov-jdk15on:1.54'
compile 'org.bouncycastle:bcpkix-jdk15on:1.54'
compile 'junit:junit:4.12'
compile 'org.jsoup:jsoup:1.9.2'
compile 'org.apache.commons:commons-lang3:3.4'
compile 'com.ibm:mq:5.3.07'
compile 'com.ibm:mq.pcf:5.3.07'
compile 'com.ibm:mq.jmqi:5.3.07'
compile 'com.ibm:mq.headers:5.3.07'
compile 'com.ibm:mq.commonservices:5.3.07'
compile 'com.ibm:connector:1.0.0'
runtime 'jaxen:jaxen:1.1.6'
runtime 'xalan:xalan:2.7.2'
runtime 'org.postgresql:postgresql:8.0-311.jdbc3'
runtime 'commons-logging:commons-logging:1.2'
}
compileJava {
sourceCompatibility = 1.6
targetCompatibility = 1.6
options.fork = true
options.compilerArgs << '-XDignore.symbol.file'
options.forkOptions.executable = 'javac'
}
task libs(type: Copy) {
description = "Copies dependencies to the 'lib' directory of the deployment."
def libsDir = new File("$buildDir", 'libs')
libsDir.mkdirs()
def dockerDir = new File("$buildDir", 'docker')
dockerDir.mkdirs()
from project.configurations.runtime
into libsDir
}
task bundleZip(type: Zip) {
from projectDir
include 'xsl/**'
include 'conf/**'
include 'js/**'
include 'test/**'
include 'mesb.sh'
from(tasks.libs.outputs) {
include 'MESB*'
}
into project.projectinfo.version
}
tasks.bundleZip.dependsOn jar
tasks.bundleZip.dependsOn libs
def dockerUsername = project.properties['dockerUsername'] ?: ""
def dockerPassword = project.properties['dockerPassword'] ?: ""
docker {
registryCredentials {
username = dockerUsername
password = dockerPassword
}
}
task buildImage(type: com.bmuschko.gradle.docker.tasks.image.DockerBuildImage) {
doFirst {
copy {
from "${buildDir}/libs/MESB-${projectinfo.version}.jar"
into "${buildDir}/docker"
rename { String fileName ->
fileName.replace("-${projectinfo.version}", "")
}
}
copy {
from "docker/jdk/Dockerfile"
into "${buildDir}/docker"
}
copy {
from "xsl"
into "${buildDir}/docker/xsl"
}
copy {
from "conf"
into "${buildDir}/docker/conf"
}
copy {
from "test"
into "${buildDir}/docker/test"
}
copy {
from "${buildDir}/libs"
into "${buildDir}/docker/libs"
}
}
inputDir = project.file("${buildDir}/docker")
tag = "company/mesb:${projectinfo.version}"
}
tasks.buildImage.dependsOn build
task pushImage(type: com.bmuschko.gradle.docker.tasks.image.DockerPushImage) {
imageName = "company/mesb"
tag = "${projectinfo.version}"
}
tasks.pushImage.dependsOn buildImage
artifacts {
archives bundleZip
}
/* Remove the default JAR file from the uploaded artifacts */
configurations.archives.artifacts.with { archives ->
def jarArtifact
archives.each {
if (it.file =~ 'jar') {
jarArtifact = it
}
}
remove(jarArtifact)
}
jar {
dependsOn configurations.runtime
manifest {
attributes 'Main-Class': 'main.MESB'
}
}
tasks.build.dependsOn libs
sourceSets {
main {
java {
srcDir 'src'
}
}
}
Apparently moving root repository definitions benieth the apply plugins section solved this.
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'com.company.gradle.java'
apply plugin: 'com.bmuschko.docker-remote-api'
repositories {
jcenter()
mavenCentral()
}
Don't know whether you have solved your issue but either way...
I encountered a similar issue regarding:
Could not resolve all dependencies for configuration ':dockerJava'.
Could not find com.aries:docker-java-shaded:3.1.0-rc-3.
We solved it by adding the following
repositories {
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}

Gluon javafx with netbeans error android install

Error while trying to to do android install
Execution failed for task ':mergeClassesIntoJar'.
Cannot expand ZIP 'C:\Users\Path..\AppData\Local\Android\sdk\extras\android\support\multidex\library\libs\android-support-multidex.jar' as it does not exist.
Can any one pleas help am fed up of this issue no proper solution below is my code
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:1.0.9'
}
}
apply plugin: 'org.javafxports.jfxmobile'
repositories {
jcenter()
maven {
url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
}
}
mainClassName = 'com.netbeansdemo.NetbeansDemo'
dependencies {
compile 'com.gluonhq:charm:3.0.0'
androidRuntime 'com.gluonhq:charm-android:3.0.0'
iosRuntime 'com.gluonhq:charm-ios:3.0.0'
desktopRuntime 'com.gluonhq:charm-desktop:3.0.0'
}
jfxmobile {
android {
manifest = 'src/android/AndroidManifest.xml'
androidSdk = 'C:/Users/ee209275/AppData/Local/Android/Sdk'
}
ios {
infoPList = file('src/ios/Default-Info.plist')
forceLinkClasses = [
'com.gluonhq.**.*',
'io.datafx.**.*',
'javax.annotations.**.*',
'javax.inject.**.*',
'javax.json.**.*',
'org.glassfish.json.**.*'
]
}
}
You need to update the Gluon plugin for your IDE, so you can generate a project with updated dependencies. Current versions of the plugin are 2.5.0 for NetBeans and IntelliJ, 2.4.0 for Eclipse.
For a single view project, this will be the build.gradle file you will get:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:1.3.6'
}
}
apply plugin: 'org.javafxports.jfxmobile'
repositories {
jcenter()
maven {
url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
}
}
mainClassName = 'com.gluonhq.testplugin.GluonTestPlugin'
dependencies {
compile 'com.gluonhq:charm:4.3.5'
}
jfxmobile {
downConfig {
version = '3.3.0'
// Do not edit the line below. Use Gluon Mobile Settings in your project context menu instead
plugins 'display', 'lifecycle', 'statusbar', 'storage'
}
android {
manifest = 'src/android/AndroidManifest.xml'
}
ios {
infoPList = file('src/ios/Default-Info.plist')
forceLinkClasses = [
'com.gluonhq.**.*',
'javax.annotations.**.*',
'javax.inject.**.*',
'javax.json.**.*',
'org.glassfish.json.**.*'
]
}
}
You have an issue with the Android SDK path. This question shows how to solve it.
Basically:
Open the Android SDK Manager and make sure you have installed Extras/Google Repository and Extras/Android Support Repository.
Remove the androidSdk line from the android block on your build.gradle file and move it to a properties file. For that, just create a properties file under C:\Users\<user>\.gradle\gradle.properties, and add the ANDROID_HOME variable: ANDROID_HOME=C:/<path.to.Android>/sdk.
Then reload your project, see that it works on desktop, and then deploy to mobile.

Grails assets not work in deployed .WAR

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.

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.

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