Maven: Binden Sie die Plugin-Ausführung an die Ausführung eines anderen Plugins, nicht an eine Lebenszyklusphase

Hinweis zur akzeptierten Antwort: Ich habe die Antwort aufgrund starker Indizien angenommen. Dies ist jedoch ein Indiz dafür, nehmen Sie es mit einem Körnchen Salz.

Wie kann ich ein Plugin auslösen lassen, wenn der Benutzer ein Plugin-Ziel ausführt und keine Lebenszyklusphase? (Diesewurde gefragt vorher, aber die Antwort war, eine Lebenszyklusphase zu verwenden.)

Ein typisches Beispiel: Ich braucherelease:branch anrufenregex-plugin einen Zweig mit der aktuellen Version als Namen zu erzeugen,minus dem -SNAPSHOT-Suffix. Dies ist, was ich habe, was erfordert, dass der Entwickler ein Profil aktiviert und das aufruftverify Phase. Ich muss den Entwickler einfach aufrufenrelease:branch, was wiederum dazu führen sollteregex-plugin zu rennen. In einer Art Ehe mit Gitflow.

<profile>
    <id>Release Branch</id>
    <build>
        <plugins>
            <!-- On validate, compute the current version without -SNAPSHOT. -->
            <!-- Put the result in a property. -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>1.7</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>regex-property</goal>
                        </goals>
                        <configuration>
                            <value>${project.version}</value>
                            <regex>^(.*)-SNAPSHOT
<profile>
    <id>Release Branch</id>
    <build>
        <plugins>
            <!-- On validate, compute the current version without -SNAPSHOT. -->
            <!-- Put the result in a property. -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>1.7</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>regex-property</goal>
                        </goals>
                        <configuration>
                            <value>${project.version}</value>
                            <regex>^(.*)-SNAPSHOT$</regex>
                            <replacement>$1</replacement>
                            <name>project.unqualifiedVersion</name>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- Also on validate, run the branch plugin, and use -->
            <!-- the non-SNAPSHOT version thus computed in the branch name. -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>2.3.2</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>branch</goal>
                        </goals>
                        <configuration>
                            <branchName>release/${project.unqualifiedVersion}</branchName>
                            <updateWorkingCopyVersions>true</updateWorkingCopyVersions>
                            <updateBranchVersions>false</updateBranchVersions>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</profile>
lt;/regex> <replacement>$1</replacement> <name>project.unqualifiedVersion</name> </configuration> </execution> </executions> </plugin> <!-- Also on validate, run the branch plugin, and use --> <!-- the non-SNAPSHOT version thus computed in the branch name. --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-release-plugin</artifactId> <version>2.3.2</version> <executions> <execution> <phase>validate</phase> <goals> <goal>branch</goal> </goals> <configuration> <branchName>release/${project.unqualifiedVersion}</branchName> <updateWorkingCopyVersions>true</updateWorkingCopyVersions> <updateBranchVersions>false</updateBranchVersions> </configuration> </execution> </executions> </plugin> </plugins> </build> </profile>

Die Absicht ist fürrelease:branch Verschieben der aktuellen Snapshot-Version (z. B.1.0.5-SNAPSHOT) in einen neuen Zweig, der nach der Version aber ohne das Überflüssige benannt werden soll-SNAPSHOT Suffix (1.0.5). Der aktuelle Zweig sollte dann eine neue Snapshot-Version aufnehmen (1.1.0-SNAPSHOTnicht1.0.6-SNAPSHOT, weil wir loslassen wollen1.0.x um Platz für Hotfixes zu haben, reservieren wir es für den Zweig) (Ich habe noch nicht die automatische Berechnung der nächsten Snapshot-Version herausgefunden, also, wenn Sie die Maven-Konfiguration oben mit ausführenvalidatemüssen Sie es an einer Eingabeaufforderung eingeben).

Antworten auf die Frage(2)

Ihre Antwort auf die Frage