sbt-ssh-git-proto-deployment-poc

sbt-ssh-git-proto-deployment-PoC

This is a Proof of Concept project that demonstrates how to compile protobuf file
that depends on another external protobuf file that lives in another git repository.

1. Requirements:

  1. sbt
  2. sbt-protoc plugin to compile .proto files to .java .scala classes
  3. SSH key (in ~/.ssh/) to access private git repository

2. Set build.sbt

  • If you need to reference a sbt sub-project from the github repository:

    lazy val sbtProjectFromOtherGitRepo = ProjectRef(
      build = uri("ssh://git@github.com/<user>/<repo>.git#<branch|commit|tag>"),
      project = "sub-project"
    )
  • Else just specify github repository:

    lazy val projectFromOtherGitRepo = RootProject(
      build = uri("ssh://git@github.com/<user>/<repo>.git#<branch|commit|tag>")
    )

Dependency projects will be cloned/checkouted to: ~/.sbt/<sbt version>/staging/<sha>/<repo>/

  • Then using sbt-protoc specify location of .proto files from project dependency:

    PB.protoSources in Compile ++= Seq(
      baseDirectory.in(projectFromOtherGitRepo).value / "path/to/folder/where/protos/are"
    )

3. Run:

  1. git clone git@github.com:fpopic/sbt-ssh-git-proto-deployment-poc.git
  2. cd sbt-ssh-git-proto-deployment-poc
  3. sbt
  4. compile

4. Notes:

External projects that the current project depends on (RootProject) are not getting updated using sbt update command after they have been changed in git,
(that’s reason why it’s always better to hardcode “immutable” commit/tag version of the dependency than just specifying the repository name), so if a dependend project changes sbt won’t reupdate the source code of the dependency

This PoC is made for CI automatization (Jenkins) for deploying proto files to maven repository (every time cloning from scratch)

Visit original content creator repository
https://github.com/fpopic/sbt-ssh-git-proto-deployment-poc

Comments

One response to “sbt-ssh-git-proto-deployment-poc”

  1. fjuhjojmrh Avatar

    neymjxfsgmfxjsypvvgukjivolxuzi

Leave a Reply

Your email address will not be published. Required fields are marked *