ScalaPB + Intellij

Created on 19 May 2016  ยท  9Comments  ยท  Source: scalapb/ScalaPB

The default ScalaPB configuration only generated the .class into the output dir.

I need to have the generated .scala classes in order to Intellij see it. How can I configure the .scala classes output dir?

Most helpful comment

scalaSource in PB.protobufConfig <<= (sourceDirectory in Compile)(_ / "generated-proto")
does not seem to work with the latest scalapb. I got value protobufConfig is not a member of object sbtprotoc.ProtocPlugin.autoImport.PB error. Using the latest scalapb, the generated files are inside target folder and Intellij's default setting ignores anything in that folder.

how can I change the output path now?

Thanks

All 9 comments

Hi Nykolas,

IntelliJ should be able to see the files in the default place where ScalaPB
puts them, however you can control this by putting something like the
following in build.sbt:

scalaSource in PB.protobufConfig <<= (sourceManaged in Compile) { _ / "
compiled_protobuf" }

or

scalaSource in PB.protobufConfig := file("path/to/somewhere")

On Wed, May 18, 2016 at 3:45 PM, Nykolas Laurentino de Lima <
[email protected]> wrote:

The default ScalaPB configuration only generated the .class into the
output dir.

I need to have the generated .scala classes in order to Intellij see it.
How can I configure the .scala classes output dir?

โ€”
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
https://github.com/trueaccord/ScalaPB/issues/120

@nadavsr thank you very much! I was already posting the solution because I saw it on another issue, thank you anyway!

scalaSource in PB.protobufConfig <<= (sourceDirectory in Compile)(_ / "generated-proto")

Had the same problem, IntelliJ won't see the generated proto classes. Used the following trick:

scalaSource in PB.protobufConfig <<= (sourceDirectory in Compile)(_ / "generated-proto")

@nadavsr You mentioned IntelliJ should see the generated classes, why do we need to add this? I'm using IntelliJ 2016.1.2 with ScalaPB 0.5.27.

Thanks

IntelliJ should see the files in the right place even if you don't add
this. The limitation is that IntelliJ won't generate the files. You need to
generate the files from the SBT shell (by compiling there first). IntelliJ
should pick them up.

On Tue, May 31, 2016 at 11:54 AM, Martin Tapp [email protected]
wrote:

Had the same problem, IntelliJ won't see the generated proto classes. Used
the following trick:

scalaSource in PB.protobufConfig <<= (sourceDirectory in Compile)(_ /
"generated-proto")

@nadavsr https://github.com/nadavsr You mentioned IntelliJ should see
the generated classes, why do we need to add this? I'm using IntelliJ
2016.1.2 with ScalaPB 0.5.27.

Thanks

โ€”
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/trueaccord/ScalaPB/issues/120#issuecomment-222785123,
or mute the thread
https://github.com/notifications/unsubscribe/AASwrbjw3n-QEvKN9aJ8jagXzcABj27lks5qHIPegaJpZM4IhxLm
.

-Nadav

By default, my setup doesn't work with IntelliJ. I see the files generated
under target/scala-2.10/src_managed/[package]/[* proto classes].scala. I
did a full clean/compile with sbt. Even tried a SBT refresh from IntelliJ.
Only way IntelliJ sees the generated classes after being compiled from sbt
is if I add scalaSource in PB.protobufConfig <<= (sourceDirectory in Compile)(_ / "generated-proto").

What can I check?

Thanks

On Wed, Jun 1, 2016 at 12:54 AM, Nadav Samet [email protected]
wrote:

IntelliJ should see the files in the right place even if you don't add
this. The limitation is that IntelliJ won't generate the files. You need to
generate the files from the SBT shell (by compiling there first). IntelliJ
should pick them up.

On Tue, May 31, 2016 at 11:54 AM, Martin Tapp [email protected]
wrote:

Had the same problem, IntelliJ won't see the generated proto classes.
Used
the following trick:

scalaSource in PB.protobufConfig <<= (sourceDirectory in Compile)(_ /
"generated-proto")

@nadavsr https://github.com/nadavsr You mentioned IntelliJ should see
the generated classes, why do we need to add this? I'm using IntelliJ
2016.1.2 with ScalaPB 0.5.27.

Thanks

โ€”
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<https://github.com/trueaccord/ScalaPB/issues/120#issuecomment-222785123
,
or mute the thread
<
https://github.com/notifications/unsubscribe/AASwrbjw3n-QEvKN9aJ8jagXzcABj27lks5qHIPegaJpZM4IhxLm

.

-Nadav

โ€”
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/trueaccord/ScalaPB/issues/120#issuecomment-222892466,
or mute the thread
https://github.com/notifications/unsubscribe/ADbqNMUDrJmkRbGkD1wH6g_LTe4qEg6vks5qHRCigaJpZM4IhxLm
.

Can you try to 'rm -rf .idea' and reimport the project into IntelliJ?

On Wed, Jun 1, 2016 at 4:33 AM, Martin Tapp [email protected]
wrote:

By default, my setup doesn't work with IntelliJ. I see the files generated
under target/scala-2.10/src_managed/[package]/[* proto classes].scala. I
did a full clean/compile with sbt. Even tried a SBT refresh from IntelliJ.
Only way IntelliJ sees the generated classes after being compiled from sbt
is if I add scalaSource in PB.protobufConfig <<= (sourceDirectory in Compile)(_ / "generated-proto").

What can I check?

Thanks

On Wed, Jun 1, 2016 at 12:54 AM, Nadav Samet [email protected]
wrote:

IntelliJ should see the files in the right place even if you don't add
this. The limitation is that IntelliJ won't generate the files. You need
to
generate the files from the SBT shell (by compiling there first).
IntelliJ
should pick them up.

On Tue, May 31, 2016 at 11:54 AM, Martin Tapp [email protected]
wrote:

Had the same problem, IntelliJ won't see the generated proto classes.
Used
the following trick:

scalaSource in PB.protobufConfig <<= (sourceDirectory in Compile)(_ /
"generated-proto")

@nadavsr https://github.com/nadavsr You mentioned IntelliJ should
see
the generated classes, why do we need to add this? I'm using IntelliJ
2016.1.2 with ScalaPB 0.5.27.

Thanks

โ€”
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<
https://github.com/trueaccord/ScalaPB/issues/120#issuecomment-222785123
,
or mute the thread
<

https://github.com/notifications/unsubscribe/AASwrbjw3n-QEvKN9aJ8jagXzcABj27lks5qHIPegaJpZM4IhxLm

.

-Nadav

โ€”
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<https://github.com/trueaccord/ScalaPB/issues/120#issuecomment-222892466
,
or mute the thread
<
https://github.com/notifications/unsubscribe/ADbqNMUDrJmkRbGkD1wH6g_LTe4qEg6vks5qHRCigaJpZM4IhxLm

.

โ€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/trueaccord/ScalaPB/issues/120#issuecomment-222966575,
or mute the thread
https://github.com/notifications/unsubscribe/AHQbPuHJERSbDX6kQ5f19saDa3pUZafeks5qHW4hgaJpZM4IhxLm
.

Thanks, but that didn't work. Seems anything under target/ is not
considered sources by IntelliJ. I have the same problem with Scrooge for
Thrift and did the same hack of redirecting to a generated folder under
src/main.

If you know of a better trick or that would embed this within ScalaPB, that
would be super!

Martin

On Wed, Jun 1, 2016 at 9:28 AM, Nadav S. Samet [email protected]
wrote:

Can you try to 'rm -rf .idea' and reimport the project into IntelliJ?

On Wed, Jun 1, 2016 at 4:33 AM, Martin Tapp [email protected]
wrote:

By default, my setup doesn't work with IntelliJ. I see the files
generated
under target/scala-2.10/src_managed/[package]/[* proto classes].scala. I
did a full clean/compile with sbt. Even tried a SBT refresh from
IntelliJ.
Only way IntelliJ sees the generated classes after being compiled from
sbt
is if I add scalaSource in PB.protobufConfig <<= (sourceDirectory in Compile)(_ / "generated-proto").

What can I check?

Thanks

On Wed, Jun 1, 2016 at 12:54 AM, Nadav Samet [email protected]
wrote:

IntelliJ should see the files in the right place even if you don't add
this. The limitation is that IntelliJ won't generate the files. You
need
to
generate the files from the SBT shell (by compiling there first).
IntelliJ
should pick them up.

On Tue, May 31, 2016 at 11:54 AM, Martin Tapp <
[email protected]>
wrote:

Had the same problem, IntelliJ won't see the generated proto classes.
Used
the following trick:

scalaSource in PB.protobufConfig <<= (sourceDirectory in Compile)(_ /
"generated-proto")

@nadavsr https://github.com/nadavsr You mentioned IntelliJ should
see
the generated classes, why do we need to add this? I'm using IntelliJ
2016.1.2 with ScalaPB 0.5.27.

Thanks

โ€”
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<
https://github.com/trueaccord/ScalaPB/issues/120#issuecomment-222785123
,
or mute the thread
<

https://github.com/notifications/unsubscribe/AASwrbjw3n-QEvKN9aJ8jagXzcABj27lks5qHIPegaJpZM4IhxLm

.

-Nadav

โ€”
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<
https://github.com/trueaccord/ScalaPB/issues/120#issuecomment-222892466
,
or mute the thread
<

https://github.com/notifications/unsubscribe/ADbqNMUDrJmkRbGkD1wH6g_LTe4qEg6vks5qHRCigaJpZM4IhxLm

.

โ€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<https://github.com/trueaccord/ScalaPB/issues/120#issuecomment-222966575
,
or mute the thread
<
https://github.com/notifications/unsubscribe/AHQbPuHJERSbDX6kQ5f19saDa3pUZafeks5qHW4hgaJpZM4IhxLm

.

โ€”
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/trueaccord/ScalaPB/issues/120#issuecomment-222991879,
or mute the thread
https://github.com/notifications/unsubscribe/ADbqNF9mH2ttOEgy-eZUb-VGRioJ4WvFks5qHYkFgaJpZM4IhxLm
.

scalaSource in PB.protobufConfig <<= (sourceDirectory in Compile)(_ / "generated-proto")
does not seem to work with the latest scalapb. I got value protobufConfig is not a member of object sbtprotoc.ProtocPlugin.autoImport.PB error. Using the latest scalapb, the generated files are inside target folder and Intellij's default setting ignores anything in that folder.

how can I change the output path now?

Thanks

@githubsheng

import sbtprotoc.ProtocPlugin.ProtobufConfig

And then

scalaSource in ProtobufConfig <<= (sourceDirectory in Compile)(_ / "generated-proto")
Was this page helpful?
0 / 5 - 0 ratings

Related issues

ngbinh picture ngbinh  ยท  4Comments

matt-christiansen-exa picture matt-christiansen-exa  ยท  36Comments

mroth picture mroth  ยท  10Comments

jportway picture jportway  ยท  13Comments

xuwei-k picture xuwei-k  ยท  6Comments