Hello! After a bit long time, I am writing a post in this "Gyan   of Java" blog. Today, we will look into few concepts of Apache Maven building tool. Have you ever come across a situation where you need to push build   artifacts to a remote repository? Have you ever come across a situation where you need to push third party artifacts to a remote repository? Let's look into these now.
  
  
  To answer first query, need to add a <distributionManagement> tag entries in the pom.xml of the application.
  
  Step: 1 
  <!-- remote repository server info where artifacts would be pushed -->  
   <distributionManagement>
    <repository>
     <id>remoteRepo</id>
     <name>Internal Nexus Repository</name>
     <url>http://<remote host name>:<port name>/<remote repository path>/</url>
    </repository>
  </distributionManagement>
  
  
  Also, need to below add entries in the settings.xml file located in M2_HOME directory.
  
  Step: 2
     <servers>
  <server>
  <id>remoteRepo</id>
  <username><username></username>
  <password><password></password>
  </server>
  </servers>
After doing these changes, build your app with following command:
mvn clean deploy
Regarding the later question, pushing third party artifacts whose pom.xml is not available, below   is the code snippet.
Step: 3
mvn deploy:deploy-file -DgroupId=com.company.app -DartifactId=appName -Dversion=1.0 -Dfile=<path-to-file>/appName.jar   -Dpackaging=jar -DrepositoryId=remoteRepo -Durl=http://<remote host>:<port no>/<remote repository path> -DgeneratePom=true
but before executing Step :3 command, please make sure to add entries in settings.xml file as mentioned in Step:   2