How to execute maven plugins by using gradle


(Kasun Siyambalapitiya) #1

Hi all,
I need to execute a maven plugin on a system that does not have both maven and java installed and installing both of them on the system is not an option. While searching for the ways, I found out that by using gradle we can build executable binaries that does not even require gradle to get executed, which perfectly fits my situation :slight_smile: . Is there any way to execute maven plugins by using gradle. Thanks in advance

(uklance) #2

See embedding maven

(Kasun Siyambalapitiya) #3

Just read the article, but it is on how to execute maven goals programatically which has the requirement of both java and maven being installed on the system. What I need is a way to run maven plugins in a environment where both maven and java does not exists. For example, by executing a binary built from gradle ( that can be run without gradle being installed) which run specified maven plugings inside it. Is there a way to reach that?

(uklance) #4

It’s probably best to split this into the individual pieces

  1. You want to build an application
  2. Which executes a maven plugin without installing maven
  3. Which runs without a pre-installed jre
  1. Can be solved using gradle (or maven or ant)
  2. Can be solved with maven embedder
    I’m not 100% sure how to solve 3, perhaps you could pack a jre inside your application zip and have a batch file (windows) or shell script (xnix) which fires java from the packed jre

(Kasun Siyambalapitiya) #5

Thank you Lance for your valuable time. Could you please be kind enough to inform me if you find out a way to solve the third part of the question ( Which runs without a pre-installed jre)

(uklance) #6

As I said, you’ll probably need to pack the JRE inside your application and have a batch file / shell script which invokes java from the embedded JRE. Do you need to support multiple operating systems? If so you’ll probably need multiple versions (flavours) of your app since each OS has its own version of the JRE.

There’s likely licensing issues embedding the Oracle JRE, you might find the OpenJDK JRE has a more permissive license.

(uklance) #7

Another thing to consider is docker but this would need to be pre-installed on the machine, I’m guessing that’s a no-no too