ฉันต้องการสร้างไฟล์ jar จากโปรเจ็กต์ maven ฉันจำเป็นต้องใช้ Assembly.xml ของตัวเองเพราะฉันต้องแยกไฟล์ .so บางไฟล์ออก:
แอสเซมบลี.xml
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>assembly-with-so</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<!-- package the regular dependencies -->
<dependencySet>
<outputDirectory>/</outputDirectory>
<useProjectArtifact>true</useProjectArtifact>
<unpack>true</unpack>
<scope>runtime</scope>
<excludes>
<exclude>jcuda:libJCublas:so:linux-x86_64:0.6.5</exclude>
[...]
</excludes>
</dependencySet>
<dependencySet>
<outputDirectory>/</outputDirectory>
<includes>
<include>jcuda:libJCublas:so:linux-x86_64:0.6.5</include>
[...]
</includes>
</dependencySet>
</dependencySets>
</assembly>
pom.xml
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>jar-with-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptor>src/main/assembly/assembly.xml</descriptor>
<appendAssemblyId>false</appendAssemblyId>
<archive>
<manifest>
<mainClass>org.test.Test</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
[...]
</build>
เมื่อฉันเริ่มไฟล์ jar โดยใช้ java -jar File.jar
ฉันได้รับข้อผิดพลาดว่าคลาส org.test.Test
หายไป เมื่อฉันเปิดไฟล์ .jar เพื่อดูว่ามีอะไรอยู่ในนั้น ฉันเห็นว่ามีไฟล์อ้างอิงทุกไฟล์ แต่ไฟล์ของโปรเจ็กต์หลักหายไป
jcuda
ในชุดแรกและรวมอีกครั้งในชุดที่สอง - person Aaron Digulla   schedule 23.10.2014<unpack>true</unpack>
) เหตุใดคุณจึงเรียกใช้แอสเซมบลีในprepare-package
แทนที่จะเป็นpackage
เฟส .. สิ่งนี้สามารถอธิบายได้ว่าทำไมคลาสหลักjar-file
จึงไม่ถูกบรรจุเข้าไป - person khmarbaise   schedule 24.10.2014prepare-package
เป็นpackage
ไม่สามารถแก้ปัญหาได้ - person user1406177   schedule 24.10.2014