我正在使用 Maven 来构建我的项目。我想创建包含一些依赖项的程序集 jar,所以我编写了自定义程序集描述符。
POM.XML
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.guavus.exporter.Exporter</mainClass>
</manifest>
</archive>
<descriptors>
<descriptor>/Users/archit.thakur/Documents/Code_dev_cdn_mapreduce/exporter/src/main/assembly/configurator.xml</descriptor>
<!-- <descriptorRef>jar-with-dependencies</descriptorRef> -->
</descriptors>
<finalName>Exporter-${project.version}</finalName>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>default-jar</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
汇编描述符:
<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>dep</id>
<formats>
<format>jar</format>
</formats>
<dependencySets>
<dependencySet>
<outputDirectory>${project.artifactId}</outputDirectory>
<unpack>true</unpack>
<useProjectArtifact>true</useProjectArtifact>
<includes>
<include>log4j:log4j</include>
<include>org.slf4j:slf4j-api</include>
<include>ch.qos.logback:logback-access</include>
<include>ch.qos.logback:logback-classic</include>
<include>ch.qos.logback:logback-core</include>
</includes>
</dependencySet>
</dependencySets>
</assembly>
问题是,现在它正在创建只有依赖 jar 的 jar。而不是从我的代码中制作 jar 并将其包含在最终的 jar 中。