2

I am using Grails 2.3.6 and have a few questions surrounding these 2 SDK commands. I usually don't like to write "multi-questions" like this, but as you can see, they are so close in concept that I'd rather just put them all here than bog down SO with 5 petty mini-questions.

  • What does (did; since its now deprecated) grails maven-install do, specifically?
  • What does grails install-plugin do?
  • What does grails install-plugin maven-publisher do?
  • What is the maven-publisher, and what does it do?
  • Why is the job of grails maven-install now the responsibility of BuildConfig.groovy's compile or build targets (post-deprecation)?
AdjustingForInflation
  • 1,571
  • 2
  • 26
  • 50

1 Answers1

4

The install-plugin script was removed in 2.3 because "installing" plugins doesn't make much sense. Instead we add a dependency on a plugin like we do on a jar file, and let Grails resolve the dependency and make it available to the app. So now we add all deps in BuildConfig.groovy.

The old approach of using install-plugin was too simplistic, but now with the dependency resolution DSL in BuildConfig.groovy we can specify the scope of a dependency, specify exclusions of dependencies of dependencies (e.g. if plugin X depends on plugin (or jar) Y but Y is only optional or it causes problems, you can install just X and exclude Y), and in general have a lot more control over the process.

But we use a plugin to release plugins, which makes things a bit confusing. The functionality was originally in Grails core, but a lot of functionality that doesn't belong in core is being pulled out as plugins. This started way back with the Quartz plugin, then later with Hibernate and Tomcat, and recently with scaffolding plugin. Originally the "maven-publisher" plugin was used to release plugins, but as more features were added the name was changed to ensure that people didn't get confused that it only worked with Maven.

So to release a plugin, we need to "install" the http://grails.org/plugin/release plugin that superceded the maven-publisher plugin. You can use the install-plugin script in 2.2.x and earlier, but you should get out of the habit of using install-plugin and uninstall-plugin since they're gone in 2.3.

Grails can use multiple Maven-compatible repos to resolve plugin and jar dependencies. Maven Central (mavenCentral()) usually has all of the jars that we need, but some are in other repos. Grails plugins are published to http://repo.grails.org/ (you can see them all at http://repo.grails.org/grails/plugins/org/grails/plugins/) but again, you can also get plugins from other repos also. When Maven is used to resolve a dependency, it's cached in $HOME/.m2/repository/ (this is mavenLocal()) so you only have to download each version once.

The maven-install script from the release plugin builds a plugin zip and generates the associated metadata files, and copies everything to the correct location in $HOME/.m2/repository/ and afterwards, the dependency resolvers can't know whether the files are there because they were downloaded from a "real" repo and cached there, or put there via a script. But it doesn't matter - if the files are there, they're usable. So once you run maven-install on your "foo" plugin with version 0.42, you can add a dependency for it in an app's BuildConfig.groovy:

plugins {
   runtime ':foo:0.42'
   ...
}

and it will be resolved from the local cache as if it had been officially published.

There is more info available in the release plugin's docs: http://grails-plugins.github.io/grails-release/docs/manual/

Burt Beckwith
  • 75,342
  • 5
  • 143
  • 156