I have an existing project that I want to build in the IntelliJ Community Edition 11.1.4 running on Ubuntu 12.04.1 LTS
In the Ant Build window I added the project's build.xml
by clicking on the + button in the top left hand corner of the window and navigating to the file. The ant tasks associated with the build file are listed and I click on the green play button to run the ant build which commences as expected.
I was expecting to see compiler errors and have IntelliJ CE present those compiler errors and allow me to Jump to (the offending) Source having double clicked on the errors in the Messages window.
Instead, the messages window displays the following error which when I double-click on it takes me to the javac
ant task in the build.xml
file.
build.xml:389: Compile failed; see the compiler error output for details.
This is great advice and I very much want to follow it but I cannot because the compiler error is not displayed anywhere in the Messages window. Next and Previous Message do not navigate to an actual compiler error.
I want to know how to be able to see the compiler error messages in IntelliJ having run an Ant build.
I tried adding the -v flag to the Ant command line:field in Execution Properties. This made no difference to the behaviour.
I then tried down grading from Ant 1.8 to Ant 1.7. this time I did see a change in behaviour. the build does not run at all and I get the following error https://gist.github.com/4073149 at the terminal.
The javac
ant task looks like this.
<target name="compile-only" depends="">
<stopwatch name="Compilation"/>
<javac destdir="${build.classes.dir}" debug="on" deprecation="off"
classpathref="base.path" excludes="/filtering/**/**">
<src path="${src.dir}"/>
<src path="${build.autogen.dir}"/>
</javac>
<!-- Copy all resource files to the output dir -->
<copy todir="${build.classes.dir}">
<fileset dir="${src.dir}">
<include name="**/*.properties"/>
<include name="**/*.gif"/>
<include name="**/*.png"/>
<include name="**/*.jpg"/>
<include name="**/*.svg"/>
<include name="**/*.jpeg"/>
<exclude name="**/.svn"/>
</fileset>
</copy>
<stopwatch name="Compilation" action="total"/>
In "Settings" --> Build, Execution, Deployment --> "Compiler" check the checkbox "Build project automatically". This will immediately show any compile errors in the project tree.
after fix it by right click at src folder > Mark Directory as > Source Root , the compile error shows.
IDEA just prints Ant's output. Try switching the output from the tree view to the plain text view using the corresponding button on the left of the messages panel:
If the output contains errors, you should be able to see them there.
Also it's much faster and easier to use IDEA provided incremental compilation (Build
| Make
).
When using plain (not tree) output for ant IntelliJ uses
file (line,col): error msg
format for javac errors.
But error view parser only understands file:line: error msg
format.
You could tweak it in PlainTextView class from antIntegration.jar http://grepcode.com/file/repository.grepcode.com/java/ext/com.jetbrains/intellij-idea/10.0/com/intellij/lang/ant/config/execution/PlainTextView.java#98
I just changed addJavacMessage method to following and recompiled the class ``` java
public void addJavacMessage(AntMessage message, String url) {
final VirtualFile file = message.getFile();
if (message.getLine() > 0) {
final StringBuilder builder = StringBuilderSpinAllocator.alloc();
try {
if (file != null) {
ApplicationManager.getApplication().runReadAction(new Runnable() {
public void run() {
String presentableUrl = file.getPresentableUrl();
builder.append(presentableUrl);
// builder.append(' ');
}
});
}
else if (url != null) {
builder.append(url);
// builder.append(' ');
}
// builder.append('(');
builder.append(':');
builder.append(message.getLine());
builder.append(':');
builder.append(' ');
// builder.append(message.getColumn());
// builder.append(")");
print(builder.toString(), ProcessOutputTypes.STDOUT);
}
finally {
StringBuilderSpinAllocator.dispose(builder);
}
}
print(message.getText(), ProcessOutputTypes.STDOUT);
}
public void addException(AntMessage exception, boolean showFullTrace) {
String text = exception.getText();
showFullTrace = false;
if (!showFullTrace) {
int index = text.indexOf("\r\n");
if (index != -1) {
text = text.substring(0, index) + "\n";
}
}
print(text, ProcessOutputTypes.STDOUT);
}
```
And now I have clickable links in 'plain text' output mode of ant tool. Note, that 'tree mode' shows line & columns correctly - I used IDEA 13 CE.
It would be nice if somebody to create pull request for Intellij regarding this issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With