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 :) . Is there any way to execute maven
plugins by using gradle
. Thanks in advance
问题:
回答1:
Java is required for Maven and for Gradle too.
You can use Maven Wrapper exactly like with Gradle.
Execute this command in project directory (this creates executable script like in gradle)
mvn -N io.takari:maven:wrapper
To invoke this project without maven installed use:
./mvnw GOAL
回答2:
Gradle is a build system. You can build anything with it, including native binaries.
And yes, you can call Maven Plugins from Gradle, as Maven Plugins are written in Java and Gradle is based on Groovy and thus on Java.
But both facts have nothing to do with each other.
You can of course also use Gradle (or any other build system including manually stuffing things together) to build a distributable that includes a Java runtime environment. But then Java is, as said, shipped with your result. You cannot run Java code without having Java around, besides porting the Java code to something else like C++ that compiles to a native binary.
Yes, you can also call Java code from native code if you do some glueing, but no, also this will not work without having Java around, because that's the way Java works.
回答3:
Both Maven and Gradle require java to be installed. See https://docs.gradle.org/current/userguide/installation.html