Skip to content

Commit 050eaf5

Browse files
authored
Move to gradle (#1178)
Fixes #1166
1 parent db3b639 commit 050eaf5

File tree

9 files changed

+517
-29
lines changed

9 files changed

+517
-29
lines changed

.github/workflows/ci-build.yml

+9-26
Original file line numberDiff line numberDiff line change
@@ -9,38 +9,21 @@ on:
99

1010
jobs:
1111

12-
build-jdk8:
13-
name: "Build JDK 8"
12+
build-gradle:
13+
name: "Build"
1414
runs-on: ubuntu-latest
15-
services:
16-
gitlab-instance:
17-
image: gitlab/gitlab-ce:12.9.2-ce.0
18-
env:
19-
GITLAB_OMNIBUS_CONFIG: gitlab_rails['initial_root_password']="password";gitlab_rails['lfs_enabled']=false;
20-
ports:
21-
- 8090:80
2215
steps:
23-
- uses: actions/checkout@v2
16+
- uses: actions/checkout@v4
2417
with:
2518
fetch-depth: 0
26-
- name: Set up JDK 8
27-
uses: actions/setup-java@v2
19+
- name: Setup JDK 8
20+
uses: actions/setup-java@v3
2821
with:
29-
distribution: adopt-hotspot
22+
distribution: temurin
3023
java-version: 8
31-
- name: Get Date
32-
id: get-date
33-
run: |
34-
echo "date=$(/bin/date -u "+%Y-%m")" >> $GITHUB_OUTPUT
35-
shell: bash
36-
- name: Cache Maven Repository
37-
id: cache-maven
38-
uses: actions/cache@v2
39-
with:
40-
path: ~/.m2/repository
41-
# refresh cache every month to avoid unlimited growth
42-
key: gitlab4jmaven-${{ steps.get-date.outputs.date }}
24+
- name: Setup Gradle
25+
uses: gradle/actions/setup-gradle@v3
4326
- name: GitLab4j verify
4427
id: gitlab4j-verify
4528
run: |
46-
./mvnw verify -B -V
29+
./gradlew build --console=PLAIN --stacktrace

build.gradle

+155
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
2+
plugins {
3+
id 'java-library'
4+
id 'signing'
5+
id 'maven-publish'
6+
id 'de.marcphilipp.nexus-publish' version '0.4.0'
7+
id 'net.researchgate.release' version '3.0.2'
8+
id 'io.codearte.nexus-staging' version '0.22.0'
9+
}
10+
11+
wrapper {
12+
gradleVersion = '7.6.2'
13+
}
14+
15+
group = 'org.gitlab4j'
16+
17+
dependencies {
18+
api 'jakarta.activation:jakarta.activation-api:1.2.2'
19+
api 'org.glassfish.jersey.inject:jersey-hk2:2.39.1'
20+
api 'org.glassfish.jersey.core:jersey-client:2.39.1'
21+
api 'org.glassfish.jersey.connectors:jersey-apache-connector:2.39.1'
22+
api 'org.glassfish.jersey.media:jersey-media-multipart:2.39.1'
23+
api 'org.glassfish.jersey.media:jersey-media-json-jackson:2.39.1'
24+
api 'jakarta.servlet:jakarta.servlet-api:4.0.4'
25+
testImplementation 'org.junit.jupiter:junit-jupiter:5.8.2'
26+
testImplementation 'org.mockito:mockito-core:4.4.0'
27+
testImplementation 'org.mockito:mockito-junit-jupiter:4.4.0'
28+
testImplementation 'org.hamcrest:hamcrest-all:1.3'
29+
testImplementation 'uk.org.webcompere:system-stubs-jupiter:1.2.0'
30+
}
31+
32+
signing {
33+
useGpgCmd()
34+
sign(publishing.publications)
35+
}
36+
37+
tasks.withType(Sign) {
38+
onlyIf {
39+
project.hasProperty('signing.gnupg.keyName')
40+
}
41+
}
42+
43+
java {
44+
withJavadocJar()
45+
withSourcesJar()
46+
47+
compileJava.options.encoding = "UTF-8"
48+
toolchain {
49+
languageVersion = JavaLanguageVersion.of(8)
50+
}
51+
}
52+
53+
repositories {
54+
mavenCentral()
55+
}
56+
57+
nexusPublishing {
58+
repositories {
59+
sonatype {
60+
nexusUrl.set(uri("https://oss.sonatype.org/service/local/"))
61+
username = project.findProperty('sonatypeUser') ?: ''
62+
password = project.findProperty('sonatypePassword') ?: ''
63+
}
64+
}
65+
}
66+
67+
nexusStaging {
68+
serverUrl = "https://oss.sonatype.org/service/local/"
69+
packageGroup = 'org.gitlab4j'
70+
username = project.findProperty('sonatypeUser') ?: ''
71+
password = project.findProperty('sonatypePassword') ?: ''
72+
}
73+
74+
publishing {
75+
publications {
76+
mavenJava(MavenPublication) {
77+
pom {
78+
name = 'GitLab4J-API - GitLab API Java Client'
79+
description = 'GitLab4J-API (gitlab4j-api) provides a full featured Java client library for working with GitLab repositories and servers via the GitLab REST API.'
80+
packaging = 'jar'
81+
url = 'https://' + "$githubRepositoryOwner" + '.github.io/' + "$githubRepositoryName" + '/'
82+
licenses {
83+
license {
84+
name = 'The MIT License (MIT)'
85+
url = 'http://opensource.org/licenses/MIT'
86+
distribution = 'repo'
87+
}
88+
}
89+
developers {
90+
developer {
91+
id = 'gmessner'
92+
name = 'Greg Messner'
93+
94+
}
95+
developer {
96+
id = 'gdesaintmartinlacaze'
97+
name = 'Gautier de Saint Martin Lacaze'
98+
99+
}
100+
developer {
101+
url = 'https://github.com/orgs/' + "$githubRepositoryOwner" + '/people'
102+
}
103+
}
104+
scm {
105+
connection = 'scm:git:https://github.com/' + "$githubRepositoryOwner" + '/' + "$githubRepositoryName" + '.git'
106+
developerConnection = 'scm:git:https://github.com/' + "$githubRepositoryOwner" + '/' + "$githubRepositoryName" + '.git'
107+
url = 'https://github.com/' + "$githubRepositoryOwner" + '/' + "$githubRepositoryName" + '/'
108+
}
109+
}
110+
from components.java
111+
}
112+
}
113+
}
114+
115+
release {
116+
buildTasks = ['releaseBuild']
117+
git {
118+
requireBranch.set('main')
119+
}
120+
}
121+
122+
task releaseBuild {
123+
dependsOn(
124+
'checkLastVersionValue',
125+
'clean',
126+
'build',
127+
project.getTasksByName('publishToSonatype', true)
128+
)
129+
}
130+
131+
tasks.register('checkLastVersionValue') {
132+
doLast {
133+
if(version.endsWith('SNAPSHOT')) {
134+
throw new GradleException("version '$version' ends with SNAPSHOT, this is not a release build!")
135+
}
136+
if(lastVersion != version) {
137+
throw new GradleException("lastVersion '$lastVersion' does not match version '$version', fix it in the 'gradle.properties' file.")
138+
}
139+
}
140+
}
141+
142+
def updateLastVersionValueTask = tasks.register('updateLastVersionValue') {
143+
doLast {
144+
def propertiesFile = file('gradle.properties')
145+
def content = propertiesFile.text
146+
content = content.replaceAll("lastVersion=[0-9\\.]+", "lastVersion=" + version.replace('-SNAPSHOT', ''))
147+
propertiesFile.text = content
148+
}
149+
}
150+
151+
model {
152+
tasks.unSnapshotVersion {
153+
dependsOn updateLastVersionValueTask
154+
}
155+
}

gradle.properties

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
version=5.7.0-SNAPSHOT
2+
lastVersion=5.6.0
3+
4+
githubRepositoryOwner=gitlab4j
5+
githubRepositoryName=gitlab4j-api

gradle/wrapper/gradle-wrapper.jar

60.2 KB
Binary file not shown.
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip
4+
networkTimeout=10000
5+
zipStoreBase=GRADLE_USER_HOME
6+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)