apache / apache/maven-jar-plugin

Skip jar creation when no existing files will be included

Open
#510 4 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
92
Forks
84
Avg merge
19h 45m
Merged PRs (30d)
6

Description

### New feature, improvement proposal

Hello,

my understanding is that with `skipIfEmpty=true` will skip jar creation when src path does not exist or it does not contain any file.
It would be usefull if the above option could be used to skip jar creation also when no files will be included.

[example.zip](https://github.com/user-attachments/files/24235079/example.zip)

In the attached example i have create the following possible use case:
```
example
├── module1
│   ├── pom.xml
│   └── src
│   ├── main
│   │   └── java
│   │   └── my
│   │   └── org
│   │   └── app1
│   │   └── App1.java
│   └── test
│   └── java
│   └── my
│   └── org
│   └── app1
│   ├── App1Test.java
│   └── junit
│   ├── MyExtension.java
│   └── MyExtensionTest.java
├── module2
│   ├── pom.xml
│   └── src
│   ├── main
│   │   └── java
│   │   └── my
│   │   └── org
│   │   └── app2
│   │   └── App2.java
│   └── test
│   └── java
│   └── my
│   └── org
│   └── app2
│   └── App2Test.java
└── pom.xml
```
where parent pom contains:
```

org.apache.maven.plugins
maven-jar-plugin
3.5.0



junit
true

**/junit/*


**/*Test.class



test-jar




```
In the above scenario I would expect that junit jar will be created only for app1, while now it is created also for app2 with only pom and manifest files
```
❯ unzip -l module2/target/app2-1.0-junit.jar
Archive: module2/target/app2-1.0-junit.jar
Length Date Time Name
--------- ---------- ----- ----
0 2025-12-18 13:13 META-INF/
81 2025-12-18 13:13 META-INF/MANIFEST.MF
0 2025-12-18 13:13 META-INF/maven/
0 2025-12-18 13:13 META-INF/maven/my.org/
0 2025-12-18 13:13 META-INF/maven/my.org/app2/
515 2025-12-18 10:48 META-INF/maven/my.org/app2/pom.xml
43 2025-12-18 13:13 META-INF/maven/my.org/app2/pom.properties
--------- -------
639 7 files
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by running the attached example.zip with the parent POM configuration and compare the test JARs produced for module1 and module2. Inspect the maven-jar-plugin test-jar execution and skipIfEmpty behavior; done means the JUnit JAR is created for app1 but skipped for app2 when includes and excludes leave no files.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.