|
2 | 2 | // License https://www.backblaze.com/using_b2_code.html |
3 | 3 |
|
4 | 4 | import org.gradle.api.credentials.PasswordCredentials |
| 5 | +import org.gradle.api.publish.internal.PublicationInternal |
5 | 6 |
|
6 | 7 | plugins { |
7 | 8 | java |
@@ -139,25 +140,33 @@ publishing { |
139 | 140 | } |
140 | 141 | } |
141 | 142 |
|
142 | | -// Don't configure signing unless this is present |
143 | 143 | val sonatypeUsername = findProperty("sonatypeUsername") |
144 | 144 | val sonatypePassword = findProperty("sonatypePassword") |
145 | 145 |
|
146 | 146 | val gpgSigningKey = System.getenv("GPG_SIGNING_KEY") |
147 | 147 | val gpgPassphrase = System.getenv("GPG_PASSPHRASE") |
148 | 148 |
|
149 | | -if (sonatypeUsername != null && sonatypePassword != null) { |
150 | | - signing { |
151 | | - setRequired { |
152 | | - gradle.taskGraph.hasTask("publishToSonatype") |
153 | | - } |
| 149 | +signing { |
| 150 | + setRequired { |
| 151 | + gradle.taskGraph.hasTask("publishToSonatype") || gradle.taskGraph.hasTask("createBundle") |
| 152 | + } |
154 | 153 |
|
155 | | - if (gpgSigningKey != null && gpgPassphrase != null) { |
156 | | - useInMemoryPgpKeys(gpgSigningKey, gpgPassphrase) |
157 | | - } else { |
158 | | - useGpgCmd() |
159 | | - } |
| 154 | + if (gpgSigningKey != null && gpgPassphrase != null) { |
| 155 | + useInMemoryPgpKeys(gpgSigningKey, gpgPassphrase) |
| 156 | + } else { |
| 157 | + useGpgCmd() |
| 158 | + } |
160 | 159 |
|
161 | | - sign(publishing.publications["maven"]) |
| 160 | + sign(publishing.publications["maven"]) |
| 161 | +} |
| 162 | + |
| 163 | +tasks.register<Jar>("createBundle") { |
| 164 | + archiveBaseName.set("bundle-for-${project.name}") |
| 165 | + from((project.publishing.publications["maven"] as PublicationInternal<*>).publishableArtifacts.files) { |
| 166 | + rename { |
| 167 | + it |
| 168 | + .replace("pom-default.xml", "${project.name}-${project.version}.pom") |
| 169 | + .replace("module.json", "${project.name}-${project.version}.module") |
| 170 | + } |
162 | 171 | } |
163 | 172 | } |
0 commit comments