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

ScalaPB + Intellij #120

Closed
nykolaslima opened this issue May 18, 2016 · 10 comments
Closed

ScalaPB + Intellij #120

nykolaslima opened this issue May 18, 2016 · 10 comments

Comments

@nykolaslima
Copy link

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?

@nadavsr
Copy link
Contributor

nadavsr commented May 18, 2016

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 <
notifications@github.com> 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
#120

@nykolaslima
Copy link
Author

@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")

@doctapp
Copy link

doctapp commented May 31, 2016

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

@thesamet
Copy link
Contributor

thesamet commented Jun 1, 2016

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 notifications@github.com
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
#120 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AASwrbjw3n-QEvKN9aJ8jagXzcABj27lks5qHIPegaJpZM4IhxLm
.

-Nadav

@doctapp
Copy link

doctapp commented Jun 1, 2016

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 notifications@github.com
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 notifications@github.com
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
<#120 (comment)
,
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
#120 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/ADbqNMUDrJmkRbGkD1wH6g_LTe4qEg6vks5qHRCigaJpZM4IhxLm
.

@nadavsr
Copy link
Contributor

nadavsr commented Jun 1, 2016

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

On Wed, Jun 1, 2016 at 4:33 AM, Martin Tapp notifications@github.com
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 notifications@github.com
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 notifications@github.com
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
<
#120 (comment)
,
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
<#120 (comment)
,
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
#120 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AHQbPuHJERSbDX6kQ5f19saDa3pUZafeks5qHW4hgaJpZM4IhxLm
.

@doctapp
Copy link

doctapp commented Jun 2, 2016

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 notifications@github.com
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 notifications@github.com
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 notifications@github.com
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 <
notifications@github.com>
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
<
#120 (comment)
,
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
<
#120 (comment)
,
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
<#120 (comment)
,
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
#120 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/ADbqNF9mH2ttOEgy-eZUb-VGRioJ4WvFks5qHYkFgaJpZM4IhxLm
.

@githubsheng
Copy link

githubsheng commented Jan 8, 2017

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

@rafaparadela
Copy link

@githubsheng

import sbtprotoc.ProtocPlugin.ProtobufConfig

And then

scalaSource in ProtobufConfig <<= (sourceDirectory in Compile)(_ / "generated-proto")

@ovesco
Copy link

ovesco commented Apr 13, 2021

For those having an error with SBT compilation, this line did the job for me (based on @rafaparadela's answer, but with the new syntax)

scalaSource in sbtprotoc.ProtocPlugin.ProtobufConfig := sourceDirectory.value / "generated-proto"

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

7 participants