Skip to content

Commit

Permalink
Publish results of build locally, instead of uploading artifact to lo…
Browse files Browse the repository at this point in the history
…cal repo
  • Loading branch information
WojciechMazur committed Sep 4, 2023
1 parent e96c306 commit bfaa751
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 33 deletions.
26 changes: 2 additions & 24 deletions project-builder/mill/MillCommunityBuild.sc
Original file line number Diff line number Diff line change
Expand Up @@ -82,30 +82,8 @@ trait CommunityBuildCoursierModule extends CoursierModule { self: JavaModule =>
}

// Extension to publish module allowing to upload artifacts to custom maven repo
// Left for compliance with legacy versions
trait CommunityBuildPublishModule extends PublishModule with CommunityBuildCoursierModule {
def publishCommunityBuild() = T.command {
val PublishModule.PublishData(metadata, artifacts) = publishArtifacts()
val artifactModulePath = {
val org = metadata.group.replace(".", "/")
s"$org/${metadata.id}/${metadata.version}"
}
for {
(artifactPath, artifactName) <- artifacts
repoUrl <- mavenRepoUrl
url = s"$repoUrl/$artifactModulePath/$artifactName"
} {
val res = put(
url = url,
data = RequestBlob.NioFileRequestBlob(artifactPath.path.toNIO),
verifySslCerts = false
)
if (!res.is2xx) {
throw new RuntimeException(
s"Failed to publish artifact ${url.stripPrefix(repoUrl)}: ${res.statusMessage}"
)
}
}
}
}

/** Replace all Scala in crossVersion with `buildScalaVersion` if its matching `buildScalaVersion`
Expand Down Expand Up @@ -268,7 +246,7 @@ def runBuild(configJson: String, targets: Seq[String])(implicit ctx: Ctx) = {
tryEval(module.publishVersion) match {
case Result.Success(`publishVersion`) =>
PublishResult(
evalAsDependencyOf(compileResult, docResult)(module.publishCommunityBuild)
evalAsDependencyOf(compileResult, docResult)(module.publishLocal)
)
case Result.Success(version: String) =>
PublishResult(
Expand Down
10 changes: 1 addition & 9 deletions project-builder/sbt/CommunityBuildPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ object CommunityBuildPlugin extends AutoPlugin {

val runBuild = inputKey[Unit]("")
val moduleMappings = inputKey[Unit]("")
val publishResults = taskKey[Unit]("")
val publishResultsConf = taskKey[PublishConfiguration]("")

import complete.DefaultParsers._

Expand All @@ -82,12 +80,6 @@ object CommunityBuildPlugin extends AutoPlugin {
.map("Community Build Repo".at(_))
.map { ourResolver =>
Seq(
publishResultsConf :=
publishM2Configuration.value
.withPublishMavenStyle(true)
.withResolverName(ourResolver.name)
.withOverwrite(true),
publishResults := Classpaths.publishTask(publishResultsConf).value,
externalResolvers := ourResolver +: externalResolvers.value
)
}
Expand Down Expand Up @@ -543,7 +535,7 @@ object CommunityBuildPlugin extends AutoPlugin {
)
else
PublishResult(
evalAsDependencyOf(compileResult)(Compile / publishResults)
evalAsDependencyOf(compileResult)(Compile / publishLocal)
)
}

Expand Down

0 comments on commit bfaa751

Please sign in to comment.