0
votes

I am trying to start a Grails application that consists of multiple plug-ins each of which is stored as a separate Maven module. Dependencies are specified within BuildConfig.groovy files. While starting the app classes (both Java and Groovy) stored in other plugins are not loaded. I've checked the classpath and it seems it does not include classed generated by other plugins.

Dependencies within BuildConfig.groovy look like this:


    grails.project.class.dir = "target/classes"
    grails.project.test.class.dir = "target/test-classes"
    grails.project.test.reports.dir = "target/test-reports"

    grails.plugin.location.'plugin-one' = "${basedir}/../plugin-one"
    grails.plugin.location.'plugin-two' = "${basedir}/../plugin-two"

    grails.project.dependency.resolution = {
        inherits("global") {
            excludes 'commons-logging', 'commons-collections'
        }
        log "warn"
        repositories {
            inherit false
            mavenRepo "http://my.maven.repo"
        }
        plugins {
            runtime ':tomcat:1.3.7'
            runtime ':hibernate:1.3.7'
            ...
        }
        dependencies {
            compile "org.apache.httpcomponents:httpclient:4.2.1"
            compile "org.apache.httpcomponents:httpmime:4.2.1"
            compile "commons-collections:commons-collections:3.2.1"

            build "org.apache.httpcomponents:httpclient:4.2.1"
            build "org.apache.httpcomponents:httpmime:4.2.1"
            build "commons-collections:commons-collections:3.2.1"
            ...
        }
    }

    gwt.version = "2.3.0"

The structure of Maven modules is as follows:


    /pom.xml
    /my-app/pom.xml
    /plugin-one/pom.xml
    /plugin-two/pom.xml
    ...

1
"stored as separate Maven module" - can you elaborate on this? Is the app you work on mavenized as well? - dmahapatro
Can you share your BuildConfig.groovy? - user800014
@dmahapatro - I have a flat structure of Maven modules: my-app, plugin-one, plugin-two, etc. Although I'm pretty sure this is not the case. - czerwin

1 Answers

0
votes

The grails application does not extends its classpath to plugin directories. Instead, all compiled classes are copied into target/plugin-classes directory contained by your application base directory.

The problem described in the previous post was caused by Grails not wanting to copy plug-ins resources to the application classpath due to missing Grails plug-in's descriptors. In particular, plugin.xml files. Unfortunately, Grails documentation is silent about that. However, you can generate plugin.xml files for all your plugins by invoking grails package-plugin command within plugin's base directory. Remember to regenerate plugin descriptor after significant changes to plugin configuration if you don't want Grails to fail silently.