Fork me on GitHub jcabi

23-Sep-2013 0.8

Deploying JAR/WAR/EAR projects to Heroku

Create new application in Heroku.

Download Heroku SSH key (heroku.pem) and put it somewhere outside of project directory (in your CI server). Configure the server (and its private key) in settings.xml

<settings>
  <servers>
    <server>
      <id>heroku.com</id>
      <privateKey>${user.home}/.ssh/id_rsa</privateKey>
    </server>
  </servers>
</settings>

Configure jcabi-heroku-maven-plugin in your pom.xml:

<project>
  <build>
    <plugins>
      <plugin>
        <groupId>com.jcabi</groupId>
        <artifactId>jcabi-heroku-maven-plugin</artifactId>
        <version>0.8</version>
        <configuration>
          <server>heroku.com</server> <!-- name from settings.xml -->
          <name>my-test-app</name>
          <artifacts>
            <artifact>${project.groupId}:${project.artifactId}:jar::${project.version}</artifact>
          </artifacts>
          <procfile>web: java -Xmx256m -jar ./${project.artifactId}.jar ${PORT}</procfile>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>deploy</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

Every artifact will be downloaded during deployment into the root directory of the application (in Heroku server). Maven coordinates are used to specify artifact locations (always five parts). Downloaded artifacts are renamed to artifactId.packaging format.

Run mvn deploy.

If you have any problems - don't hesitate to submit a ticket to github.

Cutting Edge Version

If you want to use current version of the product, you can do it with this configuration in your pom.xml:

<pluginRepositories>
  <pluginRepository>
    <id>oss.sonatype.org</id>
    <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
  </pluginRepository>
</pluginRepositories>
<build>
  <plugins>
    <plugin>
      <groupId>com.jcabi</groupId>
      <artifactId>jcabi-heroku-maven-plugin</artifactId>
      <version>1.0-SNAPSHOT</version>
      [...]
    </plugin>
  </plugins>
</build>

Copyright © 2012-2013 jcabi.com, All Rights Reserved. Privacy Policy.

site is built by Apache Maven