Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output directory conflicts with IntelliJ #37

Closed
jportway opened this issue Aug 27, 2015 · 14 comments
Closed

Output directory conflicts with IntelliJ #37

jportway opened this issue Aug 27, 2015 · 14 comments

Comments

@jportway
Copy link

When IntelliJ imports an SBT project using the ScalaPB plugin it adds both directories:
"src_managed / main" and "src_managed / main / compiled_protobuf" to it's internal build system.
So when you build the project with IntelliJ the generated classes get included twice, causing conflicts.

is it possible to build directly into the "src_managed / main" directory ?
sbt-protobuf has some instructions about this, but it's not obvious how they map to ScalaPB.

@nadavsr
Copy link
Contributor

nadavsr commented Aug 27, 2015

Can you try setting "scalaSource in PB.protobufConfig", that should do it.

On Thu, Aug 27, 2015 at 12:37 PM, jportway [email protected] wrote:

When IntelliJ imports an SBT project using the ScalaPB plugin it adds both
directories:
"src_managed / main" and "src_managed / main / compiled_protobuf" to
it's internal build system.
So when you build the project with IntelliJ the generated classes get
included twice, causing conflicts.

is it possible to build directly into the "src_managed / main" directory ?
sbt-protobuf has some instructions
https://github.com/sbt/sbt-protobuf#changing-the-location-of-the-generated-java-files
about this, but it's not obvious how they map to ScalaPB.


Reply to this email directly or view it on GitHub
#37.

@jportway
Copy link
Author

That worked. Brilliant! Thank you.
Perhaps this is obvious to those who are experienced with SBT but for newcomers like me it would be really useful to have it documented. I've been striuggling all day with verious approaches to the problem.
thanks again.

@dmolesUC
Copy link

@jportway would you mind posting exactly what you did to which build files? I tried adding

scalaSource in PB.protobufConfig <<= (sourceManaged / "main")

to my build.sbt and refreshing the project, but target/src_managed/main isn't showing up as a source folder in the IDEA module.

(It doesn't help that I'm new to SBT, having built all my Scala projects with Gradle till now.)

@angelcervera
Copy link

angelcervera commented Jun 4, 2016

@nadavsr When you said : "Can you try setting "scalaSource in PB.protobufConfig", that should do it.", what do you mean exactly? Setting it with what values?

@dholbrook
Copy link

This is how I configured it to work with InteliJ

PB.protobufSettings
scalaSource in PB.protobufConfig <<= (sourceManaged in Compile)

@angelcervera
Copy link

@dholbrook #126

@dantodor
Copy link

dantodor commented Nov 4, 2016

I tried the same, but for whatever reason in IntelliJ protobufConfig shows in red, as if it's not a member of PB ... any idea(pun not intended) why ?
Thanks!

@thesamet
Copy link
Contributor

thesamet commented Nov 4, 2016

Are you using sbt-protoc? With it the defaults should just work with IntelliJ.

@dantodor
Copy link

dantodor commented Nov 7, 2016

In plugins.sbt I have

addSbtPlugin("com.thesamet" % "sbt-protoc" % "0.99.1")

libraryDependencies += "com.trueaccord.scalapb" %% "compilerplugin" % "0.5.42"

In build.sbt I have
PB.targets in Compile := Seq(scalapb.gen() -> (sourceManaged in Compile).value)

When I try to add the advised line in build.sbt, the .protobufConfig is red, assume somehow IntelliJ doesn't sees it as a member of PB ... what am I doing wrong ?

@thesamet
Copy link
Contributor

thesamet commented Nov 7, 2016

In sbt-protoc there's no PB.protobufConfig, this is probably coming from old code. What are you trying to accomplish?

NOTE: in sbt-protoc there's something called PB.ProtobufConfig (with capital P), but it's rarely needed and has a different role (hence the different name)

@dantodor
Copy link

dantodor commented Nov 9, 2016

I'm trying to get visibility of the generated classes in the project. As it is right now, all classes are shown in red, as they're not defined. Compiling via sbt works. But it's a nuisance to not be able to see class members in IntelliJ

@thesamet
Copy link
Contributor

thesamet commented Nov 9, 2016

Try importing the project to IntelliJ now that you have a few proto files. It looks like if there are no protocol buffers at the time the IntelliJ project is created it will not find the generated sources.

@dantodor
Copy link

I'll try that, thank you

@ndeverge
Copy link

For those still having the issue, I made it work with

scalaSource in sbtprotoc.ProtocPlugin.ProtobufConfig := (Compile / sourceManaged).value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants