3

I have no experience with maven, so excuse me if this question is silly...

From another question (How does Grails handle plugin dependencies), I've learned that I can avoid the jar-hell in grails through maven repositories. But I now have the requirements that...

  • I am not allowed to use remote maven repositories
  • I would like to bundle the needed jars with my plugin (but low priority)
  • I would like to avoid the effort to install a local maven repository

I already worked with a reference to a local folder for plugin resolution. This works great.

But how do I have to structure a local folder in order to use this option:

repositories {
  flatDir name:'myRepo', dirs:'/path/to/repo'
}

I mean, I could just drop the jar files to this folder, but how do I then reference those jar files? Do they have a naming schema like artifact_version.jar? Or do I have to create an XML configuration for this local repository?

Or is the effort to use a local maven repo small and maven is even already on my machine through grails?

Community
  • 1
  • 1
rdmueller
  • 10,742
  • 10
  • 69
  • 126

1 Answers1

3

The fact is Maven comes already with a local repository (~/.m2 on linux boxes). If you don't have access to an external repo, you just have to install your jars in the local repo, with this command

mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>

is 'jar' (without quotes) and group-id and artifact-id are either determined if it's 3rd-party library (go make a search on mvnrepository.com if you don't know them for a particular library) or you put there your group and artifact ids

EDIT : In fact, the naming scheme under the repository is for the library example version 1.2 from jexample.com is usually com/jexample/example/1.2/example-1.2.jar (groupId : com.jexample, artifactId : example, version : 1.0)

Grooveek
  • 10,046
  • 1
  • 27
  • 37
  • thanx. that sounds good. but my command line doesn't recognize the `mvn`command. Grails uses maven under the hood, so it should be somewhere, but I can't find it. Do you have any advice? – rdmueller Jan 13 '12 at 08:54
  • linux or windows ? Can you install something ? Check if you have .m2 or .ivy2 directories if you're on linux – Grooveek Jan 13 '12 at 08:56
  • yes, grails creates a `%user%/.m2` directory. That's not the problem. And yes, I could install maven, but I guess grails already installed it - but I can't find it... I'll keep on searching. btw: windows – rdmueller Jan 13 '12 at 09:05
  • grails comes bundled with the maven jars (from the Ivy distribution I guess), but the executable is not installed... install maven and then you'll can do what you want – Grooveek Jan 13 '12 at 09:07
  • 2
    @Ralf Grails does not use Maven under the hood by default, it uses Ant and Ivy (though Ivy can read dependencies from a Maven repo) – Dónal Jan 13 '12 at 10:00
  • @Don so the .m2 folder is created by Ivy? – rdmueller Jan 13 '12 at 10:28