From b5d32288d2b115adb7728e827bbbb1221e5fdcfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Richez?= Date: Fri, 21 Jul 2023 15:56:27 +0200 Subject: [PATCH] fix module --- build.sc | 40 ++++++++++++++++++++++++++++++++++++++- plugins/githubPackages.sc | 34 +-------------------------------- 2 files changed, 40 insertions(+), 34 deletions(-) diff --git a/build.sc b/build.sc index ef26f23..9f18fb9 100644 --- a/build.sc +++ b/build.sc @@ -9,6 +9,8 @@ import mill.scalalib._ import mill.scalalib.bsp.ScalaMetalsSupport import mill.scalalib.publish.{Developer, License, PomSettings, VersionControl} import mill.scalalib.scalafmt.ScalafmtModule +import $file.plugins.githubPackages +import githubPackages.{GithubPackagesPublishModule, GithubPackagesPublisher} object core extends CommonModule with ArmadilloPublishModule { override def ivyDeps = Agg( @@ -293,7 +295,10 @@ trait CommonModule extends BaseModule { ) } -trait ArmadilloPublishModule extends PublishModule { +trait ArmadilloPublishModule extends GithubPackagesPublishModule { + + def githubOwner: String = "input-output-hk" + def githubRepository: String = "armadillo" def publishVersion = VcsVersion.vcsState().format() @@ -328,3 +333,36 @@ object Version { val Fs2 = "3.4.0" val Logback = "1.4.5" } + +object GithubPackagesPublishModule extends mill.Module { + import mill.scalalib.publish.Artifact + + def publishAll( + publishArtifacts: mill.main.Tasks[PublishModule.PublishData], + token: String, + githubOwner: String, + githubRepository: String, + readTimeout: Int = 60000, + connectTimeout: Int = 5000 + ) = + T.command { + + val x: Seq[(Seq[(os.Path, String)], Artifact)] = + T.sequence(publishArtifacts.value)().map { case PublishModule.PublishData(a, s) => + (s.map { case (p, f) => (p.path, f) }, a) + } + new GithubPackagesPublisher( + githubOwner, + githubRepository, + token, + readTimeout, + connectTimeout, + T.log + ).publishAll( + x: _* + ) + } + + lazy val millDiscover: mill.define.Discover[this.type] = + mill.define.Discover[this.type] +} diff --git a/plugins/githubPackages.sc b/plugins/githubPackages.sc index 3b78f01..2b2ca45 100644 --- a/plugins/githubPackages.sc +++ b/plugins/githubPackages.sc @@ -156,10 +156,9 @@ trait GithubPackagesPublishModule extends PublishModule { def publishGithubPackages( token: String, - // publish: Boolean = true, readTimeout: Int = 60000, connectTimeout: Int = 5000 - ): define.Command[Unit] = + ) = T.command { val PublishModule.PublishData(artifactInfo, artifacts) = publishArtifacts() @@ -174,34 +173,3 @@ trait GithubPackagesPublishModule extends PublishModule { ).publish(artifacts.map { case (a, b) => (a.path, b) }, artifactInfo) } } - -object GithubPackagesPublishModule extends ExternalModule { - def publishAll( - token: String, - githubOwner: String, - githubRepository: String, - publishArtifacts: mill.main.Tasks[PublishModule.PublishData], - readTimeout: Int = 60000, - connectTimeout: Int = 5000 - ) = - T.command { - - val x: Seq[(Seq[(os.Path, String)], Artifact)] = - T.sequence(publishArtifacts.value)().map { case PublishModule.PublishData(a, s) => - (s.map { case (p, f) => (p.path, f) }, a) - } - new GithubPackagesPublisher( - githubOwner, - githubRepository, - token, - readTimeout, - connectTimeout, - T.log - ).publishAll( - x: _* - ) - } - - lazy val millDiscover: mill.define.Discover[this.type] = - mill.define.Discover[this.type] -}