Search code examples
mavencloud-foundrymaven-invoker-plugin

Location of Maven Home on Cloud Foundry


I have an application that programmatically runs Maven command "clean package" at runtime, using plugin maven-invoker. To be able to run this application on Cloud Foundry, we need to set Maven Home on the invoker.

This question is similar to Maven Invoker: IllegalStateException, except that we are deploying on Cloud Foundry but don't know how to get the value for Maven Home.

Is it possible to get it from CF environment?


Solution

  • The Java build pack does not install Maven or set any Maven related environment variables. You can however set whatever environment variables that you like via cf set-env or in the env block of your manifest.yml file.

    https://docs.cloudfoundry.org/devguide/deploy-apps/manifest.html#env-block

    Your app when running on CF will run as the vcap user and it runs out of /home/vcap/app (or reference $HOME env variable). If you need to pick a location to use for Maven home, I would suggest putting it under that directory.