avi.elkharrat
avi.elkharrat

Reputation: 6800

Get jar-with-dependencies using ansible maven_artifact

Is it possible to get a Java jar-with-dependencies using ansible package maven_artifact?

Now for a bit of a context:

  1. I have a simple Java application. This means I need to produce a jar-with-dependencies type of jar for this app to be executable as a stand alone.
  2. I'm pushing my jar using mvn deploy in a registry (in my case: Nexus)
  3. I'm using Ansible to deploy my app and it seems to be a sensible choice to use maven_artifact package (I suppose it manages idempotence better then I would).

Very logically, when I do this, I get the simple jar (without all dependencies) and not the jar-with-dependenices.

Upvotes: 2

Views: 3283

Answers (2)

avi.elkharrat
avi.elkharrat

Reputation: 6800

Here's my vamp of the answer:

File organisation should be:

roles/fetch-my-awesome-jar/tasks/main.yml

And content:

---
- name: fetch my awesome jar
  maven_artifact:
    group_id: my.awesome.group.id
    artifact_id: my-awesom-artifact-id
    version: my.awesome.version.number
    classifier: jar-with-dependencies
    extension: jar
    repository_url: http://my-local-nexus:<port>/repository/my-awesome-repo/
    username: my-username
    password: my-password
    dest: my-awesome-target-directory

The version of maven_artifact I'm using has removed the jar-with-dependencies classifier.

Upvotes: 2

nwinkler
nwinkler

Reputation: 54467

You can do this with the following steps:

  • Make sure that your jar-with-dependencies is uploaded to Nexus with a specific classifier, e.g. full. For more info on the classifier, please check the Maven documentation.
  • Use the Ansible maven_artifact module's classifier attribute to point to your full artifact.

Upvotes: 3

Related Questions