maven java 如何打纯源码zip包

一、背景

打纯源码包给第三方进行安全漏洞扫描

二、maven插件

项目中加入下面的maven 插件

xml 复制代码
 <!-- 要将源码放上去,需要加入这个插件 -->
            <plugin>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <attach>true</attach>
                    <excludes>
                        <!--资源配置过滤-->
                        <exclude>*.properties</exclude>
                        <exclude>freemarker/*.ftl</exclude>
                        <exclude>mapper/*.xml</exclude>
                        <exclude>webapp/*.xml</exclude>
                        <exclude>license/*.*</exclude>
                    </excludes>
                </configuration>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

三、使用步骤

3.1 产出源码jar包

  1. idea maven 执行 clean compile命令
  2. 在target 目录下找到*-sources.jar包文件

3.2 转换jar包到zip包

  1. 使用jar -tf *-sources.jar查看jar包内容,是否包括其他敏感文件等
  2. 使用mv *-sources.jar *-sources.zip 生成zip包

3.3 其他方案

cd 到src/java目录,打zip包

相关推荐
六件套是我10 分钟前
无法访问org.springframeword.beans.factory.annotation.Value
java·开发语言·spring boot
LYS_061819 分钟前
C++学习(5)(函数 指针 引用)
java·c++·算法
forestsea28 分钟前
Spring Cloud Alibaba 2025.1.0.0 正式发布:拥抱 Spring Boot 4.0 与 Java 21+ 的新时代
java·spring boot·后端
IT枫斗者28 分钟前
IntelliJ IDEA 2025.3史诗级更新:统一发行版+Spring Boot 4支持,这更新太香了!
java·开发语言·前端·javascript·spring boot·后端·intellij-idea
forestsea28 分钟前
Spring Boot 4.0 + JDK 25 + GraalVM:下一代云原生Java应用架构
java·spring boot·云原生
♡喜欢做梦30 分钟前
Spring Boot 日志实战:级别、持久化与 SLF4J 配置全指南
java·spring boot·后端·spring·java-ee·log4j
青衫码上行33 分钟前
【项目部署】Spring Boot项目部署的四种方式
java·linux·服务器·spring boot·后端·docker·腾讯云
想不明白的过度思考者35 分钟前
你真的会打印日志吗?基于 Spring Boot 的全方位日志指南
java·spring boot·后端·日志
路中行37 分钟前
Spring Cloud Gateway 整合 Knife4j 聚合文档:避坑指南与解决方案(Spring Boot 3.X)
java·spring boot·spring cloud