directory structure of the Scala project

44 views
Skip to first unread message

iulian dragos

unread,
Jun 7, 2012, 5:39:00 AM6/7/12
to scala-i...@googlegroups.com
I'd like to propose a new structure of the Scala repository, one that is more in-line with existing conventions in both the Scala and Java world.

Currently, (conceptual) sub-projects are "split" between src/ and build/ top-level directories. This makes it difficult to add something other than sources to an existing subproject, without adding a new top-level directory. And that leads to weird 'sub-projects' in src/, such as src/intellij.

Usually, projects are self-contained directories and many tools follow this convention. In short, I propose to have each module have it's own project structure, more or less like this:

/modules(?)
  /library
    /src
    /target
      /classes
  /compiler
    /src
    /target
      /classes
  /asm
    /src
    /target
      /classes
  ...

I left the top-level directory undecided. It may be the basedir, where 'src' is now, or it may be a subdirectory. 

This structure has the advantage that each module can have its own build file, additional resources can be added easily (IntelliJ or Eclipse project definitions, docs, readme, etc), and the Sbt build will probably be much simpler.

As far as I can tell, git deals well with file moves, but I don't have a lot of experience in this area. What do others think? Any big disadvantages?

cheers,
iulian

--
« Je déteste la montagne, ça cache le paysage »
Alphonse Allais

Lukas Rytz

unread,
Jun 7, 2012, 7:17:49 AM6/7/12
to scala-i...@googlegroups.com
On Thu, Jun 7, 2012 at 11:39 AM, iulian dragos <jagu...@gmail.com> wrote:
I'd like to propose a new structure of the Scala repository, one that is more in-line with existing conventions in both the Scala and Java world.

Currently, (conceptual) sub-projects are "split" between src/ and build/ top-level directories. This makes it difficult to add something other than sources to an existing subproject, without adding a new top-level directory. And that leads to weird 'sub-projects' in src/, such as src/intellij.

Usually, projects are self-contained directories and many tools follow this convention. In short, I propose to have each module have it's own project structure, more or less like this:

/modules(?)
  /library
    /src
    /target
      /classes
  /compiler
    /src
    /target
      /classes
  /asm
    /src
    /target
      /classes
  ...

I left the top-level directory undecided. It may be the basedir, where 'src' is now, or it may be a subdirectory. 

This structure has the advantage that each module can have its own build file,

Not sure that makes sense / can be done easily, since everything is built in stages (locker, quick)
I think we should only change the current structure if there's a clear win (i.e. if it fixes a problem).
Looking up file history does become more complicated, even with git.

Does the current structure pose problems for using Eclipse?

Josh Suereth

unread,
Jun 7, 2012, 8:01:52 AM6/7/12
to scala-i...@googlegroups.com
The current structure does pose problems for eclipse.

However, layered compilation is still achievable with spit directories.   Ant cares nothing about them, and it would actually simplify the SBT build slightly.

You're right that it could kill history lookup.

Adriaan Moors

unread,
Jun 7, 2012, 8:06:38 AM6/7/12
to scala-i...@googlegroups.com
Does anyone have any experience with this?
I thought renames were almost transparant to git (since it tracks contents, not files)

Thomas Matthijs

unread,
Jun 7, 2012, 8:15:19 AM6/7/12
to scala-i...@googlegroups.com
On Thu, Jun 7, 2012 at 2:06 PM, Adriaan Moors <adriaa...@epfl.ch> wrote:
Does anyone have any experience with this?
I thought renames were almost transparant to git (since it tracks contents, not files)



You have to tell it detect the changes based on content, it doesn't store it.
So you need like:

git log -C -M --follow,
git diff -C -M

etc

Johannes Rudolph

unread,
Jun 7, 2012, 8:33:15 AM6/7/12
to scala-i...@googlegroups.com
On Thu, Jun 7, 2012 at 2:15 PM, Thomas Matthijs <li...@selckin.be> wrote:
> On Thu, Jun 7, 2012 at 2:06 PM, Adriaan Moors <adriaa...@epfl.ch> wrote:
> git log -C -M --follow,

`--follow` works only for single files. I've not yet found a way to
show the complete history for a renamed directory across renames. `git
blame` works pretty much flawlessly across renames.


--
Johannes

-----------------------------------------------
Johannes Rudolph
http://virtual-void.net

iulian dragos

unread,
Jun 7, 2012, 9:30:27 AM6/7/12
to scala-i...@googlegroups.com
On Thu, Jun 7, 2012 at 1:17 PM, Lukas Rytz <lukas...@epfl.ch> wrote:


On Thu, Jun 7, 2012 at 11:39 AM, iulian dragos <jagu...@gmail.com> wrote:
I'd like to propose a new structure of the Scala repository, one that is more in-line with existing conventions in both the Scala and Java world.

Currently, (conceptual) sub-projects are "split" between src/ and build/ top-level directories. This makes it difficult to add something other than sources to an existing subproject, without adding a new top-level directory. And that leads to weird 'sub-projects' in src/, such as src/intellij.

Usually, projects are self-contained directories and many tools follow this convention. In short, I propose to have each module have it's own project structure, more or less like this:

/modules(?)
  /library
    /src
    /target
      /classes
  /compiler
    /src
    /target
      /classes
  /asm
    /src
    /target
      /classes
  ...

I left the top-level directory undecided. It may be the basedir, where 'src' is now, or it may be a subdirectory. 

This structure has the advantage that each module can have its own build file,

Not sure that makes sense / can be done easily, since everything is built in stages (locker, quick)
I think we should only change the current structure if there's a clear win (i.e. if it fixes a problem).

I think this structure wouldn't make it more difficult than it is to build right now. I can see some advantages:

- separate build files for each module -- right now, everything goes into a 100KB XML file
- clearer separation of modules and their meta-data (see the example of src/intellij, other modules have build.xml files inside src/)
- simplified Sbt project
 
Looking up file history does become more complicated, even with git.

Adding `--follow` does part of the job, and it's not so complicated. Unfortunately, Johannes is right: `git log --follow -- path/to/dir` won't work. :(
 
Does the current structure pose problems for using Eclipse?

Yes, essentially that's why I proposed this change. Project files need to reside inside the directory for the project they define (they are called .project). If one wants to have one project per module (library, compiler, asm, actors, etc.), one needs to place them in separate directories. One option is src/library, src/compiler, etc. But then they need to have an output directory several levels above the project directory. It can be done, but essentially you end up with absolute paths in your project files, and they can't be shared.

The point is moot now, since I don't think it's acceptable to lose history for directory paths.

cheers,
iulian
 

 
additional resources can be added easily (IntelliJ or Eclipse project definitions, docs, readme, etc), and the Sbt build will probably be much simpler.

As far as I can tell, git deals well with file moves, but I don't have a lot of experience in this area. What do others think? Any big disadvantages?

cheers,
iulian

--
« Je déteste la montagne, ça cache le paysage »
Alphonse Allais

Lukas Rytz

unread,
Jun 7, 2012, 9:36:37 AM6/7/12
to scala-i...@googlegroups.com
That's unfortunate. A relative path with .. doesn't work?

Josh Suereth

unread,
Jun 7, 2012, 10:02:11 AM6/7/12
to scala-i...@googlegroups.com

There's nothing stopping spliting the ant build up by project now.... and nothing about the new directory structure makes doing so in Ant easier....


Just saying...

iulian dragos

unread,
Jun 7, 2012, 10:05:10 AM6/7/12
to scala-i...@googlegroups.com
On Thu, Jun 7, 2012 at 4:02 PM, Josh Suereth <joshua....@gmail.com> wrote:

There's nothing stopping spliting the ant build up by project now.... and nothing about the new directory structure makes doing so in Ant easier....


Where would you put the per-project build files?

√iktor Ҡlang

unread,
Jun 7, 2012, 10:21:14 AM6/7/12
to scala-i...@googlegroups.com
On Thu, Jun 7, 2012 at 4:05 PM, iulian dragos <jagu...@gmail.com> wrote:


On Thu, Jun 7, 2012 at 4:02 PM, Josh Suereth <joshua....@gmail.com> wrote:

There's nothing stopping spliting the ant build up by project now.... and nothing about the new directory structure makes doing so in Ant easier....


Where would you put the per-project build files?




--
Viktor Klang

Akka Tech Lead
Typesafe - The software stack for applications that scale

Twitter: @viktorklang

Josh Suereth

unread,
Jun 7, 2012, 11:14:09 AM6/7/12
to scala-i...@googlegroups.com
src/build already has delegate ant builds.

TO do layered building, we couldn't have standalone project builds anyway for ant...  

If we do restructure, Ideally we'd move to SBT so the least amount of build work would be necessary.
Reply all
Reply to author
Forward
0 new messages