sortpom
sortpom copied to clipboard
Sort plugins by executionId
So that the gpg plugin can be sorted after javadoc and source plugin
Sorted plugins should keep this order ' <sortPlugins>executionId,groupId,artifactId</sortPlugins>'
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<minmemory>128m</minmemory>
<maxmemory>512</maxmemory>
<breakiterator>true</breakiterator>
<quiet>true</quiet>
<source>${compileSource}</source>
<verbose>false</verbose>
<linksource>true</linksource>
<links>
<!-- JSE -->
<link>http://docs.oracle.com/javase/8/docs/api/</link>
</links>
</configuration>
<executions>
<execution>
<id>1_attach-javadoc</id>
<goals>
<goal>jar</goal>
</goals>
<phase>verify</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<id>2_attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
<phase>verify</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>3_sign-artifacts</id>
<goals>
<goal>sign</goal>
</goals>
<phase>verify</phase>
</execution>
</executions>
</plugin>
Branch issue-100-Sort_plugins_by_executionId created!
It works
YMMV, but I usually sort after the phase and my ids don't have numbers (I have actually never seens executionIds starting with numbers).
Just my 2 cents.
I am not sure myself of this change. There must be a better way somehow. Firstly, the ids take too much space and secondly, the default behaviour does not feel right
@famod I wasn't using numbers in executions until #81 allowed me to nail down the order. Without numbers someone might rename the execution and throw the order
Should we rather sort by execution phase (optionally)? That would need to consider some edge cases though, because one plugin may have multiple executions bound to different phases, so it is not always apparent which plugin should appear first in the pom.
The problem with phases is that the plugin does not analyze the content of the POM. It is basically an xml sorter with custom xml ordering. So the plugin does not know about a default phase of a plugin unless you explicitly state each phase in the pom file. I agree that sorting by phase would be excellent, but that is a job for another plugin.