Exclude Gradle dependency at debug - grails

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

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

MultiView FXML Project on iOS using Gluon-mobile and Java9

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.

Grails : How to migrate dependencies upgrading from 2.x.x to 3.0.8?

I am attempting to upgrade an existing Grails application from version 2.4.4 to 3.0.8. I have a couple issues that I am currently unable to resolve.
First issue: The old version's BuildConfig.groovy referenced a jar file that was in the lib directory. I tried copying the same configuration from BuildConfig.groovy to build.gradle and created a lib directory with the jar but Grails is unable to resolve the dependency.
Second issue: The old version had a plugin defined. I tried copying the same plugin definition from BuildConfig.groovy into build.gradle, but this isn't working. I noticed that the plugin isn't currently listed in Bintray, is this the problem?
Below is the dependency section of the build.gradle file.
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"
compile "com.stripe:stripe-java:1.32.1"
compile "com.google.code.gson:gson:2.3.1"
compile "javax.mail:mail:1.4"
runtime "org.grails.plugins:asset-pipeline"
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"
//jar file located in lib directory
runtime "com.easypost:easypost-java:2.1.2"
//grails plugin
compile ":shiro:1.2.1"
}
Thanks in advance for any guidance provided.
Issue 1: If that jar is a standard jar and you can reference it from maven then that would be good. But still if you need to include it from some local directory then you can do this:
repositories {
flatDir {
//Directory path containing Jar
dirs 'libs'
}
}
dependencies {
//Jar File Name - No need to add suffix .jar
compile name: 'someJarFile'
}
Issue 2: If the plugin is not listed in bintray then that means it has not been upgraded for Grails 3.x. Either you can upgrade it for yourself or remove the plugin if possible.

Creating Ldap Plug ii Grails 2.3

I'm trying to move my project from Grails 2.2.4 to Grails 2.3.5, and I need some plugins, one of them is Ldap's. To access to my repository I have an URL:
grailsRepo "http:// svn................"
and my dependency resolver is maven
an Y have this code after:
plugins {
// plugins for the build system only
build ":tomcat:7.0.50"
// plugins for the compile step
compile ":scaffolding:2.0.1"
compile ':cache:1.1.1'
// plugins needed at runtime but not for compilation
runtime ":hibernate:3.6.10.7"// or ":hibernate4:4.1.11.6" or hibernate:3.6.10.7
runtime ":database-migration:1.3.8"
runtime ":jquery:1.10.2.2"
runtime ":resources:1.2.1"
compile ":ldap:0.8.3.2"
}
and I got the next error
The following artifacts could not be resolved: org.grails.plugins:ldap:zip:0.8.3.2, org.grails.plugins:spring-security-ldap-dcas:zip:1.0.6: Could not find artifact org.grails.plugins:ldap:zip:0.8.3.2 in grailsCentral (http://repo.grails.org/grails/plugins)
|Run 'grails dependency-report' for further information.
It looks like the latest version of the ldap plugin is 0.8.2 - see http://grails.org/plugin/ldap
If this is a custom build that's in your local repo, try switching to the ivy resolver

Getting Error Fatal error during compilation org.apache.tools.ant.BuildException: Compilation Failed. in grails app

When I run grails run-app through terminal or using Grails/Groovy tool suite, it gets "compilation error" with
`Error Fatal error during compilation org.apache.tools.ant.BuildException: Compilation Failed (Use --stacktrace to see the full tr`ac`e)
.
I am using grails 2.0. Below is what happen when I run grails run-app through ubuntu terminal.
Loading Grails 2.0.0
| Configuring classpath.
| Environment set to development.....
| Packaging Grails application
> You currently already have a version of the plugin installed [hibernate-2.0.0]. Do you want to update to [hibernate-3.6.10.2]? [y,n] n
| Plugin hibernate-3.6.10.2 install aborted
> You currently already have a version of the plugin installed [tomcat-2.0.0]. Do you want to update to [tomcat-7.0.42]? [y,n] n
| Plugin tomcat-7.0.42 install aborted
> You currently already have a version of the plugin installed [release-2.2.1]. Do you want to update to [release-3.0.1]? [y,n] n
| Plugin release-3.0.1 install aborted
| Plugin release-3.0.1 install aborted..
Compiling 4 source files.
| Error Fatal error during compilation org.apache.tools.ant.BuildException: Compilation Failed (Use --stacktrace to see the full trace
)
BuildConfig.groovy
grails.servlet.version = "2.5" // Change depending on target container compliance (2.5 or 3.0)
grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
grails.project.target.level = 1.6
grails.project.source.level = 1.6
//grails.project.war.file = "target/${appName}-${appVersion}.war"
grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
// uncomment to disable ehcache
// excludes 'ehcache'
}
log "error" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
checksums true // Whether to verify checksums on resolve
repositories {
inherits true // Whether to inherit repository definitions from plugins
grailsPlugins()
grailsHome()
grailsCentral()
mavenCentral()
// uncomment these to enable remote dependency resolution from public Maven repositories
//mavenCentral()
//mavenLocal()
//mavenRepo "http://snapshots.repository.codehaus.org"
//mavenRepo "http://repository.codehaus.org"
//mavenRepo "http://download.java.net/maven/2/"
//mavenRepo "http://repository.jboss.com/maven2/"
}
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.
runtime 'mysql:mysql-connector-java:5.1.16'
}
plugins {
build ':release:2.2.1', ':rest-client-builder:1.0.3', {
export = false
}
runtime ":hibernate:$grailsVersion"
runtime ":jquery:1.7.1"
runtime ":spring-security-core:1.2.7.2"
runtime ':resources:1.2'
runtime ":cached-resources:1.0"
runtime ":zipped-resources:1.0"
compile ":cache-headers:1.1.5"
build ":tomcat:2.0.0"
//compile ":attachmentable:0.3.0"
compile ":searchable:0.6.4"
compile ":cloud-bees:0.6.2"
compile ":jquery-validation:latest.release"
compile ":jquery-validation-ui:latest.release"
compile ":twitter-bootstrap:2.3.2"
compile ":lesscss-resources:1.3.3"
runtime ":fields:1.3"
compile ":mail:1.0.1"
compile ":jquery-ui:1.8.24"
compile ":spring-security-ui:0.2"
compile ":mail:1.0"
compile ":famfamfam:1.0"
compile ":spring-security-acl:1.1.1"
}
}
When I run grails run-app, It always ask for updating tomcat and hibernate plugings to latest version. I dont know why this is happening. Any suggestion on this.
Can It related to tomcat and hibernate plugin versons?
application.properties
#Grails Metadata file
#Thu Nov 14 15:09:35 IST 2013
app.grails.version=2.0.0
app.name=VProcureFinal
app.servlet.version=2.5
app.version=0.1
plugins.avatar=0.6.3
plugins.burning-image=0.5.1
plugins.class-diagram=0.5.2
plugins.jquery-validation-ui=1.4.4
plugins.prototype=1.0
plugins.richui=0.8
plugins.webxml=1.4.1
*grails run-app out*put:
grails run-app
| Packaging Grails application
> You currently already have a version of the plugin installed [tomcat-2.0.0]. Do you want to update to [tomcat-7.0.42]? [y,n] n
| Installed plugin release-3.0.1
| Error Plugin release-3.0.1 requires version [2.3 > *] of Grails which your current Grails installation does not meet. Please try install a different version of the plugin or Grails.
| Installed plugin release-3.0.1
.
A couple of suggestions. The most likely answer is applications.properties specifying something different to BuildConfig.groovy.
You are running 2.0.0. How about at least trying 2.0.4 as there would be bug fixes?
BuildConfig.groovy doesn't look like the authoritative source. e.g. tomcat is specified as 2.0.0 specifically so you don't have the typical upgrade problem, where in 2.3.x these plugins moved from $grailsVersion.
Check application.properties. The grails version in there will be 2.0.0 - can see this from the startup. The tomcat and hibernate versions may be specified here as the versions you see in the startup.
grails clean and/or delete .grails directory in your home directory.

Resources