sbt-idea icon indicating copy to clipboard operation
sbt-idea copied to clipboard

in multiple projects setup, the project-build content root is incorrect

Open chesterxgchen opened this issue 11 years ago • 10 comments

If you have project setup like Parent depends on Child1 and child2

parent/project parent/child1/project parent/child2/project

at parent you run

sbt gen-idea

the conten root of the project-child1-build and project-child2-build all points to project-parent-build which is "parent/project" instead of parent/child1/project and parent/child2/project

IDEA complains about this is you trying to edit project structure.

chesterxgchen avatar Apr 25 '13 17:04 chesterxgchen

Yes, this kind of setup is probably not correctly supported right now. I think this is pretty rare setup(?), as I don't remember seeing a single project with dedicated project definition directory for every child project.

Pull requests welcomed! :)

mpeltonen avatar Apr 29 '13 16:04 mpeltonen

Thanks for looking at. The sbt-idea plugin is great. Saved me a lot of times. The project setup came from following consideration. I want to enforce the clear separation for different child projects, so they can develop and tests independently, of course, we module/project level dependency.

So all the children projects can be considered as independent projects, where the dependency among them is specified via jar file in SBT files. These jar files are produced and published via sbt publish-local

But at the same time, this kind of setup is not efficient for development, as we might need to change several child projects to make different but related changes.

So we thought, we can simple create a parent-child project structure by bringing the child projects directly into the parent project with minimal changes in child sbt configuration (removing the jar dependency and replace it with parent-level specified project dependency)

With this setup, the child project can be split from parent project if we wish too, and become a independent project very easily.

chesterxgchen avatar Apr 29 '13 22:04 chesterxgchen

Ok, thanks for the details. Sounds like a reasonable use case.

mpeltonen avatar Apr 30 '13 06:04 mpeltonen

Could you create a simple example project to github, demonstrating the issue?

mpeltonen avatar Apr 30 '13 06:04 mpeltonen

Having the same issue. Started a new project and configured it in .scala file like this:

import sbt._
import Keys._

object IntegrationBuild extends Build {
  lazy val root = Project(id = "integration-root",
    base = file(".")) aggregate(server, client)

  lazy val messages = Project(id = "integration-messages",
    base = file("integration-messages"))

  lazy val server = Project(id = "integration-server",
    base = file("integration-server")) dependsOn (messages)

  lazy val client = Project(id = "integration-client",
    base = file("integration-client")) dependsOn (messages)

}

Don't know why, but every time I do a gen-idea, Idea forgets about configured JDK, so I have to reset it. And set content root to every -build subproject. Wich isn't all that difficult, just a little bit annoying) Would appreciate if that bug is solved.

vasa-chi avatar Apr 30 '13 12:04 vasa-chi

Don't know why, but every time I do a gen-idea, Idea forgets about configured JDK

What are your JDK names in Idea? Only "1.6" and "1.7" work, I think. The one added to Idea metafiles is based on the java version you run 'gen-idea' with.

mpeltonen avatar Apr 30 '13 12:04 mpeltonen

Yep. I have a JDK named "1.7" configured, but it seems that gen-idea adds another JDK named "1.7 (2)" and it is somehow misconfigured... Here's a screenshot. 2013-04-30 18 32 44

Also wow, it's possible to configure JDK for the whole project))))))) And here I was resetting it for every subproject :(

vasa-chi avatar Apr 30 '13 14:04 vasa-chi

I created a sample multi project setup in https://github.com/chesterxgchen/multiproject

you can run sbt gen-idea on the parent project to see the issue.

chesterxgchen avatar Apr 30 '13 17:04 chesterxgchen

Thanks @chesterxgchen!

mpeltonen avatar May 01 '13 11:05 mpeltonen

I am having this issue. It is not very hard to fix by hand, but it is a nice to have.

malaverdiere avatar Dec 03 '13 19:12 malaverdiere