[MNG-7804] Ability to order plugin executions using the priority xml element (#1147)

This commit is contained in:
Guillaume Nodet 2023-10-16 13:28:47 +02:00 committed by GitHub
parent bd608d8cc9
commit f2df54723b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 2 deletions

View File

@ -2634,7 +2634,7 @@
</field> </field>
<field xml.transient="true"> <field xml.transient="true">
<name>priority</name> <name>priority</name>
<version>4.0.0+</version> <version>4.0.0</version>
<type>int</type> <type>int</type>
<description> <description>
<![CDATA[ <![CDATA[
@ -2645,6 +2645,15 @@
]]> ]]>
</description> </description>
</field> </field>
<field>
<name>priority</name>
<version>4.1.0+</version>
<type>int</type>
<description>The priority of this execution compared to other executions which are bound to the same phase.
Executions derived from the default lifecycle have a negative priority by default so that they are executed
before any custom plugin executions.
</description>
</field>
<field> <field>
<name>goals</name> <name>goals</name>
<version>4.0.0+</version> <version>4.0.0+</version>

View File

@ -90,10 +90,16 @@ under the License.
<id>modello-site-docs</id> <id>modello-site-docs</id>
<goals> <goals>
<goal>xdoc</goal> <goal>xdoc</goal>
<goal>xsd</goal>
</goals> </goals>
<phase>pre-site</phase> <phase>pre-site</phase>
</execution> </execution>
<execution>
<id>modello-schema</id>
<goals>
<goal>xsd</goal>
</goals>
<phase>generate-resources</phase>
</execution>
<execution> <execution>
<id>model-v3</id> <id>model-v3</id>
<goals> <goals>

View File

@ -19,8 +19,12 @@
package org.apache.maven.model.v4; package org.apache.maven.model.v4;
import java.io.InputStream; import java.io.InputStream;
import java.util.Collections;
import org.apache.maven.api.model.Build;
import org.apache.maven.api.model.Model; import org.apache.maven.api.model.Model;
import org.apache.maven.api.model.Plugin;
import org.apache.maven.api.model.PluginExecution;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -59,4 +63,13 @@ class MavenModelVersionTest {
Model m = model.withPreserveModelVersion(true); Model m = model.withPreserveModelVersion(true);
assertEquals("4.1.0", new MavenModelVersion().getModelVersion(m)); assertEquals("4.1.0", new MavenModelVersion().getModelVersion(m));
} }
@Test
void testV4V4ModelPriority() {
Model m = model.withBuild(Build.newInstance()
.withPlugins(Collections.singleton(Plugin.newInstance()
.withExecutions(Collections.singleton(
PluginExecution.newInstance().withPriority(5))))));
assertEquals("4.1.0", new MavenModelVersion().getModelVersion(m));
}
} }