如何在maven中的某个阶段后显式执行插件?

时间:2016-03-08 18:30:53

标签: java maven jar-signing

我使用javafx-maven插件创建了一个javafx webstart应用程序。我在使用javafx-maven插件签署jar文件时遇到了一些问题。我想要做的是,使用javafx-maven插件打包(jar)应用程序,然后使用maven-jarsigner-plugin对jar文件进行签名。 在打包应用程序后,如何执行maven-jarsigner-plugin来签署我的文件?

<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>

1 个答案:

答案 0 :(得分:0)

为了解决此问题,我移动了签名以验证阶段。

            <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>

然后我像这样调用maven:     mvn验证

或者验证您的默认目标

或者,您可以将javafx-maven插件移至“prepare-package”阶段:

    <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>