Note that there are some explanatory texts on larger screens.

plurals
  1. POIntellij Building Using Ant
    primarykey
    data
    text
    <p>Thanks to Android-Studio I am now trying to use the IntelliJ Idea for my non-Android projects.</p> <p>I've installed the latest version of the Community version of IntelliJ (12.1.4). I've created a simple test project with a few classes a JavaCC grammar definition to try things out. From the command line the ant script builds the project just fine.</p> <p>From an Ant building point of view I have everything configured just fine.</p> <p>But I haven't quite got things working within IntelliJ. I do have that part of the ant script being executed to update the generated Java source from the grammar file. I can see in the logs that the ant task to run javaCC is called each time, just before the "Make".</p> <p>But IntelliJ doesn't "see" that part of the tree.</p> <p>In "File -> Project Structure -> Modules" I've configured the source paths thus:</p> <pre><code>&lt;project-root&gt; build classes &lt;- Excluded java &lt;- Sources libs src main java &lt;- Sources javacc &lt;- Place where grammar file lives. test data java &lt;- Test sources </code></pre> <p>And in the sources list it reports the followin:</p> <pre><code>Source Folders src/main/java build/java Test Source Folder src/test/java </code></pre> <p>In <code>build/java</code> are all the sources generated from running JavaCC (in the appropriate package sub-directory). So why is IntelliJ not picking them up?</p> <p>As always thanks for any help.</p> <p>Steve</p> <p><strong>UPDATE</strong></p> <p>My computer runs Linux, Debian to be precise, and JavaCC has installing into /usr/share/java.</p> <p>1). Create a new project "Test"</p> <p>2). Create a new directory off the project root: <code>javacc</code>.</p> <p>3). Added the following file <code>Test.jj</code> to <code>javacc</code></p> <pre><code>options { STATIC = false; } PARSER_BEGIN(Test) package com.example; import java.io.StringReader; public class Test { private boolean mIsBaseball = false; public Test(final String text) { this(new StringReader(text)); } } PARSER_END(Test) TOKEN: { &lt;DOT: "."&gt; } TOKEN: { &lt;SLASH: "/"&gt; } void dummy(): { } { &lt;SLASH&gt; &lt;DOT&gt; } </code></pre> <p>4). Added the following ant script <code>build.xml</code> to the project base.</p> <pre><code>&lt;?xml version="1.0" encoding="iso-8859-1" standalone="no"?&gt; &lt;project name="test" default="all" basedir="."&gt; &lt;property name="pkg.name" value="test"/&gt; &lt;property name="dir.src.java" value="${basedir}/src/"/&gt; &lt;property name="dir.src.javacc" value="${basedir}/javacc"/&gt; &lt;property name="dir.test.java" value="${basedir}/out/src"/&gt; &lt;property name="dir.class" value="${basedir}/out/Test"/&gt; &lt;target name="grammar"&gt; &lt;mkdir dir="${basedir}"/&gt; &lt;mkdir dir="${basedir}/out/"/&gt; &lt;mkdir dir="${dir.test.java}"/&gt; &lt;mkdir dir="${dir.test.java}/com"/&gt; &lt;mkdir dir="${dir.test.java}/com/example"/&gt; &lt;javacc target="${dir.src.javacc}/Test.jj" outputdirectory="${dir.test.java}/com/example" javacchome="/usr/share/java/" debugparser="true" /&gt; &lt;/target&gt; &lt;target name="compile" depends="grammar"&gt; &lt;mkdir dir="${dir.class}"/&gt; &lt;javac destdir="${dir.class}" includeantruntime="false" debug="on"&gt; &lt;compilerarg value="-Xlint:-path"/&gt; &lt;src path="${dir.src.java}"/&gt; &lt;src path="${dir.test.java}"/&gt; &lt;/javac&gt; &lt;/target&gt; &lt;/project&gt; </code></pre> <p>5). In the "Ant Build" window register the new build script.</p> <p>6). Run the <code>gammar</code> target from the "And Build" window. You should see some new Java classes in <code>${PROJECT_BASE}/out/src</code>.</p> <p>7). In "Project Structure -> Modules -> Paths" select "Use module output path" and deselect the "Exclude output paths"</p> <p>6). In "Project Structure -> Modules -> Sources" add "out -> src" as a source directory. Both <code>src</code> and <code>out/scr</code> should be the only listings.</p> <p>8). Edit <code>Main.java</code> to the following:</p> <pre><code>package com.example; import com.example.Test; public class Main { public static void main(String[] args) { try { Test test = new Test("/."); test.dummy(); } catch (Throwable cause) { cause.printStackTrace(); } } } </code></pre> <p>As you can see the generated source is not visible (well I can on mine).</p> <p>9). From the command line you can compile and run things quite happily.</p> <pre><code>$ ant $ java -cp out/Test com.example.Main Call: dummy Consumed token: &lt;"/" at line 1 column 1&gt; Consumed token: &lt;"." at line 1 column 2&gt; Return: dummy $ </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload