|
1 | 1 | buildscript {
|
2 | 2 | ext {
|
3 | 3 | // Typically, only edit those two:
|
4 |
| - def objectboxVersionNumber = '2.9.0' // without "-SNAPSHOT", e.g. '2.5.0' or '2.4.0-RC' |
| 4 | + def objectboxVersionNumber = '2.9.1' // without "-SNAPSHOT", e.g. '2.5.0' or '2.4.0-RC' |
5 | 5 | def objectboxVersionRelease = true // set to true for releasing to ignore versionPostFix to avoid e.g. "-dev" versions
|
6 | 6 |
|
7 | 7 | // version post fix: '-<value>' or '' if not defined; e.g. used by CI to pass in branch name
|
@@ -42,6 +42,7 @@ buildscript {
|
42 | 42 | classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
|
43 | 43 | // https://github.com/spotbugs/spotbugs-gradle-plugin/releases
|
44 | 44 | classpath "gradle.plugin.com.github.spotbugs.snom:spotbugs-gradle-plugin:4.5.1"
|
| 45 | + classpath "io.github.gradle-nexus:publish-plugin:1.0.0" |
45 | 46 | }
|
46 | 47 | }
|
47 | 48 |
|
@@ -82,108 +83,97 @@ def hasSigningProperties() {
|
82 | 83 | }
|
83 | 84 |
|
84 | 85 | configure(subprojects.findAll { projectNamesToPublish.contains(it.name) }) {
|
85 |
| - apply plugin: 'maven' |
| 86 | + apply plugin: 'maven-publish' |
86 | 87 | apply plugin: 'signing'
|
87 | 88 |
|
88 |
| - configurations { |
89 |
| - deployerJars |
90 |
| - } |
| 89 | + publishing { |
| 90 | + repositories { |
| 91 | + maven { |
| 92 | + name = 'GitLab' |
| 93 | + if (project.hasProperty('gitlabUrl') && project.hasProperty('gitlabPrivateToken')) { |
| 94 | + // "https://gitlab.example.com/api/v4/projects/<PROJECT_ID>/packages/maven" |
| 95 | + url = "$gitlabUrl/api/v4/projects/14/packages/maven" |
| 96 | + println "GitLab repository set to $url." |
| 97 | + |
| 98 | + credentials(HttpHeaderCredentials) { |
| 99 | + name = "Private-Token" |
| 100 | + value = gitlabPrivateToken |
| 101 | + } |
| 102 | + authentication { |
| 103 | + header(HttpHeaderAuthentication) |
| 104 | + } |
| 105 | + } else { |
| 106 | + println "WARNING: Can not publish to GitLab: gitlabUrl or gitlabPrivateToken not set." |
| 107 | + } |
| 108 | + } |
| 109 | + // Note: Sonatype repo created by publish-plugin. |
| 110 | + } |
91 | 111 |
|
92 |
| - dependencies { |
93 |
| - // Using an older version to remain compatible with Wagon API used by Gradle/Maven |
94 |
| - deployerJars 'org.apache.maven.wagon:wagon-webdav-jackrabbit:3.2.0' |
95 |
| - deployerJars 'org.apache.maven.wagon:wagon-ftp:3.3.2' |
| 112 | + publications { |
| 113 | + mavenJava(MavenPublication) { |
| 114 | + // Note: Projects set additional specific properties. |
| 115 | + pom { |
| 116 | + packaging = 'jar' |
| 117 | + url = 'https://objectbox.io' |
| 118 | + licenses { |
| 119 | + license { |
| 120 | + name = 'The Apache Software License, Version 2.0' |
| 121 | + url = 'https://www.apache.org/licenses/LICENSE-2.0.txt' |
| 122 | + distribution = 'repo' |
| 123 | + } |
| 124 | + } |
| 125 | + developers { |
| 126 | + developer { |
| 127 | + id = 'ObjectBox' |
| 128 | + name = 'ObjectBox' |
| 129 | + } |
| 130 | + } |
| 131 | + issueManagement { |
| 132 | + system = 'GitHub Issues' |
| 133 | + url = 'https://github.com/objectbox/objectbox-java/issues' |
| 134 | + } |
| 135 | + organization { |
| 136 | + name = 'ObjectBox Ltd.' |
| 137 | + url = 'https://objectbox.io' |
| 138 | + } |
| 139 | + scm { |
| 140 | + connection = 'scm:[email protected]:objectbox/objectbox-java.git' |
| 141 | + developerConnection = 'scm:[email protected]:objectbox/objectbox-java.git' |
| 142 | + url = 'https://github.com/objectbox/objectbox-java' |
| 143 | + } |
| 144 | + } |
| 145 | + } |
| 146 | + } |
96 | 147 | }
|
97 | 148 |
|
98 | 149 | signing {
|
99 | 150 | if (hasSigningProperties()) {
|
100 | 151 | String signingKey = new File(signingKeyFile).text
|
101 | 152 | useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
|
102 |
| - sign configurations.archives |
| 153 | + sign publishing.publications.mavenJava |
103 | 154 | } else {
|
104 | 155 | println "Signing information missing/incomplete for ${project.name}"
|
105 | 156 | }
|
106 | 157 | }
|
| 158 | +} |
107 | 159 |
|
108 |
| - // Use afterEvaluate or all dependencies will be lost in the generated POM |
109 |
| - afterEvaluate { |
110 |
| - uploadArchives { |
111 |
| - repositories { |
112 |
| - mavenDeployer { |
113 |
| - def preferredRepo = project.findProperty('preferredRepo') |
114 |
| - println "preferredRepo=$preferredRepo" |
115 |
| - |
116 |
| - if (preferredRepo == 'local') { |
117 |
| - repository url: repositories.mavenLocal().url |
118 |
| - println "uploadArchives repo is mavenLocal()." |
119 |
| - } else if (preferredRepo != null |
120 |
| - && project.hasProperty('preferredUsername') |
121 |
| - && project.hasProperty('preferredPassword')) { |
122 |
| - if (!hasSigningProperties()) { |
123 |
| - throw new InvalidUserDataException("To upload to repo signing is required.") |
124 |
| - } |
125 |
| - |
126 |
| - configuration = configurations.deployerJars |
127 |
| - |
128 |
| - // replace placeholders |
129 |
| - def repositoryUrl = preferredRepo |
130 |
| - .replace('__groupId__', project.group) |
131 |
| - .replace('__artifactId__', project.archivesBaseName) |
132 |
| - repository(url: repositoryUrl) { |
133 |
| - authentication(userName: preferredUsername, password: preferredPassword) |
134 |
| - } |
135 |
| - |
136 |
| - println "uploadArchives repo is $repositoryUrl." |
137 |
| - } else if (project.hasProperty('sonatypeUsername') |
138 |
| - && project.hasProperty('sonatypePassword')) { |
139 |
| - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } |
140 |
| - |
141 |
| - def isSnapshot = version.endsWith('-SNAPSHOT') |
142 |
| - def sonatypeRepositoryUrl = isSnapshot |
143 |
| - ? "https://oss.sonatype.org/content/repositories/snapshots/" |
144 |
| - : "https://oss.sonatype.org/service/local/staging/deploy/maven2/" |
145 |
| - repository(url: sonatypeRepositoryUrl) { |
146 |
| - authentication(userName: sonatypeUsername, password: sonatypePassword) |
147 |
| - } |
148 |
| - |
149 |
| - println "uploadArchives repo is $sonatypeRepositoryUrl." |
150 |
| - } else { |
151 |
| - println "WARNING: uploadArchives settings incomplete, can not upload archives." |
152 |
| - } |
153 |
| - |
154 |
| - pom.project { |
155 |
| - packaging 'jar' |
156 |
| - url 'https://objectbox.io' |
157 |
| - |
158 |
| - scm { |
159 |
| - url 'https://github.com/objectbox/objectbox-java' |
160 |
| - connection 'scm:[email protected]:objectbox/objectbox-java.git' |
161 |
| - developerConnection 'scm:[email protected]:objectbox/objectbox-java.git' |
162 |
| - } |
163 |
| - |
164 |
| - developers { |
165 |
| - developer { |
166 |
| - id 'ObjectBox' |
167 |
| - name 'ObjectBox' |
168 |
| - } |
169 |
| - } |
170 |
| - |
171 |
| - issueManagement { |
172 |
| - system 'GitHub Issues' |
173 |
| - url 'https://github.com/objectbox/objectbox-java/issues' |
174 |
| - } |
| 160 | +wrapper { |
| 161 | + distributionType = Wrapper.DistributionType.ALL |
| 162 | +} |
175 | 163 |
|
176 |
| - organization { |
177 |
| - name 'ObjectBox Ltd.' |
178 |
| - url 'https://objectbox.io' |
179 |
| - } |
180 |
| - } |
181 |
| - } |
| 164 | +// Plugin to publish to Central https://github.com/gradle-nexus/publish-plugin/ |
| 165 | +// This plugin ensures a separate, named staging repo is created for each build when publishing. |
| 166 | +apply plugin: "io.github.gradle-nexus.publish-plugin" |
| 167 | +nexusPublishing { |
| 168 | + repositories { |
| 169 | + sonatype { |
| 170 | + if (project.hasProperty("sonatypeUsername") && project.hasProperty("sonatypePassword")) { |
| 171 | + println('nexusPublishing credentials supplied.') |
| 172 | + username = sonatypeUsername |
| 173 | + password = sonatypePassword |
| 174 | + } else { |
| 175 | + println('nexusPublishing credentials NOT supplied.') |
182 | 176 | }
|
183 | 177 | }
|
184 | 178 | }
|
185 | 179 | }
|
186 |
| - |
187 |
| -wrapper { |
188 |
| - distributionType = Wrapper.DistributionType.ALL |
189 |
| -} |
0 commit comments