Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Usage of maven deploy-file

Tags:

maven

Reading the doc. of the deploy:deploy-file (https://maven.apache.org/plugins/maven-deploy-plugin/deploy-file-mojo.html), it seems that the only required parameters are Required Parameters <file>, <repositoryId> and <url>, nevertheless when I run :

mvn deploy:deploy-file -Durl={url} -DrepositoryId={repoId} -Dfile=D:\Users\nunito\IdeaProjects\calzada\target\calzada.zip

I got this error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy-file (default-cli) on project oib-kw-guards-web: The artifact i
nformation is incomplete or not valid:
[ERROR]   [0]  'groupId' is missing.
[ERROR]   [1]  'artifactId' is missing.
[ERROR]   [2]  'version' is missing.
like image 310
Nunyet de Can Calçada Avatar asked Aug 20 '20 11:08

Nunyet de Can Calçada


People also ask

What does Maven deploy do?

The maven deploy plugin can be used to deploy either files or projects to the remote repository for sharing it with other developers and projects. There are various methods can be used to deploy your artifact to the remote repository by using a maven deploy plugin.

What is the use of mvn deploy command in Maven?

The mvn deploy runs the deploy plugin which deploys an artifact to the remote repository. A project may include the main jar and associated sources and Javadoc jars. The sources jar contains the Java sources, and the Javadoc jar contains the generated Javadoc.

What is Maven deploy command?

mvn deploy. This command invokes the deploy phase: deploy : copies the final package to the remote repository for sharing with other developers and projects.

How do I run Maven deploy?

If you want to execute a specific execution from the command line, you'll need mvn deploy:deploy-file@deploy-file , i.e. @ the id of the configured execution, and make sure you're using at least Maven 3.3.


2 Answers

I usually use deploy:deploy-file in command-line, when I have an 3rd-party artifact without its pom.xml:

cmd /v /c "set a=an-artifact-name&& set g=com.company.xxx&& \
mvn deploy:deploy-file -Dfile=C:\path\to\!a!.jar -Dpackaging=jar -DgroupId=!g! -DartifactId=!a! \
-Dversion=1.0-DEV-SNAPSHOT -DrepositoryId=nexus \
-Durl=http://company.com/nexus/content/repositories/company-snapshots/"

All you need to do is to modify a and g at the beginning of the command.

You can add a version v if you have a specific version, and put it in the release part of your Nexus:

cmd /v /c "set a=an-artifact-name&& set g=com.company.xxx&& && set v=1.2.3&& \
mvn deploy:deploy-file -Dfile=C:\path\to\!a!.jar -Dpackaging=jar -DgroupId=!g! -DartifactId=!a! \
-Dversion=!v! -DrepositoryId=nexus \
-Durl=http://company.com/nexus/content/repositories/company-releases/"
like image 128
VonC Avatar answered Nov 15 '22 07:11

VonC


The plugin "Usage" page (https://maven.apache.org/plugins/maven-deploy-plugin/usage.html) states:

If the following required information is not specified in some way, the goal will fail:

  • the artifact file to deploy
  • the group, artifact, version and packaging of the file to deploy. These can be taken from the specified pomFile, and overriden or specified using the command line. When the pomFile contains a parent section, the parent's groupId can be considered if the groupId is not specified further for the current project or on the command line.
  • the repository information: the url to deploy to and the repositoryId mapping to a server section in the settings.xml file. If you don't specify a repositoryId, Maven will try to extract authentication information using the id 'remote-repository'.

So you either need to specify the coordinates or give a POM file.

like image 36
J Fabian Meier Avatar answered Nov 15 '22 07:11

J Fabian Meier