Skip to content

Commit

Permalink
Move to gradle
Browse files Browse the repository at this point in the history
  • Loading branch information
jmini committed Oct 12, 2024
1 parent db3b639 commit 256a9ac
Show file tree
Hide file tree
Showing 9 changed files with 517 additions and 29 deletions.
35 changes: 9 additions & 26 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,21 @@ on:

jobs:

build-jdk8:
name: "Build JDK 8"
build-gradle:
name: "Build"
runs-on: ubuntu-latest
services:
gitlab-instance:
image: gitlab/gitlab-ce:12.9.2-ce.0
env:
GITLAB_OMNIBUS_CONFIG: gitlab_rails['initial_root_password']="password";gitlab_rails['lfs_enabled']=false;
ports:
- 8090:80
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 8
uses: actions/setup-java@v2
- name: Setup JDK 8
uses: actions/setup-java@v3
with:
distribution: adopt-hotspot
distribution: temurin
java-version: 8
- name: Get Date
id: get-date
run: |
echo "date=$(/bin/date -u "+%Y-%m")" >> $GITHUB_OUTPUT
shell: bash
- name: Cache Maven Repository
id: cache-maven
uses: actions/cache@v2
with:
path: ~/.m2/repository
# refresh cache every month to avoid unlimited growth
key: gitlab4jmaven-${{ steps.get-date.outputs.date }}
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: GitLab4j verify
id: gitlab4j-verify
run: |
./mvnw verify -B -V
./gradlew build --console=PLAIN --stacktrace
155 changes: 155 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@

plugins {
id 'java-library'
id 'signing'
id 'maven-publish'
id 'de.marcphilipp.nexus-publish' version '0.4.0'
id 'net.researchgate.release' version '3.0.2'
id 'io.codearte.nexus-staging' version '0.22.0'
}

wrapper {
gradleVersion = '7.6.2'
}

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.junit.jupiter:junit-jupiter:5.8.2'
testImplementation 'org.mockito:mockito-core:4.4.0'
testImplementation 'org.mockito:mockito-junit-jupiter:4.4.0'
testImplementation 'org.hamcrest:hamcrest-all:1.3'
testImplementation 'uk.org.webcompere:system-stubs-jupiter:1.2.0'
}

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

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

java {
withJavadocJar()
withSourcesJar()

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

repositories {
mavenCentral()
}

nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri("https://oss.sonatype.org/service/local/"))
username = project.findProperty('sonatypeUser') ?: ''
password = project.findProperty('sonatypePassword') ?: ''
}
}
}

nexusStaging {
serverUrl = "https://oss.sonatype.org/service/local/"
packageGroup = 'org.gitlab4j'
username = project.findProperty('sonatypeUser') ?: ''
password = project.findProperty('sonatypePassword') ?: ''
}

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 = ['releaseBuild']
git {
requireBranch.set('main')
}
}

task releaseBuild {
dependsOn(
'checkLastVersionValue',
'clean',
'build',
project.getTasksByName('publishToSonatype', true)
)
}

tasks.register('checkLastVersionValue') {
doLast {
if(version.endsWith('SNAPSHOT')) {
throw new GradleException("version '$version' ends with SNAPSHOT, this is not a release build!")
}
if(lastVersion != version) {
throw new GradleException("lastVersion '$lastVersion' does not match version '$version', fix it in the 'gradle.properties' file.")
}
}
}

def updateLastVersionValueTask = tasks.register('updateLastVersionValue') {
doLast {
def propertiesFile = file('gradle.properties')
def content = propertiesFile.text
content = content.replaceAll("lastVersion=[0-9\\.]+", "lastVersion=" + version.replace('-SNAPSHOT', ''))
propertiesFile.text = content
}
}

model {
tasks.unSnapshotVersion {
dependsOn updateLastVersionValueTask
}
}
5 changes: 5 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
version=5.7.0-SNAPSHOT
lastVersion=5.6.0

githubRepositoryOwner=gitlab4j
githubRepositoryName=gitlab4j-api
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 256a9ac

Please sign in to comment.