简体   繁体   English

用Maven包装Gradle项目

[英]wrapping a gradle project with maven

I want to wrap an existing gradle project (build.gradle) to also have a pom.xml file such that the following gradle tasks will be invoked when we invoke maven: 我想包装一个现有的gradle项目(build.gradle),使其也具有pom.xml文件,以便在调用maven时将调用以下gradle任务:

  • 'maven install' -> invoke 'gradle build' 'maven install'->调用'gradle build'
  • 'maven clean' -> invoke 'gradle clean' 'maven clean'->调用'gradle clean'
  • 'maven clean install -DskipTests' -> invoke 'gradle clean build -x tests' 'maven clean install -DskipTests'->调用'gradle clean build -x tests'

So my question is: Is there a way to create a pom.xml that I can customize (and override) what 'install', 'clean' do? 所以我的问题是:有没有一种方法可以创建pom.xml,我可以自定义(并覆盖)“ install”,“ clean”的作用? Additionally, Can I have access to the flags that were passed to maven so that I can rewrite them as the flags I want to pass to gradle? 此外,我是否可以访问传递给Maven的标志,以便可以将它们重写为要传递给Gradle的标志?

The ultimate goal is to include this project inside a larger multi project where all projects are maven based and we can automate everything based on maven commands. 最终目标是将该项目包含在一个较大的多项目中,该项目中的所有项目均基于Maven,我们可以根据Maven命令自动执行所有操作。

If the build.gradle is not to complicated, I would just rewrite it as pom. 如果build.gradle不太复杂,我将其重写为pom。 If you do not want to do that, one could have a closer look at the commands you mentioned: 如果您不想这样做,可以仔细看看您提到的命令:

  • AFAIK, mvn clean and gradle clean do the same, so no need to worry. AFAIK, gradle clean mvn cleangradle clean也是如此,因此无需担心。

  • calling gradle build when starting mvn install can probably be achieved by using the gradle-maven-plugin ( https://github.com/LendingClub/gradle-maven-plugin ). 开始mvn install时调用gradle build可能可以通过使用gradle-maven-plugin( https://github.com/LendingClub/gradle-maven-plugin )来实现。

  • Sending the skipTests parameter to gradle can probably also achieved through the gradle-maven-plugin. skipTests参数发送到gradle可能也可以通过gradle-maven-plugin实现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM