|
14 | 14 | * limitations under the License. |
15 | 15 | */ |
16 | 16 |
|
17 | | -import io.github.zenhelix.gradle.plugin.MavenCentralUploaderPlugin.Companion.MAVEN_CENTRAL_PORTAL_NAME |
18 | | -import io.github.zenhelix.gradle.plugin.extension.MavenCentralUploaderExtension |
19 | 17 | import io.github.zenhelix.gradle.plugin.extension.PublishingType |
20 | | -import io.github.zenhelix.gradle.plugin.task.PublishBundleMavenCentralTask |
21 | | -import io.github.zenhelix.gradle.plugin.task.ZipDeploymentTask |
22 | 18 | import java.time.Duration |
23 | | -import org.gradle.api.publish.plugins.PublishingPlugin.PUBLISH_TASK_GROUP |
24 | 19 | import org.gradle.kotlin.dsl.mavenCentralPortal |
25 | 20 | import org.jetbrains.changelog.date |
26 | 21 | import org.jetbrains.gradle.ext.settings |
@@ -82,123 +77,15 @@ mavenCentralPortal { |
82 | 77 | // baseUrl = "https://central.sonatype.com" |
83 | 78 | uploader { |
84 | 79 | // 2 seconds * 3600 = 7200 seconds = 2hrs |
85 | | - delayRetriesStatusCheck = Duration.ofSeconds(2) |
86 | | - maxRetriesStatusCheck = 3600 |
87 | | - |
88 | | - aggregate { |
89 | | - // Aggregate submodules into a single archive |
90 | | - modules = true |
91 | | - // Aggregate publications into a single archive for each module |
92 | | - modulePublications = true |
93 | | - } |
| 80 | + statusCheckDelay = Duration.ofSeconds(2) |
| 81 | + maxStatusChecks = 3600 |
94 | 82 | } |
95 | 83 | } |
96 | 84 |
|
97 | | -// The following code aggregates the publishable parts of every module into a single zip. |
98 | | -// This is necessary to have an "atomic" release of all modules. |
99 | | - |
100 | | -val mavenCentralDeploymentZipAggregation by configurations.creating |
101 | | - |
102 | | -mavenCentralDeploymentZipAggregation.isTransitive = true |
103 | | - |
104 | | -val zipAggregateMavenCentralDeployment by |
105 | | - tasks.registering(Zip::class) { |
106 | | - group = PUBLISH_TASK_GROUP |
107 | | - description = "Generates the aggregated Maven publication zip file." |
108 | | - |
109 | | - inputs.files(mavenCentralDeploymentZipAggregation) |
110 | | - from(mavenCentralDeploymentZipAggregation.map { zipTree(it) }) |
111 | | - // archiveFileName = mavenCentralPortal.deploymentName.orElse(project.name) |
112 | | - destinationDirectory.set(layout.buildDirectory.dir("aggregatedDistribution")) |
113 | | - doLast { logger.lifecycle("Built aggregated distribution ${archiveFile.get()}") } |
114 | | - } |
115 | | - |
116 | | -val publishAggregateMavenCentralDeployment by |
117 | | - tasks.registering(PublishBundleMavenCentralTask::class) { |
118 | | - group = PUBLISH_TASK_GROUP |
119 | | - description = |
120 | | - "Publishes the aggregated Maven publications $MAVEN_CENTRAL_PORTAL_NAME repository." |
121 | | - |
122 | | - val task = this |
123 | | - |
124 | | - dependsOn(zipAggregateMavenCentralDeployment) |
125 | | - inputs.file(zipAggregateMavenCentralDeployment.flatMap { it.archiveFile }) |
126 | | - |
127 | | - project.extensions.configure<MavenCentralUploaderExtension> { |
128 | | - val ext = this |
129 | | - task.baseUrl.set(ext.baseUrl) |
130 | | - task.credentials.set( |
131 | | - ext.credentials.username.flatMap { username -> |
132 | | - ext.credentials.password.map { password -> |
133 | | - io.github.zenhelix.gradle.plugin.client.model.Credentials.UsernamePasswordCredentials( |
134 | | - username, |
135 | | - password, |
136 | | - ) |
137 | | - } |
138 | | - } |
139 | | - ) |
140 | | - |
141 | | - task.publishingType.set( |
142 | | - ext.publishingType.map { |
143 | | - when (it) { |
144 | | - PublishingType.AUTOMATIC -> |
145 | | - io.github.zenhelix.gradle.plugin.client.model.PublishingType.AUTOMATIC |
146 | | - PublishingType.USER_MANAGED -> |
147 | | - io.github.zenhelix.gradle.plugin.client.model.PublishingType.USER_MANAGED |
148 | | - } |
149 | | - } |
150 | | - ) |
151 | | - task.deploymentName.set(ext.deploymentName) |
152 | | - |
153 | | - task.maxRetriesStatusCheck.set(ext.uploader.maxRetriesStatusCheck) |
154 | | - task.delayRetriesStatusCheck.set(ext.uploader.delayRetriesStatusCheck) |
155 | | - |
156 | | - task.zipFile.set(zipAggregateMavenCentralDeployment.flatMap { it.archiveFile }) |
157 | | - } |
158 | | - } |
159 | | - |
160 | 85 | // Configure the 'io.github.zenhelix.maven-central-publish' plugin to all projects |
161 | 86 | allprojects.forEach { p -> |
162 | 87 | p.pluginManager.withPlugin("maven-publish") { |
163 | 88 | p.pluginManager.apply("io.github.zenhelix.maven-central-publish") |
164 | | - p.extensions.configure<MavenCentralUploaderExtension> { |
165 | | - val aggregatedMavenCentralDeploymentZipPart by p.configurations.creating |
166 | | - aggregatedMavenCentralDeploymentZipPart.description = "Maven central publication zip" |
167 | | - val aggregatedMavenCentralDeploymentZipPartElements by p.configurations.creating |
168 | | - aggregatedMavenCentralDeploymentZipPartElements.description = |
169 | | - "Elements for the Maven central publication zip" |
170 | | - aggregatedMavenCentralDeploymentZipPartElements.isCanBeResolved = false |
171 | | - aggregatedMavenCentralDeploymentZipPartElements.extendsFrom( |
172 | | - aggregatedMavenCentralDeploymentZipPart |
173 | | - ) |
174 | | - aggregatedMavenCentralDeploymentZipPartElements.attributes { |
175 | | - attribute( |
176 | | - Usage.USAGE_ATTRIBUTE, |
177 | | - project.getObjects().named(Usage::class.java, "publication"), |
178 | | - ) |
179 | | - } |
180 | | - |
181 | | - val aggregatemavenCentralDeployment by |
182 | | - p.tasks.registering { |
183 | | - val zip = p.tasks.findByName("zipDeploymentMavenPublication") as ZipDeploymentTask |
184 | | - dependsOn(zip) |
185 | | - outputs.file(zip.archiveFile.get().asFile) |
186 | | - } |
187 | | - |
188 | | - val artifact = |
189 | | - p.artifacts.add( |
190 | | - aggregatedMavenCentralDeploymentZipPart.name, |
191 | | - aggregatemavenCentralDeployment, |
192 | | - ) { |
193 | | - builtBy(aggregatemavenCentralDeployment) |
194 | | - } |
195 | | - aggregatedMavenCentralDeploymentZipPart.outgoing.artifact(artifact) |
196 | | - |
197 | | - rootProject.dependencies.add( |
198 | | - mavenCentralDeploymentZipAggregation.name, |
199 | | - rootProject.dependencies.project(p.path, aggregatedMavenCentralDeploymentZipPart.name), |
200 | | - ) |
201 | | - } |
202 | 89 | } |
203 | 90 | } |
204 | 91 |
|
|
0 commit comments