2

I have quite a few dependencies in my project. Is it possible to modify the POM file to unpack all the dependencies to a central location and reference that location for the build. This way I don't have to unpack into the target folder for every single build.

I will have a 'release' profile that will execute the maven unpacking normally however. I'm just looking to speed up development builds.

Aerith
  • 337
  • 3
  • 11
  • Why would you need to unpack your dependencies to build your project? – Erwin Bolwidt Aug 12 '16 at 04:05
  • You know that by running maven all dependencies are already cached on the local hard drive in $HOME/.m2/repository ...Why do you need to unpack dependencies? Does not make sense? Can you please elaborate more in detail... – khmarbaise Aug 12 '16 at 10:23
  • I am using the stock POM from a netbeans JavaFX project. If I remove the unpack dependencies plugin - then I get build success, but runtime error. Caused by: java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory – Aerith Aug 12 '16 at 19:03
  • Thank you! I used the default POM created by netbeans JavaFX project. I removed the plugins for unpacking, and changed the actions and build went from 35 seconds to 5 seconds. No more unpacking. – Aerith Aug 12 '16 at 23:37
  • If someone has the same problem, maybe my answer here https://stackoverflow.com/a/52739640/3519572 could help...? – tomorrow Oct 10 '18 at 13:25

3 Answers3

1

just comment out 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>
Majo
  • 96
  • 1
  • 4
0

You will have to use dependency:unpack-dependencies goal. Use the outputDirectory option in the configuration.

For eg:

<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>
RITZ XAVI
  • 3,633
  • 1
  • 25
  • 35
  • Still getting: --- maven-dependency-plugin:2.10:unpack-dependencies (unpack-dependencies) @ MyProject --- Unpacking C:\Users\admin\.m2\repository\org\scream3r\jssc\2.8.0\jssc-2.8.0.jar to D:\Dev\MyProject\target\..\alternateLocation with includes "**/*.class" and excludes "**/*.properties" -- For every dependency included in my project – Aerith Aug 12 '16 at 18:43
0

Edited: Netbeans stock POM for JavaFX includes maven codehaus unpacking. Remove that and change the actions to not utilize the plugin and no more unpacking for every build.

Aerith
  • 337
  • 3
  • 11