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

Source generators trigger creation of incorrect source folders #310

Open
varju opened this issue Jul 5, 2014 · 1 comment
Open

Source generators trigger creation of incorrect source folders #310

varju opened this issue Jul 5, 2014 · 1 comment

Comments

@varju
Copy link

varju commented Jul 5, 2014

Using either 1.6.0 or 1.7.0-SNAPSHOT, the presence of source generators causes extra sourceFolder entries to be added to the module. A simple example that demonstrates this issue:

import sbt._
import Keys._

object ApplicationBuild extends Build {
  val main = Project("foo", file(".")).settings(

    sourceGenerators in Compile += Def.task {
      val file1 = (sourceManaged in Compile).value / "one" / "Test.java"
      IO.write(file1, """
package one;
class Test {}
""")

      val file2 = (sourceManaged in Compile).value / "two" / "Test.java"
      IO.write(file2, """
package two;
class Test {}
""")

      Seq(file1, file2)
    }.taskValue
  )
}

This leads to a module file containing extra src_managed/main/one and src_managed/main/two source folders:

<sourceFolder url="file://$MODULE_DIR$/../target/scala-2.10/src_managed/main/one" isTestSource="false"/>
<sourceFolder url="file://$MODULE_DIR$/../target/scala-2.10/src_managed/main/two" isTestSource="false"/>
<sourceFolder url="file://$MODULE_DIR$/../target/scala-2.10/src_managed/main" isTestSource="false"/>

In the real world, this is causing problems with Play 2.3.1, leading to errors like this when compiling from IntelliJ:

Error:(7, 14) routes is already defined as object routes
public class routes {
@teigen
Copy link
Contributor

teigen commented Aug 5, 2014

I was hit by this bug too and have a potential fix here https://github.com/teigen/sbt-idea/tree/sbt-0.13-source-generators

There are two obvious ways to solve this by either using sourceManaged as sources or use managedSources as sources. Having both leads nesting of source directories which causes this error.

My fix uses managedSources and ignores any sourceManaged directories which are subfolders of managedSources.

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

2 participants