Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access sbt-plugin-project resource from sbt-plugin during a build?

Tags:

scala

sbt

I have an sbt plugin project that looks like this

/
    src/
        main/
            resources/
                hello.txt/
    Build.scala

I would like to load hello.txt at build time in order to do stuff with it. However, when I try loading resources (or other files in general), I can only load resources from the project I'm building, and not from the plugin project. Is there any way to refer to hello.txt during the build? My alternative is to copy out hello.txt into one big multiline-string in the source code, but that feels gross.

like image 624
Li Haoyi Avatar asked Nov 17 '13 17:11

Li Haoyi


1 Answers

Use getClass.getClassLoader.getResourceAsStream("hello.txt").

like image 178
Robin Green Avatar answered Sep 28 '22 09:09

Robin Green