MultiView FXML Project on iOS using Gluon-mobile and Java9 - ios

Creating a completely new MultiView FXML Project and then adding the Java9 necessities in Gradle:
buildscript {
repositories {
jcenter()
google()
maven{
url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
}
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:2.0.5'
}
}
...
sourceCompatibility = 1.8
targetCompatibility = 1.8
...
dependencies {
compile 'com.gluonhq:charm:4.4.0-jdk9'
androidRuntime 'com.gluonhq:charm:4.4.1'
compile 'com.airhacks:afterburner.mfx:1.6.3'
// Added because of javax.annotation.PostConstruct Java9 issues
compile group: 'javax.xml.ws', name: 'jaxws-api', version: '2.2.6'
}
leads to [SUB] Exception in thread "JavaFX Application Thread" java.lang.IllegalStateException: Stage must be showing before making the Dialog visible.
full console log
The project runs as expected on Desktop and Android, but not on iOS simulator and device. I have tried many things, but since this error comes on newly created projects leads me to believe that it's something caused by the interplay of gluon-mobile and Java9.
Bonus: Changing only the jfxmobile-plugin to 2.0.18 fails even compiling with:
[15:08:15:141] com.gluonhq.higgs.Higgs: Still compiling... 8823
classes left.
[15:08:25:143] com.gluonhq.higgs.Higgs: Still
compiling... 4152 classes left.
[15:08:34:389] com.gluonhq.higgs.Compiler: halfway done round 0
java.lang.StackOverflowError
at java.base/java.util.HashMap.putVal(HashMap.java:642)
at java.base/java.util.HashMap.put(HashMap.java:612)
at java.base/java.util.HashSet.add(HashSet.java:220)
at com.gluonhq.higgs.DependencyGraph.visitReachableNodes(DependencyGraph.java:170)

These steps work for me:
Using Java 9, and NetBeans 9 (beta version) with Gluon IDE plugin 2.6.2, I've created a Gluon project (multi view with FXML). Of course, this will work with other IDEs as well.
I've checked that the gradle wrapper was using 4.3.1 (or superior).
I've modified the build.gradle file to use Gluon VM with jfxmobile 2.0.18:
build.gradle file:
buildscript {
repositories {
jcenter()
google()
maven {
url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
}
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:2.0.18'
}
}
and updated the dependencies:
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile 'com.gluonhq:charm:4.4.0-jdk9'
compile 'com.airhacks:afterburner.mfx:1.6.3'
compile 'javax.annotation:javax.annotation-api:1.3.2'
androidRuntime 'com.gluonhq:charm:4.4.1'
}
Then I just deployed the project to my iOS device without any issue.
Note that it may be convenient to clean your ~/.gvm cache, as it might contain classes from older versions that shouldn't be used anymore. Of course, you should also clean your project ./gradle and /build folders.

Related

Grails 4: Is spring-security-ldap updated for Grails 4.0?

I am upgrading my Grails 3.3.2 application to Grails 4.0.0.RC2 and all references to org.springframework.security.ldap classes are unresolved. I'm not sure if this is a matter of waiting for a later version of the plugin or if there's something different I should be doing for Grails 4. If I need to wait for a later version, is there an ETA on this?
I'm using this version in my build.gradle file:
compile "org.grails.plugins:spring-security-ldap:3.0.2"
Here's an example of some unresolved errors:
unable to resolve class org.springframework.ldap.core.DirContextOperations
unable to resolve class org.springframework.ldap.core.DirContextAdapter
Due to Gradle change:
Separation of compile and runtime dependencies when consuming POMs
To use some Grails 3 plugins in Grails 4 apps you need to include their transitive dependencies directly. Otherwise they are not brought into the classpath.
The fix is to include the dependencies directly in your build.
ext {
springSecurityVersion="5.1.6.RELEASE"
springSecurityCoreVersion="4.0.0.RC2"
springSecurityLdapVersion="3.0.2"
}
dependencies {
...
// Security
compile "org.grails.plugins:spring-security-core:$springSecurityCoreVersion"
compile ("org.grails.plugins:spring-security-ldap:$springSecurityLdapVersion") {
exclude group: 'org.grails.plugins', module:'spring-security-core'
}
compile "org.springframework.security:spring-security-ldap:$springSecurityVersion", {
['apacheds-core', 'apacheds-core-entry', 'apacheds-protocol-ldap', 'apacheds-protocol-shared',
'apacheds-server-jndi', 'commons-logging', 'fest-assert', 'jcl-over-slf4j', 'junit',
'ldapsdk', 'logback-classic', 'mockito-core', 'shared-ldap', 'slf4j-api', 'spring-beans',
'spring-context', 'spring-core', 'spring-ldap-core', 'spring-security-core',
'spring-test', 'spring-tx'].each { exclude module: it }
}
compile 'org.springframework.ldap:spring-ldap-core:2.0.4.RELEASE', {
['commons-lang', 'gsbase', 'junit', 'mockito-core', 'powermock-api-mockito',
'powermock-api-support', 'powermock-core', 'powermock-module-junit4',
'powermock-module-junit4-common', 'powermock-reflect', 'slf4j-log4j12', 'spring-beans',
'spring-core', 'spring-data-commons', 'spring-test', 'spring-tx'].each { exclude module: it }
}
I took the transitive dependencies from the plugin:
https://github.com/grails-plugins/grails-spring-security-ldap/blob/master/build.gradle#L63-L76

Gradle build error with SDK tools version 27

When I create a new project with my android studio 3.0.1 build.gradle (module:app) is configured automatically as bellow:
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.android.myapplication"
minSdkVersion 17
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.0.0-alpha1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:0.5'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2'
and build.gradle (project:my application) is configured automatically as bellow:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I've done nothing unless creating a new project but at this point an error appears with red line under appcompat implementation saying:
When using a compileSdkVersion android-O revision 2 or higher, the support library version should be 26.0.0-beta1 or higher (was 26.0.0-alpha1)
Also test:runner implementation is highlighted with following hint:
A newer version of com.android.support.test:runner than 0.5 is available: 1.0.1
and espresso-core implementation is highlighted with following hint:
A newer version of com.android.support.test.espresso:espresso-core than 2.2.2 is available: 3.0.1
QUESTION 1- I have SDK tools versions 27.0.0 and 27.0.1 and 27.0.3 installed on my system. Why android studio uses 26.0.0-alpha1 as a default which causes error?
QUESTION 2- How can I change this default to proper 27 version?
When I try changing compileSdkVersion and targetSdkVersion to 27 and changing appcompat version to v7:27.0.0 then I come up with following errors after syncing:
image description
QUESTION 3- Why this error is happening and how to rectify it?
I revert back to SDK 26 and try to upgrade test:runner and test.espresso:espresso-core to what android studio suggests. It ends up with this error:
image description
QUESTION 4- Why android studio cannot resolve the upgrading which it suggests?
QUESTION 5- What is a sample working gradle build configuration using latest SDK version (27)?
After too many investigations, I regretfully found that all errors were due to unfair sanctions by Google against my country's people (not against the government as they claim!).
My Android Studio was not able to contact jcenter and maven repositories.
After using a VPN program everything was settled and all errors were vanished!!

Exclude Gradle dependency at debug

I'm using Grails plugin to execute (war and debug) Grails 2.5.0 project.
It seems one of dependencies contain older dependency than I would like to you. When I war a project correct version is used, but at debug it uses older dependenvy version:
dependencies {
bootstrap "org.grails.plugins:tomcat:7.0.50" // No container is deployed by default, so add this
// plugins for the compile step
compile "joda-time:joda-time:2.3"
compile("org.grails.plugins:spring-security-rest:1.5.2") {
exclude module: 'xml-apis'
exclude module: 'joda-time'
}
compile 'org.grails.plugins:cache:1.1.8'
// plugins needed at runtime but not for compilation
runtime ("org.grails.plugins:hibernate4:4.3.8.1") { exclude module: 'xml-apis' } // or ":hibernate:3.6.10.18"
runtime "org.grails.plugins:database-migration:1.4.0"
}
So at debug I have joda-time 1.6 which is shipped with spring-security-rest:1.5.2. But when war-ed joda-time version is 2.3

Replace a global library with a new version in Grails

Grails comes with Protobuf 2.4.1 as a 'global dependency', but my app uses a library that compiled against Protobuf 2.5.0 (and version 2.5.0 isn't compatible with 2.4.1).
The problem that I don't see any way to tell Grails to use only specified version instead of bundled. If I exclude it in BuildConfig it just excluded from application, all versions. I mean:
inherits("global") {
excludes 'protobuf-java'
}
dependencies {
//build 'com.google.protobuf:protobuf-java:2.5.0'
// or
compile 'com.google.protobuf:protobuf-java:2.5.0'
}
Grails fails with:
Fatal error during compilation org.apache.tools.ant.BuildException:
java.lang.NoClassDefFoundError: com/google/protobuf/MessageOrBuilder
How I can exclude global library, and add it as a new dependency instead? I'm using Grails 2.2.2
You do not need to exclude protobuf-java. The newest version, when provided as a dependency, should evict the older one. So v2.4.1 will be evicted by v2.5.0.
inherits("global") {
//excludes 'protobuf-java'
}
dependencies {
build 'com.google.protobuf:protobuf-java:2.5.0'
}
The above should be good. To witness the same, run a dependency-report on the grails app and look for the dependency.
To support with facts, I tested it and it works perfectly for me.
import com.google.protobuf.TextFormat
//Just to replicate your issue, but it did not complain about this import.
import com.google.protobuf.MessageOrBuilder
class BootStrap {
def init = { servletContext ->
TextFormat t = new TextFormat()
println t
}
def destroy = {
}
}
//Prints:
com.google.protobuf.TextFormat#372688e8

how to delete guilty jar file after grails dependency-report

when I tried to run grails -Dgrails.env=local run-app, I got the below error
Server failed to start: java.lang.LinkageError: loader constraint violation: loader (instance of ) previously initiated loading for a different type with name "javax/management/MBeanServer"
After analysing I understood that it has something to do with "Two dependencies link the same jar with different versions"
I ran grails dependency-report, and here is the observation:
commons-beanutils by commons-beanutils 1.8.3 release default false 227 kB
commons-beanutils by commons-beanutils 1.8.0 release default true 0 kB(evicted by 1.8.3)
How do I exclude this jar or remove the linkage?
The dependency report should show what is pulling in the problematic jar. Once you have that, explicitly exclude it from the dependencies in your BuildConfig.groovy, like so:
grails.project.dependency.resolution = {
dependencies {
runtime("i-depend-on-beanutils-1.8.3") {
excludes "beanutils"
}
}
}

Resources