Bug 24134 - JDTCompilertAdapter doesn't throw BuildException on compile error
Summary: JDTCompilertAdapter doesn't throw BuildException on compile error
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.1 M2   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-09-26 09:46 EDT by Olivier Thomann CLA
Modified: 2002-10-17 10:25 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2002-09-26 09:46:51 EDT
From EC:

Hi,

I use the JDTCompilerAdapter in ant scripts.
The script always completes with "BUILD SUCCESSFUL" even there are compiler 
errors. failonerror is set to true.

Any idea how to comunicate the compile error to ant ?

See ant log snippet below:

     [javac] Using JDT compiler
     [javac] Compilation arguments:
     [javac] '-noExit'
     [javac] '-classpath'
     [javac] 
'D:\sbi\audi\build\integration\zzLibs\Gwp\1.5\classes.zip;D:\sbi\aud
i\build\integration\zzLibs\Gwp\1.5\collx.zip;D:\sbi\audi\build\integration\zzLib
s\Gwp\1.5\timer.zip;D:\sbi\audi\build\integration\zzLibs\OSGi\2.0\osgi.jar;D:\sb
i\audi\build\integration\zzLibs\javax.servlet\2.1\servlet.jar;D:\sbi\audi\build\
integration\zzLibs\JUnit\3.7\junit.jar;D:\sbi\audi\build\integration\zzLibs\Mock
Objects\02.05.2002\mockobjects-core.jar;D:\sbi\audi\build\integration\zzLibs\MQe
\1.2.7\MQeGateway.jar;C:\Programme\j2sdk1.4.0\jre\lib\ext\Coroutine4Java.jar;C:\
Programme\j2sdk1.4.0\jre\lib\ext\dnsns.jar;C:\Programme\j2sdk1.4.0\jre\lib\ext\l
dapsec.jar;C:\Programme\j2sdk1.4.0\jre\lib\ext\localedata.jar;C:\Programme\j2sdk
1.4.0\jre\lib\ext\sunjce_provider.jar;D:\sbi\audi\build\integration\BackendProto
typing\bin;D:\sbi\audi\build\integration\Utilities\bin;D:\sbi\audi\build\integra
tion\zzLibs\JavaRuntime\1.4.0\rt.jar'
     [javac] 
'-warn:constructorName,packageDefaultMethod,maskedCatchBlocks,deprec
ation'
     [javac] '-d'
     [javac] 'D:\sbi\audi\build\integration\BackendPrototyping\bin'
     [javac] '-g'
     [javac] '-time'
     [javac] '-noImportError'
     [javac]
     [javac] The ' characters around the executable and arguments are
     [javac] not part of the command.
     [javac] Files to be compiled:
     [javac] 
D:\sbi\audi\build\integration\BackendPrototyping\src\de\dreisoft
\audi\telematics\backend\prototype\BackendBean.java
     [javac] 
D:\sbi\audi\build\integration\BackendPrototyping\src\de\dreisoft
\audi\telematics\backend\prototype\BackendContext.java
     [javac] 
D:\sbi\audi\build\integration\BackendPrototyping\src\de\dreisoft
\audi\telematics\backend\prototype\BackendControlServlet.java
     [javac] 
D:\sbi\audi\build\integration\BackendPrototyping\src\de\dreisoft
\audi\telematics\backend\prototype\BHBackendBean.java
     [javac] 
D:\sbi\audi\build\integration\BackendPrototyping\src\de\dreisoft
\audi\telematics\backend\prototype\Constants.java
     [javac] 
D:\sbi\audi\build\integration\BackendPrototyping\src\de\dreisoft
\audi\telematics\backend\prototype\DLUBackendBean.java
     [javac] 
D:\sbi\audi\build\integration\BackendPrototyping\src\de\dreisoft
\audi\telematics\backend\prototype\HBackendBean.java
     [javac] 
D:\sbi\audi\build\integration\BackendPrototyping\src\de\dreisoft
\audi\telematics\backend\prototype\TTBackendBean.java
     [javac] ----------
     [javac] 1. ERROR in 
D:\sbi\audi\build\integration\BackendPrototyping\src\de\
dreisoft\audi\telematics\backend\prototype\TTBackendBean.java (at line 22)
     [javac]     }
     [javac]     ^
     [javac] Syntax error on token "}", ";" expected
     [javac] ----------
     [javac] Compiled 1704 lines in 3359 ms (507.2 lines/s)
     [javac] 1 problem (1 error)
     [javac] 9 .class files generated

BUILD SUCCESSFUL
Total time: 6 seconds


Best Regards,
Stefan
Comment 1 Olivier Thomann CLA 2002-09-26 10:19:27 EDT
We always return true from the execute method of the JDTCompilerAdapter. We
should not call directly the main method of the batch compiler, but rather
create a new instance and call compile(String[]) which returns a boolean. It
should be fairly simple to fix this issue. 
If the compilation fails, return false, otherwise return true.
Comment 2 Olivier Thomann CLA 2002-09-26 10:51:50 EDT
Using the compile method of the batch compiler fixed the problem. Wait for
approval to release.
Comment 3 Philipe Mulet CLA 2002-09-27 05:29:24 EDT
Does running the default javac task (using JDK javac) provide such a behavior ?
If so, then the proposal sounds good to me, please go ahead and release the fix.

Comment 4 Olivier Thomann CLA 2002-09-27 08:33:59 EDT
Yes, javac uses a method that returns a boolean according to the result of the 
compilation. Then ANT is using this value to report whether or not the build 
was successful.
Should I release in 2.0.2 stream as well?
Comment 5 Olivier Thomann CLA 2002-09-27 08:52:33 EDT
Fixed and released in 2.1 stream.
Comment 6 David Audel CLA 2002-10-17 10:25:53 EDT
Verified.