简体   繁体   中英

Execute jar file through maven by pulling them from a remote repository

I have a maven project which I build and deploy on a private remote repository. The code is built through continuous integration pipeline.

This repository is accessible from my remote machine. What I want is to pull the artifact and execute it on this remote machine without pulling the source code for the project.

From what I can understand, one needs a pom file which contains this repo, as a dependency, but is their any other way of doing the same without having to download the sources

If it is possible for you to have just one file to download pushed to Artifactory (I assume you are using artifactory from the tag) it is possible to download the file with a simple http get request (via Artifactory REST API), like curl, or even use the JFrog cli.

I recommend using the CLI: https://www.jfrog.com/confluence/display/CLI/CLI+for+JFrog+Artifactory

To use Artifactory REST API directly go to: https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API

Retrieve Artefact api or Retrieve Latest Artefact can be helpful.

you can simply download the file using CLI provided that you have maven installed. Below is an example command.

call mvn org.apache.maven.plugins:maven-dependency-plugin:2.4:get -DrepoUrl=<your nexus url> -Dartifact=<groupid>:<artifactid>:<version>:jar:jar-with-dependencies -Ddest=<destination>

Have you tried the exec-maven-plugin ? http://www.mojohaus.org/exec-maven-plugin/examples/example-exec-for-java-programs.html That is if you want to do the job with Maven (it is not very clear to me if you do or do not want to use Maven on your remote machine).

Note : repacking the dependencies in your executable jar would not be a good practice. You can still build a distribution archive along with your jar (look at the maven-assembly-plugin https://maven.apache.org/plugins/maven-assembly-plugin/ ) and use that archive instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM