Bug 104536 - [compiler] Ant adapter doesn't use the right source and target values
Summary: [compiler] Ant adapter doesn't use the right source and target values
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2 M6   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-07-20 13:37 EDT by Olivier Thomann CLA
Modified: 2006-03-28 08:16 EST (History)
1 user (show)

See Also:


Attachments
Proposed fix (10.40 KB, patch)
2005-07-20 13:38 EDT, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2005-07-20 13:37:28 EDT
Usign such build script:

<?xml version="1.0" encoding="UTF-8"?>
<project name="compile" default="main" basedir="../.">
	<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
	<property name="src" value="${basedir}/src"/>
	<property name="out" value="${basedir}/out" />
	<target name="main">
		<delete dir="${out}"/>
		<mkdir dir="${out}"/>		
		<javac 	srcdir="${src}"
				destdir="${out}" 
				source="1.4" 
				target="1.4"
				debug="on"
				nowarn="true">
<compilerarg compiler="org.eclipse.jdt.core.JDTCompilerAdapter" line="-1.4"/>
		</javac>		
	</target>
</project>

The ant adapter is compiling in source 1.3 and target 1.2 mode. Assert
statements are reported as errors.

The problem comes from the fact that source="1.4" and target="1.4" sets the
value in the custom options. But -1.4 overrides the source and target settings
because it believes that no source and target have been specified.
Comment 1 Olivier Thomann CLA 2005-07-20 13:38:50 EDT
Created attachment 25064 [details]
Proposed fix

With this fix it works fine.
I didn't use the same mecanism for didSpecifyCompliance because the user might
want to override the inferred compliance in a compilerarg argument.
Comment 2 Philipe Mulet CLA 2006-03-01 19:11:25 EST
Will it allow me to do:
-1.5 -source 1.3 -target 1.4 ?
Comment 3 Olivier Thomann CLA 2006-03-01 21:57:59 EST
No. This is not intended. It would still be rejected.
Comment 4 Olivier Thomann CLA 2006-03-01 21:59:21 EST
Target level cannot be higher than the source level.
Comment 5 Olivier Thomann CLA 2006-03-02 11:54:19 EST
I don't know if we should allow source and target values to be specified through the compiler arg since the javac task has some predefined attributes for source and target.
Comment 6 Olivier Thomann CLA 2006-03-02 16:33:16 EST
Fixed and released in HEAD.
There is no regression test for the ant adapter.
Comment 7 Jerome Lanneluc CLA 2006-03-28 08:16:24 EST
Verified for 3.2 M6 using build I20060328-0010