1

In Grails 2.3.0, the plugins that my plugin depends on are not being exported when I run maven-install. This works in 2.2.3:

$ which grails
/Applications/grails-2.2.4/bin/grails
$ grails create-plugin myplugin
| Created plugin Myplugin
# add spring-security-core
$ cd myplugin; cat grails-app/conf/BuildConfig.groovy
...
  plugins {
    build(":tomcat:$grailsVersion",
          ":release:2.2.1",
          ":rest-client-builder:1.0.3") {
        export = false
    }
    compile ":spring-security-core:1.2.7.3"
  }
$ grails compile; grails maven-install
$ cat target/pom.xml|grep spring
  <artifactId>spring-security-core</artifactId>
$ cat ~/.m2/repository/org/grails/plugins/myplugin/0.1/myplugin-0.1.pom|grep spring
  <artifactId>spring-security-core</artifactId>

But not in 2.3.0

$ which grails
/Applications/grails-2.3.0/bin/grails
$ grails create-plugin mynewplugin
| Created plugin Mynewplugin
# add spring-security-core
$ cd mynewplugin; cat grails-app/conf/BuildConfig.groovy
...
  plugins {
    build(":release:3.0.0",
          ":rest-client-builder:1.0.3") {
        export = false
    }
    compile ":spring-security-core:1.2.7.3"
  }
$ grails compile; grails maven-install
$ cat target/pom.xml|grep spring
$ cat ~/.m2/repository/org/grails/plugins/mynewplugin/0.1/mynewplugin-0.1.pom|grep spring
$

My application.properties has no dependencies listed. I also tried Grails 2.3.1 built from source, but it behaved the same as 2.3.0. The goal is to be able to have a plugin that depends on other plugins and exports those dependencies to the main app without the main app having to explicitly declare them. Is that supposed to be possible and if so, what am I missing? I have read a lot of other related stackoverflow answers and the Grails mailing list, but nothing has cleared this up for me.

Brian Deterling
  • 13,556
  • 4
  • 55
  • 59
  • 1
    See Burt's answer here: http://stackoverflow.com/questions/18995006/how-to-add-plugin-dependencies-to-pom-xml – zoran119 Sep 26 '13 at 05:24
  • As of this comment, that does resolve the issue. http://stackoverflow.com/questions/18995006/how-to-add-plugin-dependencies-to-pom-xml#comment28118466_18995834 – Brian Deterling Sep 26 '13 at 15:03

2 Answers2

1

I have also discovered this issue while upgrading our projects to use Grails 2.3. As of yet, have not discovered the cause, as in some cases the generated pom does contain some dependencies, but in most cases not all. I have however discovered a work around which seems to allow everything to build:

  1. In BuildConfig.groovy add use pom, along with grails.project.dependency.resolver = "maven", checksums true and legacyResolve false
  2. Create a pom.xml in the root of the project. Populate as desired.
  3. Move dependencies from BuildConfig.groovy to the pom. Dependency definition for plugins (any build plugins, I have defined in provided scope once under Maven):

    <dependency>
        <groupId>org.grails.plugins</groupId>
        <artifactId>spring-security-core</artifactId>
        <version>1.2.7.3</version>
        <type>zip</type>
    </dependency>
    

    For entries in the dependency block:

    <dependency>
        <groupId>some.group</groupId>
        <artifactId>artifact</artifactId>
        <version>1.0.0</version>
    </dependency>
    
  4. Doing a grails maven-install or grails maven-deploy should now use that pom and work correctly. We have tied this in with using a parent pom, along with a number of switches within the global settings.groovy, which should hopefully (untested at time of writing) allow us to inline still.

Jamie Kemp
  • 46
  • 1
  • 3
  • Thanks Jamie, I will try that workaround. Leaving the question unanswered for now to see if there's a more natural way to do it. – Brian Deterling Sep 25 '13 at 15:35
1

For anyone struggling with this, it turned out to be a bug or omission in the release plugin version 3.0.0. It was fixed in 3.0.1 so adding this to your BuildConfig.groovy and re-running maven-install resolves the issue:

build(":release:3.0.1",...

Here is the JIRA issue for the bug.

Brian Deterling
  • 13,556
  • 4
  • 55
  • 59