Docs menu

Java on Primcloud

How Primcloud detects a Java app, builds it with Maven or Gradle, and starts your process.

On this page

Detection#

Primcloud builds your app as Java when the root of your repo has either:

  • A Maven POM: pom.xml, or one of the polyglot POM formats (pom.atom, pom.clj, pom.groovy, pom.rb, pom.scala, pom.yaml, pom.yml).
  • A Gradle build file: build.gradle, settings.gradle, build.gradle.kts, or settings.gradle.kts.

If both are present, Maven is used.

The build#

The build installs the OpenJDK version from your system.properties, or the latest LTS if you don't set one; see Runtime versions. JAVA_HOME points at it and java is on the PATH, during the build and at runtime.

Maven apps build with mvn clean install -DskipTests, using your Maven wrapper (mvnw) if you commit one. Gradle apps build with ./gradlew stage, so commit gradlew and gradle/wrapper/; you define what stage does in build.gradle. Package managers covers both, and Customizing the build covers changing the goals or task.

The JDK, your Maven repository, and your Gradle caches are reused from the previous build, so dependencies aren't downloaded again on every deploy.

Launching your process#

A Procfile at the root of your repo decides your processes; see Formations.

Spring Boot and WildFly Swarm apps get a web process without one. Other Java apps need a Procfile.

A typical Spring Boot Procfile:

Procfile
web: java -Dserver.port=$PORT $JAVA_OPTS -jar target/myapp-0.0.1-SNAPSHOT.jar

Micronaut and Quarkus are the same shape: build a runnable JAR and launch it:

web: java -Dmicronaut.server.port=$PORT -jar target/myapp-0.1.jar
web: java -Dquarkus.http.port=$PORT -jar target/quarkus-app/quarkus-run.jar

Port. Your web process must listen on $PORT (5000), by passing -Dserver.port=$PORT (Spring Boot), -Dmicronaut.server.port=$PORT (Micronaut), -Dquarkus.http.port=$PORT (Quarkus), or by reading the env var directly in your startup code. Other process types don't get a PORT.

Environment. Every process gets JAVA_HOME and your secrets. To tune the JVM (heap size, encoding, GC flags) without editing your command, add a JAVA_TOOL_OPTIONS secret.