Oct 8, 2026
How to Create a Pure Source Code ZIP Package with Maven
Learn how to package pure Java source code with the Maven Source Plugin and convert the resulting sources.jar into a ZIP file for third-party security vulnerability scanning.
Background
Package pure source code for third-party security vulnerability scanning.
Maven Plugin
Add the following Maven plugin to the project:
<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>
Steps
3.1 Create the Source JAR
- Run
mvn clean compilewith Maven in IntelliJ IDEA. - Find the
*-sources.jarfile in thetargetdirectory.
3.2 Convert the JAR to a ZIP File
- Use
jar -tf *-sources.jarto inspect the JAR contents and check for sensitive files. - Rename the JAR file with
mv *-sources.jar *-sources.zipto create the ZIP file.
3.3 Alternative Approach
Change to the src/java directory and create a ZIP file there.