繁体   English   中英

打包源代码和依赖项

[英]Packing Source Code and Dependencies

我正在尝试使用带有源代码和所有依赖项的Maven构建jar包。 问题在于,Maven没有打包源代码,而是仅打包依赖项。

我是否还需要设置配置以打包源代码?

<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>courier-perf-test</groupId>
    <artifactId>courier-perf-test</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>ze.delivery.HTTPRequestClass</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>
        <!-- https://mvnrepository.com/artifact/org.json/json -->
        <!-- https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple -->
        <dependency>
            <groupId>com.googlecode.json-simple</groupId>
            <artifactId>json-simple</artifactId>
            <version>1.1.1</version>
        </dependency>

    </dependencies>
</project>

在程序集插件配置中将src用作描述符Ref,可以为您的项目创建源档案,或者最好使用预定义的描述符project

<descriptorRefs>
   <descriptorRef>jar-with-dependencies</descriptorRef>
   <descriptorRef>src</descriptorRef>
</descriptorRefs>

要么:

<descriptorRefs>
   <descriptorRef>jar-with-dependencies</descriptorRef>
   <descriptorRef>project</descriptorRef>
</descriptorRefs>

参考: maven-assembly-plugin

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM