heroku-buildpack-java-maven

by maksym-mikheienko

GitHub Readme.md

Heroku buildpack: Java with Maven

This is a Heroku buildpack for Java apps with Maven available during runtime. It's used for Vertx.io deployment on Heroku.

Usage

Example usage:

$ ls
Procfile  pom.xml  system.properties  src 

$ heroku create --stack cedar --buildpack https://github.com/maksym-mikheienko/heroku-buildpack-java-maven.git

$ git push heroku master
...
-----> Heroku receiving push
-----> Fetching custom language pack... done
-----> Java app detected
-----> Installing OpenJDK 1.7... done
-----> Installing Maven 3.0.3... done
-----> Installing settings.xml... done
-----> executing /app/tmp/repo.git/.cache/.maven/bin/mvn -B -Duser.home=/tmp/build_19z6l4hp57wqm -Dmaven.repo.local=/app/tmp/repo.git/.cache/.m2/repository -s /app/tmp/repo.git/.cache/.m2/settings.xml -DskipTests=true clean install
       [INFO] Scanning for projects...
       [INFO]                                                                         
       [INFO] ------------------------------------------------------------------------
       [INFO] Building readmeTest 1.0-SNAPSHOT
       [INFO] ------------------------------------------------------------------------
...

What's hacked?

This buildpack has the only change from the source:

For example if you want to have maven available to use at runtime in your application you simply have to copy it from the cache directory to the build directory by adding the following lines to the compile script:

for DIR in ".m2" ".maven" ; do
  cp -r $CACHE_DIR/$DIR $BUILD_DIR/$DIR
done

This will copy the local maven repo and maven binaries into your slug.

Commit and push the changes to your buildpack to your Github fork, then push your sample app to Heroku to test. Once the push succeeds you should be able to run:

$ heroku run bash

and then:

$ ls -al

and you'll see the .m2 and .maven directories are now present in your slug.

License

Licensed under the MIT License. See LICENSE file.