Skip to content

Instantly share code, notes, and snippets.

@metasim
Created March 22, 2016 13:19
Show Gist options
  • Select an option

  • Save metasim/0dcdb300cd835aa08918 to your computer and use it in GitHub Desktop.

Select an option

Save metasim/0dcdb300cd835aa08918 to your computer and use it in GitHub Desktop.
M2 publish to a directory in SBT
// Keys to have a submodule publish to a micro-repo.
val publishMicroRepo = taskKey[Unit]("Task to publish artifacts to a local brooklyn micro-repo")
val microRepoTargetDir = settingKey[File]("Directory where to save repository")
val microRepoPublishConfiguration = taskKey[sbt.PublishConfiguration]("Micro-repo publish task config")
val microRepoName = settingKey[String]("Unique sbt repository ID")
// ----------------------------------------------------------------------------
// Support for publishing core libraries to project micro-repo
// ----------------------------------------------------------------------------
lazy val publishSettings = Seq(
microRepoName := "publish-m2-other-project",
microRepoTargetDir := (baseDirectory in ThisBuild).value / ".." / "other-project" / "repo",
otherResolvers += MavenRepository(microRepoName.value, microRepoTargetDir.value.toURI.toASCIIString),
publishMicroRepo <<= publishTask(microRepoPublishConfiguration, deliverLocal),
packagedArtifacts in publishMicroRepo := (packagedArtifacts in Compile).value.filterNot(_._1.`type` == "src"),
microRepoPublishConfiguration := publishConfig(
(packagedArtifacts in publishMicroRepo).value, None,
resolverName = microRepoName.value,
checksums = checksums.in(publishMicroRepo).value,
logging = ivyLoggingLevel.value,
overwrite = isSnapshot.value)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment