Triggering Maven profiles from Heroku configured Environment Variables

You can do this without a custom build pack.

Use this snippet in your pom.xml to display all properties available on Heroku and pick one that is not in your local: http://florianlr.wordpress.com/2012/04/24/16/

I used env.DYNO

    <profile>
        <id>heroku</id>
        <activation>
            <property>
                <name>env.DYNO</name>
            </property>
        </activation>
    ...
    </profile>
    ...

Works like a charm:)


Or you can introduce your own customized Maven settings.xml file, e.g. heroku-settings.xml:

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

    <!-- activate by setting the MAVEN_SETTINGS_PATH config var to heroku-settings.xml in Heroku project settings tab.
    See https://devcenter.heroku.com/articles/using-a-custom-maven-settings-xml for more details.
     -->

    <activeProfiles>
        <activeProfile>production</activeProfile>
    </activeProfiles>
</settings>

Then activate the settings by setting the MAVEN_SETTINGS_PATH config var to heroku-settings.xml in Heroku project settings tab

Tags:

Maven

Heroku