This simple post is a reminder on how to create a Maven2 repository and use it with Maven in a "pom.xml" file or in Java Play!.
The first step is to create a GitHub Repository (it will be named "maven2").
Then reproduce the folder structure of a Maven Repository, as I did in my "Maven2" repo (https://github.com/enreeco/maven2).
For instance, given this artifact (jar):
1 2 3 4 | < groupId >com.rubenlaguna</ groupId > < artifactId >evernote-api</ artifactId > < name >Official Evernote API</ name > < version >1.22</ version > |
Create these folders:
./com ./com/rubenlaguna ./com/rubenlaguna/evernote-api ./com/rubenlaguna/evernote-api/1.22 ./com/rubenlaguna/evernote-api/1.22/evernote-api-1.22.jar ./com/rubenlaguna/evernote-api/1.22/evernote-api-1.22.pom
Now you have a pubblicly accessible Maven2 repository at https://github.com/[username]/[repoName]/raw/master/ (in my case https://github.com/enreeco/maven2/raw/master/).
To consume it in your projects, just add this lines in the "pom.xml" file of your project:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <? xml version = "1.0" encoding = "UTF-8" ?> < modelVersion >4.0.0</ modelVersion > < groupId >com.echoservice</ groupId > < version >1.0-SNAPSHOT</ version > < artifactId >echoservlet</ artifactId > < repositories > < repository > < id >myRepository</ id > </ repository > </ repositories > < dependencies > . . . </ depencencies > . . . </ project > |
To integrate the maven repo in a Java Play! project (necessary if you're messing with Heroku), take the "/prject/Build.scala" file and add those lines:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | import sbt._ import Keys._ import PlayProject._ object ApplicationBuild extends Build { val appName = "evernote-integration" val appVersion = "0.1" val appDependencies = Seq( "com.rubenlaguna" % "evernote-api" % "1.22" , //Evernote Thrift Library "com.rubenlaguna" % "libthrift" % "1.0-SNAPSHOT" , //Thrift core library "postgresql" % "postgresql" % "9.1-901.jdbc4" , //Postgres "org.apache.httpcomponents" % "fluent-hc" % "4.2.1" //Apache HTTP client ) val main = PlayProject(appName, appVersion, appDependencies, mainLang = JAVA).settings( ) } |
Maven will search for the selected jars in the default locations, but when it's not finding anything it will search for your personal resolvers.