Người ta cũng có thể tạo một JAR đơn bằng cách sử dụng trình cắm thêm maven-assembly.
Cùng với đề xuất khác của Eric Anderson (khi ký một JAR khác), người ta có thể ký JAR lắp ráp này (thay vì JAR nguyên bản). Lưu ý rằng thứ tự của các định nghĩa plugin quan trọng ở đây.
Giả định rằng sign.keystore.file vv được đặt ở nơi khác (ví dụ: trong tiểu sử).
<build>
<plugins>
<!-- It seems that maven-assembly-plugin must be declared before the maven-jar-plugin,
so that it is executed first in the package phase,
and then the signing of the packaged jar can succeed. -->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifestEntries>
<!-- ... -->
</manifestEntries>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<goals>
<goal>jar</goal>
</goals>
</execution>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<jarPath>${project.build.directory}/${project.build.FinalName}-${project.packaging}-with-dependencies.${project.packaging}</jarPath>
<keystore>${sign.keystore.file}</keystore>
<type>${sign.keystore.type}</type>
<storepass>${sign.keystore.storepass}</storepass>
<alias>${sign.keystore.alias}</alias>
<verify>true</verify>
<verbose>false</verbose>
<removeExistingSignatures>true</removeExistingSignatures>
</configuration>
</execution>
</executions>
<configuration>
<archive>
<manifest>
<!-- <addClasspath>true</addClasspath> -->
</manifest>
<manifestEntries>
<!-- ... -->
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
Đó sẽ là một tham số Plugin jarsigner (http://maven.apache.org/plugins/maven-jarsigner-plugin/sign-mojo.html#archiveDirectory), nhưng mục tiêu không phải là một giá trị tốt. Thư mục đích không tương ứng với thư mục gốc của jar mong muốn. – Eero