February 10, 2017 | Written by: Ram Vennam
Categorized: Compute Services | How-tos
Share this post:
Bluemix has a rich plugin for Eclipse that makes it easy to deploy and manage cloud foundry applications. You can push wars/ears, Liberty server packages, consume services and manage your deployed applications. You can also do remote debugging, incremental updates, etc. Read more…
But what about IntelliJ?
Currently, there is no Bluemix plugin for IntelliJ, but you can do many of the deployment tasks using the powerful cf-maven-plugin. These tasks include push, start, stop, delete and scale applications as well as explore, create, bind, unbind and delete services. Best of all, it is very easy to set up.
Start by importing your project into IntelliJ. If you don’t have one, you can use https://github.com/IBM-Bluemix/java-helloworld.
Open up the pom.xml and add the following plugin inside <plugins>…</plugins>
<org>yourBluemiOrg..LikelyYourEmail</org> <!-- update -->
<space>dev</space> <!-- update -->
<appname>APPLICATION_NAME</appname> <!-- update -->
<url>UNIQUE_APPLICATION_URL.mybluemix.net</url> <!-- update -->
<username>firstname.lastname@example.org</username> <!-- update, insecure -->
<password>yourbluemixpassword</password> <!-- update, insecure -->
Security Note: Be careful to not share your pom.xml if you store your credentials like this. This method is easy to get started, but it is more secure to store your Bluemix credentials in your maven settings.xml file instead of the pom.xml. See https://docs.cloudfoundry.org/buildpacks/java/build-tool-int.html
Update the <configuration> elements to the appropriate values.
Next, in IntelliJ, click on View -> Tool Windows -> Maven projects
Double click on the cf:push goal to deploy your application. You should start seeing some log output and if all goes well, there will be a URL for you to click in a couple of minutes.
See recent logs by running cf:recentLogs. See detailed status of this app by running cf:app, or cf:apps for all your applications. Update the pom.xml configuration and run cf:scale to add/remove instances. You can also see all services available by running cf:service-plans (will take a few moments) and then add the service you want to your pom.xml to create them. For example, I can create and bind a Compose MySQL service by adding this to my pom.xml inside the <configuration> block.
Then run cf:push again.
Keep in mind that you can also run these maven goals directly from the command line.
The cf-maven-plugin is extremely useful when you want to deploy your application as part of your devops build. It allows for easy integration if you’re already doing maven builds as part of Jenkins. If you’re using Gradle instead of Maven, similar tasks are available using the cf-gradle-plugin.