apache / apache/maven-enforcer
[MENFORCER-517] requireReleaseDeps ignores optioanal dependencies
- Dominant language
- Java
- Stars
- 161
- Forks
- 180
- Avg merge
- 1d 20m
- Merged PRs (30d)
- 8
Description
**[James Nord](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=jnord_cbs)** opened **[MENFORCER-517](https://issues.apache.org/jira/browse/MENFORCER-517?redirect=false)** and commented
A project configured with an optional dependency with a snapshot version and enforcer with `requireReleaseDeps` set to fail should fail the build, however the rule does not look at optional dependencies.
Whilst this makes not difference to consumers, it means that `requireReleaseDeps` can not be used to help enforce the reproducibility of release builds.
### Steps to Reproduce
create a maven pom with the following:
```java
4.0.0 maven.test
enforcer-bug
jar
1-SNAPSHOT
maven-enforcer-plugin
3.5.0
maven-enforcer-plugin
enforce-no-snapshots
enforce
No Snapshots Allowed For Release Versions
false
true
false
junit
junit
4.1-SNAPSHOT
jar
test
true
```
run `mvn validate`
### Expected results
The build fails with
```java
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:3.5.0:enforce (enforce-no-snapshots) on project enforcer-bug:
[ERROR] Rule 0: org.apache.maven.enforcer.rules.dependency.RequireReleaseDeps failed with message:
[ERROR] No Snapshots Allowed For Release Versions
[ERROR] maven.test:enforcer-bug:jar:1-SNAPSHOT
[ERROR] junit:junit:jar:4.1-SNAPSHOT <--- is not a release dependency
```
### Actual results
the build passes
```java
[INFO] Rule 0: org.apache.maven.enforcer.rules.dependency.RequireReleaseDeps passed
```
Note if you remove the `true` from the dependency you will see that the enforcer rule passes
---
**Affects:** 3.5.0
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the org.apache.maven.enforcer.rules.dependency.RequireReleaseDeps rule described in the issue and reproduce the case using the supplied Maven POM. Run `mvn validate` with an optional snapshot dependency and compare the result with the expected failure. Done means requireReleaseDeps rejects the optional snapshot dependency as shown.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100