Java

Java is officially supported on Scalingo

Versions

  • 1.6
  • 1.7
  • 1.8
  • 1.9 - pre-release

Frameworks

Most frameworks should work on the platform, the only condition is to listen on the port defined by the environment variable PORT

  • Spring Boot: You can find custom information about this framework at the following page

Deployment

It uses Maven 3.2.5 to build your application and OpenJDK 8u51 to run it (by default).

Example usage:

$ ls
Procfile  pom.xml  src

$ scalingo create java-app

$ git push scalingo master
...
-----> Java app detected
-----> Installing OpenJDK 1.8... done
-----> Installing Maven 3.2.5... 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] ------------------------------------------------------------------------
...

The buildpack will detect your app as Java if it has the file pom.xml in the root. It will use Maven to execute the build defined by your pom.xml and download your dependencies.

If your build results in a .war file you need to add a small dependency to your project in order to execute it, follow the guide

The .m2 folder (local maven repository) will be cached between builds for faster dependency resolution. However neither the mvn executable or the .m2 folder will be available in your slug at runtime.

Configuration

Choose a JDK

Create a system.properties file in the root of your project directory and set java.runtime.version=1.7.

Example:

$ ls
Procfile pom.xml src

$ echo "java.runtime.version=1.7" > system.properties

$ git add system.properties && git commit -m "Java 7"

$ git push scalingo master
...
-----> Java app detected
-----> Installing OpenJDK 1.7... done
...

Choose a Maven Version

The system.properties file also allows for maven.version entry (regardless of whether you specify a java.runtime.version entry). For example:

java.runtime.version=1.7
maven.version=3.1.1

Supported versions of Maven include 3.0.5, 3.1.1 and 3.2.5. You can request new versions of Maven by submitting a pull request against vendor/maven/sources.txt.

Customize Maven

There are three config variables that can be used to customize the Maven execution:

  • MAVEN_CUSTOM_GOALS: set to clean install by default
  • MAVEN_CUSTOM_OPTS: set to -DskipTests=true by default

These variables can be set like this:

$ scalingo env-set MAVEN_CUSTOM_GOALS="clean package"
$ scalingo env-set MAVEN_CUSTOM_OPTS="--update-snapshots -DskipTests=true"

Other options are available for defining custom a settings.xml file.

Buildpack

More details on the buildpack https://github.com/Scalingo/java-buildpack

schedule 01 Sep 2015