Thursday, December 19, 2013

Adding an Eclipse Project to Heroku

I'm still picking up the pieces, just want to record what I did, not that I fully understand every step.

Heroku has tutorials on creating Java app from command line and using Eclipse. The Eclipse tutorial shows you how to use the plug-in to create the Heroku project. I want to see how I can create an independent Maven project in Eclipse, then push it up to Heroku.

This writing assumes your Heroku account and git is all setup properly.

1. I created a Maven project inside Eclipse. I used the Spring MVC archetype from here:

I noticed that Git is not happy when I created the project in default workspace. Not sure why, so I picked a separate spot. Since Heroku plugin uses "C:\Users\ymeng\git", so I just picked that spot.

2. I added the Procfile, here is the content
web: java $JAVA_OPTS -jar target/dependency/webapp-runner.jar --port $PORT target/*.war

3. I added the following to the pom.xml
4. In Eclipse, right click the project, select "Team", then follow the options to pick "git" 

5. I set the .gitignore in my project root directory to:
6. Then go to "Team" again, and select "commit", pick the files (i picked all). Now your project is committed.
7. This step, i have to do it from the command line:
go to your project root directory, assuming you logged to Heroku already, run "heroku create yourappname". This step will create the git remote for you and also setup "yourappname" on Heroku site for you.
8. Go to "Team" again, select "remote > push", it will asks you to put in your "master" branch.

If all works fine, then your app is on Heroku now.