Bug 35978 - JDTCompilerAdapter doesn't use user preference for warnings
Summary: JDTCompilerAdapter doesn't use user preference for warnings
Status: RESOLVED DUPLICATE of bug 25510
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1   Edit
Hardware: PC All
: P3 major (vote)
Target Milestone: 3.0 M1   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-04-02 09:39 EST by Etienne Juliot CLA
Modified: 2003-06-02 06:13 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Etienne Juliot CLA 2003-04-02 09:39:50 EST
If you launch an Ant compilation with
-Dbuild.compiler=org.eclipse.jdt.core.JDTCompilerAdapter or with a
build.compiler target, the compilation is done without using user's preferences
of Eclipse.

If you want to not see all "unused imports" warning, you go in
Eclipse->window->preference->java->compiler.
In Eclipse, it will compile without warning.

But with Ant launch by Eclipse with JDTCompilerAdapter, it will show all warnings.

I search inside the source code itself of Eclipse project. And I think
I found a bug for JDTCompilerAdapter.
See at :
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jdt.core/antadapter/org/eclipse/jdt/core/JDTCompilerAdapter.java?rev=1.20&content-type=text/vnd.viewcvs-markup

I can see :


	/*
		 * Handle the nowarn option. If none, then we generate all warnings.
		 */		
        if (attributes.getNowarn()) {
			if (deprecation) {
				cmd.createArgument().setValue("-warn:allDeprecation"); //$NON-NLS-1$
			} else {
	            cmd.createArgument().setValue("-nowarn"); //$NON-NLS-1$
			}
        } else {
			/*
			 * deprecation option.
			 */		
			if (deprecation) {
				cmd.createArgument().setValue(
				
"-warn:allDeprecation,constructorName,packageDefaultMethod,maskedCatchBlocks,unusedImports,staticReceiver");
//$NON-NLS-1$
			} else {
				cmd.createArgument().setValue(
				
"-warn:constructorName,packageDefaultMethod,maskedCatchBlocks,unusedImports,staticReceiver");
//$NON-NLS-1$
			}
        }



As you can see, when getNoWarn is false, every warning level are
written INSIDE the code (hard coding).
It doesn't use user's preferences.
Comment 1 Philipe Mulet CLA 2003-04-02 09:42:51 EST
The Ant task isn't using any Eclipse setting, nor does it actually need an 
Eclipse instance to run. 
Comment 2 Etienne Juliot CLA 2003-04-02 09:56:04 EST
When I speak about Ant task, I speak about build.compiler specified INSIDE the
build.xml itself (instead of using -Dbuild.compiler).

With something like :

      <condition property="build_compiler" value="modern">
         <not>
            <isset property="eclipse.running"/>
         </not>
      </condition>
      <condition property="build_compiler"
value="org.eclipse.jdt.core.JDTCompilerAdapter">
        <isset property="eclipse.running"/>
      </condition>
      <echo message="build compiler : ${build_compiler}"/>
      <property name="build.compiler" value="${build_compiler}"/>
Comment 3 Olivier Thomann CLA 2003-04-02 13:41:55 EST
This is not a bug in the JDTCompiler adapter. This is simply an adapter for the 
javac ant task. This task doesn't allow you to use a custom level of warnings. 
If you don't want any warning, please update the build.xml file adding 
nowarn="on" inside your javac ant task. By default this is off.
There is no way to give Eclipse warnings to the ant task. Ant javac task uses 
specific options and it doesn't allow us to reuse Eclipse settings.
Like Philippe said, Eclipse might not run and you can still use this ant javac 
adapter.
Ok to close?
Comment 4 Etienne Juliot CLA 2003-04-04 04:33:19 EST
I don't want to change the build.xml to add level of warnings. I know that Ant
doesn't support it.
But I think the goal of an adapter is to call Ant and to have a return to the
adapter to use some Eclipse's specific features.

JDTCompilerAdapter can detect if Eclipse is running :
- if no, it compile as today, with default parameters
- if yes, it uses user's preferences.

It doesn't need any modification of Ant or build.xml.

What is the goal of JDTCompilerAdapter if it doesn't use the power of Eclipse
compiler ?

As I already say, I don't want to turn nowarn to on, because :
- I work on a big project, with more than 100 developers, I can change
preference of all users with changing global build.xml
- I want some standard warnings (deprecation, bad import, ...) but not too much
(unused variables or import ...)
- I would like to use fine granularity of warnings level of Eclipse. You do
something very good, I would be too bad to don't use it.

Comment 5 Olivier Thomann CLA 2003-04-04 15:39:07 EST
Close as duplicate of bug 25510. We will definitely investigate it.
Here is what we'd like to achieve. If the ant script is used inside Eclipse, 
then Eclipse settings are used. Otherwise use default options (actual options).

*** This bug has been marked as a duplicate of 25510 ***
Comment 6 Olivier Thomann CLA 2003-04-04 15:39:27 EST
Change milestone.