【发布时间】:2019-03-04 19:37:26
【问题描述】:
我们有一个公司父 POM,它定义了项目的构建方式。我们还购买了一个产品(视觉规则),它需要完全独立的构建和完全独立的插件。
因此,自然的解决方案是为此使用 Maven 配置文件。但是,Visual Rules 插件不会检查它们是针对 POM 还是针对模块执行的。这意味着仅激活配置文件(在我的情况下为-Pvisual-rules)将导致构建失败,因为插件会查找特定文件,这些文件在父项目中不存在,仅在模块中。
公司父 POM 中的配置文件如下所示:
<profile>
<id>visual-rules</id>
<build>
<plugins>
<plugin>
<groupId>de.visualrules.builder</groupId>
<artifactId>visualrules-validation-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>validate</goal>
</goals>
</execution>
</executions>
</plugin>
...and other Visual Rules plugins
</plugins>
</build>
</profile>
(如果有人对如何跳过仅针对父项目的构建有更好的解决方案,请随时发表评论...)
所以,在命令行上激活是行不通的。
下一个可能性:通过现有文件激活:模块在src/main/resources/ 中具有特定于视觉规则的文件 - 当然,父项目没有任何视觉规则文件。这意味着我可以使用以下方法激活父项目中的配置文件:
<profiles>
<profile>
<id>visual-rules</id>
<activation>
<file>
<exists>src/main/resources</exists>
</file>
</activation>
</profile>
</profiles>
使用 mvn help:active-profiles clean package 我现在得到以下输出:
10:10:31.788 [INFO] --- maven-help-plugin:3.1.0:active-profiles (default-cli) @ global-regeln ---
10:10:32.080 [INFO]
Active Profiles for Project 'foobar:global-regeln:pom:1.21.0-SNAPSHOT':
The following profiles are active:
- default (source: external)
- local (source: foobar:corporate-parent:1.52.0-SNAPSHOT)
Active Profiles for Project 'foobar:global-regeln-edossier-schlagwort-zu-doktyp:jar:1.21.0-SNAPSHOT':
The following profiles are active:
- default (source: external)
- visual-rules (source: foobar:global-regeln:1.21.0-SNAPSHOT)
- local (source: foobar:corporate-parent:1.52.0-SNAPSHOT)
Active Profiles for Project 'foobar:global-regeln-zahlungspflichtdatum-fuer-gebuehrtyp:jar:1.21.0-SNAPSHOT':
The following profiles are active:
- default (source: external)
- visual-rules (source: foobar:global-regeln:1.21.0-SNAPSHOT)
- local (source: foobar:corporate-parent:1.52.0-SNAPSHOT)
Active Profiles for Project 'foobar:global-regeln-fristberechnung:jar:1.21.0-SNAPSHOT':
The following profiles are active:
- default (source: external)
- visual-rules (source: foobar:global-regeln:1.21.0-SNAPSHOT)
- local (source: foobar:corporate-parent:1.52.0-SNAPSHOT)
Active Profiles for Project 'foobar:global-regeln-terminberechnung:jar:1.21.0-SNAPSHOT':
The following profiles are active:
- default (source: external)
- visual-rules (source: foobar:global-regeln:1.21.0-SNAPSHOT)
- local (source: foobar:corporate-parent:1.52.0-SNAPSHOT)
... Rest of the build, no Visual Rules plugin output!
但尽管visual-rules 配置文件显示为活动状态,但配置文件中的插件并未启动 - 为什么?
为了确定,我也使用mvn help:active-profiles clean package -Pvisual-rules 启动了构建,这里的插件启动并导致了上述问题。
10:18:50.608 [INFO] ------------------------------------------------------------------------
10:18:50.608 [INFO] Reactor Summary:
10:18:50.608 [INFO]
10:18:50.608 [INFO] Globale Regeln ..................................... FAILURE [ 3.414 s]
10:18:50.608 [INFO] eDossierregeln-Schlagworte zu Dokumententypen ...... SKIPPED
10:18:50.608 [INFO] Globale Zahlungspflichtdatumberechnung-Regel ....... SKIPPED
10:18:50.608 [INFO] Globale Fristberechnung ............................ SKIPPED
10:18:50.608 [INFO] Globale Terminberechnung ........................... SKIPPED
10:18:50.608 [INFO] ------------------------------------------------------------------------
10:18:50.608 [INFO] BUILD FAILURE
10:18:50.608 [INFO] ------------------------------------------------------------------------
10:18:50.608 [INFO] Total time: 5.515 s
10:18:50.608 [INFO] Finished at: 2019-02-28T10:18:50+01:00
10:18:50.801 [INFO] Final Memory: 72M/793M
10:18:50.801 [INFO] ------------------------------------------------------------------------
10:18:50.803 [ERROR] Failed to execute goal de.visualrules.builder:visualrules-validation-maven-plugin:6.4.10:validate (default) on project global-regeln: RuleModel 'global-regeln-edossier-schlagwort-zu-doktyp' is not valid: Referenziertes Element "allgemein-regeln-fachdaten" nicht gefunden
也许我不太了解 Maven 配置文件激活,但这对我来说似乎很奇怪......非常感谢任何帮助!
【问题讨论】:
-
mvn clean package -P visual-rules你少了一个空格。尝试添加的那个,看看是否有效 -
谢谢,但结果是一样的。
-
RuleModel Referenced element "general-rules-data" not found .Looks like maven is trying to find general-rules-data
-
是的,这就是视觉规则在做它的事情......但是,视觉规则插件不应该为父项目执行。
-
所以基本上你想跳过其中包含视觉规则文件的模块(资源)?如有错误请指正。
标签: maven maven-profiles visualrules