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包

相关推荐
橙淮13 小时前
并发编程(六)
java·jvm
拽着尾巴的鱼儿13 小时前
springboot openfeign 自定义feign 接口重试机制
java·spring boot·后端
白露与泡影13 小时前
2026大厂Java面试题大全!牛客网最新版
java·开发语言
EntyIU14 小时前
JVM内存与GC笔记
java·jvm·笔记
XS03010614 小时前
并发编程 六
java·后端
yaoxin52112314 小时前
419. 现代 Java IO 最佳实践 - 写入文本文件
java·windows·python
雪宫街道14 小时前
synchronized 锁的范围:对象锁、类锁与代码块锁
java·jvm·后端·面试
x***r15114 小时前
linux安装 jdk-8u291-linux-x64.tar.gz 详细步骤(解压配置环境变量)
java
极光代码工作室15 小时前
基于SpringBoot的校园论坛系统
java·springboot·web开发·后端开发
XS03010615 小时前
Spring Bean 作用域 & 生命周期
java·后端·spring