Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy sources files into target directory with SBT

Tags:

scala

sbt

I recently decided to use SBT to build an existing project. In this project I have some .glsl files within the scala packages which I need to copy during the compilation phase.

The project is structured like this :

- myapp.opengl
   - Shader.scala
- myapp.opengl.shaders
   - vertex_shader.glsl
   - fragment_shader.glsl

Is this file structure correct for SBT or do I need to put the .glsl files into an other directory. And do you know a clean way to copy these files into the target folder ?

I would prefer not putting these files into the resources directory since they are (non-compiled) sources files

Thanks

like image 987
Mr_Qqn Avatar asked Apr 15 '11 07:04

Mr_Qqn


1 Answers

I would not recommend putting those files into src/main/scala as they do not belong there. If you want to keep them separate from your resource files, you can put them in a custom path, e.g. src/main/glsl and add the following lines to your project definition to have them copied into output directory:

val shaderSourcePath = "src"/"main"/"glsl"

// use shaderSourcePath as root path, so directory structure is
// correctly preserved (relative to the source path)
def shaderSources = (shaderSourcePath ##) ** "*.glsl"

override def mainResources = super.mainResources +++ shaderSources
like image 122
Moritz Avatar answered Oct 07 '22 20:10

Moritz