【发布时间】:2018-01-22 15:52:11
【问题描述】:
我的java项目不大,其实是一个学习项目,我用的是一些maven无法导入的eclipse jar。所以我只是把它们放在资源文件夹中并创建了依赖项。 但是当我做一个包裹时,一切都出错了。它要么不包含这些依赖项,要么不包含我的 src 文件夹(!)。
我的项目结构是:
src/com/myName/Main
资源/jar1 jar2
我使用 jar-with-dependencies 描述符,但我似乎迷失了其中。我如何解决它?现在我的 src 在结果 jar 中丢失了。
我的 pom.xml 是
<?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>
<groupId>groupId</groupId>
<artifactId>MyProgram</artifactId>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>controller.MainController</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.eclipse.swt</groupId>
<artifactId>org.eclipse.swt</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/resources/org.eclipse.swt.win32.win32.x86_64_3.106.2.v20171129-0543.jar
</systemPath>
</dependency>
<dependency>
<groupId>swing2swt</groupId>
<artifactId>swing2swt</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/resources/swing2swt.jar</systemPath>
</dependency>
<dependency>
<groupId>org.eclipse.ui</groupId>
<artifactId>ide</artifactId>
<version>3.2.1-M20060915-1030</version>
</dependency>
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.swt</artifactId>
<version>3.106.2</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.4</version>
</dependency>
</dependencies>
</project>
【问题讨论】: