|
1 | 1 | plugins {
|
2 | 2 | id 'java-library'
|
3 | 3 | id 'maven-publish'
|
4 |
| - id 'signing' |
| 4 | + id 'org.jreleaser' version '1.18.0' |
5 | 5 | id "com.diffplug.spotless" version "6.13.0"
|
6 | 6 | }
|
7 | 7 |
|
|
11 | 11 | }
|
12 | 12 |
|
13 | 13 | group = 'cloud.eppo'
|
14 |
| -version = '5.2.1-SNAPSHOT' |
| 14 | +version = '5.2.1' |
15 | 15 | ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
|
16 | 16 |
|
17 | 17 | import org.apache.tools.ant.filters.ReplaceTokens
|
|
86 | 86 |
|
87 | 87 | publishing {
|
88 | 88 | publications {
|
89 |
| - mavenJava(MavenPublication) { |
| 89 | + maven(MavenPublication) { |
| 90 | + groupId = 'cloud.eppo' |
90 | 91 | artifactId = 'eppo-server-sdk'
|
91 | 92 | from components.java
|
92 | 93 | versionMapping {
|
@@ -123,26 +124,66 @@ publishing {
|
123 | 124 | }
|
124 | 125 | repositories {
|
125 | 126 | maven {
|
126 |
| - def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" |
127 |
| - def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/" |
128 |
| - url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl |
129 |
| - credentials { |
130 |
| - username = project.properties.containsKey("ossrhUsername") ? project.properties["ossrhUsername"] : "" |
131 |
| - password = project.properties.containsKey("ossrhPassword") ? project.properties["ossrhPassword"] : "" |
132 |
| - } |
| 127 | + url = layout.buildDirectory.dir('staging-deploy') |
133 | 128 | }
|
134 | 129 | }
|
135 | 130 | }
|
136 | 131 |
|
137 |
| -if (!project.gradle.startParameter.taskNames.contains('publishToMavenLocal')) { |
| 132 | + |
| 133 | +jreleaser { |
138 | 134 | signing {
|
139 |
| - sign publishing.publications.mavenJava |
140 |
| - if (System.env['CI']) { |
141 |
| - useInMemoryPgpKeys(System.env.GPG_PRIVATE_KEY, System.env.GPG_PASSPHRASE) |
| 135 | + active = 'ALWAYS' |
| 136 | + armored = true |
| 137 | + verify = false |
| 138 | + } |
| 139 | + deploy { |
| 140 | + maven { |
| 141 | + mavenCentral { |
| 142 | + 'release-deploy' { |
| 143 | + active = 'RELEASE' |
| 144 | + url = 'https://central.sonatype.com/api/v1/publisher' |
| 145 | + stagingRepository('build/staging-deploy') |
| 146 | + } |
| 147 | + } |
| 148 | + nexus2 { |
| 149 | + 'snapshot-deploy' { |
| 150 | + active = 'SNAPSHOT' |
| 151 | + snapshotUrl = 'https://central.sonatype.com/repository/maven-snapshots' |
| 152 | + url = 'https://central.sonatype.com/repository/maven-snapshots' |
| 153 | + applyMavenCentralRules = true |
| 154 | + snapshotSupported = true |
| 155 | + closeRepository = true |
| 156 | + releaseRepository = true |
| 157 | + stagingRepository('build/staging-deploy') |
| 158 | + } |
| 159 | + } |
142 | 160 | }
|
143 | 161 | }
|
144 | 162 | }
|
145 | 163 |
|
| 164 | + |
| 165 | +// Custom task to ensure we can conditionally publish either a release or snapshot artifact |
| 166 | +// based on a command line switch. See github workflow files for more details on usage. |
| 167 | +tasks.register('checkVersion') { |
| 168 | + doLast { |
| 169 | + if (!project.hasProperty('release') && !project.hasProperty('snapshot')) { |
| 170 | + throw new GradleException("You must specify either -Prelease or -Psnapshot") |
| 171 | + } |
| 172 | + if (project.hasProperty('release') && project.version.endsWith('SNAPSHOT')) { |
| 173 | + throw new GradleException("You cannot specify -Prelease with a SNAPSHOT version") |
| 174 | + } |
| 175 | + if (project.hasProperty('snapshot') && !project.version.endsWith('SNAPSHOT')) { |
| 176 | + throw new GradleException("You cannot specify -Psnapshot with a non-SNAPSHOT version") |
| 177 | + } |
| 178 | + project.ext.shouldPublish = true |
| 179 | + } |
| 180 | +} |
| 181 | + |
| 182 | +// Ensure checkVersion runs before publishing |
| 183 | +tasks.named('publish').configure { |
| 184 | + dependsOn checkVersion |
| 185 | +} |
| 186 | + |
146 | 187 | javadoc {
|
147 | 188 | if (JavaVersion.current().isJava9Compatible()) {
|
148 | 189 | options.addBooleanOption('html5', true)
|
|
0 commit comments