*.proto files are ignored - protocol-buffers

Im trying to use protobuffers and scalaPB, i've added:
import com.trueaccord.scalapb.compiler.Version.scalapbVersion
libraryDependencies += "com.trueaccord.scalapb" %% "scalapb-runtime" %
scalapbVersion % "protobuf"
PB.targets in Compile := Seq(
scalapb.gen() -> (sourceManaged in Compile).value
)
and below lines to plugins.sbt
addSbtPlugin("com.thesamet" % "sbt-protoc" % "0.99.3")
libraryDependencies += "com.trueaccord.scalapb" %% "compilerplugin" % "0.5.47"
and .proto file under src/main/protobuf:
syntax = "proto3";
import "scalapb/scalapb.proto";
import "google/protobuf/wrappers.proto";
package actors;
message ExamplePROTO {
double value = 1;
}
but using sbt compile nothing happens - class is not generated in target. File is ignored, because even with some typo in protobuf file project still compiles. Ive also tried to look at debug logs using
logLevel in Global := Level.Debug
but the only files .proto which are mentioned there are some internal ones like: /target/protobuf_external/google/protobuf/source_context.proto
How can I proceed with it? Can I get some more information what scalaPB is looking at?

Related

Protobuf: to use same Message name with different packages

I am using protobuf java, with following .proto
// service1.proto
option java_package = "package";
option java_outer_classname = "Proto1";
message M {
... // some definition
}
and
// service2.proto
option java_package = "package";
option java_outer_classname = "Proto2";
message M {
... // some different definition
}
while compile, error is thrown in service2.proto saying that "M" is already defined in service1.proto
But from package and generated code they should be package.Proto1.M and package.Proto2.M, is this conflict?
The "package" is also a .proto concept (not just a language/framework concept); if you need to have both schemas involved in anything, it may be useful to add
package Proto1;
to service1.proto and
package Proto2;
to service2.proto
Alternatively, if the M is actually the same in both places: move M to a different single file, and use import from both service1.proto and service2.proto

Unsupported tarball from ... File located at "result" is a symbolic link to absolute path

I used cachix for nix if it has any bearing, and reinstalled stack, too. The repo in question is at: https://github.com/NorfairKing/tickler
[jk#jk tickler]$ stack build
Cloning 85ee8a577fb576e2dd7643bf248ff8fbbe9598ec from git#github.com:NorfairKing/pretty-relative-time.git
Enter passphrase for key '/home/jk/.ssh/id_rsa':
Unsupported tarball from /tmp/with-repo-archive30826/foo.tar: File located at "result" is a symbolic link to absolute path /nix/store/j0l1f389pmxdazxr0h0ax8v6c8ln578h-pretty-relative-time-0.0.0.0
Running nix build:
[jk#jk tickler]$ nix build
error: Please be informed that this pseudo-package is not the only part of
Nixpkgs that fails to evaluate. You should not evaluate entire Nixpkgs
without some special measures to handle failing packages, like those taken
by Hydra.
let
pkgsv = import (import ./nix/nixpkgs.nix);
pkgs = pkgsv {};
intray-version = import ./nix/intray-version.nix;
intray-repo = pkgs.fetchFromGitHub intray-version;
intray-overlay = import (intray-repo + "/nix/overlay.nix");
validity-version = import (intray-repo + "/nix/validity-version.nix");
validity-overlay = import (pkgs.fetchFromGitHub validity-version + "/nix/overlay.nix");
in pkgsv {
overlays = [ validity-overlay intray-overlay (import ./nix/overlay.nix) ];
config.allowUnfree = true;
}

Golang invalid import path when importing from "main" folder

Been trying for the last few days to get rid of "invalid import path:"Atom First project/main/Extension" (build)" error when installing my main.go file but i haven't been able to find the reason behind the error.
OS - Windows 10
IDE - Atom
GOBIN - E:\Github Repository\Programming\Golang\bin
GOPATH - E:\Github Repository\Programming\Golang
File DIR- E:\Github Repository\Programming\Golang\src\Atom First project\main\main.go
E:\Github Repository\Programming\Golang\src\Atom First project\main\Extension/foo.go
main.go
package main
import (
"Atom First project/main/Extension"
)
func main() {
Extension.Extend()
}
foo.go
package Extension
import (
"fmt"
)
func Extend(){
fmt.Println("Hello from Extend func")
}
It's simple: import paths cannot contain spaces. Spec: Import declarations:
Implementation restriction: A compiler may restrict ImportPaths to non-empty strings using only characters belonging to Unicode's L, M, N, P, and S general categories (the Graphic characters without spaces) and may also exclude the characters !"#$%&'()*,:;<=>?[]^`{|} and the Unicode replacement character U+FFFD.
Simply rename your Atom First project folder to e.g. atom-first-project, and change the import declaration.
import (
"atom-first-project/main/Extension"
)
Also note that the package name (which is usually the folder name but not necessarily) must be a valid Go identifier. Spec: Package clause:
A package clause begins each source file and defines the package to which the file belongs.
PackageClause = "package" PackageName .
PackageName = identifier .

How to delete files on Windows with Rapture IO

I'm writing Scala code. What is the correct path schema for writing a URI when using Rapture to operate with files on Windows? I have added the following dependencies:
libraryDependencies += "com.propensive" %% "rapture" % "2.0.0-M3" exclude("com.propensive","rapture-json-lift_2.11")
Here is part of my code:
import rapture.uri._
import rapture.io._
val file = uri"file:///C:/opt/eric/spark-demo"
file.delete()
but I got the message:
Error:(17, 16) value file is not a member of object rapture.uri.UriContext
val file = uri"file:///C:/opt/eric/spark-demo"
or I tried this one:
val file = uri"file://opt/eric/spark-demo"
The same error:
Error:(17, 16) value file is not a member of object rapture.uri.UriContext
val file = uri"file://opt/eric/spark-demo"
And my local path is:
C:\opt\eric\spark-demo
How can I avoid the error?
You're missing an import:
import rapture.io._
import rapture.uri._
import rapture.fs._
val file = uri"file:///C:/opt/eric/spark-demo"
file.delete()
rapture.fs is the package defining an EnrichedFileUriContext implicit class, which is what the uri macro trys to build when being provided with a file URI scheme.

proto3 -> go with custom extensions resulting in imports to package ("google/protobuf") in go code

I am prototyping a meta model on top of proto3. To generate domain specific boilerplate as the go proto3 extension syntax is ridiculously expressive. My domain proto files depend on meta.proto which contain the extensions.
I can compile the these to go. When including the meta.proto file the generated go ends up with the following include block:
import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
import google_protobuf "google/protobuf" <--- this import does not exist !!
My extension file has the following structure(based off this):
syntax = "proto2";
package "...";
option go_package = "...";
import "google/protobuf/descriptor.proto"; <--- this causes the import
// message MyExtensionClass ...
// message MyExtensionField ...
extend google.protobuf.MessageOptions {
optional MyExtensionClass class = 50000;
}
extend google.protobuf.FieldOptions {
optional MyExtensionField field = 50001;
}
I know the solution is likely very simple, the google/protobuf include is meant for C++ generation.
In my workspace the included package should be "github.com/golang/protobuf/protoc-gen-go/descriptor"
Poor mans solution. Not ideal, directing it to the relevant go import works:
sed -i '' -e 's/import google_protobuf \"google\/protobuf\"/import google_protobuf \"github.com\/golang\/protobuf\/protoc-gen-go\/descriptor\"/g' pkg/domain/proto/extensions/*.pb.go

Resources