|
| 1 | + |
| 2 | +plugins { |
| 3 | + id 'java-library' |
| 4 | + id 'com.diffplug.spotless' version '6.25.0' |
| 5 | + id 'signing' |
| 6 | + id 'maven-publish' |
| 7 | + id 'io.github.gradle-nexus.publish-plugin' version '1.3.0' |
| 8 | + id 'net.researchgate.release' version '3.0.2' |
| 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: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 | +} |
| 32 | + |
| 33 | +signing { |
| 34 | + useGpgCmd() |
| 35 | + sign(publishing.publications) |
| 36 | +} |
| 37 | + |
| 38 | +tasks.withType(Sign) { |
| 39 | + onlyIf { |
| 40 | + project.hasProperty('signing.gnupg.keyName') |
| 41 | + } |
| 42 | +} |
| 43 | + |
| 44 | +java { |
| 45 | + withJavadocJar() |
| 46 | + withSourcesJar() |
| 47 | + |
| 48 | + compileJava.options.encoding = "UTF-8" |
| 49 | + toolchain { |
| 50 | + languageVersion = JavaLanguageVersion.of(11) |
| 51 | + } |
| 52 | +} |
| 53 | + |
| 54 | +tasks.named('test') { |
| 55 | + useJUnitPlatform() |
| 56 | +} |
| 57 | + |
| 58 | +repositories { |
| 59 | + mavenCentral() |
| 60 | +} |
| 61 | + |
| 62 | +spotless { |
| 63 | + java { |
| 64 | + palantirJavaFormat() |
| 65 | + importOrder 'java', 'javax', 'jakarta', 'org', 'com', '' |
| 66 | + removeUnusedImports() |
| 67 | + } |
| 68 | +} |
| 69 | + |
| 70 | +nexusPublishing { |
| 71 | + packageGroup = 'org.gitlab4j' |
| 72 | + repositories { |
| 73 | + sonatype { |
| 74 | + nexusUrl.set(uri("https://oss.sonatype.org/service/local/")) |
| 75 | + username = project.findProperty('ossSonatypeUsername') ?: '' |
| 76 | + password = project.findProperty('ossSonatypePassword') ?: '' |
| 77 | + } |
| 78 | + } |
| 79 | +} |
| 80 | + |
| 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 | + |
| 122 | +release { |
| 123 | + buildTasks = ['doRelease'] |
| 124 | + git { |
| 125 | + requireBranch.set('6.x') |
| 126 | + } |
| 127 | +} |
| 128 | + |
| 129 | +def checkLastVersionValueTask = tasks.register('checkLastVersionValue') { |
| 130 | + doLast { |
| 131 | + if(version.endsWith('SNAPSHOT')) { |
| 132 | + throw new GradleException("version '$version' ends with SNAPSHOT, this is not a release build!") |
| 133 | + } |
| 134 | + if(lastVersion != version) { |
| 135 | + throw new GradleException("lastVersion '$lastVersion' does not match version '$version', fix it in the 'gradle.properties' file.") |
| 136 | + } |
| 137 | + } |
| 138 | +} |
| 139 | + |
| 140 | +def updateLastVersionValueTask = tasks.register('updateLastVersionValue') { |
| 141 | + doLast { |
| 142 | + def propertiesFile = file('gradle.properties') |
| 143 | + def content = propertiesFile.text |
| 144 | + def newVersion = project.findProperty('release.releaseVersion') ?: version.replace('-SNAPSHOT', '') |
| 145 | + content = content.replaceAll("lastVersion=[0-9a-z\\.\\-]+", "lastVersion=" + newVersion) |
| 146 | + propertiesFile.text = content |
| 147 | + } |
| 148 | +} |
| 149 | + |
| 150 | +tasks.register('doRelease') { |
| 151 | + dependsOn( |
| 152 | + checkLastVersionValueTask, |
| 153 | + 'initializeSonatypeStagingRepository', |
| 154 | + 'clean', |
| 155 | + 'build', |
| 156 | + project.getTasksByName('publishToSonatype', true) |
| 157 | + ) |
| 158 | +} |
| 159 | + |
| 160 | +model { |
| 161 | + tasks.unSnapshotVersion { |
| 162 | + dependsOn updateLastVersionValueTask |
| 163 | + } |
| 164 | +} |
0 commit comments