| Summary: | Expose version qualifier property | ||
|---|---|---|---|
| Product: | z_Archived | Reporter: | Aleksandr Kravets <aleksandr.kravets> |
| Component: | Buckminster | Assignee: | buckminster.core-inbox <buckminster.core-inbox> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | enhancement | ||
| Priority: | P3 | CC: | info, michael.wenz, mtaal, stefan.bolton, tamar.e.cohen, thomas |
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
I would really like to have this feature available and wouldn't mind implementing this. I've never worked with Buckminster code, but perhaps with some guidance I can implement this and contribute code back if somewhere can give me some pointers on where to look for relevant code? I would also be interested in having this feature This feature is pretty essential for me. I'm not sure how I'm supposed to publish built jars to a maven repo without knowing what the qualifier is as I have to specify an exact jars filename - which Buckminster adds the qualifier to. Unfortunately the deploy task doesn't seem to support wildcards :/ We do this already. It's not very intuitive though. The source for all of this can be found in the org.eclipse.equinox.p2.director.product project in our SVN. Here's a brief explanation.
When a cspec or cspex action executes an ant task using the ant-actor, it will set a property 'buckminster.pdetasks' to appoint the ant script bundled with Buckminsters pde support. You can import this file into another antscript using:
<import file="${buckminster.pdetasks}"/>
That script contains macros such as 'extractFeatureVersion' and 'extractFeatureId'.
Key to all of this is that the product is defined in a feature. The product must be feature based and use one single feature (the one that it is defined within). Here is the task that builds the actual zip file for the product:
<target name="create.product.zip">
<extractFeatureVersion file="${sp:manifest}" property="product.version"/>
<extractFeatureId file="${sp:manifest}" property="product.name"/>
<dirname file="${sp:product.dir}" property="product.parent.dir"/>
<basename file="${sp:product.dir}" property="relative.product.dir"/>
<mkdir dir="${sp:action.output}"/>
<exec dir="${product.parent.dir}" executable="zip" outputproperty="zip.output" failonerror="true">
<arg value="-r"/>
<arg value="-9"/>
<arg value="${sp:action.output}${product.name}_${product.version}.zip"/>
<arg value="${relative.product.dir}"/>
</exec>
<echo message="${zip.output}"/>
</target>
This task is called from the cspex like so:
<public name="create.product.zip" actor="ant">
<actorProperties>
<property key="buildFile" value="product.ant"/>
<property key="targets" value="create.product.zip"/>
</actorProperties>
<prerequisites>
<attribute name="create.product" alias="product.dir"/>
<attribute name="manifest" alias="manifest"/>
</prerequisites>
<products alias="action.output" base="${buckminster.output}" upToDatePolicy="COUNT" fileCount="1">
<path path="director.zip/"/>
</products>
</public>
and since this cspex resides in the feature that defines the product, the 'manifest' that is defined in its auto generated cspec is referencing it's feature.xml. The extractFeatureVersion and extractFeatureId extracts the version and id from that file.
Thanks Thomas, just tried this approach and it works great! Hi Thomas --
I'm trying to do the same thing and would really enjoy having access to the version & qualifier in a property I can access from ant!
I have tried following your direction and my issue is this:
In the main feature which includes the product when I call the ant task <extractFeatureVersion file="${sp:manifest}" property="full.version"/> the full.version is set correctly. However, my about.mappings and branding stuff are in a different plugin. If I call that <extractFeatureVersion ... within my branding plugin, instead of just getting the version back I get the contents of the entire manifest in the property!
Given that I need to adjust the information in the about.mappings BEFORE it is jarred up etc, what would be the correct approach?
thanks
Tamar
See here for another solution to this: http://www.eclipse.org/forums/index.php/t/263216/ An approach I did myself was to retrieve the version from the generated jar file names. In ant you can use javascript for this: <macrodef name="computeVersionQualifier"> <attribute name="directory" /> <attribute name="pattern" /> <sequential> <path id="versionQualifierFileName.id"> <fileset dir="@{directory}"> <include name="@{pattern}" /> </fileset> </path> <property name="versionQualifierFileName" refid="versionQualifierFileName.id" /> <script language="javascript"> <![CDATA[ var lastIndex = versionQualifierFileName.lastIndexOf('.'); var version = versionQualifierFileName.substring(0, lastIndex); lastIndex = version.lastIndexOf('.'); version = version.substring(lastIndex + 1); project.setProperty('versionQualifier', version); ]]> </script> </sequential> </macrodef> See for an example file name I use to parse: https://hudson.eclipse.org/hudson/job/emf-teneo-nightly/ws/build/output/org.eclipse.emf.teneo.hibernate.mapper_2.0.0-osgi.bundle/jar Closing this since the questions seems to have been answered. Please open a new bug or enhancement request if you feel that there are some outstanding issues. |
Build Identifier: 20100218-1602 When generator.last.revision.format is set, for example as Nightly-{0,number,00000} and qualifier.replacement.*=generator:lastRevision is used during components assembly, components that are build and their Manifest.mf file have this revision in the bundle name and Bundle-Version. Currently in create.product.zip action for example, my path is prodcut.${target.ws}.${target.os}.${target.arch}, the resulting zip file could be product.win32.win32.x86. However, this does not say anything about its version or what type of build was performed, as Manifest.mf does. If there was a property that could be used that was set as a result of performing qualifier.replacement.*=generator:lastRevision, user would be able to do something like prodcut.${target.ws}.${target.os}.${target.arch}_{version.qualifier}, and create more descriptive description of the product: product.win32.win32.x86_0.1.0.Nightly-56459 for example. Discussion about this is here http://www.eclipse.org/forums/index.php?t=msg&th=172889&start=0&S=a5948dcaabb8325cb6578bb6b758c24b Reproducible: Always