In a Tycho build, how do I add a timestamp style qualifier when I don't have the .qualifier text added to my version in my MANIFEST.MF file - eclipse-plugin

I have a Tycho build project that successfully builds a feature and its bundles as well as a p2 repository. Everything is built using .qualifier and -SNAPSHOT. For example:
My MANIFEST.MF file in my bundle is has the version of the bundle set to something like ...
Bundle-Version: 1.0.3.qualifier
My feature is also has its version set to ...
<feature version="1.0.3.qualifier"
id="com.myurl.my.feature"
label="My Feature"
provider-name="My Company">
My pom.xml file has its version set like so...
<version>1.0.3-SNAPSHOT</version>
This all works great. The resulting bundles have the qualifier replaced with the standard timestamp, and the resulting built manifest file's version looks like this...
Bundle-Version: 1.0.3.201402101829
The resulting plugin jar file has a name as such as...
com.myurl.mybundle.1.0.3.201402101829.jar
My artifacts that get deployed to my Maven repository have the -SNAPSHOT
1.0.3-SNAPSHOT
What I want to do is change my version numbers from using .qualifier and -SNAPSHOT at release time so that I can deploy to my Maven repository a bundle that doesn't have a -SNAPSHOT associated with it.
I use this command to change my version numbers...
org.eclipse.tycho:tycho-versions-plugin:set-version -DnewVersion=1.0.3
After I execute this command, I run my maven build, and the resulting artifacts now have version numbers that don't have the .qualifier and -SNAPSHOT, which is what I expect.
But... What I would like to do is have the resulting bundles have a timestamp as they did when I was using the .qualifier, but I want the artifacts that are deployed to my Maven repository to not have the -SNAPSHOT modifier. Is this possible using some thing like the ...
-DforceContextQualifier
... thats availabe in the tycho-packaging-plugin? If so, how?

Related

Why are artifacts built with tycho-buildtimestamp-jgit still named -SNAPSHOT?

We use tycho-buildtimestamp-jgit as explained in the tycho wiki to create reproducible version qualifiers for bundles.
The bundle jars created in the target/ directory are still named bundle.name-1.2.3-SNAPSHOT.jar even though the MANIFEST.MF already contains the generated version qualifier.
Why isn't SNAPSHOT replaced with the generated qualifier? How can the pom.xml be adjusted to include the generated version in the bundle file name?
Every bundle built by Tycho has a Maven version and an OSGi/p2 version. Which one of the two versions you see depends on the context. E.g. in the target/ folder, being a Maven concept, you will see the bundle jar with the Maven version.
If you aggregate the bundle into a p2 repository (with the packaging type eclipse-repository), you'll see the bundle jar with a file name that includes the OSGi version.
Note that the tycho-buildtimestamp-jgit plugin only affects the OSGi version, i.e. the replacement of the qualifier literal. Maven's SNAPSHOT literal is never replaced by Tycho.

Maven 2, Nexus and snapshot timestamps are causing problems with eclipse:eclipse

We have moved from Archiva to Nexus and are still using Maven 2.
We execute eclipse:eclipse locally so that Eclipse .project and .classpath files are generated, based on the dependencies in the POMs, and then we import the projects into Eclipse to do our development. We don't use M2Eclipse for a variety of reasons.
Since using Nexus, we have the problem that projects don't always reference each other in the workspace, rather they reference the respective JAR.
I have noticed that Nexus is appending a timestamp to the JAR name, and the MVN output states, e.g.:
[INFO] Artifact myapp-bom:jar:7.3.0.2.1-SNAPSHOT already available as a workspace project, but with different version. Expected: 7.3.0.2.1-20120508.115037-68, found: 7.3.0.2.1-SNAPSHOT
I get the feeling that is the reason why eclipse:eclipse generates .classpath files which contains JAR references (based on local maven repo) rather than project references. When we used Archiva (and there were no timestamps) then we used to get project references, and that is exactly what we want.
Has anyone else had this problem and how is it solved? I read that maven 3 forces timestamps to always be generated. Again, how do you get eclipse:eclipse to generate sensible .classpath files?
Cheers,
Ant
PS - some of our projects come from different SVN repositories. It seems that if the Eclipse Projects are refernced in the parent pom, eclipse:eclipse creates a project reference, but if the Eclipse Projects are from a different parent pom, but still in the workspace, then it can only generate JAR references.
The problem was resolved by using maven-eclipse-plugin (eclipse:eclipse) version 2.9, rather than 2.8! Doh...

Maven Unique Version in Jar File Name

I am using Maven with Nexus for building my project with hudson ci. Everytime when I am deploying a new snapshot artifact he is doing this with a unique version in nexus. Which is OK for me as Nexus is giving me always the latest version.
Now I looked into the war file of my project which is using this snapshot dependency and its having the following jar file in its lib directory which is absolutely not fine:
framework-client-1.1-20120302.141044-3.jar
The problem is that I am using EBean as an ORM and I need to specify the jar name in the ebean.properties to let him know where to find its models.
How can I prevent such behaviour so that the latest snapshot dep is always call framework-client-1.1-SNAPSHOT.jar?
Thank you!
Just rename the jar in the war file to whatever name you like. Details are here
Renaming Maven dependency in WAR's WEB-INF/lib folder

How to convert Ant project to Maven project

How to convert a Ant project to Maven project? A sample project that would link (a Wicket project)
Thanks
The nice part of using maven is that most standard stuff works automatically once you do things the maven way. For a simple webapp:
Create a pom with groupId, artifactId and version (packaging: war)
Add the required dependencies to the pom
move the
java sources to src/main/java,
resources to src/main/resources,
webapp content to src/main/webapp,
test content to src/test/java and src/test/resources
set the compiler compliance version using the maven compiler plugin
That should get you up 'n' running.
http://www.sonatype.com/people/2009/04/how-to-convert-from-ant-to-maven-in-5-minutes/
I don't know what your ant script looks like, but assuming its a basic script for building, you will need to create a pom.xml file for your project, add your dependencies, and then build it via maven.
For anyone who lands here in future, there is an easier way to find dependencies for maven using the file hashes. So, you won't have to guess artifact versions.
As per the below article, the idea is to generate a SHA1 checksum of the dependency that you want to find the information, then do a reverse search in Nexus repository manager using that hash. For the checksum generation, you can use Microsoft's FCIV (free) utility.
https://devreads.xyz/ant-to-maven-conversion-the-painless-method/

maven install file manually without version

How do I add a jar file to my local repository without appending the version number to the jar file?
Lets say I have a jar file named abc.jar and run the following command, it will create abc-1.0.jar and if I bundle this artifact in a war file, the resulting file name will be abc-1.0.jar. If I remove the -Dversion, the command fails. If I mention blank value -Dversion="", then abc-.jar is created. How do I keep the original jar's filename(abc.jar)?
mvn install:install-file -Dfile="d:\abc.jar" -DgroupId=grp1 -DartifactId=art1 -Dversion=1.0 -Dpackaging=jar
How do I add a jar file to my local repository without appending the version number to the jar file?
You can't.
This works for war packages. I haven't tried it for jars.
<build>
<!-- Ensures that the version number is not included in the packaged file name -->
<finalName>myrenamedpackage</finalName>
</build>
You can not change the name of the arifact in your maven repository, but you can configure the war plugin to use a specific nming scheme for the libs it bundles in WEB-INF/lib using the outputFileNameMapping option. To remove version information and classifiers the mapping pattern would be #{artifactId}#.#{extension}#. If the artifact id matches the original filename this should give the wanted result.