Search code examples
grails-pluginartifactorygrails-2.3

How to get the latest changes in custom Grails plugin from artifactory without deleting the plugin from .grails folder?


PROBLEM

I have a custom plugin successfully published into Artifactory and I have successfully loaded it into my application by using the following syntax in my BuildConfig.groovy below. However, as I make changes to the plugin, and publish them of course, I want to get those latest changes into my application that is using the plugin?

I thought that doing a grails compile or grails refresh-dependencies would pick up the lasted code but when I go to grails-app.domain folder I do not see my newer Domain classes.

CURRENT WORKAROUND

I had to go to my .grails/2.3.4/projects/myProject/plugins delete the plugin and then run the grails refresh-dependencies in order to get the latest version of the plugin.

QUESTION

  • Is there a quicker/better way to do this without having to haunt the plugin in the .grails directory?

Attached are the relevant sections of my BuildConfig.groovy in case are needed to assist:

repositories {
    inherits true // Whether to inherit repository definitions from plugins

    //This is to be able to download our own custom plugins
    String serverRoot = 'http://serverRoot/artifactory'
    mavenRepo serverRoot + '/plugins-snapshot-local/'
    mavenRepo serverRoot + '/plugins-release-local/'

    grailsPlugins()
    grailsHome()
    mavenLocal()
    grailsCentral()
    mavenCentral()
    mavenRepo 'http://repo.spring.io/milestone'
}


plugins {

    // plugins for the build system only
    build ":tomcat:7.0.47"

    // 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.6" // or ":hibernate4:4.1.11.6"
    runtime ":database-migration:1.3.8"
    runtime ":jquery:1.10.2.2"
    runtime ":resources:1.2.1"
    compile ':spring-security-core:2.0-RC2'
    compile ":spring-security-ldap:2.0-RC2"
    compile ":spring-security-ui:1.0-RC1"
    compile ":mycustomplugin:0.1"    //This is the plugin that I want get the latest code for

}

Solution

  • Best practice to manage plugins is to change the plugin version whenever you modify the plugin code.

    For example, your current version is 0.1 and when you change something in domain or somewhere else then change the version to 0.2 or something else in your plugin descriptor file and then release the plugin. Now use that new version 0.2 in your BuildConfig.groovy as compile ":mycustomplugin:0.1".

    But sometime it is required to make some changes in already published version, then there are two ways to do it. First is to add -SNAPSHOT in your plugin version then Grails will always pull the latest version of that plugin and second is to add changing flag to it.

    compile(":mycustomplugin:0.1") {
        changing = true
    }
    

    Please have a look at http://grails.org/doc/latest/guide/conf.html#changingDependencies for more info.

    Thanks,
    SA