Maven publish & consume the third-party runtime jars while building our own custom.jar

Viewed 184

I've a maven project for which we are loading internal abc-1.0.jar using S3 repository and whatever runtime dependencies requires for abc-1.0.jar to be a part of my project, we load in the form of .zip and extract it as

Interesting Note: When I say third-party runtime jars as a zip, there are some jars which might not have used while building abc-1.0.jar

project.zip
 -- lib
    -- abc-1.0.jar
    -- runtime_jars_for_abc.jar
    -- runtime_jars_for_project.jar

There is possibility that when deliver abc-1.0.jar jar to my-project the runtime zip might have one set of jars but for abc-2.0.jar I need to ship another set of jars.

I've solved the problem by shipping it in the form of zip and extracting it while creating the project.zip

But, is it possible that I can ship or announce those runtime.jar along with my abc-1.0.jar or abc-2.0.jar so that my-project/pom.xml can consume that announcement on the fly from either mavenCentral() or my internal maven-repo?

EDIT

I found maven changes plugin here https://maven.apache.org/plugins/maven-changes-plugin/. this is mostly going to publish the new changes but how can I dynamically consume the new changes for each new build? any thoughts?

*What I was thinking is to push the abc-1.0.jar along with it's abc-1.0-pom.xml file which should consist of some custom scope or logical grouping of dependent jar, so that I can specify those custom scopes or groups in consumption project to uniquely copy those jars using maven copy dependencies plugin https://maven.apache.org/plugins/maven-dependency-plugin/examples/copying-project-dependencies.html but unfortunately maven doesn't support custom scopes

1 Answers

In your project-b, prefix your version by -SNAPSHOT, like this

<groupId>my.groupid</groupId>
<artifactId>my.artifactid</artifactId>
<version>0.0.1-SNAPSHOT</version>

So, every time when you do update in your project-b, your project-a will pick the latest snapshot from maven repository

As you can see, maven organize snapshot by adding a timestamp to deliver the latest publish

enter image description here

Note that your project-a must never go to acceptance, pprod or production environment with snapshot dependencies !

Related