2016-10-20 3 views
2

auspacken von Abhängigkeiten zu verhindern, habe ich ein neues Maven JavaFX-Programm (ich Java FX bin neu) in Netbeans die Standard-POM versuchen Abhängigkeiten zum /target/classes Verzeichnis zu entpacken.Wie in Java FX Programm

Das ist ärgerlich, weil ich einige ziemlich große Abhängigkeiten (zB Eclipse-Link) haben.

Ich habe versucht mit copy-dependencies statt und ohne die großen Abhängigkeiten verwenden, aber es ist nicht die Klassen zu finden.

Warum haben Netbeans dieses POM bauen, ist Java FX entpackten Abhängigkeiten müssen (für FXML, usw.)?

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> 

Antwort

1

In Ihrem pom.xml, finden Sie den Code unten:

<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> 

Bitte den Namen des Elements <excludeGroupIds>

finden und nur die groupId Name, die Sie unter <dependencies> finden.

groupId Namen sollten Komma (,) getrennt werden.