@@ -83,19 +83,9 @@ def hasSigningProperties() { |
83 | 83 | } |
84 | 84 |
|
85 | 85 | configure(subprojects.findAll { projectNamesToPublish.contains(it.name) }) { |
86 | | - apply plugin: 'maven' |
| 86 | + apply plugin: 'maven-publish' |
87 | 87 | apply plugin: 'signing' |
88 | 88 |
|
89 | | - configurations { |
90 | | - deployerJars |
91 | | - } |
92 | | - |
93 | | - dependencies { |
94 | | - // Using an older version to remain compatible with Wagon API used by Gradle/Maven |
95 | | - deployerJars 'org.apache.maven.wagon:wagon-webdav-jackrabbit:3.2.0' |
96 | | - deployerJars 'org.apache.maven.wagon:wagon-ftp:3.3.2' |
97 | | - } |
98 | | - |
99 | 89 | signing { |
100 | 90 | if (hasSigningProperties()) { |
101 | 91 | String signingKey = new File(signingKeyFile).text |
@@ -106,79 +96,78 @@ configure(subprojects.findAll { projectNamesToPublish.contains(it.name) }) { |
106 | 96 | } |
107 | 97 | } |
108 | 98 |
|
109 | | - // Use afterEvaluate or all dependencies will be lost in the generated POM |
110 | | - afterEvaluate { |
111 | | - uploadArchives { |
112 | | - repositories { |
113 | | - mavenDeployer { |
114 | | - def preferredRepo = project.findProperty('preferredRepo') |
115 | | - println "preferredRepo=$preferredRepo" |
116 | | - |
117 | | - if (preferredRepo == 'local') { |
118 | | - repository url: repositories.mavenLocal().url |
119 | | - println "uploadArchives repo is mavenLocal()." |
120 | | - } else if (preferredRepo != null |
121 | | - && project.hasProperty('preferredUsername') |
122 | | - && project.hasProperty('preferredPassword')) { |
123 | | - if (!hasSigningProperties()) { |
124 | | - throw new InvalidUserDataException("To upload to repo signing is required.") |
125 | | - } |
126 | | - |
127 | | - configuration = configurations.deployerJars |
128 | | - |
129 | | - // replace placeholders |
130 | | - def repositoryUrl = preferredRepo |
131 | | - .replace('__groupId__', project.group) |
132 | | - .replace('__artifactId__', project.archivesBaseName) |
133 | | - repository(url: repositoryUrl) { |
134 | | - authentication(userName: preferredUsername, password: preferredPassword) |
135 | | - } |
136 | | - |
137 | | - println "uploadArchives repo is $repositoryUrl." |
138 | | - } else if (project.hasProperty('sonatypeUsername') |
139 | | - && project.hasProperty('sonatypePassword')) { |
140 | | - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } |
141 | | - |
142 | | - def isSnapshot = version.endsWith('-SNAPSHOT') |
143 | | - def sonatypeRepositoryUrl = isSnapshot |
144 | | - ? "https://oss.sonatype.org/content/repositories/snapshots/" |
145 | | - : "https://oss.sonatype.org/service/local/staging/deploy/maven2/" |
146 | | - repository(url: sonatypeRepositoryUrl) { |
147 | | - authentication(userName: sonatypeUsername, password: sonatypePassword) |
148 | | - } |
149 | | - |
150 | | - println "uploadArchives repo is $sonatypeRepositoryUrl." |
151 | | - } else { |
152 | | - println "WARNING: uploadArchives settings incomplete, can not upload archives." |
| 99 | + publishing { |
| 100 | + repositories { |
| 101 | + maven { |
| 102 | + name = 'GitLab' |
| 103 | + if (project.hasProperty('gitlabUrl') && project.hasProperty('gitlabPrivateToken')) { |
| 104 | + // "https://gitlab.example.com/api/v4/projects/<PROJECT_ID>/packages/maven" |
| 105 | + url = "$gitlabUrl/api/v4/projects/14/packages/maven" |
| 106 | + println "GitLab repository set to $url." |
| 107 | + |
| 108 | + credentials(HttpHeaderCredentials) { |
| 109 | + name = "Private-Token" |
| 110 | + value = gitlabPrivateToken |
| 111 | + } |
| 112 | + authentication { |
| 113 | + header(HttpHeaderAuthentication) |
| 114 | + } |
| 115 | + } else { |
| 116 | + println "WARNING: Can not publish to GitLab: gitlabUrl or gitlabPrivateToken not set." |
| 117 | + } |
| 118 | + } |
| 119 | + maven { |
| 120 | + name = 'Sonatype' |
| 121 | + url = version.endsWith('SNAPSHOT') ? |
| 122 | + "https://oss.sonatype.org/content/repositories/snapshots/" : |
| 123 | + "https://oss.sonatype.org/service/local/staging/deploy/maven2/" |
| 124 | + if (project.hasProperty('sonatypeUsername') && project.hasProperty('sonatypePassword')) { |
| 125 | + if (!hasSigningProperties()) { |
| 126 | + throw new InvalidUserDataException("To upload to repo signing is required.") |
153 | 127 | } |
154 | 128 |
|
155 | | - pom.project { |
156 | | - packaging 'jar' |
157 | | - url 'https://objectbox.io' |
158 | | - |
159 | | - scm { |
160 | | - url 'https://github.com/objectbox/objectbox-java' |
161 | | - |
162 | | - |
163 | | - } |
164 | | - |
165 | | - developers { |
166 | | - developer { |
167 | | - id 'ObjectBox' |
168 | | - name 'ObjectBox' |
169 | | - } |
170 | | - } |
| 129 | + credentials { |
| 130 | + username = sonatypeUsername |
| 131 | + password = sonatypePassword |
| 132 | + } |
| 133 | + } else { |
| 134 | + println "WARNING: Can not publish to Sonatype OSSRH: sonatypeUsername or sonatypePassword not set." |
| 135 | + } |
| 136 | + } |
| 137 | + } |
171 | 138 |
|
172 | | - issueManagement { |
173 | | - system 'GitHub Issues' |
174 | | - url 'https://github.com/objectbox/objectbox-java/issues' |
| 139 | + publications { |
| 140 | + mavenJava(MavenPublication) { |
| 141 | + // Note: Projects set additional specific properties. |
| 142 | + pom { |
| 143 | + packaging = 'jar' |
| 144 | + url = 'https://objectbox.io' |
| 145 | + licenses { |
| 146 | + license { |
| 147 | + name = 'The Apache Software License, Version 2.0' |
| 148 | + url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' |
| 149 | + distribution = 'repo' |
175 | 150 | } |
176 | | - |
177 | | - organization { |
178 | | - name 'ObjectBox Ltd.' |
179 | | - url 'https://objectbox.io' |
| 151 | + } |
| 152 | + developers { |
| 153 | + developer { |
| 154 | + id = 'ObjectBox' |
| 155 | + name = 'ObjectBox' |
180 | 156 | } |
181 | 157 | } |
| 158 | + issueManagement { |
| 159 | + system = 'GitHub Issues' |
| 160 | + url = 'https://github.com/objectbox/objectbox-java/issues' |
| 161 | + } |
| 162 | + organization { |
| 163 | + name = 'ObjectBox Ltd.' |
| 164 | + url = 'https://objectbox.io' |
| 165 | + } |
| 166 | + scm { |
| 167 | + |
| 168 | + |
| 169 | + url = 'https://github.com/objectbox/objectbox-java' |
| 170 | + } |
182 | 171 | } |
183 | 172 | } |
184 | 173 | } |
|