Reputation: 3597
I created a new Maven JavaFX program (I'm new to Java FX) in Netbeans the default POM tries to unpack dependencies to the /target/classes
directory.
This is annoying because I have some pretty big dependencies (ie eclipse-link).
I have tried using using copy-dependencies
instead and excluding the big dependencies but it's not find the classes.
Why did Netbeans build this POM, does Java FX need unpacked dependencies (for FXML, etc) ?
Unpacking C:\Users\mjmen\.m2\repository\example\automate\Automate-modbus\1.0-SNAPSHOT\Automate-modbus-1.0-SNAPSHOT.jar to C:\Users\mjmen\Documents\NetBeansProjects\Supervision\Automate\Automate-sys\target\classes with includes "" and excludes ""
Unpacking C:\Users\mjmen\.m2\repository\mysql\mysql-connector-java\5.1.40\mysql-connector-java-5.1.40.jar to C:\Users\mjmen\Documents\NetBeansProjects\Supervision\Automate\Automate-sys\target\classes with includes "" and excludes ""
Unpacking C:\Users\mjmen\.m2\repository\org\eclipse\persistence\javax.persistence\2.1.1\javax.persistence-2.1.1.jar to C:\Users\mjmen\Documents\NetBeansProjects\Supervision\Automate\Automate-sys\target\classes with includes "" and excludes ""
Unpacking C:\Users\mjmen\.m2\repository\org\glassfish\javax.json\1.0.4\javax.json-1.0.4.jar to C:\Users\mjmen\Documents\NetBeansProjects\Supervision\Automate\Automate-sys\target\classes with includes "" and excludes ""
Unpacking C:\Users\mjmen\.m2\repository\javax\validation\validation-api\1.1.0.Final\validation-api-1.1.0.Final.jar to C:\Users\mjmen\Documents\NetBeansProjects\Supervision\Automate\Automate-sys\target\classes with includes "" and excludes ""
Unpacking C:\Users\mjmen\.m2\repository\sotec\supervision\automate\Automate-model\1.0-SNAPSHOT\Automate-model-1.0-SNAPSHOT.jar to C:\Users\mjmen\Documents\NetBeansProjects\Supervision\Automate\Automate-sys\target\classes with includes "" and excludes ""
Unpacking C:\Users\mjmen\.m2\repository\org\eclipse\persistence\eclipselink\2.6.4\eclipselink-2.6.4.jar to C:\Users\mjmen\Documents\NetBeansProjects\Supervision\Automate\Automate-sys\target\classes with includes "" and excludes ""
Unpacking C:\Users\mjmen\.m2\repository\org\eclipse\persistence\commonj.sdo\2.1.1\commonj.sdo-2.1.1.jar to C:\Users\mjmen\Documents\NetBeansProjects\Supervision\Automate\Automate-sys\target\classes with includes "" and excludes ""
.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>Automate</artifactId>
<groupId>example.automate</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>example.automate</groupId>
<artifactId>Automate-sys</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Automate-sys</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<mainClass>example.automate.Application</mainClass>
</properties>
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.fxml</include>
<include>**/*.css</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>unpack-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<excludeScope>system</excludeScope>
<excludeGroupIds>junit,org.mockito,org.hamcrest</excludeGroupIds>
<outputDirectory>${project.build.directory}/classes</outputDirectory>
</configuration>
</execution>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/classes</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>unpack-dependencies</id>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${java.home}/../bin/javafxpackager</executable>
<arguments>
<argument>-createjar</argument>
<argument>-nocss2bin</argument>
<argument>-appclass</argument>
<argument>${mainClass}</argument>
<argument>-srcdir</argument>
<argument>${project.build.directory}/classes</argument>
<argument>-outdir</argument>
<argument>${project.build.directory}</argument>
<argument>-outfile</argument>
<argument>${project.build.finalName}.jar</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>default-cli</id>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${java.home}/bin/java</executable>
<commandlineArgs>${runfx.args}</commandlineArgs>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArguments>
<bootclasspath>${sun.boot.class.path}${path.separator}${java.home}/lib/jfxrt.jar</bootclasspath>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<additionalClasspathElements>
<additionalClasspathElement>${java.home}/lib/jfxrt.jar</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
</plugin>
<plugin>
<!-- Build an executable JAR -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>classes/lib/</classpathPrefix>
<mainClass>sotec.supervision.automate.Application</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>sotec.supervision.automate</groupId>
<artifactId>Automate-model</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>sotec.supervision.automate</groupId>
<artifactId>Automate-modbus</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
Upvotes: 3
Views: 908
Reputation: 21
In your pom.xml, find the code below:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>unpack-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<excludeScope>system</excludeScope>
<excludeGroupIds>junit,org.mockito,org.hamcrest</excludeGroupIds>
<outputDirectory>${project.build.directory}/classes</outputDirectory>
</configuration>
</execution>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/classes</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
Please find the element name <excludeGroupIds>
and just add the groupId name,which you will find under <dependencies>
.
groupId names should be comma(,) separated.
Upvotes: 2