diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2019-07-09 02:43:10 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-09 02:43:10 +0800 |
commit | 996b05d3ff66f7d4fdda7e110fa14818e3e225a2 (patch) | |
tree | 74934ed22145cdc128896947dae06998963c3bfb /scalalib | |
parent | 4faefb132f918e971f1f0f1428ca790ce7b128b2 (diff) | |
download | mill-996b05d3ff66f7d4fdda7e110fa14818e3e225a2.tar.gz mill-996b05d3ff66f7d4fdda7e110fa14818e3e225a2.tar.bz2 mill-996b05d3ff66f7d4fdda7e110fa14818e3e225a2.zip |
Bump sonatype "wait for something to happen" timeout, make it configurable (#652)
Somehow it seems sonatype has gotten slower recently and no longer completes operations in the same 60s timeout that it used to
Diffstat (limited to 'scalalib')
-rw-r--r-- | scalalib/src/PublishModule.scala | 12 | ||||
-rw-r--r-- | scalalib/src/publish/SonatypePublisher.scala | 22 |
2 files changed, 23 insertions, 11 deletions
diff --git a/scalalib/src/PublishModule.scala b/scalalib/src/PublishModule.scala index e5d6a3a4..d47b16a8 100644 --- a/scalalib/src/PublishModule.scala +++ b/scalalib/src/PublishModule.scala @@ -85,7 +85,8 @@ trait PublishModule extends JavaModule { outer => signed: Boolean = true, readTimeout: Int = 60000, connectTimeout: Int = 5000, - release: Boolean): define.Command[Unit] = T.command { + release: Boolean, + awaitTimeout: Int = 120 * 1000): define.Command[Unit] = T.command { val PublishModule.PublishData(artifactInfo, artifacts) = publishArtifacts() new SonatypePublisher( sonatypeUri, @@ -96,7 +97,8 @@ trait PublishModule extends JavaModule { outer => signed, readTimeout, connectTimeout, - T.ctx().log + T.ctx().log, + awaitTimeout ).publish(artifacts.map{case (a, b) => (a.path, b)}, artifactInfo, release) } } @@ -117,7 +119,8 @@ object PublishModule extends ExternalModule { gpgKeyName: String = null, sonatypeUri: String = "https://oss.sonatype.org/service/local", sonatypeSnapshotUri: String = "https://oss.sonatype.org/content/repositories/snapshots", - signed: Boolean = true) = T.command { + signed: Boolean = true, + awaitTimeout: Int = 120 * 1000) = T.command { val x: Seq[(Seq[(os.Path, String)], Artifact)] = Task.sequence(publishArtifacts.value)().map{ case PublishModule.PublishData(a, s) => (s.map{case (p, f) => (p.path, f)}, a) @@ -131,7 +134,8 @@ object PublishModule extends ExternalModule { signed, readTimeout, connectTimeout, - T.ctx().log + T.ctx().log, + awaitTimeout ).publishAll( release, x:_* diff --git a/scalalib/src/publish/SonatypePublisher.scala b/scalalib/src/publish/SonatypePublisher.scala index 5c760574..ec29684d 100644 --- a/scalalib/src/publish/SonatypePublisher.scala +++ b/scalalib/src/publish/SonatypePublisher.scala @@ -14,7 +14,8 @@ class SonatypePublisher(uri: String, signed: Boolean, readTimeout: Int, connectTimeout: Int, - log: Logger) { + log: Logger, + awaitTimeout: Int) { private val api = new SonatypeHttpApi(uri, credentials, readTimeout = readTimeout, connectTimeout = connectTimeout) @@ -54,7 +55,13 @@ class SonatypePublisher(uri: String, } val releaseGroups = releases.groupBy(_._1.group) for ((group, groupReleases) <- releaseGroups) { - publishRelease(release, groupReleases.flatMap(_._2), group, releases.map(_._1)) + publishRelease( + release, + groupReleases.flatMap(_._2), + group, + releases.map(_._1), + awaitTimeout + ) } } @@ -73,7 +80,8 @@ class SonatypePublisher(uri: String, private def publishRelease(release: Boolean, payloads: Seq[(String, Array[Byte])], stagingProfile: String, - artifacts: Seq[Artifact]): Unit = { + artifacts: Seq[Artifact], + awaitTimeout: Int): Unit = { val profileUri = api.getStagingProfileUri(stagingProfile) val stagingRepoId = api.createStagingRepo(profileUri, stagingProfile) @@ -91,13 +99,13 @@ class SonatypePublisher(uri: String, api.closeStagingRepo(profileUri, stagingRepoId) log.info("Waiting for staging repository to close") - awaitRepoStatus("closed", stagingRepoId) + awaitRepoStatus("closed", stagingRepoId, awaitTimeout) log.info("Promoting staging repository") api.promoteStagingRepo(profileUri, stagingRepoId) log.info("Waiting for staging repository to release") - awaitRepoStatus("released", stagingRepoId) + awaitRepoStatus("released", stagingRepoId, awaitTimeout) log.info("Dropping staging repository") api.dropStagingRepo(profileUri, stagingRepoId) @@ -122,11 +130,11 @@ class SonatypePublisher(uri: String, private def awaitRepoStatus(status: String, stagingRepoId: String, - attempts: Int = 20): Unit = { + awaitTimeout: Int): Unit = { def isRightStatus = api.getStagingRepoState(stagingRepoId).equalsIgnoreCase(status) - var attemptsLeft = attempts + var attemptsLeft = awaitTimeout / 3000 while (attemptsLeft > 0 && !isRightStatus) { Thread.sleep(3000) |