maven java 如何打纯源码zip包

一、背景

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

二、maven插件

项目中加入下面的maven 插件

 
            <plugin>
                <artifactId>maven-source-pluginartifactId>
                <version>2.4version>
                <configuration>
                    <attach>trueattach>
                    <excludes>
                        
                        <exclude>*.propertiesexclude>
                        <exclude>freemarker/*.ftlexclude>
                        <exclude>mapper/*.xmlexclude>
                        <exclude>webapp/*.xmlexclude>
                        <exclude>license/*.*exclude>
                    excludes>
                configuration>
                <executions>
                    <execution>
                        <phase>compilephase>
                        <goals>
                            <goal>jargoal>
                        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包

你可能感兴趣的:(java基础专题,软件工程专题,git&maven,java,maven,pycharm)