0
votes

Is it possible to run mvn commands if there is no maven installed on the target machine? I know this is a strange one.

Is this possible using some wrapper tool/utility which has maven/etc tools inbuilt in the wrapper tool/utility?

This is what I'm trying to achieve. Using Ansible (and Maven) to get an artifact to a given folder from a remote Artifactory server.

  1. I want to download an artifact from Artifactory.
  2. The target machine doesn't have maven(mvn) installed.
  3. If I create a small one liner shell script then I have to deal with all the repositories one by one i.e. in some order (i.e. look into release repo first, then way down to snapshot etc or vice versa).

    (wget http://myArtifactoryServer:somePort/artifactory/libs-snapshot-local/com/company/product/artifactName/version/artifactNameVersion.extension || wget http://myArtifactoryServer:somePort/artifactory/libs-stage-local/com/company/product/artifactName/version/artifactNameVersion.extension || wget http://myArtifactoryServer:somePort/artifactory/libs-alpha-local/com/company/product/artifactName/version/artifactNameVersion.extension || wget http://myArtifactoryServer:somePort/artifactory/libs-beta-local/com/company/product/artifactName/version/artifactNameVersion.extension || wget http://myArtifactoryServer:somePort/artifactory/libs-gamma-local/com/company/product/artifactName/version/artifactNameVersion.extension || wget http://myArtifactoryServer:somePort/artifactory/libs-release-local/comcompany/product/artifactName/version/artifactNameVersion.extension )

I was wondering if there's any other easiest way I can grab an artifact by just giving "virtual repo name" i.e. libs-release (which I have created and looks into all physical release repos or just use company-repos virtual so that I don't have to name each repo name one by one using || or with wget).

I don't have to use wget either if there's any other way around. Maven automatically finds the artifact and search in all the repos (what you define in settings.xml or pom.xml or at command line maven-dependency-plugin:get/copy)

I can also write code in groovy but then groovy has to be there on the target server.

1
You could have a look on gradle. The advantage regarding this topic is, that you can ship it with an gradle wrapper shell script and the necessary gradle binary. The target environment does not need to have gradle installed. Gradle also handles repositories etc. properly. Have a look here for the wrapper.u6f6o
I am not a hundred percent sure what you are trying to achieve. Capsule is a project for building executable jars it also comes with support to download dependencies from maven repositories.Felix Leipold
You can use the Maven wrapper as well. But why don't you create an tar.gz archive containing all that stuff via Maven and download only the tar.gz file?khmarbaise
It seems like in Ansible 2.0, I can easily download the artifact from Artifactory ... So far I have Ansible < 2.0 and I was trying to use maven-dependency-plugin:copy/get goals but was dealing with this issue in this post.AKS

1 Answers

1
votes

Late to the party, but nonetheless:

Having re-read the question, what you're missing is, as you mention, a virtual repo, which combines repos so they appear to be one. Artifactory supports this out of the box.

As an alternative to maven that requires nothing other than bash, you could try this shell script from sonatype http://blog.sonatype.com/2011/01/downloading-artifacts-from-nexus-with-bash.