How to execute maven plugins from gradle without having maven and java installed

泄露秘密 提交于 2019-12-20 04:50:30

问题


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



来源:https://stackoverflow.com/questions/44911102/how-to-execute-maven-plugins-from-gradle-without-having-maven-and-java-installed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!