People keep trying to build my project with old versions of Dmd and Dub (0.9.2 instead of 1.0.0) and it does not work. Can I specify in the dub.json file the min required dub version?
Unfortunately you can't. See this issue for more details. Please make noise there ;-)
Two ideas how to workaround around this for now.
int main()
{
static if (__VERSION__ < 2069)
{
pragma(msg, "Your DMD version is outdated. Please update");
return 1;
}
...
}
2) Use preGenerateCommands = ['rdmd checkversions.d']
int main()
{
import std.process : execute;
import std.stdio : writeln;
auto ver = execute(["dub", "--version"]);
if (ver.status != 0)
{
writeln("Error: no dub installation found.");
}
else
{
import std.conv : to;
import std.regex : ctRegex, matchFirst;
auto ctr = ctRegex!`version ([0-9]+)[.]([0-9]+)[.]([0-9]+)`;
auto r = ver.output.matchFirst(ctr);
assert(r.length == 4, "version not found");
int major = r[1].to!int, minor = r[2].to!int, patch = r[3].to!int;
if (major < 2)
{
writeln(minor);
return 1;
}
}
}