This page last changed on Sep 13, 2006 by bob.swift@charter.net.

How to use Eclipse for Confluence plugin development

Eclipse can be used to make Confluence plugin development easier.

General setup

Plugin specific

The following assumes you have a somewhat standard plugin directory structure that you created or checked out from Subversion. For example:

xxx-plugin
   trunk
      src
         etc
         java
      target
  • Edit the project.xml file to make sure it contains all the dependencies needed
    • This must be done before generating the Eclipse project files
    • If the dependencies need to be changed later, the Eclipse project files will need to be re-generated and then in Eclipse, refresh your project using right click -> Refresh
  • Generate the Eclipse project and classpath files
    • From a command line, cd to the trunk directory
      cd .../xxx-plugin/trunk
      maven eclipse
      
  • Move the .project and .classfile files to the xxx-plugin directory
  • Import the project by pointing at the plugin directory (that now contains a .project file!)
    • Right click Import
    • Choose Existing Projects into Workspace
    • Customize the build path source using right click on project -> Build Path -> Configure Build Path
      • removing the default location
      • adding /trunk/src/etc
      • adding /trunk/src/java
      • adding /trunk (last)
  • Add MAVEN_REPO classpath variable to Eclipse
    • This only needs to be done for the first plugin you setup
    • MAVEN_REPO is used in the Maven generated .classpath file that contains references to all the dependencies defined to Maven in the project.xml and related files
    • Customize the build path libraries using right click on project -> Build Path -> Configure Build Path
    • Add a new variable that points to your maven repository directory

Summary

  • Eclipse should now analyse the plugin code and report errors
  • Once all errors are fixed in Eclipse, a maven build (run outside Eclipse) should be clean

new_variable.png (image/png)
MAVEN_REPO.png (image/png)
import2.png (image/png)
import1.png (image/png)
add_variable.png (image/png)
properties.png (image/png)

I've just started with this but I'm able to launch the standalone version of Confluence in a remote debugging mode through the following steps:

1) Specify the following in the environment variables (Windows):

 JAVA_OPTS = -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,suspend=y,server=y

2) Create a project in Eclipse, i.e. "Confluence", and on its Properties page, Java Build Path, Libraries tab click the Add External Jars... button and bring in all the jar files in the confluence/WEB_INF/lib directory

3) Import the source of any code you expect to be debugging during your session as well. Ensure the source package names match those of the ones used in Confluence.

4) Select your Confluence project in Eclipse and then via the menus go Run | Debug...  In the window that pops up, select the Remote Java Application in the tree on the left and then click the New button.

5) The following values should be set:

 Project:  <your project name>

 Connection Type: Standard (Socket Attach)

  Host: localhost

  Port: 8000

6) Click Apply and close the window.

7) Set any breakpoints in your source or exception handlers as appropriate and then execute the Confluence startup.bat launcher. 

6) Tomcat will try to startup and then seem to hang, it is waiting for the debugger to communicate with it so go back to Eclipse and launch the debugger using your new configuration you just created. Tomcat & Confluence should then continue to boot.

7) Exercise Confluence to get to invoke your relevant plugin and Eclipse should jump in when it hits your breakpoint or exception. 

 

- - - -

If anyone knows more, I'd like to know how to reference ALL the altassian class files in the Eclipse project since Eclipse seems to prefer .jar files.

I'd also like to avoid setting the environment variable in my system by having two separate startup.bat files, one that operates normally and another that inserts the java VM arguments without going through an environment variable..any suggestions?

 Enjoy,
Brian 

 

Posted by b.remedios at Feb 01, 2006 15:30

Should also integrate WTP instructions from http://jira.atlassian.com/browse/JRA-8749

Posted by jnolen at Feb 01, 2006 15:46

> I'd like to know how to reference ALL the altassian class files in the Eclipse project since Eclipse seems to prefer .jar files.

You can get ALL dependencies as jars in the Confluence Plugin Development Kit, including the ones that are in the main Confluence distribution (and therefore not jar'ed up in the standalone version).

Posted by jnolen at Feb 01, 2006 15:53

I started using the "Mevenide" plugin.  I was unable to get maven working through eclipse any other way under version 1.X.X.

Maven 2.0 was very easy to get running through Eclipse, but this page lead me to believe I needed to stay on Maven 1.   Is this true?

Posted by prpht9 at Sep 08, 2006 11:45

Yes, we're slowing working our way towards Maven 2, but we're not there yet. You'll need to continue using Maven 1 for the time being.

Cheers,
Jonathan

Posted by jnolen at Sep 08, 2006 14:28

This appears to download *all* the referenced jars everytime I start a new project. Is this avoidable?

Posted by mo-seph at Nov 04, 2006 09:24

It should only download the jars the first time, assuming your plugins are all referencing the same version of Confluence. My guess is that it is actually trying to download the sourcecode jar files every time, most of which don't exist, so it tries again every time. Try adding the following to your project.properties file:

maven.eclipse.src.download = false

More info can be found here.

Posted by david@randombits.org at Nov 04, 2006 09:53

The link to the Maven 1 Eclipse plugin is broken (as are the links on the apache mirrors page).

http://people.apache.org/repo/m1-ibiblio-rsync-repository/maven/plugins/ will get you where you want to be.

Posted by pip at Dec 07, 2006 05:31
Document generated by Confluence on Mar 22, 2007 21:01