Scalapb: Case class and object conflict

Created on 26 Oct 2015  路  3Comments  路  Source: scalapb/ScalaPB

After generating pb files, I cannot rebuild the project with this error

Error:(10, 18) LoginFailed is already defined as case class LoginFailed
final case class LoginFailed(

Error:(56, 8) LoginFailed is already defined as object LoginFailed
object LoginFailed extends com.trueaccord.scalapb.GeneratedMessageCompanion[LoginFailed] {

Most helpful comment

I found the problem. IntelliJ automatically marks two directories as "source root" so it tries to rebuild twice with the same files. Unmarking the "main" folder as a source root solves the problem.

Before:
screen shot 2015-11-01 at 2 28 49 pm

After:
screen shot 2015-11-01 at 2 26 26 pm

All 3 comments

Can you do an sbt clean and try again? This may happen if you move classes around and you have old Scala files lying around.

If this still happens, can you post a sample project on github that can help reproduce this problem?

Here you go: https://github.com/lapminglee/scalapb_build_conflict.git

Repro steps:
1) I am using IntelliJ Idea 14.1
2) Open the sbt console (you need to install the IntelliJ plugin) and type "clean" and "compile"
3) Once it compiles, the generated files will sit in the "target" folder
4) Then click rebuild in the Build -> Rebuild Project

I think the conflict is because the generated files are by default generated into the target folder and IntelliJ is trying to read the file twice.

I found the problem. IntelliJ automatically marks two directories as "source root" so it tries to rebuild twice with the same files. Unmarking the "main" folder as a source root solves the problem.

Before:
screen shot 2015-11-01 at 2 28 49 pm

After:
screen shot 2015-11-01 at 2 26 26 pm

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nmost picture nmost  路  3Comments

mroth picture mroth  路  10Comments

ejconlon picture ejconlon  路  9Comments

dhuadaar picture dhuadaar  路  13Comments

sideeffffect picture sideeffffect  路  36Comments