Skip to content

Commit 908c213

Browse files
committed
Split API and Model jars
Fixes gitlab4j#1067
1 parent 7dfec10 commit 908c213

File tree

596 files changed

+7114
-4602
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

596 files changed

+7114
-4602
lines changed

README.md

+27-3
Original file line numberDiff line numberDiff line change
@@ -119,20 +119,44 @@ You can also point to a specific commit:
119119

120120
```gradle
121121
dependencies {
122-
implementation 'com.github.gitlab4j:gitlab4j-api:6561c93aaf'
122+
implementation 'com.github.gitlab4j:gitlab4j-api:7dfec10189'
123123
}
124124
```
125125

126126
```xml
127127
<dependency>
128128
<groupId>com.github.gitlab4j</groupId>
129129
<artifactId>gitlab4j-api</artifactId>
130-
<version>6561c93aaf</version>
130+
<version>7dfec10189</version>
131131
</dependency>
132132
```
133133

134134
```java
135-
//DEPS https://github.com/gitlab4j/gitlab4j-api/tree/6561c93aafa6bf35cb9bad0617127a0c249a8f9f
135+
//DEPS https://github.com/gitlab4j/gitlab4j-api/tree/7dfec10189cdcb11e34fc9ead984abcd6316194a
136+
```
137+
138+
---
139+
140+
### **Models jar**
141+
142+
For some usages, the HTTP layer based on Jersey can't be used.
143+
Those projects might want to use the Jackson-based model classes, and implement the REST call themself.
144+
145+
**Gradle: build.gradle**
146+
```java
147+
dependencies {
148+
...
149+
implementation 'org.gitlab4j:gitlab4j-models:6.0.0-rc.6'
150+
}
151+
```
152+
153+
**Maven: pom.xml**
154+
```xml
155+
<dependency>
156+
<groupId>org.gitlab4j</groupId>
157+
<artifactId>gitlab4j-models</artifactId>
158+
<version>6.0.0-rc.6</version>
159+
</dependency>
136160
```
137161

138162
---

build.gradle

+45-96
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
21
plugins {
3-
id 'java-library'
4-
id 'com.diffplug.spotless' version '6.25.0'
5-
id 'signing'
6-
id 'maven-publish'
2+
id 'com.diffplug.spotless' version '6.25.0' apply false
73
id 'io.github.gradle-nexus.publish-plugin' version '1.3.0'
84
id 'net.researchgate.release' version '3.0.2'
95
}
@@ -12,58 +8,52 @@ wrapper {
128
gradleVersion = '7.6.2'
139
}
1410

15-
group = 'org.gitlab4j'
16-
17-
dependencies {
18-
api 'jakarta.activation:jakarta.activation-api:2.1.1'
19-
api 'org.glassfish.jersey.inject:jersey-hk2:3.1.1'
20-
api 'org.glassfish.jersey.core:jersey-client:3.1.1'
21-
api 'org.glassfish.jersey.connectors:jersey-apache-connector:3.1.1'
22-
api 'org.glassfish.jersey.media:jersey-media-multipart:3.1.1'
23-
api 'org.glassfish.jersey.media:jersey-media-json-jackson:3.1.1'
24-
api 'jakarta.servlet:jakarta.servlet-api:6.0.0'
25-
testImplementation 'org.mockito:mockito-core:5.2.0'
26-
testImplementation 'org.mockito:mockito-junit-jupiter:5.2.0'
27-
testImplementation 'org.hamcrest:hamcrest-all:1.3'
28-
testImplementation 'uk.org.webcompere:system-stubs-jupiter:2.0.2'
29-
testImplementation "org.junit.jupiter:junit-jupiter-api:5.10.4"
30-
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.10.4"
31-
}
11+
String groupId = 'org.gitlab4j'
3212

33-
signing {
34-
useGpgCmd()
35-
sign(publishing.publications)
36-
}
13+
subprojects {
14+
apply plugin: 'java-library'
15+
apply plugin: 'signing'
16+
apply plugin: 'com.diffplug.spotless'
17+
apply plugin: 'maven-publish'
3718

38-
tasks.withType(Sign) {
39-
onlyIf {
40-
project.hasProperty('signing.gnupg.keyName')
19+
group = groupId
20+
21+
signing {
22+
useGpgCmd()
23+
sign(publishing.publications)
4124
}
42-
}
4325

44-
java {
45-
withJavadocJar()
46-
withSourcesJar()
26+
tasks.withType(Sign) {
27+
onlyIf {
28+
project.hasProperty('signing.gnupg.keyName')
29+
}
30+
}
31+
32+
java {
33+
withJavadocJar()
34+
withSourcesJar()
4735

48-
compileJava.options.encoding = "UTF-8"
49-
toolchain {
50-
languageVersion = JavaLanguageVersion.of(11)
36+
compileJava.options.encoding = "UTF-8"
37+
toolchain {
38+
languageVersion = JavaLanguageVersion.of(11)
39+
}
5140
}
52-
}
5341

54-
tasks.named('test') {
55-
useJUnitPlatform()
56-
}
42+
spotless {
43+
java {
44+
palantirJavaFormat()
45+
importOrder 'java', 'javax', 'jakarta', 'org', 'com', ''
46+
removeUnusedImports()
47+
}
48+
}
5749

58-
repositories {
59-
mavenCentral()
60-
}
50+
repositories {
51+
// mavenLocal()
52+
mavenCentral()
53+
}
6154

62-
spotless {
63-
java {
64-
palantirJavaFormat()
65-
importOrder 'java', 'javax', 'jakarta', 'org', 'com', ''
66-
removeUnusedImports()
55+
tasks.named('test') {
56+
useJUnitPlatform()
6757
}
6858
}
6959

@@ -78,51 +68,10 @@ nexusPublishing {
7868
}
7969
}
8070

81-
publishing {
82-
publications {
83-
mavenJava(MavenPublication) {
84-
pom {
85-
name = 'GitLab4J-API - GitLab API Java Client'
86-
description = 'GitLab4J-API (gitlab4j-api) provides a full featured Java client library for working with GitLab repositories and servers via the GitLab REST API.'
87-
packaging = 'jar'
88-
url = 'https://' + "$githubRepositoryOwner" + '.github.io/' + "$githubRepositoryName" + '/'
89-
licenses {
90-
license {
91-
name = 'The MIT License (MIT)'
92-
url = 'http://opensource.org/licenses/MIT'
93-
distribution = 'repo'
94-
}
95-
}
96-
developers {
97-
developer {
98-
id = 'gmessner'
99-
name = 'Greg Messner'
100-
101-
}
102-
developer {
103-
id = 'gdesaintmartinlacaze'
104-
name = 'Gautier de Saint Martin Lacaze'
105-
106-
}
107-
developer {
108-
url = 'https://github.com/orgs/' + "$githubRepositoryOwner" + '/people'
109-
}
110-
}
111-
scm {
112-
connection = 'scm:git:https://github.com/' + "$githubRepositoryOwner" + '/' + "$githubRepositoryName" + '.git'
113-
developerConnection = 'scm:git:https://github.com/' + "$githubRepositoryOwner" + '/' + "$githubRepositoryName" + '.git'
114-
url = 'https://github.com/' + "$githubRepositoryOwner" + '/' + "$githubRepositoryName" + '/'
115-
}
116-
}
117-
from components.java
118-
}
119-
}
120-
}
121-
12271
release {
12372
buildTasks = ['doRelease']
12473
git {
125-
requireBranch.set('6.x')
74+
requireBranch.set('main')
12675
}
12776
}
12877

@@ -147,13 +96,13 @@ def updateLastVersionValueTask = tasks.register('updateLastVersionValue') {
14796
}
14897
}
14998

150-
tasks.register('doRelease') {
99+
task doRelease {
151100
dependsOn(
152-
checkLastVersionValueTask,
153-
'initializeSonatypeStagingRepository',
154-
'clean',
155-
'build',
156-
project.getTasksByName('publishToSonatype', true)
101+
checkLastVersionValueTask,
102+
'initializeSonatypeStagingRepository',
103+
'clean',
104+
'build',
105+
project.getTasksByName('publishToSonatype', true)
157106
)
158107
}
159108

gitlab4j-api/build.gradle

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
dependencies {
2+
api project(':gitlab4j-models')
3+
api 'jakarta.activation:jakarta.activation-api:2.1.1'
4+
api 'org.glassfish.jersey.inject:jersey-hk2:3.1.1'
5+
api 'org.glassfish.jersey.core:jersey-client:3.1.1'
6+
api 'org.glassfish.jersey.connectors:jersey-apache-connector:3.1.1'
7+
api 'org.glassfish.jersey.media:jersey-media-multipart:3.1.1'
8+
api 'org.glassfish.jersey.media:jersey-media-json-jackson:3.1.1'
9+
api 'jakarta.servlet:jakarta.servlet-api:6.0.0'
10+
testImplementation 'org.mockito:mockito-core:5.2.0'
11+
testImplementation 'org.mockito:mockito-junit-jupiter:5.2.0'
12+
testImplementation 'org.hamcrest:hamcrest-all:1.3'
13+
testImplementation 'uk.org.webcompere:system-stubs-jupiter:2.0.2'
14+
testImplementation "org.junit.jupiter:junit-jupiter-api:5.10.4"
15+
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.10.4"
16+
}
17+
18+
publishing {
19+
publications {
20+
mavenJava(MavenPublication) {
21+
pom {
22+
name = 'GitLab4J-API - GitLab API Java Client'
23+
description = 'GitLab4J-API (gitlab4j-api) provides a full featured Java client library for working with GitLab repositories and servers via the GitLab REST API.'
24+
packaging = 'jar'
25+
url = 'https://' + "$githubRepositoryOwner" + '.github.io/' + "$githubRepositoryName" + '/'
26+
licenses {
27+
license {
28+
name = 'The MIT License (MIT)'
29+
url = 'http://opensource.org/licenses/MIT'
30+
distribution = 'repo'
31+
}
32+
}
33+
developers {
34+
developer {
35+
id = 'gmessner'
36+
name = 'Greg Messner'
37+
38+
}
39+
developer {
40+
id = 'gdesaintmartinlacaze'
41+
name = 'Gautier de Saint Martin Lacaze'
42+
43+
}
44+
developer {
45+
url = 'https://github.com/orgs/' + "$githubRepositoryOwner" + '/people'
46+
}
47+
}
48+
scm {
49+
connection = 'scm:git:https://github.com/' + "$githubRepositoryOwner" + '/' + "$githubRepositoryName" + '.git'
50+
developerConnection = 'scm:git:https://github.com/' + "$githubRepositoryOwner" + '/' + "$githubRepositoryName" + '.git'
51+
url = 'https://github.com/' + "$githubRepositoryOwner" + '/' + "$githubRepositoryName" + '/'
52+
}
53+
}
54+
from components.java
55+
}
56+
}
57+
}

src/main/java/org/gitlab4j/api/AbstractApi.java gitlab4j-api/src/main/java/org/gitlab4j/api/AbstractApi.java

+21
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
import org.gitlab4j.api.models.Project;
1818
import org.gitlab4j.api.models.User;
1919
import org.gitlab4j.api.utils.UrlEncoder;
20+
import org.gitlab4j.models.Constants;
21+
import org.gitlab4j.models.GitLabForm;
2022

2123
/**
2224
* This class is the base class for all the sub API classes. It provides implementations of
@@ -621,6 +623,25 @@ protected Response putWithFormData(Response.Status expectedStatus, Form formData
621623
}
622624
}
623625

626+
/**
627+
* Perform an HTTP PUT call with the specified form data and path objects, returning
628+
* a ClientResponse instance with the data returned from the endpoint.
629+
*
630+
* @param expectedStatus the HTTP status that should be returned from the server
631+
* @param form the Form containing the name/value pairs for the POST data
632+
* @param pathArgs variable list of arguments used to build the URI
633+
* @return a ClientResponse instance with the data returned from the endpoint
634+
* @throws GitLabApiException if any exception occurs during execution
635+
*/
636+
protected Response putWithFormData(Response.Status expectedStatus, GitLabForm form, Object... pathArgs)
637+
throws GitLabApiException {
638+
try {
639+
return validate(getApiClient().put(new GitLabApiForm(form), pathArgs), expectedStatus);
640+
} catch (Exception e) {
641+
throw handle(e);
642+
}
643+
}
644+
624645
/**
625646
* Perform a file upload using the HTTP PUT method with the specified File instance and path objects,
626647
* returning a ClientResponse instance with the data returned from the endpoint.

src/main/java/org/gitlab4j/api/ApplicationSettingsApi.java gitlab4j-api/src/main/java/org/gitlab4j/api/ApplicationSettingsApi.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import org.gitlab4j.api.models.ApplicationSettings;
99
import org.gitlab4j.api.models.Setting;
10-
import org.gitlab4j.api.utils.ISO8601;
10+
import org.gitlab4j.models.utils.ISO8601;
1111

1212
import com.fasterxml.jackson.databind.JsonNode;
1313

src/main/java/org/gitlab4j/api/AuditEventApi.java gitlab4j-api/src/main/java/org/gitlab4j/api/AuditEventApi.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import jakarta.ws.rs.core.Response;
99

1010
import org.gitlab4j.api.models.AuditEvent;
11-
import org.gitlab4j.api.utils.ISO8601;
11+
import org.gitlab4j.models.utils.ISO8601;
1212

1313
/**
1414
* This class implements the client side API for the GitLab Instance Audit Event API.

src/main/java/org/gitlab4j/api/CommitsApi.java gitlab4j-api/src/main/java/org/gitlab4j/api/CommitsApi.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import org.gitlab4j.api.models.Diff;
2424
import org.gitlab4j.api.models.GpgSignature;
2525
import org.gitlab4j.api.models.MergeRequest;
26-
import org.gitlab4j.api.utils.ISO8601;
26+
import org.gitlab4j.models.utils.ISO8601;
2727

2828
/**
2929
* This class implements the client side API for the GitLab commits calls.
@@ -577,8 +577,9 @@ public List<CommitStatus> getCommitStatuses(
577577
throw new RuntimeException("sha cannot be null");
578578
}
579579

580-
MultivaluedMap<String, String> queryParams =
581-
(filter != null ? filter.getQueryParams(page, perPage).asMap() : getPageQueryParams(page, perPage));
580+
MultivaluedMap<String, String> queryParams = (filter != null
581+
? new GitLabApiForm(filter.getQueryParams(page, perPage)).asMap()
582+
: getPageQueryParams(page, perPage));
582583
Response response = get(
583584
Response.Status.OK,
584585
queryParams,
@@ -615,7 +616,7 @@ public Pager<CommitStatus> getCommitStatuses(
615616
}
616617

617618
MultivaluedMap<String, String> queryParams =
618-
(filter != null ? filter.getQueryParams().asMap() : null);
619+
(filter != null ? new GitLabApiForm(filter.getQueryParams()).asMap() : null);
619620
return (new Pager<CommitStatus>(
620621
this,
621622
CommitStatus.class,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package org.gitlab4j.api;
2+
3+
/**
4+
* @deprecated use {@link org.gitlab4j.models.Constants} instead.
5+
*/
6+
@Deprecated
7+
public interface Constants extends org.gitlab4j.models.Constants {}

src/main/java/org/gitlab4j/api/DeploymentsApi.java gitlab4j-api/src/main/java/org/gitlab4j/api/DeploymentsApi.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public Pager<Deployment> getProjectDeployments(Object projectIdOrPath, Deploymen
7777
*/
7878
public Pager<Deployment> getProjectDeployments(Object projectIdOrPath, DeploymentFilter filter, int itemsPerPage)
7979
throws GitLabApiException {
80-
GitLabApiForm formData = (filter != null ? filter.getQueryParams() : new GitLabApiForm());
80+
GitLabApiForm formData = (filter != null ? new GitLabApiForm(filter.getQueryParams()) : new GitLabApiForm());
8181
return (new Pager<Deployment>(
8282
this,
8383
Deployment.class,

0 commit comments

Comments
 (0)