简体   繁体   中英

How to execute a plugin explicitly after a certain phase in maven?

I'm using javafx-maven plugin to create a javafx webstart application. I had some issues signing the jar files with the javafx-maven plugin. what I want to do is, package(jar) the application with javafx-maven plugin and then sign the jar files using maven-jarsigner-plugin . How do i execute the maven-jarsigner-plugin to sign my files after the application is packaged?

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jarsigner-plugin</artifactId>
                <version>1.4</version>
                <executions>
                    <execution>

                        <goals>
                            <goal>sign</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <archiveDirectory>target/jfx/app/</archiveDirectory>
                    <includes>
                        <include>**/*.jar</include>
                    </includes>
                    <keystore>path tp keystore</keystore>
                    <alias>alias</alias>
                    <storepass>password</storepass>
                    <keypass>password</keypass>
                </configuration>
            </plugin>  

            <plugin>
                <groupId>com.zenjava</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>8.3.0</version>
                <configuration>

                    <bundler>jnlp</bundler>
                    <mainClass>com.myorg.myapp.launcher.myappLauncher</mainClass>
                    <bundleArguments>
                        <jnlp.allPermisions>true</jnlp.allPermisions>
                        <jnlp.includeDT>true</jnlp.includeDT>
                        <jnlp.outfile>myapp</jnlp.outfile>
                    </bundleArguments>
                </configuration>
            </plugin>

To workaround this I moved signing to verify phase.

            <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jarsigner-plugin</artifactId>
            <version>1.4</version>
            <executions>
                <execution>
                    <id>signing</id>
                    <goals>
                        <goal>sign</goal>
                        <goal>verify</goal>
                    </goals>
                    <phase>verify</phase>
                    <inherited>true</inherited>
                    <configuration>
                        ...
                    </configuration>
                </execution>
            </executions>
        </plugin>

Then I invoke maven like this: mvn verify

Or make verify your default goal

Alternatively you can move javafx-maven plugin to the "prepare-package" phase:

    <plugin>
        <groupId>com.zenjava</groupId>
        <artifactId>javafx-maven-plugin</artifactId>
        <version>8.1.0</version>
        <configuration>
            <bundler>jnlp</bundler>
            <mainClass>com.myorg.myapp.launcher.myappLauncher</mainClass>
            <bundleArguments>
                <jnlp.allPermisions>true</jnlp.allPermisions>
                <jnlp.includeDT>true</jnlp.includeDT>
                <jnlp.outfile>myapp</jnlp.outfile>
            </bundleArguments>
        </configuration>
        <executions>
            <execution>
                <id>create-jfxjar</id>
                <phase>prepare-package</phase>
                <goals>
                    <goal>build-jar</goal>
                </goals>
            </execution>
        </executions>
    </plugin>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM