如何在 Maven 中启动单个目标/执行 [英] how to start a single goal / execution in maven

查看:80
本文介绍了如何在 Maven 中启动单个目标/执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我正在调试 Android 应用程序的签名.如果我可以只执行这个插件,这会容易得多:

Currently I am debugging the signing of an Android app. And this would be a lot easier if I could just execute this one and only plugin:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-jarsigner-plugin</artifactId>
  <executions>
    <execution>
      <id>signing</id>
      <goals>
        <goal>sign</goal>
      </goals>
      <phase>package</phase>

但无论我尝试什么,我得到的都是:

But no matter what I try all I get is:

[ERROR] Could not find goal 'signing' in plugin org.apache.maven.plugins:maven-jarsigner-plugin:1.2 among available goals verify, sign, help -> [Help 1]
org.apache.maven.plugin.MojoNotFoundException: Could not find goal 'signing' in plugin org.apache.maven.plugins:maven-jarsigner-plugin:1.2 among available goals verify,
 sign, help

org.apache.maven.lifecycle.LifecyclePhaseNotFoundException: Unknown lifecycle phase "sign". You must specify a valid lifecycle phase or a goal in the format <plugin-pre
fix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources
, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-co
mpile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, p
ost-clean, pre-site, site, post-site, site-deploy.

或其他一些错误.

推荐答案

您可以使用以下命令只运行 sign 目标:

You can run just the sign goal with this command:

mvn jarsigner:sign

我配置的这个插件是这样的:

I have this plugin configured is my pom like this:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jarsigner-plugin</artifactId>
    <version>1.2</version>
    <executions>
        <execution>
            <id>signer</id>
            <goals>
                <goal>sign</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <archive>target/${project.artifactId}-${project.version}.jar</archive>
        <keystore>src/main/signer/.keystore</keystore>
        <alias>MyCert</alias>
        <storepass>password</storepass>
        <keypass>password</keypass>
    </configuration>
</plugin>

因为我有 指向目标目录中的工件,所以我必须先运行 mvn clean install,然后我就可以执行mvn jarsigner:sign 如果我想再次运行 maven-jarsigner-plugin 来对 jar 进行签名.(我通常不会只运行这个插件/目标,因为我一直在做一个完整的mvn clean install",但它确实有效.)

Because I have <archive> pointing to an artifact in my target directory I have to run a mvn clean install first, and from then on I can just execute mvn jarsigner:sign if I want to run the maven-jarsigner-plugin again to sign the jar. (I don't normally run only this plugin/goal as I just do a full "mvn clean install" all the time, but it does work.)

这篇关于如何在 Maven 中启动单个目标/执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆