Gradle can't find Antlr token file
<p>I created a file <code>MyLexer.g4</code> inside <code>myproject/src/main/antlr/com/mypackage</code> like:</p>

<pre><code>lexer grammar MyLexer;

DIGIT : '0' .. '9' ;
</code></pre>

<p>...</p>

<pre><code>WS  : [ \t\r\n]+ -&gt; skip ;
</code></pre>

<p>and then trying to write parser in <code>MyParser.g4</code> in the same directory:</p>

<pre><code>grammar MyParser;

options
   { tokenVocab = MyLexer; }

SHORT_YEAR: DIGIT DIGIT;
</code></pre>

<p>unfortunately, when I run gradle task of <code>generateGrammarSource</code>, the following error occurs:</p>

<pre><code>error(160): com\mypackage\MyParser.g4:4:18: cannot find tokens file MYPROJECT\build\generated-src\antlr\main\MyLexer.tokens
</code></pre>

<p>I.e. file is sought in incorrect place.</p>

<p>Actual file is created inside <code>MYPROJECT\build\generated-src\antlr\main\com\mypackage\MyLexer.tokens</code></p>