sbt-idea
sbt-idea copied to clipboard
Unable to build project in IDEA after running gen-idea
Each time I update my SBT configuration and run gen-idea
I am unable to build my project in IDEA. The problem is that the root-build
project has the same location for the Output path and Test output path.
Attempting to build the project always generates the following error:
scala: Output path /home/xxx/myproject/project/target/scala_2.9.2 is shared between: Module 'root-build' production, Module 'root-build' tests
Currently external Scala compiler prohibits output path sharing.
Either disable the external build mode or configure separate output paths.
TIP: you can use Project Artifacts to combine compiled classes.
As the external compiler is the default option in IDEA it would be very good to not have to manually change this each time I update the build settings.
looks similar to #200 what is your sbt-idea version?
I am using 1.2.0 with sbt 0.12.1, so it might well be similar to #200. I will look forward to the 1.3.0 release.
current stable version is 1.4.0 and there is 1.5.0-SNAPSHOT
I'm running into the same issue with sbt 0.12.3 and 1.4.0. This is in IDEA 12.1.3.
Well I think I fixed it by opening the module settings for the -build module and simply replacing the paths with custom ones. I still get warnings though that these paths intersect with a source root. Oh well.
+1 to mttkay -- I'm having this issue on a new project using sbt 0.12.3 and 1.4.0 w/ IDEA 12.1.4.
That's has been fixed in 1.5.0-SNAPSHOT if i remember correctly
This should be fixed already since 1.3.0. If someone is still experiencing this, a complete sample project which shows the problem would be great.
I see this problem still using sbt 0.12.4 and 1.5.1 with IDEA 12.1.4.
An example project that demonstrates the issue for me is Spray. For example, commit 8a4e617ce6e2c0ed2cc8cf5a4314ed9ec41fe0b3 on the master branch.
@asnare: Strange! I tried the exact same combination with the Spray commit above, and didn''t get any errors when compiling in Idea after 'sbt gen-idea'.
What is the exact error you're getting? You could try closing Idea, do rm -rf .idea*
in project root directory, run sbt gen-idea
and then reopen Idea and the project. Still getting the same error?
What does grep '<output' .idea_modules/root-build.iml
in project root directory give immediately after 'gen-idea'?
@mpeltonen: Thanks for the prompt response!
So, the plot thickens. With a repository I checked out earlier today (and have been working with) I still see the same error, including after trying your suggestions. (Earlier I was using 1.4.0 but have since upgraded before I posted on this issue.)
However with a fresh checkout, I don't see the error.
Tomorrow I'll dig further to try and work out what the differences are.
(As far as I can tell my environment is pretty standard, with the exception that my JDK has the name 'JDK 1.7' instead of '1.7' and therefore the default project SDK needs to be tweaked the first time I open it.)
With the problematic repository I get the following error message:
scala: Output path /Users/asnare/work/xebia/tomtom/spray/project/target/idea-test-classes is shared between: Module 'docs-build' tests, Module 'echo-server-build' tests, Module 'examples-build' tests, Module 'on-jetty-build' tests, Module 'on-spray-can-build' tests, Module 'root-build' tests, Module 'server-benchmark-build' tests, Module 'simple-http-client-build' tests, Module 'simple-http-server-build' tests, Module 'simple-routing-app-build' tests, Module 'simple-spray-client-build' tests, Module 'simple-spray-servlet-server-build' tests, Module 'site-build' tests, Module 'spray-caching-build' tests, Module 'spray-can-build' tests, Module 'spray-can-examples-build' tests, Module 'spray-can-tests-build' tests, Module 'spray-client-build' tests, Module 'spray-client-examples-build' tests, Module 'spray-http-build' tests, Module 'spray-httpx-build' tests, Module 'spray-io-build' tests, Module 'spray-io-examples-build' tests, Module 'spray-io-tests-build' tests, Module 'spray-routing-build' tests, Module 'spray-routing-examples-build' tests, Module 'spray-routing-tests-build' tests, Module 'spray-servlet-build' tests, Module 'spray-servlet-examples-build' tests, Module 'spray-testkit-build' tests, Module 'spray-util-build' tests
Output path /Users/asnare/work/xebia/tomtom/spray/project/target/idea-classes is shared between: Module 'docs-build' production, Module 'echo-server-build' production, Module 'examples-build' production, Module 'on-jetty-build' production, Module 'on-spray-can-build' production, Module 'root-build' production, Module 'server-benchmark-build' production, Module 'simple-http-client-build' production, Module 'simple-http-server-build' production, Module 'simple-routing-app-build' production, Module 'simple-spray-client-build' production, Module 'simple-spray-servlet-server-build' production, Module 'site-build' production, Module 'spray-caching-build' production, Module 'spray-can-build' production, Module 'spray-can-examples-build' production, Module 'spray-can-tests-build' production, Module 'spray-client-build' production, Module 'spray-client-examples-build' production, Module 'spray-http-build' production, Module 'spray-httpx-build' production, Module 'spray-io-build' production, Module 'spray-io-examples-build' production, Module 'spray-io-tests-build' production, Module 'spray-routing-build' production, Module 'spray-routing-examples-build' production, Module 'spray-routing-tests-build' production, Module 'spray-servlet-build' production, Module 'spray-servlet-examples-build' production, Module 'spray-testkit-build' production, Module 'spray-util-build' production
Please configure separate output paths to proceed with the compilation.
TIP: you can use Project Artifacts to combine compiled classes if needed.
The output paths in .idea_modules/root-build.iml
are:
<output url="file://$MODULE_DIR$/../project/target/idea-classes" />
<output-test url="file://$MODULE_DIR$/../project/target/idea-test-classes" />
Hmm, so for some reason you have a -build module for every subproject too. Build-module should only get generated if a project has dedicated sbt project definition (i.e. project/directory or *.sbt file).
Does your problematic checkout by any chance have multiple project directories, i.e. a separate project directory under every subproject?
Actually, it does: the sub-modules have empty project/
directories. The fresh checkout doesn't have them. After removing them (rmdir **/project
) the problem goes away.
Unfortunately, I have no idea where those directories came from:
- Given that they're empty, they obviously didn't come from git. Something must have generated them. I didn't make them by hand. :)
- Nothing matches their timestamp, so I can't infer what process may have created them as a side effect.
It's nice to have it working and understand the immediate problem, but frustrating to be missing the underlying explanation.
Thanks for your help!
Maybe some plugin generates them? You could try checking if they got generated always after you've run some sbt task?
Okay, I figured it out. I have the currently nightly build of the new sbt plugin for IntelliJ from JetBrains installed. It turns that on import, it will create all those empty project/
folders. I tried it out briefly yesterday before switching back to my regular gen-idea workflow. I did remove all the .idea* and *.iml stuff it created, but didn't notice the leftover project/
folders. (git status --ignored --unknown
misses them. Sigh. Mental note: in future nuke empty directories when cleaning up a git repository.)
So, we're running into a similar issue, I feel like I might be missing something about how this should all work. We have a series of projects that we created using the typesafe activator. We then manually created a root, top level directory which builds them all. There are dependencies defined at the sub project level, as well as the root level, with the idea being we can build the entire project, or just individual projects.
When we run sbt gen-idea and build in IntelliJ, we get: scala: Output path C:\Source\Synata GIT\Core\project\target\idea-test-classes is shared between: Module 'common-build' tests, Module 'graph-analysis-build' tests, Module 'index-backend-build' tests, Module 'index-frontend-build' tests, Module 'root-build' tests, Module 'sync-build' tests Output path C:\Source\Synata GIT\Core\project\target\idea-classes is shared between: Module 'common-build' production, Module 'graph-analysis-build' production, Module 'index-backend-build' production, Module 'index-frontend-build' production, Module 'root-build' production, Module 'sync-build' production Please configure separate output paths to proceed with the compilation. TIP: you can use Project Artifacts to combine compiled classes if needed.
First question, is this configuration supported (or a best / worst practice), or not? Second, I tried no-sbt-build-module (doesn't seem to work). Is there another work around?
I got the same problem and solved it this way in a multi-project setup (sbt 0.13):
ROOT_PROJECT -- PLAY_PROJECT -- PLAIN_SCALA_PROJECT -- project ---- plugins.sbt ---- Build.scala
plugins.sbt: addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.5.2")
Build.scala: object ApplicationBuild extends Build { lazy val myLib = Project( id = "myLib", base = file("myLib") ).settings( name := "myLibName", version := "0.1-SNAPSHOT" )
lazy val frontend = play.Project( "frontend", "0.1-SNAPSHOT", path = file("frontend"), settings = play.Project.playScalaSettings ).dependsOn(myLib)
lazy val root = play.Project( "root", "0.1-SNAPSHOT", path = file(".") ).aggregate(frontend, myLib).dependsOn(frontend, myLib) }
Using aggregate and dependsOn was necessary to build a fully functional IDEA project with "sbt gen-idea". btw just open and don't import the project.
I had the same problem in a multi-module project with 1.5.2:
lazy val stampleRootProject = Project(id = "stample",base = file("."),settings = commonSettings)
.aggregate(stampleWebProject)
.settings(
aggregate in run := true
)
lazy val stampleCoreProject = Project(id = "stample-core",base = file("stample-core"),settings = commonSettings)
lazy val stampleSearchProject = Project(id = "stample-search",base = file("stample-search"),settings = commonSettings)
lazy val stampleWebProject = play.Project("stample-web", appVersion, appDependencies,path = file("stample-web"),settings = commonSettings)
.dependsOn(stampleCoreProject,stampleSearchProject)
....
I wasn't able to run the tests in the IDE for stample-search
module.
I figured out what was the problem: my project used to be a single-module project, and I kept a Build.scala
in stample-web/project
.
In the end, I had 2 different Build.scala:
- project/Build.scala : the real one
- stample-web/project/Build.scala : the previous one which had not been deleted.
So I had the following IDEA files generated:
[info] Created /home/sebastien/Desktop/Stample/.idea_modules/stample.iml
[info] Created /home/sebastien/Desktop/Stample/.idea_modules/stample-core.iml
[info] Created /home/sebastien/Desktop/Stample/.idea_modules/stample-web.iml
[info] Created /home/sebastien/Desktop/Stample/.idea_modules/stample-search.iml
[info] Created /home/sebastien/Desktop/Stample/.idea_modules/stample-build.iml
[info] Created /home/sebastien/Desktop/Stample/.idea_modules/stample-web-build.iml
The stample-web-build
iml was kind of unexpected.
So I deleted the file stample-web/project/Build.scala
because it is not to be used anymore and now it works fine, I can launch my tests in IDEA and I generate the following files:
[info] Created /home/sebastien/Desktop/Stample/.idea_modules/stample.iml
[info] Created /home/sebastien/Desktop/Stample/.idea_modules/stample-core.iml
[info] Created /home/sebastien/Desktop/Stample/.idea_modules/stample-web.iml
[info] Created /home/sebastien/Desktop/Stample/.idea_modules/stample-search.iml
[info] Created /home/sebastien/Desktop/Stample/.idea_modules/stample-build.iml
The trick of @yeahiii didn't work for me.
Hope this helps @mpeltonen :)