We have a corporate parent POM that defines how projects are built. We have also bought a product (Visual Rules) that requires a totally separate build with totally separate plugins.
So, the natural solution is to use a Maven profile for that. However, the Visual Rules plugins don't check whether they're executed for a POM or for a module. This means that simply activating the profile (-Pvisual-rules
in my case) will fail the build, since the plugins look for specific files, which don't exist in the parent project, only in the modules.
The profile in the corporate parent POM looks like this:
<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>
(If anyone has a better solution about how to skip the build only for the parent project, feel free to comment...)
So, activating on the command line doesn't work.
Next possibility: Activate by an existing file: The modules have the Visual Rules specific files in src/main/resources/
- and of course, the parent project doesn't have any Visual Rules files. This means I can activate the profile in the parent project using this:
<profiles>
<profile>
<id>visual-rules</id>
<activation>
<file>
<exists>src/main/resources</exists>
</file>
</activation>
</profile>
</profiles>
Using mvn help:active-profiles clean package
I now get the following output:
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!
But although the visual-rules
profile is shown as active, the plugins within the profile are not started - why?
Just to be sure, I also started the build using mvn help:active-profiles clean package -Pvisual-rules
, and here the plugins were started and caused the problem described above.
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
Perhaps I don't really understand Maven profile activation, but this seems pretty weird to me... Any help is really appreciated!