Using the CloudBees Maven Plug-in with Eclipse

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:

CloudBees Maven Plug-in

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.

Maven Run Configuration

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. 

Maven Run Configuration

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:

custom Maven run configuration

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:

Maven run configuration add port

 

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… 

Comments

By the way http://mojo.codehaus.org/mojo-archetypes/webapp-javaee6/ and related archetypes are more actively developed and explicitly set Java EE API dependencies for you.

hi, i m trying to run and deploy my own app and i m encountering problems. Could you help me?<br /><br />this is the stack trace when i try to do mvn bees:run<br /><br />[WARNING] The POM for com.cloudbees:bees-maven-plugin:jar:1.3.2 is missing, no dependency information available<br />[WARNING] Failed to retrieve plugin descriptor for com.cloudbees:bees-maven-plugin:1.3.2: Plugin com.cloudbees:bees-maven-plugin:1.3.2 or one of its dependencies could not be resolved: Failed to read artifact descriptor for com.cloudbees:bees-maven-plugin:jar:1.3.2<br />Downloading: http://localhost:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-metadata.xml<br />Downloading: http://localhost:8081/nexus/content/groups/public/com/atlassian/maven/plugins/maven-metadata.xml<br />Downloading: http://localhost:8081/nexus/content/groups/public/com/cloudbees/maven-metadata.xml<br />Downloading: http://localhost:8081/nexus/content/groups/public/org/clickframes/maven-metadata.xml<br />Downloading: http://localhost:8081/nexus/content/groups/public/org/codehaus/mojo/maven-metadata.xml<br />Downloaded: http://localhost:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-metadata.xml (12 KB at 40.2 KB/sec)<br />Downloaded: http://localhost:8081/nexus/content/groups/public/com/atlassian/maven/plugins/maven-metadata.xml (389 B at 1.3 KB/sec)<br />Downloaded: http://localhost:8081/nexus/content/groups/public/com/cloudbees/maven-metadata.xml (250 B at 0.8 KB/sec)<br />Downloaded: http://localhost:8081/nexus/content/groups/public/org/codehaus/mojo/maven-metadata.xml (26 KB at 178.6 KB/sec)<br />[INFO] ------------------------------------------------------------------------<br />[INFO] BUILD FAILURE<br />[INFO] ------------------------------------------------------------------------<br />[INFO] Total time: 2.025s<br />[INFO] Finished at: Wed Oct 17 13:54:40 CEST 2012<br />[INFO] Final Memory: 5M/81M<br />[INFO] ------------------------------------------------------------------------<br />[ERROR] No plugin found for prefix 'bees' in the current project and in the plugin groups [org.clickframes, com.atlassian.maven.plugins, com.cloudbees, org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/Users/alonso/.m2/repository), nexus (http://localhost:8081/nexus/content/groups/public)] -> [Help 1]<br />[ERROR] <br />[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.<br />[ERROR] Re-run Maven using the -X switch to enable full debug logging.<br />[ERROR] <br />[ERROR] For more information about the errors and possible solutions, please read the following articles:<br />[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoPluginFoundForPrefixException<br /><br />I declare necesary tags in pom.xml <br /><br /> <br /> cloudbees-public-release<br /> http://repository-cloudbees.forge.cloudbees.com/public-release<br /> <br /> true<br /> <br /> <br /> false<br /> <br /> <br /> <br /><br /><br /> <br /> com.cloudbees<br /> bees-maven-plugin<br /> 1.3.2<br /> <br /></plugins<br /><br />I also tryed to proxy on my local nexus the url http://repository-cloudbees.forge.cloudbees.com/public-release but no way. <br />Could you help me a bit? <br /><br />Thx<br /><br />Alonso

Add new comment