title: Compiling 3.2 Antlr grammar with gradle
body: <p>I'm trying to compile my antlr grammar with gradle. I'm very new to gradle, so am having trouble working out how to fix the issue.</p>
  
  <p>I think it's trying to use the 2.7 antlr to compile (as I've seen a few other people reporting similar errors when using wrong version), and hence throwing errors. </p>
  
  <p>How can I:</p>
  
  <ol>
  <li>Show what version of Antlr gradle is trying to use?</li>
  <li>Get gradle to compile properly?</li>
  </ol>
  
  <p>Here's my grammar:</p>
  
  <pre><code>grammar Test;
  
  options {
    language = Java;
  }
  
  rule: ;
  </code></pre>
  
  <p>Here's my gradle script:</p>
  
  <pre><code>apply plugin: 'java'
  apply plugin: 'antlr'
  
  repositories {
      mavenCentral()
  }
  
  dependencies {
      antlr 'org.antlr:antlr:3.2'
      testCompile group: 'junit', name: 'junit', version: '4.+'
  }
  </code></pre>
  
  <p>Here's the output trying to compile:</p>
  
  <pre><code>$ gradle compileJava
  :generateGrammarSource
  /home/admin/workspace/BuildTools/src/main/antlr/Test.g:1:1: unexpected token: grammar
  :compileJava UP-TO-DATE
  
  BUILD SUCCESSFUL
  
  Total time: 2.458 secs
  </code></pre>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Seems Antlr3 isn't supported directly in gradle yet.</p>
  
  <p>There's a <a href="https://github.com/gradle/gradle/pull/69" rel="nofollow">pull request to add antlr3 support</a> to gradle that's <a href="http://gradle.1045684.n5.nabble.com/Antlr-v3-plugin-td5605784.html" rel="nofollow">discussed here</a>.</p>
  
  <p>Here's <a href="http://tapestryjava.blogspot.co.uk/2011/03/combining-gradle-with-antlr3.html" rel="nofollow">another version of including support for Antlr3</a> manually.</p>