Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 353505

Summary: javacSource and javacTarget from build.properties should be read by Tycho
Product: z_Archived Reporter: Tobias Oberlies <t-oberlies>
Component: TychoAssignee: Jan Sievers <jan.sievers>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: anna.dushistova, gunnar, igor, jan.sievers, t-oberlies
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Tobias Oberlies CLA 2011-08-01 10:42:56 EDT
Currently, the build properties javacSource and javacTarget are not evaluated by Tycho. This would be useful because it eases the migration of PDE build projects to Tycho.

The build properties should take precedence over the POM and the Manifest, yielding the following order of precedence (cf. [1]):
1. build.properties
2. explicit POM configuration
3. inherited POM configuration
4. bundle runtime environment from bundle manifest
5. default (depending on Tycho version)


The workaround for the missing javacSource/Target support is POM configuration (i.e. the configuring source and target of the tycho-compiler-plugin).

[1] https://issues.sonatype.org/browse/TYCHO-476
Comment 1 Igor Fedorenko CLA 2011-12-13 09:33:55 EST
(In reply to comment #0)
> Currently, the build properties javacSource and javacTarget are not evaluated
> by Tycho. This would be useful because it eases the migration of PDE build
> projects to Tycho.
> 
> The build properties should take precedence over the POM and the Manifest,
> yielding the following order of precedence (cf. [1]):
> 1. build.properties
> 2. explicit POM configuration
> 3. inherited POM configuration
> 4. bundle runtime environment from bundle manifest
> 5. default (depending on Tycho version)
> 
> 
> The workaround for the missing javacSource/Target support is POM configuration
> (i.e. the configuring source and target of the tycho-compiler-plugin).
> 
> [1] https://issues.sonatype.org/browse/TYCHO-476

pom should take precedence over everything else!
Comment 2 Jan Sievers CLA 2011-12-13 09:56:30 EST
(In reply to comment #1)
> pom should take precedence over everything else!

fine with me. So we would have

1. explicit POM configuration
2. inherited POM configuration
3. build.properties
4. bundle runtime environment from bundle manifest
5. default (depending on Tycho version)
Comment 4 Tobias Oberlies CLA 2011-12-14 03:53:38 EST
(In reply to comment #1)
> pom should take precedence over everything else!
Why do you think so?

The POM may have configuration inherited, whereas the build.properties are specific to one module. A change of configuration in the parent POM could therefore override an arbitrary number of other configuration files. IMHO this contradicts to the principle of least astonishment.

Secondly, this also contradicts to the manifest-first principle of Tycho. Obviously, "manifest-first" doesn't say anything about build.properties, but Tycho is also "feature.xml-first", so the principle is (up to now) mostly interpreted as "Eclipse metadata files over POM configuration".
Comment 5 Igor Fedorenko CLA 2011-12-14 06:56:41 EST
I agree that perfect order of precedence should be

1. explicit POM configuration
2. build.properties
3. inherited POM configuration
4. bundle runtime environment from bundle manifest
5. default (depending on Tycho version)

The idea here is that no matter how hard we try, there will be discrepancies between what PDE and Tycho like, and we may need to force tycho-specific configuration. Unfortunately, there is no straightforward way to know if POM configuration was inherited or not, so implementing this perfect order can be tricky. 

The way I solve this problem for <executionEnvironment> configuration is by special syntax for inherited configuration. I think we can do the same for <source> and <target>, i.e.

<source>1.7</source> in pom.xml means "use 1.7, ignore build.properties"
<source>?1.7</source> in pom.xml means "use 1.7 if build.properties does not tell otherwise"
Comment 6 Tobias Oberlies CLA 2011-12-14 07:34:25 EST
Due to the manifest-first principle, I think that build.properties should have first precedence.

> I think we can do the same for <source> and <target>, i.e.
> <source>1.7</source> in pom.xml means "use 1.7, ignore build.properties"
> <source>?1.7</source> in pom.xml means "use 1.7 if build.properties does not
> tell otherwise"

This could be an option, except that the default (no prefix) should be "use value unless build.properties tell differently". To override, we could use a "+" prefix, e.g. <source>+1.7</source>
Comment 7 Igor Fedorenko CLA 2011-12-14 09:46:28 EST
I think by default pom.xml configuration should take precedence. This is expected Maven behaviour. We are being extra nice to "other" build tool here, after all.
Comment 8 Tobias Oberlies CLA 2011-12-15 05:30:01 EST
(In reply to comment #7)
> I think by default pom.xml configuration should take precedence. This is
> expected Maven behaviour. We are being extra nice to "other" build tool here,
> after all.
Tycho is clearly addressed at former PDE-build users, so in case of a Maven vs. Eclipse expected behaviour, Eclipse should win.

Plus there is no good way do distinguish inherited from non-inherited POM configuration, so the definately non-inherited build.properties configuration should win.
Comment 9 Igor Fedorenko CLA 2011-12-15 10:43:30 EST
(In reply to comment #8)
> (In reply to comment #7)
> > I think by default pom.xml configuration should take precedence. This is
> > expected Maven behaviour. We are being extra nice to "other" build tool here,
> > after all.
> Tycho is clearly addressed at former PDE-build users, so in case of a Maven vs.
> Eclipse expected behaviour, Eclipse should win.
> 
> Plus there is no good way do distinguish inherited from non-inherited POM
> configuration, so the definately non-inherited build.properties configuration
> should win.

Honestly, you don't need to repeat yourself again and again. I understand your opinion and I still disagree. In any case, if you or Jan feel strongly enough to change this now, please make sure to update <executionEnvironment> to behave the same (btw, current implementation behaves consistently for <executionEnvironment> and source/target configuration already and "?1.7" can be added later when somebody actually asks for it).
Comment 10 Jan Sievers CLA 2012-01-31 11:30:23 EST
I am resolving this bug now because javacSource and javacTarget in build.properties are read now by tycho, which was the main point to implement here and I want this to show up in the 0.14.0 release notes.

If you want to change pom/build.properties precedence, please open a new separate bug.