Skip to content

Commit

Permalink
Split API and Model jars
Browse files Browse the repository at this point in the history
Fixes #1067
  • Loading branch information
jmini committed Nov 28, 2024
1 parent 7dfec10 commit 908c213
Show file tree
Hide file tree
Showing 596 changed files with 7,114 additions and 4,602 deletions.
30 changes: 27 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,20 +119,44 @@ You can also point to a specific commit:

```gradle
dependencies {
implementation 'com.github.gitlab4j:gitlab4j-api:6561c93aaf'
implementation 'com.github.gitlab4j:gitlab4j-api:7dfec10189'
}
```

```xml
<dependency>
<groupId>com.github.gitlab4j</groupId>
<artifactId>gitlab4j-api</artifactId>
<version>6561c93aaf</version>
<version>7dfec10189</version>
</dependency>
```

```java
//DEPS https://github.com/gitlab4j/gitlab4j-api/tree/6561c93aafa6bf35cb9bad0617127a0c249a8f9f
//DEPS https://github.com/gitlab4j/gitlab4j-api/tree/7dfec10189cdcb11e34fc9ead984abcd6316194a
```

---

### **Models jar**

For some usages, the HTTP layer based on Jersey can't be used.
Those projects might want to use the Jackson-based model classes, and implement the REST call themself.

**Gradle: build.gradle**
```java
dependencies {
...
implementation 'org.gitlab4j:gitlab4j-models:6.0.0-rc.6'
}
```

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

---
Expand Down
141 changes: 45 additions & 96 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@

plugins {
id 'java-library'
id 'com.diffplug.spotless' version '6.25.0'
id 'signing'
id 'maven-publish'
id 'com.diffplug.spotless' version '6.25.0' apply false
id 'io.github.gradle-nexus.publish-plugin' version '1.3.0'
id 'net.researchgate.release' version '3.0.2'
}
Expand All @@ -12,58 +8,52 @@ wrapper {
gradleVersion = '7.6.2'
}

group = 'org.gitlab4j'

dependencies {
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:2.0.2'
testImplementation "org.junit.jupiter:junit-jupiter-api:5.10.4"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.10.4"
}
String groupId = 'org.gitlab4j'

signing {
useGpgCmd()
sign(publishing.publications)
}
subprojects {
apply plugin: 'java-library'
apply plugin: 'signing'
apply plugin: 'com.diffplug.spotless'
apply plugin: 'maven-publish'

tasks.withType(Sign) {
onlyIf {
project.hasProperty('signing.gnupg.keyName')
group = groupId

signing {
useGpgCmd()
sign(publishing.publications)
}
}

java {
withJavadocJar()
withSourcesJar()
tasks.withType(Sign) {
onlyIf {
project.hasProperty('signing.gnupg.keyName')
}
}

java {
withJavadocJar()
withSourcesJar()

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

tasks.named('test') {
useJUnitPlatform()
}
spotless {
java {
palantirJavaFormat()
importOrder 'java', 'javax', 'jakarta', 'org', 'com', ''
removeUnusedImports()
}
}

repositories {
mavenCentral()
}
repositories {
// mavenLocal()
mavenCentral()
}

spotless {
java {
palantirJavaFormat()
importOrder 'java', 'javax', 'jakarta', 'org', 'com', ''
removeUnusedImports()
tasks.named('test') {
useJUnitPlatform()
}
}

Expand All @@ -78,51 +68,10 @@ nexusPublishing {
}
}

publishing {
publications {
mavenJava(MavenPublication) {
pom {
name = 'GitLab4J-API - GitLab API Java Client'
description = 'GitLab4J-API (gitlab4j-api) provides a full featured Java client library for working with GitLab repositories and servers via the GitLab REST API.'
packaging = 'jar'
url = 'https://' + "$githubRepositoryOwner" + '.github.io/' + "$githubRepositoryName" + '/'
licenses {
license {
name = 'The MIT License (MIT)'
url = 'http://opensource.org/licenses/MIT'
distribution = 'repo'
}
}
developers {
developer {
id = 'gmessner'
name = 'Greg Messner'
email = '[email protected]'
}
developer {
id = 'gdesaintmartinlacaze'
name = 'Gautier de Saint Martin Lacaze'
email = '[email protected]'
}
developer {
url = 'https://github.com/orgs/' + "$githubRepositoryOwner" + '/people'
}
}
scm {
connection = 'scm:git:https://github.com/' + "$githubRepositoryOwner" + '/' + "$githubRepositoryName" + '.git'
developerConnection = 'scm:git:https://github.com/' + "$githubRepositoryOwner" + '/' + "$githubRepositoryName" + '.git'
url = 'https://github.com/' + "$githubRepositoryOwner" + '/' + "$githubRepositoryName" + '/'
}
}
from components.java
}
}
}

release {
buildTasks = ['doRelease']
git {
requireBranch.set('6.x')
requireBranch.set('main')
}
}

Expand All @@ -147,13 +96,13 @@ def updateLastVersionValueTask = tasks.register('updateLastVersionValue') {
}
}

tasks.register('doRelease') {
task doRelease {
dependsOn(
checkLastVersionValueTask,
'initializeSonatypeStagingRepository',
'clean',
'build',
project.getTasksByName('publishToSonatype', true)
checkLastVersionValueTask,
'initializeSonatypeStagingRepository',
'clean',
'build',
project.getTasksByName('publishToSonatype', true)
)
}

Expand Down
57 changes: 57 additions & 0 deletions gitlab4j-api/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
dependencies {
api project(':gitlab4j-models')
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:2.0.2'
testImplementation "org.junit.jupiter:junit-jupiter-api:5.10.4"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.10.4"
}

publishing {
publications {
mavenJava(MavenPublication) {
pom {
name = 'GitLab4J-API - GitLab API Java Client'
description = 'GitLab4J-API (gitlab4j-api) provides a full featured Java client library for working with GitLab repositories and servers via the GitLab REST API.'
packaging = 'jar'
url = 'https://' + "$githubRepositoryOwner" + '.github.io/' + "$githubRepositoryName" + '/'
licenses {
license {
name = 'The MIT License (MIT)'
url = 'http://opensource.org/licenses/MIT'
distribution = 'repo'
}
}
developers {
developer {
id = 'gmessner'
name = 'Greg Messner'
email = '[email protected]'
}
developer {
id = 'gdesaintmartinlacaze'
name = 'Gautier de Saint Martin Lacaze'
email = '[email protected]'
}
developer {
url = 'https://github.com/orgs/' + "$githubRepositoryOwner" + '/people'
}
}
scm {
connection = 'scm:git:https://github.com/' + "$githubRepositoryOwner" + '/' + "$githubRepositoryName" + '.git'
developerConnection = 'scm:git:https://github.com/' + "$githubRepositoryOwner" + '/' + "$githubRepositoryName" + '.git'
url = 'https://github.com/' + "$githubRepositoryOwner" + '/' + "$githubRepositoryName" + '/'
}
}
from components.java
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import org.gitlab4j.api.models.Project;
import org.gitlab4j.api.models.User;
import org.gitlab4j.api.utils.UrlEncoder;
import org.gitlab4j.models.Constants;
import org.gitlab4j.models.GitLabForm;

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

/**
* Perform an HTTP PUT call with the specified form data and path objects, returning
* a ClientResponse instance with the data returned from the endpoint.
*
* @param expectedStatus the HTTP status that should be returned from the server
* @param form the Form containing the name/value pairs for the POST data
* @param pathArgs variable list of arguments used to build the URI
* @return a ClientResponse instance with the data returned from the endpoint
* @throws GitLabApiException if any exception occurs during execution
*/
protected Response putWithFormData(Response.Status expectedStatus, GitLabForm form, Object... pathArgs)
throws GitLabApiException {
try {
return validate(getApiClient().put(new GitLabApiForm(form), pathArgs), expectedStatus);
} catch (Exception e) {
throw handle(e);
}
}

/**
* Perform a file upload using the HTTP PUT method with the specified File instance and path objects,
* returning a ClientResponse instance with the data returned from the endpoint.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import org.gitlab4j.api.models.ApplicationSettings;
import org.gitlab4j.api.models.Setting;
import org.gitlab4j.api.utils.ISO8601;
import org.gitlab4j.models.utils.ISO8601;

import com.fasterxml.jackson.databind.JsonNode;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import jakarta.ws.rs.core.Response;

import org.gitlab4j.api.models.AuditEvent;
import org.gitlab4j.api.utils.ISO8601;
import org.gitlab4j.models.utils.ISO8601;

/**
* This class implements the client side API for the GitLab Instance Audit Event API.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.gitlab4j.api.models.Diff;
import org.gitlab4j.api.models.GpgSignature;
import org.gitlab4j.api.models.MergeRequest;
import org.gitlab4j.api.utils.ISO8601;
import org.gitlab4j.models.utils.ISO8601;

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

MultivaluedMap<String, String> queryParams =
(filter != null ? filter.getQueryParams(page, perPage).asMap() : getPageQueryParams(page, perPage));
MultivaluedMap<String, String> queryParams = (filter != null
? new GitLabApiForm(filter.getQueryParams(page, perPage)).asMap()
: getPageQueryParams(page, perPage));
Response response = get(
Response.Status.OK,
queryParams,
Expand Down Expand Up @@ -615,7 +616,7 @@ public Pager<CommitStatus> getCommitStatuses(
}

MultivaluedMap<String, String> queryParams =
(filter != null ? filter.getQueryParams().asMap() : null);
(filter != null ? new GitLabApiForm(filter.getQueryParams()).asMap() : null);
return (new Pager<CommitStatus>(
this,
CommitStatus.class,
Expand Down
7 changes: 7 additions & 0 deletions gitlab4j-api/src/main/java/org/gitlab4j/api/Constants.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.gitlab4j.api;

/**
* @deprecated use {@link org.gitlab4j.models.Constants} instead.
*/
@Deprecated
public interface Constants extends org.gitlab4j.models.Constants {}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public Pager<Deployment> getProjectDeployments(Object projectIdOrPath, Deploymen
*/
public Pager<Deployment> getProjectDeployments(Object projectIdOrPath, DeploymentFilter filter, int itemsPerPage)
throws GitLabApiException {
GitLabApiForm formData = (filter != null ? filter.getQueryParams() : new GitLabApiForm());
GitLabApiForm formData = (filter != null ? new GitLabApiForm(filter.getQueryParams()) : new GitLabApiForm());
return (new Pager<Deployment>(
this,
Deployment.class,
Expand Down
Loading

0 comments on commit 908c213

Please sign in to comment.