DraxDomax
DraxDomax

Reputation: 1068

Is it possible to package a portable maven in the project (and some general direction on how)?

My idea is to include some sort of Maven with the project, such that can be set up in a script like so:

  1. set up maven repo as a folder under the solution folder (using relative reference)
  2. set up anything else maven needs (don't know what, exactly)
  3. call /path/to/maven/mvn compile -f /path/to/oneAndOnly/pom.xml
  4. java /target/MySolutionClas

I am aware of: https://dzone.com/articles/embedding-maven but it gets confusing when he talks about configuring the portable maven into the pom.xml - wait, how is that pom.xml going to mean anything if maven is not configured yet? (PS: I mean no disrespect to the author. I probably got it all wrong)

Upvotes: 0

Views: 1318

Answers (2)

Joe
Joe

Reputation: 607

Maven Wrapper aims to do just that, similar to the gradle wrapper seen in many gradle projects.

Running the wrapper goal of the maven wrapper plugin will generate a mvnw script in your project that can be run in place of a globally installed mvn command.

It's part of the maven 3.7.0 release, and documented more fully here: https://maven.apache.org/plugins/maven-wrapper-plugin/index.html

See https://github.com/takari/maven-wrapper for maven < 3.7.0

Upvotes: 1

aballaci
aballaci

Reputation: 1093

One could include a shell script that would setup maven if it is not already present.

The same for building and packaging encapsulating the complexities of the setup to just runing a couple of scripts.

Upvotes: 1

Related Questions