Difference between revisions of "Deploying Single Files with Maven"

From Pterodactylus
Jump to: navigation, search
(Add commands to install/deploy files with Maven even if they’re not under Maven control.)
 
(Include pomFile parameter in deploy-file call)
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
In order to deploy single files that are not controlled by Maven, you need the <tt>deploy:deploy-file</tt> goal.
 
In order to deploy single files that are not controlled by Maven, you need the <tt>deploy:deploy-file</tt> goal.
  
     # mvn deploy:deploy-file -Dfile=''file'' -DgroupId=''groupId'' -DartifactId=''artifactId'' -Dpackaging=pom -Dversion=''version'' -DrepositoryId=''repositoryId'' -Durl=scp://''host''/''path''
+
     # mvn -Dfile=''file'' -DgroupId=''groupId'' -DartifactId=''artifactId'' -Dpackaging=jar -Dversion=''version'' -DrepositoryId=''repositoryId'' -Dsources=''source.jar'' -Durl=scpexe://''host''/''path'' -DpomFile=pom.xml deploy:deploy-file
  
The repository ID is necessary in case you have authentication information defined for your repository.
+
<!-- -Durl=scpexe://maven.pterodactylus.net/var/www/pterodactylus.net/maven -->
 +
 
 +
The repository ID is necessary in case you have authentication information defined for your repository. You might additionally also need the following in your <code>pom.xml</code>:
 +
 
 +
    <project>
 +
      <modelVersion>4.0.0</modelVersion>
 +
      <groupId>''groupId''</groupId>
 +
      <artifactId>''artifactId''</artifactId>
 +
      <version>''version''</version>
 +
      <build>
 +
        <extensions>
 +
          <extension>
 +
            <groupId>org.apache.maven.wagon</groupId>
 +
            <artifactId>wagon-ssh-external</artifactId>
 +
            <version>1.0</version>
 +
          </extension>
 +
        </extensions>
 +
      </build>
 +
    </project>
 +
 
 +
And most definitely ''should'' you add a <code>pom.xml</code> in order to declare dependencies of the file you are deploying.
  
 
To install a file only locally, use:
 
To install a file only locally, use:
  
     # mvn install:install-file -Dfile=''file'' -DgroupId=''groupId'' -DartifactId=''artifactId'' -Dpackaging=pom -Dversion=''version''
+
     # mvn install:install-file -Dfile=''file'' -DgroupId=''groupId'' -DartifactId=''artifactId'' -Dpackaging=jar -Dversion=''version''
 +
 
 +
To additionally install the sources for a JAR file, use:
 +
 
 +
    # mvn install:install-file -Dfile=''file'' -DgroupId=''groupId'' -DartifactId=''artifactId'' -Dpackaging=jar -Dversion=''version'' -Dclassifier=sources
  
 +
[http://maven.apache.org/plugins/maven-install-plugin/install-file-mojo.html Other userful options] include <tt>localRepositoryPath</tt>.
 
[[Category:Programming]]
 
[[Category:Programming]]
 
[[Category:Java]]
 
[[Category:Java]]
 
[[Category:Maven]]
 
[[Category:Maven]]

Latest revision as of 21:30, 1 March 2025

In order to deploy single files that are not controlled by Maven, you need the deploy:deploy-file goal.

   # mvn -Dfile=file -DgroupId=groupId -DartifactId=artifactId -Dpackaging=jar -Dversion=version -DrepositoryId=repositoryId -Dsources=source.jar -Durl=scpexe://host/path -DpomFile=pom.xml deploy:deploy-file


The repository ID is necessary in case you have authentication information defined for your repository. You might additionally also need the following in your pom.xml:

   <project>
     <modelVersion>4.0.0</modelVersion>
     <groupId>groupId</groupId>
     <artifactId>artifactId</artifactId>
     <version>version</version>
     <build>
       <extensions>
         <extension>
           <groupId>org.apache.maven.wagon</groupId>
           <artifactId>wagon-ssh-external</artifactId>
           <version>1.0</version>
         </extension>
       </extensions>
     </build>
   </project>

And most definitely should you add a pom.xml in order to declare dependencies of the file you are deploying.

To install a file only locally, use:

   # mvn install:install-file -Dfile=file -DgroupId=groupId -DartifactId=artifactId -Dpackaging=jar -Dversion=version

To additionally install the sources for a JAR file, use:

   # mvn install:install-file -Dfile=file -DgroupId=groupId -DartifactId=artifactId -Dpackaging=jar -Dversion=version -Dclassifier=sources

Other userful options include localRepositoryPath.