How-tos

Deploy and manage Bluemix Java applications from IntelliJ

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…

Screen Shot 2017-02-01 at 3.12.52 PM

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.

Screen Shot 2017-02-01 at 2.32.01 PM

Open up the pom.xml and add the following plugin inside <plugins>…</plugins>

<plugin>
    <groupId>org.cloudfoundry</groupId>
    <artifactId>cf-maven-plugin</artifactId>
    <version>1.1.2</version>
    <configuration>
        <target>https://api.ng.bluemix.net</target>
        <org>yourBluemiOrg..LikelyYourEmail</org>        <!-- update -->
        <space>dev</space>                               <!-- update -->
        <appname>APPLICATION_NAME</appname>              <!-- update -->
        <url>UNIQUE_APPLICATION_URL.mybluemix.net</url>  <!-- update -->
        <memory>512</memory>
        <instances>1</instances>
        <username>yourbluemixid@email.com</username> <!-- update, insecure -->
        <password>yourbluemixpassword</password>     <!-- update, insecure --> 
    </configuration> 
</plugin>

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

Screen Shot 2017-02-01 at 3.05.39 PM

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.

Screen Shot 2017-02-01 at 3.25.53 PM

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.

<services>
    <service>
        <name>my-mysql-service</name>
        <label>compose-for-mysql</label>
        <plan>Standard</plan>
    </service>
</services>

Then run cf:push again.

Keep in mind that you can also run these maven goals directly from the command line.

Screen Shot 2017-02-01 at 3.42.52 PM

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.

Happy Coding!

IBM Cloud Technical Offering Manager

More How-tos stories
May 3, 2019

Kubernetes Tutorials: 5 Ways to Get You Building Fast

Ready to start working with Kubernetes? Want to build your Kubernetes skills? The five tutorials in this post will teach you everything you need to know about how to manage your containerized apps with Kubernetes.

Continue reading

May 3, 2019

Using Portworx to Deploy and Manage an HA MySQL Cluster on IBM Cloud Kubernetes Service

This tutorial is a walkthrough of the steps involved in deploying and managing a highly available MySQL cluster on IBM Cloud Kubernetes Service.

Continue reading

May 2, 2019

Kubernetes v1.14.1 Now Available in IBM Cloud Kubernetes Service

We are excited to announce the availability of Kubernetes v1.14.1 for your clusters that are running in IBM Cloud Kubernetes Service. IBM Cloud Kubernetes Service continues to be the first public managed Kubernetes service to support the latest upstream versions from the community.

Continue reading