In this article we will discuss how can we integrate our Eclipse IDE to OpenShift and create new applications. In previous articles we discussed about how we can connect to OpenShift and create application through command line and management console ? But of-course it would be really great if we can create, build, test, modify and publish our applications directly from the IDE itself.
I am going to use Eclipse Juno, which is the latest eclipse IDE and will create a sample JBossAS-7 application
Download Eclipse Juno depending on your Operating System. I chose Windows-64 bit version. If you are already running an older version of Eclipse, you can always upgrade it or try to follow the same steps with little tweaks
Step-1: Start Eclipse and navigate to Help tab. Here select Eclipse Marketplace and search for JBoss Tools, click on install.
Select the OpenShift tools as shown in image :
Once done, click next and accept the License Agreements and then restart Eclipse. It will come up with a welcome page like below :
Step-2 : Lets create an application now. On the welcome page itself click on OpenShift Application. It will ask you to sign-in with your OpenShift account. Saving the password is completely your choice.
Now give a name to your application and select what type of application you want to create from the available options shown in below image. Also select the embedded cartridges, if you want to use any.
I am not using any embedded cartridge for now, now click next.
Here we get an option, whether we want to create a new project or would like to use an existing project. Also it is good to check the option for creating a server, which will help us to easily test and publish our application. Click next.
Now we need to setup clone destination, basically the application created on OpenShift Server will be cloned to this directory. Make sure that directory exists, before this setup
Step-3 : Now it is time to configure SSH keys, if you don’t.. you would end up with below.
Click on SSH2 Preferences to configure your keys. Navigate to Key Management and click on Generate RSA Key.
Let’s save the private key and click Ok.
Step-4 : Now you must add this public key to your OpenShift account. For this
login to your OpenShift account. Navigate to My Account page and add your Public Key there.
Let’s carry forward the Step-3 and click on finish. This will prompt you to enter a passphrase for your private key.
Click Ok and you will get a local copy of the application on your machine. You may see an error mark against your application in Package Explorer view, this can be solved by updating you maven configuration. Check below :
Step-5 : Now lets make some changes in to the application. I made a change in “index.html”. once you save this, you might get a popup stating that there has been a change in one of your file, would you like to publish it ? you can click on yes and the change would be pushed to OpenShift server.
Right click on your project and run the application on server.
This will first build your application :
and then it will publish it as well, see the changes that we made :
You can also navigate to the Servers tab, right click on your OpenShift Server and click on Publish.
If you want to tail the log files, check environment variables or try port-forwarding it is all there. See below :
So once the environment has been set, you can make multiple changes and can publish them at your will.