SpinalHDL/SpinalTemplateSbt

scala file path

jiejie324 opened this issue · 5 comments

why the scala file path must be src/main/scala/mylib/xxx.scala?Is there a way to put it under another path??

That’s mostly convention. src/main/scala is the shortest path for Scala stuff in sbt. If you create multiple sbt projects in your repository, you end up having <project>/src/main/scala as the path for the Scala stuff.
If you have source files in other languages, they go into different directories, like src/main/java. If you support multiple versions of Scala and need different code for each version, you could have src/main/scala2.11 and src/main/scala2.12. If you add tests, they go to src/test/scala.

Below the Scala directory, it is your choice how you organize the source code. However, again convention kicks in that suggests that you put stuff that is part of package mylib into a directory called mylib below the Scala base directory. If you scatter your library more, you would typically create not only multiple source files but also multiple directories below the mylib folder.

If you want to change the path of the project, you can change it in build.sbt. Or you can change from sbt to the Mill build tool, which supports different or even custom directory structures.

You can review the sbt docs about the directory structure.

Mill also documents its simplified directory structure, however you can use the sbt structure or change it if needed.

The answer is interesting, maybe it could be added to RTD?

sure ^^

I think this can be closed now