https://github.com/fpopic/sbt-ssh-git-proto-deployment-poc
(PoC) This repository is consuming some examples of protobuf files from another repository.
https://github.com/fpopic/sbt-ssh-git-proto-deployment-poc
dependency git protocol-buffers sbt sbt-protoc scalapb
Last synced: 3 months ago
JSON representation
(PoC) This repository is consuming some examples of protobuf files from another repository.
- Host: GitHub
- URL: https://github.com/fpopic/sbt-ssh-git-proto-deployment-poc
- Owner: fpopic
- Created: 2018-10-30T12:21:23.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-07-29T07:01:47.000Z (almost 6 years ago)
- Last Synced: 2025-02-28T05:58:47.655Z (over 1 year ago)
- Topics: dependency, git, protocol-buffers, sbt, sbt-protoc, scalapb
- Language: Scala
- Homepage:
- Size: 24.4 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### 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](https://github.com/fpopic/github-repo-hosting-protobuf).
#### 1. Requirements:
1. [sbt](https://www.scala-sbt.org/download.html)
2. [sbt-protoc plugin](project/protoc.sbt) 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:
```scala
lazy val sbtProjectFromOtherGitRepo = ProjectRef(
build = uri("ssh://git@github.com//.git#"),
project = "sub-project"
)
```
- Else just specify github repository:
```scala
lazy val projectFromOtherGitRepo = RootProject(
build = uri("ssh://git@github.com//.git#")
)
```
Dependency projects will be cloned/checkouted to: `~/.sbt//staging///`
- Then using `sbt-protoc` specify location of .proto files from project dependency:
```scala
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```
2. ```sbt```
3. ```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
- Workaround is to delete sbt staging folder before update so the project will always clone from git
```bash
rm -r ~/.sbt//staging/
sbt update
```
You can maybe create a sbt external task and name it [cleanStagingAndUpdate](https://groups.google.com/forum/#!topic/simple-build-tool/YJnUNSjrU6Q)
- Or use sbt for downloading git repos and then ```publishLocal``` to get .jar and add jar to ```libraryDependencies``` instead of `dependsOn(project)`
- https://github.com/sbt/sbt/issues/1284
- https://stackoverflow.com/questions/22432666/how-can-sbt-project-import-library-from-github-cloned-to-local-directory
This PoC is made for CI automatization (Jenkins) for deploying proto files to maven repository (every time cloning from scratch)