How can I package a binary in Maven so that other projects can depend on it at compile time?

StackOverflow https://stackoverflow.com/questions/23304676

  •  09-07-2023
  •  | 
  •  

Question

I want to build a maven artifact that contains some executable native binaries so that other maven projects can depend on this artifact and refer to those binaries at build time.

I've looked at the maven-assembler-plugin and it appears promising, but I'm not sure how to get it going end to end. If I tell it to package up my dir I'll still need a way to tell clients to depend on that artifact and have that cause the binaries to be pulled in and put in a well-defined location.

Some specifics might help. I want to put the various platform versions of the thrift compiler into an artifact. Then I want clients to depend on that artifact and use the maven-thrift-plugin to execute the binary thrift compiler appropriate to the platform to generate the java code that will then be built by the java compiler.

Was it helpful?

Solution

The maven-assembly-plugin should be sufficient to package your native binaries into an archive.

Clients can the use the unpack goal of the maven-dependency-plugin to unpack this archive into a given directory, e.g. the current target.

Then all you need is a Maven plugin that knows how to run your native binaries and to pick them up from the given directory.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top