Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/6.x' into 'main'
Browse files Browse the repository at this point in the history
See #926

# Conflicts:
#	gradle.properties
  • Loading branch information
jmini committed Nov 28, 2024
2 parents 0e56d4f + 3693545 commit 7dfec10
Show file tree
Hide file tree
Showing 128 changed files with 742 additions and 1,362 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup JDK 8
- name: Setup JDK 11
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 8
java-version: 11
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: GitLab4j verify
Expand Down
45 changes: 8 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,69 +7,40 @@
GitLab4J™ API (gitlab4j-api) provides a full featured and easy to consume Java library for working with GitLab repositories via the GitLab REST API. Additionally, full support for working with GitLab webhooks and system hooks is also provided.

---
## Table of Contents
* [GitLab Server Version Support](#gitLab-server-version-support)<br/>
* [Using GitLab4J-API](#using-gitlab4j-api)<br/>
* [Java 8 Requirement](#java-8-requirement)<br/>
* [Javadocs](#javadocs)<br/>
* [Project Set Up](#project-set-up)<br/>
* [Usage Examples](#usage-examples)<br/>
* [Setting Request Timeouts](#setting-request-timeouts)<br/>
* [Connecting Through a Proxy Server](#connecting-through-a-proxy-server)<br/>
* [GitLab API V3 and V4 Support](#gitLab-api-v3-and-v4-support)<br/>
* [Logging of API Requests and Responses](#logging-of-api-requests-and-responses)<br/>
* [Results Paging](#results-paging)<br/>
* [Java 8 Stream Support](#java-8-stream-support)<br/>
* [Eager evaluation example usage](#eager-evaluation-example-usage)<br/>
* [Lazy evaluation example usage](#lazy%20evaluation-example-usage)<br/>
* [Java 8 Optional&lt;T&gt; Support](#java-8-optional-support)<br/>
* [Issue Time Estimates](#issue-time-estimates)<br/>
* [Making API Calls](#making-api-calls)<br/>
* [Available Sub APIs](#available-sub-apis)

---

> **Warning**
> If you are looking for our next major version `6.x.x` which is requiring **Java 11** as mimimal version and which is using Jakarta EE components using the `jakarta.*` packages instead of `javax.*` check the [`6.x` branch](https://github.com/gitlab4j/gitlab4j-api/tree/6.x).
> The `6.x.x` version is the one you need if you are using Spring Boot 3 and Spring Framework 6.0, .
## GitLab Server Version Support

GitLab4J-API supports version 11.0+ of GitLab Community Edition [(gitlab-ce)](https://gitlab.com/gitlab-org/gitlab-ce/) and GitLab Enterprise Edition [(gitlab-ee)](https://gitlab.com/gitlab-org/gitlab-ee/).

GitLab released GitLab Version 11.0 in June of 2018 which included many major changes to GitLab. If you are using GitLab server earlier than version 11.0, it is highly recommended that you either update your GitLab install or use a version of this library that was released around the same time as the version of GitLab you are using.
GitLab4J-API supports both GitLab Community Edition [(gitlab-ce)](https://gitlab.com/gitlab-org/gitlab-ce/) and GitLab Enterprise Edition [(gitlab-ee)](https://gitlab.com/gitlab-org/gitlab-ee/).

**NOTICE**:
As of GitLab 11.0 support for the GitLab API v3 has been removed from the GitLab server (see https://about.gitlab.com/2018/06/01/api-v3-removal-impending/). Support for GitLab API v3 will be removed from this library sometime in 2019. If you are utilizing the v3 support, please update your code to use GitLab API v4.

---
## Using GitLab4J-API

### **Java 8 Requirement**
As of GitLab4J-API 4.8.0, Java 8+ is now required to use GitLab4J-API.
### **Java 11 Requirement**
As of GitLab4J-API 6.0.0, Java 11+ is now required to use GitLab4J-API.

### **Javadocs**
Javadocs are available here: [![javadoc.io](https://javadoc.io/badge2/org.gitlab4j/gitlab4j-api/javadoc.io.svg)](https://javadoc.io/doc/org.gitlab4j/gitlab4j-api)


### **Project Set Up**
To utilize GitLab4J&trade; API in your Java project, simply add the following dependency to your project's build file:<br />

**Gradle: build.gradle**
```java
dependencies {
...
compile group: 'org.gitlab4j', name: 'gitlab4j-api', version: '5.7.0'
implementation group: 'org.gitlab4j', name: 'gitlab4j-api', version: '6.0.0-rc.6'
}
```

**NOTE:** Pulling dependencies may fail when using Gradle prior to 4.5. See [Gradle issue 3065](https://github.com/gradle/gradle/issues/3065#issuecomment-364092456)

**Maven: pom.xml**
```xml
<dependency>
<groupId>org.gitlab4j</groupId>
<artifactId>gitlab4j-api</artifactId>
<version>5.7.0</version>
<version>6.0.0-rc.6</version>
</dependency>
```

Expand All @@ -80,7 +51,7 @@ dependencies {
Just add this line at the top of your script:

```java
//DEPS org.gitlab4j:gitlab4j-api:5.7.0
//DEPS org.gitlab4j:gitlab4j-api:6.0.0-rc.6
```

**Ivy and SBT**<br/>
Expand Down Expand Up @@ -641,7 +612,7 @@ List<Runner> runners = gitLabApi.getRunnersApi().getAllRunners();
#### SearchApi
```java
// Do a global search for Projects
List<?> projects = gitLabApi.getSearchApi().globalSearch(SearchScope.PROJECTS, "text-to-search-for");
List<Project> projects = gitLabApi.getSearchApi().globalSearch(SearchScope.PROJECTS, "text-to-search-for");
```

#### ServicesApi
Expand Down
26 changes: 13 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

plugins {
id 'java-library'
id 'com.diffplug.spotless' version '6.2.0'
id 'com.diffplug.spotless' version '6.25.0'
id 'signing'
id 'maven-publish'
id 'io.github.gradle-nexus.publish-plugin' version '1.3.0'
Expand All @@ -15,17 +15,17 @@ wrapper {
group = 'org.gitlab4j'

dependencies {
api 'jakarta.activation:jakarta.activation-api:1.2.2'
api 'org.glassfish.jersey.inject:jersey-hk2:2.39.1'
api 'org.glassfish.jersey.core:jersey-client:2.39.1'
api 'org.glassfish.jersey.connectors:jersey-apache-connector:2.39.1'
api 'org.glassfish.jersey.media:jersey-media-multipart:2.39.1'
api 'org.glassfish.jersey.media:jersey-media-json-jackson:2.39.1'
api 'jakarta.servlet:jakarta.servlet-api:4.0.4'
testImplementation 'org.mockito:mockito-core:4.4.0'
testImplementation 'org.mockito:mockito-junit-jupiter:4.4.0'
api 'jakarta.activation:jakarta.activation-api:2.1.1'
api 'org.glassfish.jersey.inject:jersey-hk2:3.1.1'
api 'org.glassfish.jersey.core:jersey-client:3.1.1'
api 'org.glassfish.jersey.connectors:jersey-apache-connector:3.1.1'
api 'org.glassfish.jersey.media:jersey-media-multipart:3.1.1'
api 'org.glassfish.jersey.media:jersey-media-json-jackson:3.1.1'
api 'jakarta.servlet:jakarta.servlet-api:6.0.0'
testImplementation 'org.mockito:mockito-core:5.2.0'
testImplementation 'org.mockito:mockito-junit-jupiter:5.2.0'
testImplementation 'org.hamcrest:hamcrest-all:1.3'
testImplementation 'uk.org.webcompere:system-stubs-jupiter:1.2.0'
testImplementation 'uk.org.webcompere:system-stubs-jupiter:2.0.2'
testImplementation "org.junit.jupiter:junit-jupiter-api:5.10.4"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.10.4"
}
Expand All @@ -47,7 +47,7 @@ java {

compileJava.options.encoding = "UTF-8"
toolchain {
languageVersion = JavaLanguageVersion.of(8)
languageVersion = JavaLanguageVersion.of(11)
}
}

Expand Down Expand Up @@ -122,7 +122,7 @@ publishing {
release {
buildTasks = ['doRelease']
git {
requireBranch.set('main')
requireBranch.set('6.x')
}
}

Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version=5.8.1-SNAPSHOT
lastVersion=5.8.0
version=6.0.0-SNAPSHOT
lastVersion=6.0.0-rc.6

githubRepositoryOwner=gitlab4j
githubRepositoryName=gitlab4j-api
2 changes: 1 addition & 1 deletion jitpack.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
jdk:
- openjdk8
- openjdk11
10 changes: 5 additions & 5 deletions src/main/java/org/gitlab4j/api/AbstractApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import java.io.InputStream;
import java.net.URL;

import javax.ws.rs.NotAuthorizedException;
import javax.ws.rs.core.Form;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.StreamingOutput;
import jakarta.ws.rs.NotAuthorizedException;
import jakarta.ws.rs.core.Form;
import jakarta.ws.rs.core.MultivaluedMap;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.StreamingOutput;

import org.gitlab4j.api.GitLabApi.ApiVersion;
import org.gitlab4j.api.models.Group;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/gitlab4j/api/ApplicationSettingsApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.text.ParseException;
import java.util.Iterator;

import javax.ws.rs.core.Response;
import jakarta.ws.rs.core.Response;

import org.gitlab4j.api.models.ApplicationSettings;
import org.gitlab4j.api.models.Setting;
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/org/gitlab4j/api/ApplicationsApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.Response;
import jakarta.ws.rs.core.GenericType;
import jakarta.ws.rs.core.Response;

import org.gitlab4j.api.models.Application;

Expand Down Expand Up @@ -43,7 +43,8 @@ public List<Application> getApplications() throws GitLabApiException {
* @throws GitLabApiException if any exception occurs
*/
public List<Application> getApplications(int page, int perPage) throws GitLabApiException {
Response response = get(javax.ws.rs.core.Response.Status.OK, getPageQueryParams(page, perPage), "applications");
Response response =
get(jakarta.ws.rs.core.Response.Status.OK, getPageQueryParams(page, perPage), "applications");
return (response.readEntity(new GenericType<List<Application>>() {}));
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/gitlab4j/api/AuditEventApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import java.util.List;
import java.util.stream.Stream;

import javax.ws.rs.core.Form;
import javax.ws.rs.core.Response;
import jakarta.ws.rs.core.Form;
import jakarta.ws.rs.core.Response;

import org.gitlab4j.api.models.AuditEvent;
import org.gitlab4j.api.utils.ISO8601;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/gitlab4j/api/AwardEmojiApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import java.util.List;

import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.Response;
import jakarta.ws.rs.core.GenericType;
import jakarta.ws.rs.core.Response;

import org.gitlab4j.api.models.AwardEmoji;

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/gitlab4j/api/BoardsApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import java.util.Optional;
import java.util.stream.Stream;

import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.Response;
import jakarta.ws.rs.core.GenericType;
import jakarta.ws.rs.core.Response;

import org.gitlab4j.api.models.Board;
import org.gitlab4j.api.models.BoardList;
Expand Down Expand Up @@ -50,7 +50,7 @@ public List<Board> getBoards(Object projectIdOrPath) throws GitLabApiException {
*/
public List<Board> getBoards(Object projectIdOrPath, int page, int perPage) throws GitLabApiException {
Response response = get(
javax.ws.rs.core.Response.Status.OK,
jakarta.ws.rs.core.Response.Status.OK,
getPageQueryParams(page, perPage),
"projects",
getProjectIdOrPath(projectIdOrPath),
Expand Down Expand Up @@ -225,7 +225,7 @@ public List<BoardList> getBoardLists(Object projectIdOrPath, Long boardId) throw
public List<BoardList> getBoardLists(Object projectIdOrPath, Long boardId, int page, int perPage)
throws GitLabApiException {
Response response = get(
javax.ws.rs.core.Response.Status.OK,
jakarta.ws.rs.core.Response.Status.OK,
getPageQueryParams(page, perPage),
"projects",
getProjectIdOrPath(projectIdOrPath),
Expand Down
51 changes: 5 additions & 46 deletions src/main/java/org/gitlab4j/api/CommitsApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Stream;

import javax.ws.rs.core.Form;
import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import jakarta.ws.rs.core.Form;
import jakarta.ws.rs.core.GenericType;
import jakarta.ws.rs.core.MultivaluedMap;
import jakarta.ws.rs.core.Response;

import org.gitlab4j.api.models.Comment;
import org.gitlab4j.api.models.Commit;
Expand Down Expand Up @@ -662,42 +661,12 @@ public Stream<CommitStatus> getCommitStatusesStream(Object projectIdOrPath, Stri
* @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance (required)
* @param sha a commit SHA (required)
* @param state the state of the status. Can be one of the following: PENDING, RUNNING, SUCCESS, FAILED, CANCELED (required)
* @param status the CommitSatus instance hoilding the optional parms: ref, name, target_url, description, and coverage
* @param status the CommitSatus instance holding the optional parameters: ref, name, target_url, description, and coverage
* @return a CommitStatus instance with the updated info
* @throws GitLabApiException GitLabApiException if any exception occurs during execution
*/
public CommitStatus addCommitStatus(Object projectIdOrPath, String sha, CommitBuildState state, CommitStatus status)
throws GitLabApiException {
return addCommitStatus(projectIdOrPath, sha, state, null, status);
}

/**
* <p>Add or update the build status of a commit. The following fluent methods are available on the
* CommitStatus instance for setting up the status:</p>
* <pre><code>
* withCoverage(Float)
* withDescription(String)
* withName(String)
* withRef(String)
* withTargetUrl(String)
* </code></pre>
*
* <pre><code>GitLab Endpoint: POST /projects/:id/statuses/:sha</code></pre>
*
* @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance (required)
* @param sha a commit SHA (required)
* @param state the state of the status. Can be one of the following: PENDING, RUNNING, SUCCESS, FAILED, CANCELED (required)
* @param pipelineId The ID of the pipeline to set status. Use in case of several pipeline on same SHA (optional)
* @param status the CommitSatus instance hoilding the optional parms: ref, name, target_url, description, and coverage
* @return a CommitStatus instance with the updated info
* @throws GitLabApiException GitLabApiException if any exception occurs during execution
* @deprecated use {@link #addCommitStatus(Object, String, org.gitlab4j.api.Constants.CommitBuildState, CommitStatus)} and set the pipelineId value in the {@link CommitStatus} parameter
*/
@Deprecated
public CommitStatus addCommitStatus(
Object projectIdOrPath, String sha, CommitBuildState state, Long pipelineId, CommitStatus status)
throws GitLabApiException {

if (projectIdOrPath == null) {
throw new RuntimeException("projectIdOrPath cannot be null");
}
Expand All @@ -714,16 +683,6 @@ public CommitStatus addCommitStatus(
.withParam("description", status.getDescription())
.withParam("coverage", status.getCoverage())
.withParam("pipeline_id", status.getPipelineId());
if (pipelineId != null
&& status.getPipelineId() != null
&& !Objects.equals(status.getPipelineId(), pipelineId)) {
throw new IllegalArgumentException(
"The parameter 'pipelineId' and the pipelineId value the 'status' parameter are different. Set the two values to be the same or one of the two values to null.");
}
}

if (pipelineId != null) {
formData.withParam("pipeline_id", pipelineId);
}

Response response =
Expand Down
Loading

0 comments on commit 7dfec10

Please sign in to comment.