This documentation relates to the latest version of Confluence.
If you are using an earlier version, please go to the documentation home page and select the relevant version.

Building Confluence From Source Code

All Versions

Confluence 3.0 Documentation

This guide describes building a confluence.war distribution or an IDE project from the Confluence source code. Plugin developers who wish to use source code as an aid in building plugins should refer to the plugin documentation. This process should be simple and quick, so please let us know if you get stuck.

Building a WAR distribution

  1. Download Confluence source code.
    Source code access is available for commercial license holders. If you do not have access to the source code download site, log in to my.atlassian.com as your billing contact or contact our sales department.
    Please be aware that while Confluence's source code is available to licensed customers, this does not apply to the Confluence Office Connector.
  2. Confluence is built using Maven. Maven is bundled with the source distribution and therefore does not need to be installed separately. When you build Confluence, Maven will download dependencies and store them in a local repository. One of these dependencies requires manual installation for legal distribution reasons. If you do not already have it in your private repository, download JavaMail from Sun's website.
    Sun will not allow Maven to redistribute its binaries. You must install all Sun binaries manually by downloading them from Sun's website and running the mvn install command. Maven has provided documentation for both 3rd party jars in general and Sun jars in particular.

    Unzip the mail.jar file from the javamail-1_x_x.zip file. From the root of your extracted source code directory, run the following command, where Path/To/mail.jar is the absolute path to the extracted mail.jar file.:

    .\maven\bin\mvn install:install-file -DgroupId=javax.mail -DartifactId=mail -Dversion=1.x.x -Dpackaging=jar -Dfile=Path/To/mail.jar
    
  3. Run your build script.

If the build is run successfully you should have a confluence.war file created in ../confluence-project/conf-webapp/target/.

Option 1: Building the Confluence Project or Individual Libraries using IDEA

This is the simplest option. From IDEA, go to File >> Open Project. Browse to the pom.xml file of the individual project. If you are wanting to compile the Confluence project (as opposed to one of the libraries, say Atlassian User), use the pom.xml file from the confluence-project file.

Using the pom.xml at the root of the distribution to load the Confluence project and all its dependencies usually results in classloading errors. If you want to debug a dependency and the confluence core together, you'll have to integrate the projects.

Option 2: Building the Confluence Project or Individual Libraries Using Maven

Each Confluence Library is bundled with its own Maven pom file. To build one of the sub-projects, you need not build the entire source. To use the bundled maven distribution:

  1. Copy build.sh or build.bat to the appropriate sub-directory.
  2. Change M2_HOME to point to the parent directory, as so:
    build.sh:
    export M2_HOME="$PWD/../maven
    

    build.bat:

    set M2_HOME=..\maven
    

Building an Intellij Idea or an Eclipse project

  1. To build a project for an IDE, you can use the instructions above, but modify the build.sh or build.bat mvn command. Replace:
    exec mvn clean package -Dmaven.test.skip $* with:
    
    exec mvn idea:idea or exec mvn eclipse:eclipse
    

    This should leave a project file in the root of your source directory. It should have all the confluence modules.

  2. Download Intellij IDEA.
  3. Install Tomcat and get it running.
  4. In your Confluence source tree, edit confluence-project/conf-webapp/src/main/resources/confluence-init.properties. Set your home directory.
  5. From Preferences > Application Servers add Tomcat



  6. From Run > Edit Configurations, add a Tomcat Configuration. Select to deploy the confluence-webapp module to the appserver:



  7. Click Configure and configure how to deploy. Choose to Create web module exploded directory and exclude from module content:



  8. From the server tab, you might set some memory settings like:
    -XX:MaxPermSize=256M -Xmx512m
    
  9. Run the application. Have fun!

Creating a Server for Eclipse

In Eclipse creating a server defines creating a pointer to an existing installation of an application server.
To create a server:
Window->Show View->Servers
Right Click and select New->Server
In the menu bar click File->New->Other and expand the server folder and select the version of the serer you have installed on your system.
Click Next and the New Server wizard opens.  This wizard defines a new server, that contains information required to point to a specific runtime environment for local or remote testing, or for publishing to an application server. By default, this field is pre-filled with the default address: localhost

Supported Servers in Eclipse:
 

  1. Eclipse view after adding Tomcat

    Troubleshooting and Technical Support

If you get a class not found error, you may need to replace a jar file in your maven repository. Try our [forums].

Atlassian encourages our community to make use of our source code. Please be aware that upgrades may require additional modifications.

Source code modifications are not supported by Atlassian Support.

RELATED TOPICS:

FAQ and Troubleshooting
How to Build an Atlassian Plugin
Working with Sun Java Libraries

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Aug 13, 2008

    Anonymous says:

    Pls add a note that you need to configure the Public Atlassian Maven Repo as wel...

    Pls add a note that you need to configure the Public Atlassian Maven Repo as well:

    http://confluence.atlassian.com/display/DEVNET/Atlassian+Maven+Repositories\\

  2. Aug 13, 2008

    Anonymous says:

    In addition to mail-1.3.2 mail-1.3.3 and activation-1.0.2 are also needed.

    In addition to mail-1.3.2 mail-1.3.3 and activation-1.0.2 are also needed.

  3. Nov 04, 2008

    Anonymous says:

    Hello, I seem to be stuck. Is there an eclipse equivalent for the steps 6 and 7...

    Hello,

    I seem to be stuck. Is there an eclipse equivalent for the steps 6 and 7, as shown in the Intelji IDEA instruction?

    Greetings

    Martin

    1. Nov 05, 2008

      Azwandi Mohd Aris says:

      Hi Martin, Have you given a try on the "Creating a Server for Eclipse", furthe...

      Hi Martin,

      Have you given a try on the "Creating a Server for Eclipse", further down the page?

      Cheers,
      Azwandi

  4. Dec 03, 2008

    Anonymous says:

    It should be noted that version 1.3.x of the MailAPI should be used, not 1.4.x. ...

    It should be noted that version 1.3.x of the MailAPI should be used, not 1.4.x. Please see this issue: http://jira.atlassian.com/browse/CONF-13908

  5. Jan 14

    Anonymous says:

    I somehow don't get it . At first I unpacked the confluence-2.10.1-source.zip t...

    I somehow don't get it .

    At first I unpacked the confluence-2.10.1-source.zip to a folder. Strange that WinZip asked me if I want to overwrite the license.txt file...

    After that I got a folder called confluence-2.10.1-source. In that folder many subfolders and the build.bat, build.sh and pom.xml file. Changed to subfolder "confluence-project", copied the build.bat into it. Installed mail.jar.

    After that running build.bat in "confluence-project" folder gives me many errors like these, anybody an idea?:

    \[INFO\] \-----------------------------------------------------------------------\-
    \[ERROR\] BUILD FAILURE
    \[INFO\] \-----------------------------------------------------------------------\-
    \[INFO\] Compilation failure
     C:\AZ_DATEN\confluence-2.10.1-source\confluence-project\confluence-upgrade\src\main\java\com\atlassian\conflue
    nce\upgrade\UpgradeManager.java:\[3,28\] package com.atlassian.johnson does not exist
     C:\AZ_DATEN\confluence-2.10.1-source\confluence-project\confluence-upgrade\src\main\java\com\atlassian\conflue
    nce\upgrade\UpgradeManager.java:\[17,17\] cannot find symbol
    symbol  : class JohnsonEventContainer
    location: interface com.atlassian.confluence.upgrade.UpgradeManager
     C:\AZ_DATEN\confluence-2.10.1-source\confluence-project\confluence-upgrade\src\main\java\com\atlassian\conflue
    nce\upgrade\UpgradeException.java:\[3,40\] package org.apache.commons.lang.exception does not exist
     C:\AZ_DATEN\confluence-2.10.1-source\confluence-project\confluence-upgrade\src\main\java\com\atlassian\conflue
    nce\upgrade\UpgradeException.java:\[5,38\] cannot find symbol
    symbol: class NestableException
    public class UpgradeException extends NestableException
     C:\AZ_DATEN\confluence-2.10.1-source\confluence-project\confluence-upgrade\src\main\java\com\atlassian\conflue
    nce\upgrade\UpgradeLifecycleItem.java:\[3,37\] package com.atlassian.config.lifecycle does not exist
  6. Apr 08

    Kapil Verma says:

    I tried to build the war file from source distribution, but it failed. Below is ...

    I tried to build the war file from source distribution, but it failed. Below is the result of it. Could you pl help me out?

    ----------------------------------------------------------------------------------

    C:\confluence-2.10.2-source\confluence-2.10.2-source>mvn install:install-file -D
    groupId=javax.mail -DartifactId=mail -Dversion=1.4.2 -Dpackaging=jar -Dfile=C:/d
    ownloads/mail-1.4.2.jar
    [INFO] Scanning for projects...
    Downloading: http://repo1.maven.org/maven2/com/atlassian/pom/atlassian-public-po
    m/15/atlassian-public-pom-15.pom
    [INFO] Unable to find resource 'com.atlassian.pom:atlassian-public-pom:pom:15' i
    n repository central (http://repo1.maven.org/maven2)
    [INFO] ------------------------------------------------------------------------
    [ERROR] FATAL ERROR
    [INFO] ------------------------------------------------------------------------
    [INFO] Failed to resolve artifact.

    GroupId: com.atlassian.pom
    ArtifactId: atlassian-public-pom
    Version: 15

    Reason: Unable to download the artifact from any repository

      com.atlassian.pom:atlassian-public-pom:pom:15

    from the specified remote repositories:
      central (http://repo1.maven.org/maven2)

    [INFO] ------------------------------------------------------------------------
    [INFO] Trace
    org.apache.maven.reactor.MavenExecutionException: Cannot find parent: com.atlass
    ian.pom:atlassian-public-pom for project: com.atlassian.bucket:atlassian-bucket:
    jar:1.3 for project com.atlassian.bucket:atlassian-bucket:jar:1.3
            at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:432)
            at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:300)
            at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:137)
            at org.apache.maven.cli.MavenCli.main(MavenCli.java:356)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
    java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:585)
            at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
            at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
            at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)

            at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
    Caused by: org.apache.maven.project.ProjectBuildingException: Cannot find parent
    : com.atlassian.pom:atlassian-public-pom for project: com.atlassian.bucket:atlas
    sian-bucket:jar:1.3 for project com.atlassian.bucket:atlassian-bucket:jar:1.3
            at org.apache.maven.project.DefaultMavenProjectBuilder.assembleLineage(D
    efaultMavenProjectBuilder.java:1398)
            at org.apache.maven.project.DefaultMavenProjectBuilder.buildInternal(Def
    aultMavenProjectBuilder.java:823)
            at org.apache.maven.project.DefaultMavenProjectBuilder.buildFromSourceFi
    leInternal(DefaultMavenProjectBuilder.java:508)
            at org.apache.maven.project.DefaultMavenProjectBuilder.build(DefaultMave
    nProjectBuilder.java:200)
            at org.apache.maven.DefaultMaven.getProject(DefaultMaven.java:632)
            at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:515)
            at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:588)
            at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:419)
            ... 11 more
    Caused by: org.apache.maven.project.ProjectBuildingException: POM 'com.atlassian
    .pom:atlassian-public-pom' not found in repository: Unable to download the artif
    act from any repository

      com.atlassian.pom:atlassian-public-pom:pom:15

    from the specified remote repositories:
      central (http://repo1.maven.org/maven2)

     for project com.atlassian.pom:atlassian-public-pom
            at org.apache.maven.project.DefaultMavenProjectBuilder.findModelFromRepo
    sitory(DefaultMavenProjectBuilder.java:605)
            at org.apache.maven.project.DefaultMavenProjectBuilder.assembleLineage(D
    efaultMavenProjectBuilder.java:1394)
            ... 18 more
    Caused by: org.apache.maven.artifact.resolver.ArtifactNotFoundException: Unable
    to download the artifact from any repository

      com.atlassian.pom:atlassian-public-pom:pom:15

    from the specified remote repositories:
      central (http://repo1.maven.org/maven2)

            at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(De
    faultArtifactResolver.java:228)
            at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(De
    faultArtifactResolver.java:90)
            at org.apache.maven.project.DefaultMavenProjectBuilder.findModelFromRepo
    sitory(DefaultMavenProjectBuilder.java:558)
            ... 19 more
    Caused by: org.apache.maven.wagon.ResourceDoesNotExistException: Unable to downl
    oad the artifact from any repository
            at org.apache.maven.artifact.manager.DefaultWagonManager.getArtifact(Def
    aultWagonManager.java:349)
            at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(De
    faultArtifactResolver.java:216)
            ... 21 more
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 1 second
    [INFO] Finished at: Wed Apr 08 14:43:47 IST 2009
    [INFO] Final Memory: 1M/3M
    [INFO] ------------------------------------------------------------------------
    C:\confluence-2.10.2-source\confluence-2.10.2-source>

    1. Apr 08

      Ming Giet Chong says:

      Hi Kapil, Please setup your settings.xml in your C:\USERPROFILE\.m2 directory a...

      Hi Kapil,

      Please setup your settings.xml in your C:\USERPROFILE\.m2 directory as per the Example. Do not worry about the username and passwords.
      The reason it failed previously is that you have not set up the atlassian proxys in your settings.xml, thus maven could not find the needed artifacts. Please let us know how it goes. If the problem still persists, please raise a support ticket via https://support.atlassian.com and attach the settings.xml to the case.

      Regards,
      MG
      Atlassian Support

Add Comment


Except where otherwise noted, content in this space is licensed under a Creative Commons Attribution 2.5 Australia License.