Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a Grails repository using only an HTTP server?

I have some third party plugins that are not available publicly. I would like to create a local repository so that me and my co-workers can install these plugins easily. I have a server that already has nginx installed. So I'd like to use that if possible. That is, I'm not keen on installing another web server like Tomcat to run something like the grails.org web interface (as the documentation suggests in "Your own plugin portal").

Based on the grailsRepo() function and getPluginList(), I have created a "grails" directory on my web server like so:

/grails
- /.plugin-meta
  - /plugins-list.xml
- /grails-my-plugin
  - /tags
    - /RELEASE_1_0_123
      - /grails-my-plugin-1.0.123.zip

Where the plugin is named "my-plugin" and the version number of the plugin is 1.0.123.

My plugins-list.xml is like so:

<plugins revision="1">
    <plugin latest-release="1.0.123" name="my-plugin">
        <release tag="RELEASE_1_0_123" type="svn" version="1.0.123">
            <title>MyPlugin</title>
            <author>No Author</author>
            <authoremail>no@email</authoremail>
            <description>An example plugin.</description>
            <file>http://mydev.example.com/grails/grails-my-plugin/tags/RELEASE_1_0_123/grails-my-plugin-1.0.123.zip</file>
        </release>
    </plugin>
</plugins>

With the repository configured as detailed, I created a new Grails application (grails create-app test-app) and adjusted the grails-app/conf/BuildConfig.groovy to include the following configuration:

repositories {
  grailsRepo("http://mydev.example.com/grails", "myDevRepo")
}

Whenever I attempt to install the "my-plugin" plugin to this Grails app I see a request on my web server, and Grails reports that it attempted to download from my repository like so:

==== myDevRepo: tried

  -- artifact org.grails.plugins#my-plugin;latest.integration!my-plugin.zip:

  http://mydev.example.com/grails/grails-my-plugin/tags/LATEST_RELEASE/grails-my-plugin-[revision].zip

It seems to me that Grails is not attempting to read the .plugin-meta/plugins-list.xml file I have created for my repository. What do I need to do to make this repository work with minimal configuration of the local Grails app?

Note: I am using Grails 1.3.7.

like image 999
James Sumners Avatar asked Jun 22 '26 23:06

James Sumners


1 Answers

cdeszaq from #grails on irc.freenode.org led me to the following solution:

Forget about using the "grailsRepo" type repository layout. It's woefully undocumented and clearly doesn't work well. Instead, use the Maven repository layout.

Let's assume you have a plugin named "foo" at version 1.0.5 and it is packaged into a zip file named "foo-1.0.5.zip". To create an HTTP based repository we do the following:

First, create a directory structure on your web server:

/grails-maven
-/org
  -/grails
    -/plugins
      -/foo
        -/1.0.5

Place your "foo-1.0.5.zip" file, along with an MD5 sum file (md5sum -b foo-1.0.5.zip > foo-1.0.5.zip.md5), into the deepest directory of this tree. Thus, you'll have the following URLs:

http://example.com/grails-maven/org/grails/plugins/foo/1.0.5/foo-1.0.5.zip
http://example.com/grails-maven/org/grails/plugins/foo/1.0.5/foo-1.0.5.zip.md5

Enable directory indexing output for the grails-maven directory in your web server configuration. In the case of nginx, the following configuration will work:

server {
  location ^~ /grails-maven {
    autoindex on;
  }
}

Finally, enable the repository in your Grails app's BuildConfig.groovy:

repositories {
  mavenRepo("http://example.com/grails-maven/")
}

Having completed the above, you can now grails install-plugin foo and get the plugin installed into your Grails app.

like image 153
James Sumners Avatar answered Jun 25 '26 18:06

James Sumners



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!