On Monday, 13 November 2017 at 09:27:10 UTC, Adrian Matoga wrote:
On Saturday, 11 November 2017 at 14:11:50 UTC, Neia Neutuladh
wrote:
At my job, I put together a database migration tool for our
services. It scans for resources in your JAR file with an
appropriate path, interprets them as SQL scripts, and applies
them to the database if it hasn't been done yet.
I want to implement this in D. However, while D allows you to
import individual files, it doesn't let you import an entire
directory.
I can make a prebuild script to generate code for this, but
I'm wondering: do other people find themselves needing this
periodically? If so, I can write a DIP for it, or at least
publish a codegen tool that other people can use.
Why do you want to import files at compile time? Why can't it
be done in run time, by simply reading directory with
dirEntries and opening std.stdio.File for each one?
Three is a use case. I have an application which should be
translated into different languages. I created a texts.prop file.
The language department will create texts_en.prop, texts_de.prop
and so on. The language department will create GIT pull requests
which will cause the build infrastructure to recompile my
application. Any new text_**.prop should be automatically
included in the build process.
There is an advantage and a disadvantage of using import for this
scenario. The advantage is, it was really easy to implement and
in case I use non existing text keys in the coding, there is a
compiler time error.
But there is a major downside, although nothing is changed in any
file, dub will every time recompile my application. Also my
rather small application takes 4 seconds to compile due to this
logic.
Therefore I tend to reimplement the logic using a dub pre build
script.
Kind regards
Andre