sortpom icon indicating copy to clipboard operation
sortpom copied to clipboard

Sort plugins by executionId

Open Ekryd opened this issue 4 years ago • 7 comments
trafficstars

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>

Ekryd avatar Mar 28 '21 14:03 Ekryd

It works

delanym avatar Aug 06 '21 07:08 delanym

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.

famod avatar Jan 17 '22 14:01 famod

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

Ekryd avatar Jan 17 '22 17:01 Ekryd

@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

delanym avatar Jan 18 '22 05:01 delanym

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.

kwin avatar Mar 02 '22 07:03 kwin

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.

Ekryd avatar Mar 07 '22 08:03 Ekryd