|
| 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 | +} |
0 commit comments