Уже неделю я пытаюсь создать исполняемый jar с maven в затмении, но у меня проблемы. Вот что у меня есть и чем я занимаюсь:
Содержимое моего файла pom.xml:
<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>
<groupId>B4D</groupId>
<artifactId>B4D</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>B4D</name>
<description>Bot for Dofus</description>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>Cp1252</encoding>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>fr.B4D.gui.JFrame_B4D</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.jgrapht</groupId>
<artifactId>jgrapht-core</artifactId>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>net.sourceforge.tess4j</groupId>
<artifactId>tess4j</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<version>1.28.0</version>
</dependency>
<dependency>
<groupId>com.google.oauth-client</groupId>
<artifactId>google-oauth-client-jetty</artifactId>
<version>1.23.0</version>
</dependency>
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-sheets</artifactId>
<version>v4-rev493-1.23.0</version>
</dependency>
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-sqladmin</artifactId>
<version>v1beta4-rev66-1.25.0</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-drive</artifactId>
<version>v3-rev136-1.25.0</version>
</dependency>
<dependency>
<groupId>com.github.kirviq</groupId>
<artifactId>dumbster</artifactId>
<version>1.7.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.sourceforge.jpcap</groupId>
<artifactId>capture</artifactId>
<version>0.01.16</version>
<scope>system</scope>
<systemPath>${project.basedir}/jpcap/net.sourceforge.jpcap-0.01.16.jar</systemPath>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
Я строю свой проект, выполняя:
Project> Run As> сборка Maven> Цели: пакет> Run
А вот и вывод консоли:
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for B4D:B4D:jar:1.0
[WARNING] 'dependencies.dependency.systemPath' for net.sourceforge.jpcap:capture:jar should not point at files within the project directory, ${project.basedir}/jpcap/net.sourceforge.jpcap-0.01.16.jar will be unresolvable by dependent projects @ line 115, column 15
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building B4D 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ B4D ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 32 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ B4D ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 84 source files to D:\Lucas\Projets personnels\Eclipse Windows\B4D\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ B4D ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ B4D ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 7 source files to D:\Lucas\Projets personnels\Eclipse Windows\B4D\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ B4D ---
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ B4D ---
[INFO] Building jar: D:\Lucas\Projets personnels\Eclipse Windows\B4D\target\B4D-1.0.jar
[INFO]
[INFO] --- maven-assembly-plugin:2.2-beta-5:single (make-assembly) @ B4D ---
[INFO] META-INF/ already added, skipping
[INFO] META-INF/MANIFEST.MF already added, skipping
................
[INFO] com/google/api/ already added, skipping
[INFO] com/google/api/services/ already added, skipping
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:01 min
[INFO] Finished at: 2019-03-14T16:54:57+01:00
[INFO] Final Memory: 27M/307M
[INFO] ------------------------------------------------------------------------
А когда я пытаюсь запустить файл jar в консоли:
$ java -jar B4D-1.0-jar-with-dependencies.jar
Exception in thread "main" java.lang.NoClassDefFoundError: net/sourceforge/jpcap /capture/InvalidFilterException
at fr.B4D.gui.JFrame_B4D.<init>(JFrame_B4D.java:64)
at fr.B4D.gui.JFrame_B4D.main(JFrame_B4D.java:55)
Caused by: java.lang.ClassNotFoundException: net.sourceforge.jpcap.capture.Inval idFilterException
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
Обратите внимание, что в моем проекте используется локальная зависимость файла jar: net.sourceforge.jpcap-0.01.16.jar. Похоже, эта зависимость ошибочно включена в окончательный файл JAR. Конечно, я нашел много тем о том, как создать исполняемый файл JAR и как включить файл .jar. Но никто из них не решил мою проблему. В моем файле pom.xml должно быть что-то не так, но что?
Большое спасибо
MrDomoo