Question

I need to work with the Confluence API.

I work with Maven POM but I don't find how to insert the dependencies for the Confluence API.

Can you help me?

What I've already tried:
I need to work with the SpaceManager primaly.
I found this tutorial about managing the pom. So after the tutorial, my pom looks like the following:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>***.createspace</groupId>
    <artifactId>CreateSpace</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>CreateSpace</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>maven-confluence-plugin</artifactId>
                <version>3.2.3</version>
                <extensions>true</extensions>
                <configuration>
                    <productVersion>${product.version}</productVersion>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.confluence</groupId>
            <artifactId>confluence</artifactId>
            <version>${confluence.version}</version>
            <scope>provided</scope>    <!-- important! -->
        </dependency>
    </dependencies>
</project>

The *** in the groupId is just to hide my package name of my company.

But also with this pom, I get the error The import com.atlassian cannot be resolved with this import:

import com.atlassian.confluence.spaces.SpaceManager;

So can you help me? Or please tell me what I should add to avoid downvotes, then I hope you see I really searched in the net and need help!

Was it helpful?

Solution

There are instructions how to work with atlassian maven repo Atlassian Maven Repositories and the repo URL is provided: https://maven.atlassian.com/repository/public

<!-- language: xml -->
<repository>
  <id>atlassian-public</id>
  <url>https://maven.atlassian.com/repository/public</url>
  <snapshots>
    <enabled>true</enabled>
    <updatePolicy>never</updatePolicy>
    <checksumPolicy>warn</checksumPolicy>
  </snapshots>
   <releases>
     <enabled>true</enabled>
     <checksumPolicy>warn</checksumPolicy>
  </releases>
</repository>

If you're trying to add a plugin for confluence WIKI you'll probably need a dependency to:

<!-- language: xml -->
<groupId>com.atlassian.confluence</groupId>
<artifactId>confluence</artifactId>

( only once you add the atlassian maven repo to your pom.xml ) so full pom.xml will look like this:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>org.vilutis.lt</groupId>
    <artifactId>confluence-plugin</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>confluence-plugin</name>

    <repositories>
        <repository>
            <id>atlassian-public</id>
            <url>https://maven.atlassian.com/repository/public</url>
            <snapshots>
                <enabled>true</enabled>
                <updatePolicy>never</updatePolicy>
                <checksumPolicy>warn</checksumPolicy>
            </snapshots>
            <releases>
                <enabled>true</enabled>
                <checksumPolicy>warn</checksumPolicy>
            </releases>
        </repository>
    </repositories>

    <!-- I had to add this section because activation-1.0.2.jar does not exist in public maven repo -->
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>javax.activation</groupId>
                <artifactId>activation</artifactId>
                <version>1.1</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>com.atlassian.confluence</groupId>
            <artifactId>confluence</artifactId>
            <version>5.2</version>
        </dependency>
    </dependencies>
</project>

This config works fine with version 5.2 and the SpaceManager class is accessible in your java code.

OTHER TIPS

I'm not sure with Confluence API implementation you're using. You could try this:

<dependency>
  <groupId>org.jvnet.hudson</groupId>
  <artifactId>confluence-api</artifactId>
  <version>1.0</version>
</dependency>

If you're using an implementation that doesn't support maven builds, then you'll have to add the transitive dependencies yourself.

In this case confluent.version is 3.0.0

    <dependency>
        <groupId>io.confluent</groupId>
        <artifactId>common-config</artifactId>
        <version>${confluent.version}</version>
    </dependency>
    <dependency>
        <groupId>io.confluent</groupId>
        <artifactId>common-utils</artifactId>
        <version>${confluent.version}</version>
    </dependency>
    <dependency>
        <groupId>io.confluent</groupId>
        <artifactId>kafka-schema-registry-client</artifactId>
        <version>${confluent.version}</version>
    </dependency>
    <dependency>
        <groupId>io.confluent</groupId>
        <artifactId>kafka-avro-serializer</artifactId>
        <version>${confluent.version}</version>
    </dependency>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top