apache / apache/maven-resolver-ant-tasks
CreatePom throws NullPointerException when pomTarget has no parent directory
- Dominant language
- Java
- Stars
- 15
- Forks
- 18
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 8
Description
## Summary
`CreatePom` throws a `NullPointerException` when `pomTarget` points at a file with no parent directory (e.g. `pomTarget="pom.xml"`).
## Affected code
`src/main/java/org/apache/maven/resolver/internal/ant/tasks/CreatePom.java` lines 332-335 (master @ `df2908e`)
```java
@Override
public void execute() {
if (!pomFile.getParentFile().exists()) {
pomFile.getParentFile().mkdirs();
}
```
## Problem
When `pomTarget` is a bare relative filename such as `pom.xml`, `new File("pom.xml").getParentFile()` returns `null`, so `pomFile.getParentFile().exists()` throws an NPE. Only `pomTarget` values containing a directory component (e.g. `out/pom.xml`) work.
## Expected behavior
A bare filename should be written to the current working directory (skip the parent-dir creation, or treat a null parent as the base dir).
## Reproduction
```xml
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in src/main/java/org/apache/maven/resolver/internal/ant/tasks/CreatePom.java at execute(), especially lines 332-335, and inspect how pomFile is initialized from pomTarget. Reproduce with pomTarget="pom.xml" and verify that a bare filename is written in the current working directory without an exception, while targets with directory components still work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100