简体   繁体   English

如何在 pom.xml 之前在 maven 中预加载一些依赖项/插件?

[英]How do I preload some dependencies/plugins in maven before pom.xml?

we are creating a lot of short lived test projects at my work.在我的工作中,我们正在创建许多短暂的测试项目。 Dozens of them each day.每天有几十个。 we have about 10 dependencies that we use internally at our workplace - these are all custom plugins.我们在工作场所内部使用了大约 10 个依赖项——这些都是自定义插件。 I want to get people to not have to mess with their pom.xml for the official dependencies just to get started.我想让人们不必为了官方依赖而乱搞他们的 pom.xml 只是为了开始。 so either create a bash script that has all the dependencies on cli...or try to inherit one common xml from all these pom.xml.因此,要么创建一个 bash 脚本,该脚本具有对 cli 的所有依赖性……要么尝试从所有这些 pom.xml 继承一个通用的 xml。

I looked at other answers (like Reusing ant-snippets in multi-module maven build ), but i dont think these work.我查看了其他答案(比如Reusing ant-snippets in multi-module maven build ),但我认为这些都行不通。 im also looking to see if i can use multimodule builds, but then it is even more boilerplate.我也想看看我是否可以使用多模块构建,但它更像样板。

i was also looking at maven-dependency-plugin, but I think it only copies/downloads dependencies...u still need to add them to pom.xml.我也在看 maven-dependency-plugin,但我认为它只复制/下载依赖项......你仍然需要将它们添加到 pom.xml。

I also saw some similar questions in gradle area ( Add dynamic dependencies via command line ), but unsure if it works in maven.我在gradle区也看到了类似的问题( Add dynamic dependencies via command line ),但不确定在maven区是否有效。

so my question stands - how do I add a large number of dependencies to a maven project, WITHOUT messing with the pom.xml file?所以我的问题是——如何在不弄乱 pom.xml 文件的情况下向 maven 项目添加大量依赖项? Any help will be much appreciated.任何帮助都感激不尽。

You can create a parent pom dependency, include all needed dependencies in it and then use it as parent dependency for your small projects, like this:您可以创建一个父 pom 依赖项,在其中包含所有需要的依赖项,然后将其用作您的小项目的父依赖项,如下所示:

<parent>
  <groupId>com.example</groupId>
  <artifactId>some-parent-pom</artifactId>
  <version>DEV-SNAPSHOT</version>
</parent>

Do not forget to run mvn clean install to install the parent POM to your local repository.不要忘记运行mvn clean install将父 POM 安装到本地存储库。

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

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