Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.crob1140:confluence-java-client:v1.0.0'
}
dependencies {
implementation("com.github.crob1140:confluence-java-client:v1.0.0")
}
<dependency>
<groupId>com.github.crob1140</groupId>
<artifactId>confluence-java-client</artifactId>
<version>v1.0.0</version>
</dependency>
libraryDependencies += "com.github.crob1140" % "confluence-java-client" % "v1.0.0"
:dependencies [[com.github.crob1140/confluence-java-client "v1.0.0"]]
A simple Java client for the Confluence Cloud REST API
To add this package to a Gradle project, add the following to your build.gradle:
repositories {
mavenCentral()
}
dependencies {
compile group: 'com.github.crob1140', name: 'confluence-java-client', version: '1.0.0'
}
Create a new client instance:
WebTarget wikiTarget = ClientBuilder.newClient().target("http://www.sample.atlassian.net/wiki");
AuthMethod basicAuth = new BasicAuth("username", "password");
Confluence client = new ConfluenceClient(wikiTarget, basicAuth);
Create some content:
Content newPage = client.createContent(new CreateContentRequest.Builder()
.setType(StandardContentType.PAGE)
.setSpaceKey("SAMPLE")
.setTitle("Sample Page")
.setBody(ContentBodyType.STORAGE, "<ac:rich-text-body><p>SAMPLE</p></ac:rich-text-body>")
.build());
Get existing content:
List<Content> existingPages = client.getContent(new GetContentRequest.Builder()
.setSpaceKey("SAMPLE")
.setTitle("Sample Page")
.setExpandedProperties(new ExpandedContentProperties.Builder().addVersion().build())
.setLimit(1)
.build())
Update existing content:
Content updatedContent = client.updateContent(new UpdateContentRequest.Builder()
.setId(existingPage.getId())
.setType(existingPage.getType())
.setStatus(ContentStatus.CURRENT)
.setBody(ContentBodyType.STORAGE, "<ac:rich-text-body><p>Updated body</p></ac:rich-text-body>")
.setVersion(existingPage.getVersion().getNumber() + 1)
.build())
This client is a work-in-progress, and API methods will be added iteratively. If there is a particular feature you would like added, feel free to raise it as an issue, or fork the repository and create a pull request with your own changes.
MIT