Stefan S.
Stefan S.

Reputation: 4103

Remove Qualifier For Tycho Builds

I want to have some of Tycho builds without the time stamp at the end of the version in the Manifest.MF (I'm trying not to use words like "release" and "standard", else people get stuck on the fact that I'm trying something that Tycho was not build to do).

I figure I have to either configure the tycho-packaging-plugin like this:

<profiles>
    <profile>
        <id>some-special-occurrence</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.eclipse.tycho</groupId>
                    <artifactId>tycho-packaging-plugin</artifactId>
                    <configuration>
                        <format></format><!-- can't figure out what to enter -->
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

Maybe I could repurpose the tycho-versions-plugin, but I could not find any info on how to prevent it from setting ".qualifier" at the end of the version.

Does anyone have an idea how to remove the qualifier for some of the Tycho builds?

Upvotes: 2

Views: 1522

Answers (2)

lorenzo-bettini
lorenzo-bettini

Reputation: 2655

As shown in this article, http://www.lorenzobettini.it/2020/02/remove-snapshot-and-qualifier-in-maven-tycho-builds/, you can use a combination of standard Maven plugins and the tycho-versions-plugin.

For example, you can run

mvn \
  build-helper:parse-version org.eclipse.tycho:tycho-versions-plugin:set-version \
  -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.incrementalVersion}

Or alternatively

mvn \
  versions:set -DgenerateBackupPoms=false -DremoveSnapshot=true \
  org.eclipse.tycho:tycho-versions-plugin:update-eclipse-metadata

The first method will first parse the current version and set some properties; with these properties you can create a version corresponding to the current one, skipping the -SNAPSHOT, and pass it to tycho-versions-plugin.

The second method will first remove the -SNAPSHOT from the POMs and then use tycho-versions-plugin to update Eclipse projects versions (removing the .qualifier).

More details can be found in the above mentioned article.

Upvotes: 1

Tom Bryan
Tom Bryan

Reputation: 577

It's not clear what you're asking.

If your MANIFEST.MF has a version number without a qualifier, like

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Bundle
Bundle-SymbolicName: example-bundle;singleton:=true
Bundle-Version: 0.1.0

then you don't have to do anything. That is, Tycho will product artifacts with the given bundle-version, 0.1.0, with no qualifier. You don't have to mess with the tycho-packaging-plugin.

Are you saying that you want to use a Bundle-Version with a qualifier, like 0.1.0.qualifier, in your MANIFEST.MF, but you don't want your build to strip the qualifier during the build? If that's what you want, I think that you're going to have to submit a feature request.

Ideally, you could just provide a

<forceContextQualfier></forceContextQualifier> 

or maybe

<forceContextQualfier>none</forceContextQualifier> 

to indicate that you do not want the qualifier. That is, you want something that produces the same effect as qualifier=none in PDE: http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.pde.doc.user%2Ftasks%2Fpde_version_qualifiers.htm.

But looking at https://git.eclipse.org/c/tycho/org.eclipse.tycho.git/tree/tycho-packaging-plugin/src/main/java/org/eclipse/tycho/buildversion/BuildQualifierMojo.java, it looks like forceContextQualifier is treated as a literal string. There's no special handling for a none value, and a null string is always replaced with a timestamp.

The format value has to be a valid SimpleDateFormat. Again, empty values are replaced with the default, so there's no way to request an empty or null format.

Your other option is to use the tycho-versions-plugin to set the value of your bundles and remove the qualifier. That way, you could branch for a release, set the version to remove the qualifier, and then build. Or maybe have the build do it on-the-fly.

But, really, I think that it would be slicker if we could just make the tycho-packaging-plugin handle a none forceContextQualifier value.

Upvotes: 0

Related Questions