Using the CloudBees Maven Plug-in with Eclipse

Written by: Hannah Inman

Cloud Platform

3 min read

Stay connected

In a recent blog post (Getting Started with CloudBees and Eclipse ), I showed an example of using the CloudBees Maven Plug-in from within the Eclipse IDE. For that project, I simply imported a sample project from GitHub - however, if you want to build something from scratch, here's how to do it.

Make sure that you have all the correct Eclipse plug-ins installed and correctly configured first (as a minimum, you'll want the CloudBees and m2e plug-ins; you'll probably also want eGit and/or one of Subclipse/Subversive for the CloudBees Forge Repository integration).

Create a new Maven project (New -> Maven -> Maven Project), select your project directory and choose maven-archetype-webapp as the Archetype, as shown below:

Edit the <build> stanza of your project POM to include the bees-maven-plugin, like this (insert the text in bold ):

  <build>
     <plugins>
       <plugin>
         <groupId>com.cloudbees</groupId>
         <artifactId>bees-maven-plugin</artifactId>
         <version>1.0-SNAPSHOT</version>
       </plugin>
     </plugins>    
     <finalName>RESTexample</finalName>
   </build> 

If this is the first time you have used the bees-maven-plugin (or if it isn't present in your local Maven repository for any reason), then you will also want to add the following entry to pick it up from the CloudBees repository. If you already have a <pluginRepositories> stanza, then just add the lines in bold .

  <pluginRepositories>
    <pluginRepository>
      <id>bees-plugins-snapshots</id>
      <url>http://repository-cloudbees.forge.cloudbees.com/public-snapshot/</url>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </pluginRepository> 
  </pluginRepositories>

Create a Maven Run Configuration to invoke the bees:run goal by right-clicking on the POM file and choosing Run As -> Run Configurations... Choose a name (note that you can't use a colon) and specify the bees:run goal, like this.

I usually keep my Run Configuration files with the project, which you can do by clicking on Browse Workspace and then choosing the project for the base directory. Then to save the Run Configuration as a file (beesrun.launch) for re-use, just switch to the Common tab, select Shared file and browse to the project folder.

Now you can right-click on the Run Configuration file you just created and that will run your custom Maven run configuration (mvn bees:run). You can see the output in the console:

To learn more about the CloudBees Maven Plug-in, just run the following command from your project directory (which has the project POM file):

mvn help:describe \
   -Dplugin=com.cloudbees:bees-maven-plugin:1.0-SNAPSHOT -Ddetail

You will see (for example) that the listen port used by the embedded Tomcat server is controlled by ${bees.port}, so if you want to run on a different port you can simply add -Dbees.port=8081 to your Maven goal, like this:

Cheers,

Mark

By Mark Prichard , CloudBees

Mark Prichard is Java PaaS Evangelist and Senior Director of Product Management at CloudBees. He came to CloudBees after 13 years at BEA Systems and Oracle, where he was Product Manager for the WebLogic Platform. A graduate of St John's College, Cambridge and the Cambridge University Computer Laboratory, Mark is based at the CloudBees office in Los Altos, CA. Follow Mark on twitter and his blog Clouds, Bees and Blogs.

CloudBees and Eclipse: The Video Series

You may also enjoy this video tour of CloudBees and Eclipse...

CloudBees and Eclipse Overview

Getting Started with CloudBees and Eclipse: Part 1

Getting Started with CloudBees and Eclipse: Part 2

Getting Started with CloudBees and Eclipse: Part 3

Getting Started with CloudBees and Eclipse: Part 4

Getting Started with CloudBees and Eclipse: Part 5

Getting Started with CloudBees and Eclipse: Part 6

Stay up to date

We'll never share your email address and you can opt out at any time, we promise.

Loading form...
Your ad blocker may be blocking functionality on this page. Please disable for an improved experience.