How Maven Order Modules in a Reactor

Questions like this haven were asked over and over, but for some reason they simply focused on addictions. Thus, according to the maven documentation, the assembly order is defined as follows.

  • project dependency on another module in the assembly
  • plugin declaration, where the plugin is another module in the assembly
  • plugin dependency on another module in the assembly
  • declaring an assembly extension on another module in the assembly
  • the order declared in the element <modules>(unless another rule applies)

The first rule ends, for example. if module A depends on module B, the latter is created first.

The fourth rule (last) is also quite clear. If the previous three rules do not apply, we will consider the order in the module section.

The other two rules are not so clear to me. English is not my native language, but I wonder if rule two contains a typo of some kind.

I am looking for a simple example that explains these two rules in detail.

+4
source share
1 answer

Skip through them in turn.

  • project dependency on another module in the assembly

This means that if module A has a dependency on module B, then B must be built up to A. This handles the case when in the POM of group A you must:

<dependencies>
  <dependency>
    <groupId>${project.groupId}<groupId>
    <artifactId>B<artifactId>
    <version>${project.version}</version>
  </dependency>
</dependencies>
  • plugin declaration, where the plugin is another module in the assembly

, A Maven, B, B A. , POM A :

<build>
  <plugins>
    <plugin>
      <groupId>${project.groupId}<groupId>
      <artifactId>B<artifactId>
      <version>${project.version}</version>
    </plugin>
  </plugins>
</build>

, A Maven B, B A. , POM A :

<build>
  <plugins>
    <plugin>
      <groupId>some.plugin.groupId<groupId>
      <artifactId>some.plugin.artifactId<artifactId>
      <version>some.version</version>
      <dependencies>
        <dependency>
          <groupId>${project.groupId}<groupId>
          <artifactId>B<artifactId>
          <version>${project.version}</version>
        </dependency>
      </dependencies>
    </plugin>
  </plugins>
</build>

, , , , , .

, A B, B A. POM A :

<build>
  <extensions>
    <extension>
      <groupId>${project.groupId}</groupId>
      <artifactId>B</artifactId>
      <version>${project.version}</version>
    </extension>
  </extensions>
</build>
  • , <modules> ( )

, - <modules>, POM :

<modules>
  <module>A</module>
  <module>B</module>
</modules>

A B, .

+3

Source: https://habr.com/ru/post/1657025/


All Articles