maven多模块项目如何包含gradle个子项目?
How can a maven multi-module project include gradle sub-projects?
我们有一个 Maven 多模块项目,我们希望逐渐迁移到 gradle-项目。
对于初学者,我只想将几个子项目迁移到 gradle,但将它们作为子项目保留到父 maven 项目构建中。
有 supported/recommended 方法吗?
插件的指针,或任何如何最好地做到这一点的建议。
不太确定,对于此类任务是否有直接的解决方案。但是您可以看一下 gradle-maven-plugin,它允许 Maven 中的 运行 Gradle 任务。来自插件描述:
To use the plugin, simply declare the plugin and bind it to the maven
lifecycle phase of your choice:
<plugin>
<groupId>org.fortasoft</groupId>
<artifactId>gradle-maven-plugin</artifactId>
<version>1.0.8</version>
<configuration>
<tasks>
<!-- this would effectively call "gradle doSomething" -->
<task>doSomething</task>
</tasks>
</configuration>
<executions>
<execution>
<!-- You can bind this to any phase you like -->
<phase>compile</phase>
<goals>
<!-- goal must be "invoke" -->
<goal>invoke</goal>
</goals>
</execution>
</executions>
</plugin>
Now when you run maven, gradle will be invoked and execute the
"doSomething" task defined in build.gradle.
Obviously you can change the task(s) to suit your needs.
In this example, the gradle invocation will happen during the maven
"compile" phase, but this can be easily changed by changing the
element value.
遗憾的是,无法说明如何共享 Gradle 模块工件而不将其发布到某个本地存储库。
为了将构建的工件安装到您的本地 Maven 存储库,只需将 maven plugin for gradle 添加到您的 build.gradle
文件。然后,在@Stanislav 的 pom.xml 示例中使用 install
任务而不是 doSomething
。
将此添加到您要构建的 gradle 项目中,
uploadArchives {
repositories {
mavenLocal()
}
}
然后调用 gradle build publishToMavenLocal
这将构建 project/module 并将其推送到本地 maven 存储库 (.m2) 以及生成的 pom 文件。然后你可以使用它作为你以前的普通 maven 模块和 pom 文件。
阅读 https://proandroiddev.com/tip-work-with-third-party-projects-locally-with-gradle-961d6c9efb02 了解更多。
我们有一个 Maven 多模块项目,我们希望逐渐迁移到 gradle-项目。
对于初学者,我只想将几个子项目迁移到 gradle,但将它们作为子项目保留到父 maven 项目构建中。
有 supported/recommended 方法吗?
插件的指针,或任何如何最好地做到这一点的建议。
不太确定,对于此类任务是否有直接的解决方案。但是您可以看一下 gradle-maven-plugin,它允许 Maven 中的 运行 Gradle 任务。来自插件描述:
To use the plugin, simply declare the plugin and bind it to the maven lifecycle phase of your choice:
<plugin> <groupId>org.fortasoft</groupId> <artifactId>gradle-maven-plugin</artifactId> <version>1.0.8</version> <configuration> <tasks> <!-- this would effectively call "gradle doSomething" --> <task>doSomething</task> </tasks> </configuration> <executions> <execution> <!-- You can bind this to any phase you like --> <phase>compile</phase> <goals> <!-- goal must be "invoke" --> <goal>invoke</goal> </goals> </execution> </executions> </plugin>
Now when you run maven, gradle will be invoked and execute the "doSomething" task defined in build.gradle.
Obviously you can change the task(s) to suit your needs.
In this example, the gradle invocation will happen during the maven "compile" phase, but this can be easily changed by changing the element value.
遗憾的是,无法说明如何共享 Gradle 模块工件而不将其发布到某个本地存储库。
为了将构建的工件安装到您的本地 Maven 存储库,只需将 maven plugin for gradle 添加到您的 build.gradle
文件。然后,在@Stanislav 的 pom.xml 示例中使用 install
任务而不是 doSomething
。
将此添加到您要构建的 gradle 项目中,
uploadArchives {
repositories {
mavenLocal()
}
}
然后调用 gradle build publishToMavenLocal
这将构建 project/module 并将其推送到本地 maven 存储库 (.m2) 以及生成的 pom 文件。然后你可以使用它作为你以前的普通 maven 模块和 pom 文件。
阅读 https://proandroiddev.com/tip-work-with-third-party-projects-locally-with-gradle-961d6c9efb02 了解更多。