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

Bug 365638

Summary: buildQualifier parameter also updates non qualifier Bundle-Version
Product: z_Archived Reporter: Anthony Dahanne <anthony.dahanne>
Component: TychoAssignee: Project Inbox <tycho-inbox>
Status: RESOLVED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: bsd, igor, markward.schubert
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
the simple example to demonstrate the bug
none
Patch providing both the fix and the associated it test none

Description Anthony Dahanne CLA 2011-12-05 12:23:23 EST
Build Identifier: 0.13.0

Using the buildQualifier argument, -DbuildQualifier=M01 for example, I found out that, even for bundles already specifying a full version without qualifier, they see their qualifiers updated with the buildQualifier.
Here is the example I attached to demonstrate this case :

* build this example with mvn clean install : you'll see in target/MANIFEST.MF  Bundle-Version: 1.0.0 and the jar will be named target/tycho.qualifier.example-1.0.0.jar
* now build this example with mvn clean install -DbuildQualifier=M01 :
you'll see in target/MANIFEST.MF  Bundle-Version: 1.0.0.M01 and the jar will still be named target/tycho.qualifier.example-1.0.0.jar

The problem occurs when you have a reactor with projects having a qualifier, and some not having a qualifier : I expect that if I set a buildQualifier, only the projects having a qualifier would be impacted not the others (and also there is an inconsistency  between the manifest version and the jar name in this case)

The code that seems to update the Bundle-Version is :
DefaultReactorProject.setExpandedVersion
I only tried with tycho 0.13.0


Reproducible: Always

Steps to Reproduce:
1. build this example with mvn clean install : you'll see in target/MANIFEST.MF  Bundle-Version: 1.0.0 and the jar will be named target/tycho.qualifier.example-1.0.0.jar
2. now build this example with mvn clean install -DbuildQualifier=M01 :
you'll see in target/MANIFEST.MF  Bundle-Version: 1.0.0.M01 and the jar will still be named target/tycho.qualifier.example-1.0.0.jar
Comment 1 Anthony Dahanne CLA 2011-12-05 12:24:11 EST
Created attachment 207934 [details]
the simple example to demonstrate the bug
Comment 2 Anthony Dahanne CLA 2011-12-05 13:20:56 EST
just a thought about the resolution :
I think that if we add :

 if (version.getQualifier() != null && !version.getQualifier().equals("qualifier")) {
            project.setContextValue(TychoConstants.CTX_EXPANDED_VERSION, version);
            return;
        }

to 

https://git.eclipse.org/c/tycho/org.eclipse.tycho.git/tree/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/DefaultReactorProject.java#n169


that should fix it. (ok ok, the "qualifier" string should be shared; it is already the case... in org.eclipse.tycho.buildversion.VersioningHelper that depends on ... tycho-core :-( )

what do you think ?
Comment 3 Igor Fedorenko CLA 2011-12-05 15:32:02 EST
I think I'll be happy to review&apply a patch that includes the fix and corresponding unit/integration tests ;-)
Comment 4 Anthony Dahanne CLA 2011-12-06 14:02:20 EST
Created attachment 208015 [details]
Patch providing both the fix and the associated it test

This provided patch fixes the bug.
I don't think it creates any regression (some it tests never run on my machine...)
I hope reviewing this patch will make you happy ;-)
Have a good day !
Comment 5 Anthony Dahanne CLA 2011-12-06 18:00:33 EST
Wow !
seems like I got a total misunderstanding of the build qualifier...
the env. variable "buildQualifier" is only used internally and should not be used when launching maven.
instead, using the build qualifier goal of the tycho-packaging-plugin takes care of everything.
with this snippet in the parent :

<plugin>
				<!-- Generates the build qualifier and expose a property named 'buildQualifier' -->
				<groupId>org.eclipse.tycho</groupId>
				<artifactId>tycho-packaging-plugin</artifactId>
				<version>${tycho-version}</version>
				<executions>
					<execution>
						<id>build-qualifier</id>
						<goals>
							<goal>build-qualifier</goal>
						</goals>
						<phase>validate</phase>
						<configuration>
							<format>${build.qualifier}</format>
						</configuration>						
					</execution>
					<execution>
						<id>packaging</id>
						<configuration>
							<archive>
								<addMavenDescriptor>false</addMavenDescriptor>
							</archive>
						</configuration>						
					</execution>
				</executions>
			</plugin>	


a -Dbuild.qualifier=M01 will put M01 as a qualifier and will not update the fixed versions.

I'd like to document this somewhere so that other users may know; can I create a wiki page for that ? (TychoAndBuildQualifier page in tycho wiki)
Comment 6 Igor Fedorenko CLA 2011-12-06 18:06:41 EST
(In reply to comment #5)
> 
> I'd like to document this somewhere so that other users may know; can I create
> a wiki page for that ? (TychoAndBuildQualifier page in tycho wiki)

Yes, by all means document this, wiki.eclipse.org is open for everybody.
Comment 7 Brian de Alwis CLA 2011-12-22 10:26:20 EST
I added a note to http://wiki.eclipse.org/Tycho/FAQ 

Marking this as RESOLVED WONTFIX.
Comment 8 Anthony Dahanne CLA 2011-12-22 22:07:51 EST
Thanks Brian, I forgot to document,  will do better next time ;-)