一次解包maven依赖项以加速maven构建



在我的项目中有相当多的依赖项。是否有可能修改POM文件,将所有依赖项解压缩到一个中心位置,并在构建时引用该位置。这样,我就不必为每个单独的构建解压到目标文件夹。

我将有一个"发布"配置文件,它将正常执行maven解包。我只是想加快开发构建。

注释掉clean goal in action run in nbactions.xml

<action>
        <actionName>run</actionName>
        <goals>
            <!--<goal>clean</goal>-->
            <goal>package</goal>
            <goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
        </goals>
        <properties>
            <runfx.args>-jar "${project.build.directory}/${project.build.finalName}.jar"</runfx.args>
        </properties>
    </action>

您必须使用dependency:unpack-dependencies goal。在配置中使用outputDirectory选项。

例如

:

<project>
  [...]
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>2.10</version>
        <executions>
          <execution>
            <id>unpack-dependencies</id>
            <phase>package</phase>
            <goals>
              <goal>unpack-dependencies</goal>
            </goals>
            <configuration>
              <includes>**/*.class</includes>
              <excludes>**/*.properties</excludes>
              <outputDirectory>${project.build.directory}/alternateLocation</outputDirectory>
              <overWriteReleases>false</overWriteReleases>
              <overWriteSnapshots>true</overWriteSnapshots>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  [...]
</project>

编辑:Netbeans用于JavaFX的库存POM包括maven codehaus解包。删除它并更改动作以不使用插件,并且在每次构建时不再解包。

最新更新