【发布时间】:2018-06-17 15:48:21
【问题描述】:
我们在几个 (10+) 项目中使用frontend-maven-plugin。 这些项目是结合我们自己的 CMS 构建的。这些项目在 pom 中使用特定的“父级”,例如:
<parent>
<groupId>nl.companyname</groupId>
<artifactId>companyname-corporate-pom</artifactId>
<version>2.0.13</version>
</parent>
在这个'corporate pom'中,我们有一些预定义的配置和'插件管理',例如:
<project.frontendmavenplugin.version>1.3</project.frontendmavenplugin.version>
<project.frontendmavenplugin.workingDirectory>./</project.frontendmavenplugin.workingDirectory>
<project.node.downloadRoot>http://nodejs.COMPANYURL.nl/dist/</project.node.downloadRoot>
<project.node.version>v6.9.1</project.node.version>
<project.yarn.version>v0.17.9</project.yarn.version>
<project.yarn.downloadRoot>http://yarnpkg.COMPANYURL.nl/</project.yarn.downloadRoot>
<project.npm.registryUrl>http://nexus.COMPANYURL.nl/content/groups/npm-all/</project.npm.registryUrl>
和
<build>
<pluginManagement>
<!-- Generic configuration for plugins used by (almost) all projects. -->
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>${project.frontendmavenplugin.version}</version>
<executions>
<execution>
<id>install node and yarn</id>
<goals>
<goal>install-node-and-yarn</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<workingDirectory>${project.frontendmavenplugin.workingDirectory}</workingDirectory>
<nodeVersion>${project.node.version}</nodeVersion>
<nodeDownloadRoot>${project.node.downloadRoot}</nodeDownloadRoot>
<yarnVersion>${project.yarn.version}</yarnVersion>
<yarnDownloadRoot>${project.yarn.downloadRoot}</yarnDownloadRoot>
</configuration>
</execution>
etc.
这样我们就不必复制/管理每个项目中的所有配置。 这很好用。
但是:我们现在也在创建越来越多的新应用程序(基于 Spring Boot),这些应用程序独立于我们的 CMS,我们不能使用这个“父 pom”,因为 Spring Boot 有它自己的(spring-boot-starter- parent)和我们的“corporate pom”还包含非常具体的插件/配置,这些插件/配置仅适用于我们的 CMS(我们不包括在这些 Spring Boot 项目中)。
所以我需要的是更“独立”的前端 maven-plugin 配置(可能在未来更多“平台”独立配置/插件)。据我所知,不可能有超过 1 个父母,那么还有其他选择吗? 我想创建一个新的“companyname-frontend-maven-plugin”,它都包含 PluginManagement 作为前端 Maven 插件的所有(可扩展)配置。但我不知道这是否可行,而且在 git / Jenkins 等中创建和维护它需要做很多工作。 我还有其他选择吗?
感谢大家的宝贵时间!
【问题讨论】:
-
@Tome 谢谢,看起来很有趣,但阅读答案stackoverflow.com/a/47954088/639033 - 似乎与此解决方案相符,我需要将大量与 Spring Boot 相关的内容复制到每个 Spring Boot 项目中。目标是:减少重复。我认为这不是最合适的吗?
-
在 Maven 拥有 mixins (issues.apache.org/jira/browse/MNG-5102) 之前,我不知道现有的减少重复的解决方案。
-
谢谢。查看问题活动,它似乎不再具有任何优先级。我投票/评论了。该线程提到了github.com/maoo/maven-tiles,这似乎很有趣,但看起来它不再维护(并且仍处于测试阶段)。
-
您可以通过 import 将 Spring Boot 依赖项导入dependencyManagement,然后使用它...您不需要使用 Spring Boot 父级...
标签: maven spring-boot maven-3 maven-plugin parent-pom