typelead/sbt-eta

Support better directory structure

rahulmutt opened this issue · 3 comments

@carymrobbins suggested that the directory structure should look something like this:

example/
├── example.cabal
├── Setup.hs
└── src/
    ├── main/
    │   ├── eta/
    │   │   └── Example/
    │   │       └── Transform.hs
    │   └── java/
    │       └── Main.java
    └── test/
        └── eta/
            └── Example/
                └── TransformTest.hs

The layout is a lot better than the existing layout, which places the .cabal file inside of src/main/eta.

I always forget this, but the Main.java probably needs to go in the src/main/eta directory. Build tools usually try to compile all of the src/main/java sources with just javac and before any other sources, so if Main.java references anything from src/main/eta it'll fail to compile. Maybe sbt is different, but either way this is a potential gotcha.

So in these inter-project setups, there's always the question of where the dependencies flow. SBT has a mechanism which allows you to select whether you want to compile Scala or Java dependencies first. We probably need to add a new option that chooses the order among, Java, Scala, Eta (in case anybody wants such complicated setups).

In this particular case, it would make sense to disable javac building altogether and add the following to the cabal file -

java-sources: src/main/java/Main.java

or

java-sources: src/main/eta/Main.java

Whichever was preferred (the latter of which would not require disabling or changing when the javac build happens).