Do not want version number on my jar/ear/war while using maven to deploy to nexus - maven

I have an ant build invoked my jenkins that creates my .ear/.war file but using maven in jenkins to upload archive to Nexus for deployment tool to use.
The archive from ant is titled myear.ear but ends up as myear-version.ear in nexus upon deploy.
I do not want the version number added to the artifact - Any way to avoid this behavior?
Thank You!

The artifact in the Maven repository will always contain the version number as part of the filename since that is part of the Maven repository format. The filename is artifactId-version[-classifier].packaging.
However that is never really a problem because nothing stops you from downloading it following that naming convention and then changing the name of the downloaded file. And if you dont know the version you can query Nexus for the available versions via the REST API.

You can add the finalName configuration inside your pom as below
<build>
<finalName>desiredName</finalName>
</build>

Related

Set Debian control file properties when deploying to Artifactory

I'm building a binary Debian archive with Maven, using org.vafer.jdeb plugin to create the .deb and maven-deploy-plugin plugin to deploy the archive on Artifactory.
The archive is correctly built (with control file and its mandatory fields). Nevertheless, when deployed to Artifactory, properties as deb.distribution, deb.component, deb.architecture, etc... are not set ; the archive can't be found.
Any idea on how to set the properties ?
Can you please specify to which repository type are you deploying?
Since this is a .deb file, in order for Artifactory to produce the right metadata for it, you will need to use Debian repositories. Since you are deploying using Maven, it sounds like you deploy the artifacts to a Maven repository which could cause the metadata to be calculated differently.
I recommend maybe adding a promotion step to copy/move these files from the Maven repository to a Debian repository and check whether this step adds the properties.
I hope this helps and clarifies further.

Can i configure maven to use custom build number for Snapshot version

If i am deploying a snapshot jar file using mvn deploy, then maven generates the jar file name depending based as follows
projectname-1.0-20170509.204524-1.jar
That is
$project1-$version-$date.$time-$buildnumber.jar
Can i configure maven to use custom jar file name?
Eg projectname-1.0-1.jar, projectname-1.0-2.jar
In your case, the artifact's version is a snapshot. Snapshot artifacts (since Maven 3.x) always must have a timestamped version.
You should not be changing this.
If, you would like to change it for purposes other than for deploying to an artifact repository, I believe you can do this via the finalName, or via the maven-assembly-plugin.
Either way, this is (usually) a very bad idea.

Maven deploy plugin keep the file name when uploading

I am using maven deploy plugin to upload a file inside bamboo deployment stage. I am uploading the file without pom file. When I upload the file to Nexus, the file name is changing completely. Its appending with project name, version number and build number. I want to keep the filename as it is. Any one know how to do this?
mvn deploy:deploy-file
-Dfile=${bamboo.artifacts.path.artifactFile}
-Dpackaging=cba
-url=https://nexus.internal.organisation.com/content/repositories/snapshots/
-DrepositoryId=snapshots
-DgroupId=com.organisation.art
-DartifactId=myproject
-Dversion=0.0.1-SNAPSHOT
A maven managed repository, such as that provided by Nexus et al, is set up in a way that is intended for deployed products to be returned to a maven build process that has them declared as dependencies.
It is not intended to be a generic file server.
If you have Nexus 3.0 or newer then you have access to so called "raw" repositories that you can set up any way you like.
However you would not use mvn deploy:deploy-file to add files to it. Instead you would follow the instructions in Uploading Files to Hosted Raw Repositories.

Can I avoid Maven deployed war version with timestamp in Archiva?

In out project we are using using deployed war file in /archiva-2.2.0/repositories/internal/com/xyz/1-SNAPSHOT/proj-1-20160204.122021-15.war path using shell script to copy to jboss. However finding the latest build timestamp and build number is very difficult. Is there a way to avoid using timestamp while storing it in archiva like proj-1-SNAPSHOT.war?
I have already read about <uniqueVersion>false</uniqueVersion> whcih is not supported in maven 3.
I am using archiva-2.2.0, maven-3.3.9.
Maven repositories wasn't designed to distribute deployable components, your continuous integration environment should take care of this. Jenkins has eg Archive Artifacts (native) and Copy Artifact Plugin which you can use to store and recover binaries in your pipelines.
But you can workaround this behavior changing the version of the war to a stable one - removing the -SNAPSHOT suffix. This will lead you with a predictable URL.
I am posting this as it is a new finding, if I wget http://xx.xx.xx.xx:8083/repository/internal/com/xyz/1-SNAPSHOT/proj-1-SNAPSHOT.war. I get the latest deployed artifact in the archiva repository. So archiva does a 302 redirect to point to url of http://xx.xx.xx.xx:8083/repository/internal/com/xyz/1-SNAPSHOT/proj-1-20160204.122021-15.war location and downloads the latest build. I am not sure if this works for other repositories like nexus or artifactory etc.
Ofcourse I will need a cron job to periodically clear of the stale snapshot artifacts.

deploy on nexus artifacts with Snapshot policy but without SNAPSHOT string in version

apparently my Nexus is rejecting every deploy I throw at him if the artifact has not -SNAPSHOT in the version.
Data:
name of the failing artifact: entando-core-engine-experiment-bundles_with_bootstrap.jar where experiment-bundles_with_bootstrap is the version as in the version element of the pom.xml
hosted repository policy on my Nexus: Snapshot, allow redeploy and so on (classic conf for snapshots)
deployer: Jenkins 1.481
same Jenkins job, but entando-core-engine-SNAPSHOT.jar ---> SUCCESS
I need this naming convention because I'm building one of the several experiments we run internally, as opposite to the canonical develop branch which produces a proper entando-core-engine-SNAPSHOT.jar
Any advice?
I'm totally lost.
The thing is that usually your Nexus is configured not to allow a redeployment of a release. A release from Maven point of view is an artifact where it's version it NOT -SNAPSHOT. In contradiction a SNAPSHOT is intended to be deployed several times into nexus.
This sounds like you don't using the release plugin of Maven nor the Release PLugin of Jenkins.
Nexus is a repository manager that uses different repository formats, with the main format being the Maven repository format. Changing the names of artifacts on the server is not possible since it violates the format. They have to be located in the directory structure established by groupId, artifactId and version and use the artifactId-version-classifier.packaging for the file names.
If you need a different file name on the server you have to look at a different repository format (bad idea). If you need the filename on the client just download from the correct name and rename..

Resources