How to upgrade from 2.2.4 to 2.4.3 - grails

I am trying to upgrade from 2.2.4 to 2.4.3
What is the best way to do this? I've made the following changes to my BuildConfig.groovy
plugins {
runtime ':hibernate4:4.3.5.2'
runtime ':jquery:1.11.0.2'
runtime ":jquery-ui:1.8.24"
//runtime ":resources:1.2"
runtime ':twitter-bootstrap:3.2.0.2'
compile ':spring-security-core:2.0-RC4'
compile ":rabbitmq:1.0.0"
compile (":events-push:1.0.M7") {
excludes "resources"
}
compile ":rest-client-builder:1.0.3"
test(":spock:0.7") {
exclude "spock-grails-support"
}
build ':tomcat:7.0.52.1'
runtime ':database-migration:1.4.0'
compile ':cache:1.1.3'
compile ":pretty-time:0.3"
compile ":tagcloud:0.3"
compile ':asset-pipeline:1.8.3'
}
After making the changes what command do I need to run? Are there changes I need to make now that since resources plugin is replaced with asset-pipeline
I've also changed app.grails.version=2.2.4 in application.properties to 2.4.3

Firstly, we can't actually see any of the changes you've made.
Are there changes I need to make now that since resources plugin is replaced with asset-pipeline
You can continue using the resources plugin in Grails 2.4.3, but if you want to migrate to the asset-pipeline, I'd advise you to do that after you have your app running stably on Grails 2.4.3.
After making the changes what command do I need to run
grails test-app to automatically test if your app is still working. If you don't have any tests, run grails run-app and manually test it.

Related

How to install plugins in grails-3.2.0 which i have used in grails-2.4.4 while upgrading application

I am trying to upgrade my application from Grails 2.4.4 to Grails 3.2.0. I am having problems installing plugins used in previous version. Following Questions did gave me some clarification :
1) First one
2) Second one
Now I have few plugins like tomcat, jquery,etc which are not available at https://bintray.com/grails/plugins as described in First one question.
So can you tell me how do I add plugins which are not in this directory on plugins at bintray.
There is some problem as well I am using database-migration plugin. There is listing available at bintray and says to use it as
compile 'org.grails.plugins:database-migration:3.0.0'
as I added same in build.gradle file in my project under dependencies section. Project gets compiled successfully but does not run. Shows long exception but starting is as follows :
org.gradle.api.tasks.TaskExecutionException: Execution failed for task
':bootRun'.
Please help to resolve this errors while installing plugin in Grails 3.2.0
You need an extra configuration for that plugin as its doc says.
Add in build.gradle
buildscript {
dependencies {
...
classpath 'org.grails.plugins:database-migration:3.0.0'
}
}
dependencies {
...
compile 'org.grails.plugins:database-migration:3.0.0'
}
It is also recommended to add a direct dependency to liquibase because Spring Boot overrides the one provided by this plugin
dependencies {
...
compile 'org.liquibase:liquibase-core:3.5.3'
}
You should also tell Gradle about the migrations folder
sourceSets {
main {
resources {
srcDir 'grails-app/migrations'
}
}
}
Maybe plugins are no longer necessary and don't have direct replacements. The tomcat plugin is not needed because Grails 3 is built on Spring Boot and the dependency:
compile "org.springframework.boot:spring-boot-starter-tomcat"
Provides tomcat already. The jQuery plugin is not needed either because you can simply declare a dependency on the jquery.js file directly using asset pipeline which is just as simple. See How to Use jQuery in Grails 3.0

error while running grails command line

in my grails 2.3.4 application (after upgrading from grails 2.2.3) , when I run the grails command line grails install-plugin pluginname I get the below error , even I tried grails list-plugins I'm getting the same error:
Error Resolve error obtaining dependencies: Failed to resolve dependencies (Se log level to 'warn' in BuildConfig.groovy for more information): org.grails.plugins:tomcat:2.3.4 (Use --stacktrace to see the full trace)
i reviewed the BuildConfig.groovy there is no tomcat 2.3.4 what i'm using is 7.0.47 , here are my plugins :
runtime ":hibernate:3.6.10.6"
runtime ":jquery:1.8.3"
runtime :resources:1.1.6
build ":tomcat:7.0.47"
runtime database-migration:1.2.1
compile :cache:1.0.1
how i can solve this issue ?
you problem seems slovable due to the fact that ...you need to clean the grails project first without building it and then do
grails refresh-dependencies
and then finally
grails clean
and
grails compile
When you run refresh-dependencies your Grails application will try to resolve your grails plugins defined in BuildConfig.groovy file. If this doesn't work remove the plugins and do the above step until the error you have posted in the question vanished then add the correct plugin format and version with the correct precedence dependency, then make sure everything should work well.
Your dependencies are in a dependency block, but they are plugins. Put them in the plugins block of your BuildConfig.groovy file. So instead of what you have, put this:
plugins {
runtime ":hibernate:3.6.10.6"
runtime ":jquery:1.8.3"
runtime ":resources:1.1.6"
build ":tomcat:7.0.47"
runtime ":database-migration:1.2.1"
compile ":cache:1.0.1"
}
Also, this is no "dependency" block. This is a dependencies block, however. See this link for information on dependency resolution in Grails.
I need to add the following repo in buildconfig.groovy to the repositories section:
mavenRepo "https://repo.grails.org/grails/plugins"

Grails wants to downgrade my plugins when I copy my app to a new machine

When I copy my app to a different machine and do 'grails run-app' grails seems to skip a step as far as updating its local plugins. (What I mean is the first computer has just done Downloading: plugins-list.xml, but when I run the app on the second machine, the new machine will not do that step.) I get this message:
Loading Grails 2.0.3
Configuring classpath
Environment set to development.....
Packaging Grails application
You currently already have a version of the plugin installed [resources-1.1.6]. Do you want to update to [resources-1.1.5]? [y,n] n
Plugin resources-1.1.5 install aborted
Compiling 92 source files
Am I diagnosing this correctly, and how do I force an update? Also, if I do accept the downgrade my app breaks. Not sure whats up with that as it was working with 1.1.5 for a while..
What I feel like is happening is that grails makes a note in the project when grails' plugin magic was last updated, so that when I move the project the other grails mistakenly thinks it just updated. Is this at all correct?
Are you specifying your plugins in your BuildConfig.groovy file or are you "installing" the plugins using the install-plugin command? My reading indicates usage of the install-plugin command isn't recommended anymore, you should instead specify the plugin as in your BuildConfig.groovy file then Grails will just handle it regardless of what machine you deploy on.
Example:
plugins {
/*
* build - dependency that is only needed by the build process
* compile - dependency that is needed at both compile-time and runtime. This is the most common case
* provided - dependency that is needed at compile-time but should not be packaged with the app (usually because it is provided by the container). An example is the Servlet API
* runtime - dependency that is needed to run the application, but not compile it e.g. JDBC implementation for specific database vendor. This would not typically be needed at compile-time because code depends only the JDBC API, rather than a specific implementation thereof
* test - dependency that is only needed by the tests
*/
runtime ":cached-resources:1.0"
runtime ":database-migration:1.1"
runtime ":hibernate:$grailsVersion"
runtime ":jquery:1.7.1"
runtime ":resources:1.1.6"
runtime ":yui-minify-resources:0.1.4"
runtime ":zipped-resources:1.0"
compile ":cache-headers:1.1.5"
compile ":commentable:0.8.1"
compile ":jquery-ui:1.8.15"
compile ":joda-time:1.4"
compile ":searchable:0.6.3"
compile ":spring-security-ldap:1.0.6" // Also installs spring-security-core
build ":tomcat:$grailsVersion"
}
Note too that some plugins also require a special entry in the dependencies section of your BuildConfig.groovy file. The JodaTime plugin is one such plugin.
dependencies {
compile "org.jadira.usertype:usertype.jodatime:1.9"
}
A plugin's docs should specify if any entry in the dependencies section is needed.

Spock framework has conflict with other plugins in Grails 1.3.8

I have installed Spock on Grails 1.3.8 application. It fails after running the test-app. It seems it has some conflicts with my other plugins but I cannot figure it out. I have over 20 plugins installed.
The error is :
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Could not instantiate global transform class
org.spockframework.compiler.SpockTransform specified at jar:file:
/C:/Documents%20and%20Settings/xxxxxxx/.ivy2/cache/org.spock
framework/spock-core/jars/spock-core-0.6-groovy-1.8.jar!/META-INF/services
/org.codehaus.groovy.transform.ASTTransformation because of exception
org.spockframework.util.IncompatibleGroovyVersionException: The Spock
compiler plugin cannot execute because Spock 0.6.0-groovy-1.8 is not compatible
with Groovy 1.7.8. For more information,see http://versioninfo.spockframework.org
Spock location: file:/C:/Documents%20and%20Settings/xxxxxx/.ivy2/cache
/org.spockframework
/spock-core/jars/spock-core-0.6-groovy-1.8.jar
Groovy location: file:/C:/dev/Grails/grails-1.3.8/lib/groovy-all-1.7.8.jar
Here is my buildConfig:
dependencies {
test "org.spockframework:spock-grails-support:0.6-groovy-1.7"
}
plugins {
compile ":joda-time:1.4"
compile ":excel-import:0.9.6"
compile ":export:1.3"
test(":spock:0.6") {
exclude "spock-grails-support"
}
}
I am able to run the spock test without any issue if I dont install any plugin. I am not sure if there is something specific to one of the plugins or something about Spock or even anything I am doing wrong.
Additional Information:
I found out that for some reason one/more of the plugins prevents Grails from downloading the
spock-grails-support:0.6-groovy-1.7
With my plugins, Grails only download the spock-grails-support:0.6-groovy-1.8 not 1.7 that is required for 1.3.8.
So now I am not sure what is preventing Grails from downloading the dependency.
Thanks for any advice
It appeared that Joda-time plugin has a dependency on Spock, although, it has set the export to false in the plugin, it was forcing the Grails to download the spock-grails-support:0.6-groovy-1.8 in my application. I had it to exclude the spock and so far it seems its working.
compile (":joda-time:1.4") { exclude "spock" }

Grails BuildConfig.groovy, difference between build, compile, and runtime?

What's the difference between build, runtime, and compile, in BuildConfig.groovy (1.3.7)
grails.project.dependency.resolution = {
plugins {
build "acme:acme-cache:latest.integration"
}
dependencies {
build "com.foo.bar:foobar:1.0.5"
runtime "org.apache.httpcomponents:httpclient:4.0.3"
compile("com.thoughtworks.xstream:xstream:1.3.1")
}
}
build - dependency that is only needed by the build process
runtime - dependency that is needed to run the application, but not compile it e.g. JDBC implementation for specific database vendor. This would not typically be needed at compile-time because code depends only the JDBC API, rather than a specific implementation thereof
compile - dependency that is needed at both compile-time and runtime. This is the most common case
There are a couple of other dependency scopes:
test - dependency that is only needed by the tests, e.g. a mocking/testing library
provided - dependency that is needed at compile-time but should not be packaged with the app (usually because it is provided by the container). An example is the Servlet API
It seems the 2 previous answers conflict on the distinction between compile and build. I believe that build is the scope that includes grails compile and grails run-app, while compile is just the former.
Starting from Grails 3, dependencies are managed by Gradle. The grails-app/conf/BuildConfig.groovy file has been replaced by the build.gradle file in the project's root.
The Grails user guide explain how to set grails depencies with gradle. See also the related Gradle documentation for further details on managing dependencies using it.
A couple grails commands help illustrate the difference. Consider grails run-app and grails compile. grails compile is the compile step and will include compile-time dependencies. grails run-app is the run step and will include runtime dependencies. Build dependencies are anything that you might need to run any of these commands, for example, a custom script that hooks into some build events.
So you would pick the one that best fits when you need to be certain the dependency is included.

Resources