We have a third party jar sitting in internal maven artifactory. We have to wrap it as docker image and persist in a docker registry. We have CI process in place to build a maven project and wrap it with docker and deploy it. But in this case, there is no additional java build process required as its a runnable 3rd party jar.
I know as part of CI step, we can do this and then continue to docker build
mvn dependency:copy -Dartifact=<org:artifact:version> -DoutputDirectory=<Path>/target
But this needs a custom CI step just to accommodate this. Qn: Is there anyway that we can avoid this special CI step, probably by using a dummy wrapper pom.xml to download the thirdparty jar and make it as the build output.
Not married to maven, it can be gradle too.
2
Answers
If I understand the issue correctly, you want to wrap a 3-rd party jar in its own container within a Maven build.
So it would not be a completely dummy
pom.xml
, but a small Maven project that:maven-assembly-plugin
with an assembly descriptor insrc/assembly
to put that jar intotarget
for further usagejib-maven-plugin
.That project could be both an independent one, or you can include the same into your existing project if you want.
The "copy" part seems to be trivial: you just need to add corresponding
maven-dependency-plugin
configuration topom.xml
and assign proper lifecycle phase tocopy
goal, for example, the configuration below:causes maven to copy required jar into target directory during build lifecycle.
As regards to "mark third party jar as the build output" part, there are a couple of options:
I. basically, you may
unpack
third party jar into classes directory and askmaven-jar-plugin
do not create manifest:II. another option is to trick maven build via disabling
maven-jar-plugin
and modifying project’s state usinggmavenplus-plugin
: