首页 > 解决方案 > 在 IntelliJ 运行配置中指定 maven 插件执行 ID

问题描述

所以我在我的 pom 中定义了这个插件:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>3.2.1</version>
    <executions>

      <!-- Executed when building for deployment. Shade plugin relocated lib classes to avoid multi-plugin conflicts. -->
      <execution>
        <id>deployment</id>
        <phase>package</phase>
        <goals>
          <goal>shade</goal>
        </goals>
        <configuration>
          <createDependencyReducedPom>false</createDependencyReducedPom>
          <relocations>
            <relocation>
              ...
            </relocation>
          </relocations>
          <finalName>${project.name}-${project.version}</finalName>
          <outputDirectory>deployment</outputDirectory>
        </configuration>
      </execution>

      <!-- Executed when building for testing. Shade plugin does not relocate to enable HotSwapping. -->
      <execution>
        <id>testing</id>
        <phase>package</phase>
        <goals>
          <goal>shade</goal>
        </goals>
        <configuration>
          <createDependencyReducedPom>false</createDependencyReducedPom>
          <finalName>${project.name}-${project.version}</finalName>
          <outputDirectory>test</outputDirectory>
        </configuration>
      </execution>

    </executions>
  </plugin>

有两种不同的执行方式——一种用于部署,一种用于测试。

如何在 IntelliJ 中创建运行配置,允许我指定要运行的执行。该对话框在任何地方都没有提供该字段,我无法弄清楚如何在 VM 选项字段中执行此操作,因为我不知道如何从命令行设置该参数(如果这甚至是正确的方法) .

我想避免在 pom 中使用配置文件,因为 pom 很长,唯一的区别是这个插件中的重定位步骤。使用配置文件我会有很多不必要的重复......

有任何想法吗?

标签: mavenintellij-idea

解决方案


推荐阅读