[ https://issues.apache.org/jira/browse/MENFORCER-378?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17652320#comment-17652320 ]
Petr Široký commented on MENFORCER-378: --------------------------------------- I tried to run the test project with plugin version {{3.1.0}} and that seems to work as I would expect: {code:java} $ /tmp/test ❯ mvn validate [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Reactor Build Order: [INFO] [INFO] Homeserver Domains [pom] [INFO] Domeinen [pom] [INFO] Common Libraries [jar] [INFO] Common Libs [jar] [INFO] [INFO] ------------------------< nl.mytest:homeserver >------------------------ [INFO] Building Homeserver Domains 0.0.1-SNAPSHOT [1/4] [INFO] --------------------------------[ pom ]--------------------------------- [INFO] [INFO] -------------------------< nl.mytest:domains >-------------------------- [INFO] Building Domeinen 0.0.1-SNAPSHOT [2/4] [INFO] --------------------------------[ pom ]--------------------------------- [INFO] [INFO] --- maven-enforcer-plugin:3.1.0:enforce (enforce) @ domains --- [INFO] [INFO] -----------------------< nl.mytest:domain_libs >------------------------ [INFO] Building Common Libraries 0.0.1-SNAPSHOT [3/4] [INFO] --------------------------------[ jar ]--------------------------------- [WARNING] The POM for nl.myshared.datafiles:runtime_data:selector:0.0.1-SNAPSHOT is missing, no dependency information available [INFO] [INFO] --- maven-enforcer-plugin:3.1.0:enforce (enforce) @ domain_libs --- [ERROR] Rule 0: org.apache.maven.plugins.enforcer.RequireReleaseDeps failed with message: Found Banned Dependency: nl.myshared.datafiles:runtime_data:selector:0.0.1-SNAPSHOT Use 'mvn dependency:tree' to locate the source of the banned dependencies. [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary for Homeserver Domains 0.0.1-SNAPSHOT: [INFO] [INFO] Homeserver Domains ................................. SUCCESS [ 0.001 s] [INFO] Domeinen ........................................... SUCCESS [ 0.195 s] [INFO] Common Libraries ................................... FAILURE [ 0.005 s] [INFO] Common Libs ........................................ SKIPPED [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.247 s [INFO] Finished at: 2022-12-27T23:36:28+01:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:3.1.0:enforce (enforce) on project domain_libs: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed. -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException [ERROR] [ERROR] After correcting the problems, you can resume the build with the command [ERROR] mvn <args> -rf :domain_libs {code} There is a WARN about missing pom for that dependency, which seems OK. The enforcer rule also fails because the dependency is in fact a SNAPSHOT. I would say the rule should not really care if the dependency is optional or not. If it's a SNAPSHOT then I would expect a failure. I am aware that this issue is almost 2 years old, but I figured I would try to double-check if this is has been already fixed or not and if yes, then we should close it and clean-up the backlog a bit. > requireReleaseDeps does not support optional dependencies or runtime scope > -------------------------------------------------------------------------- > > Key: MENFORCER-378 > URL: https://issues.apache.org/jira/browse/MENFORCER-378 > Project: Maven Enforcer Plugin > Issue Type: Bug > Components: Standard Rules > Affects Versions: 3.0.0-M3 > Environment: Windows > Reporter: Casper Roubos > Priority: Major > Attachments: test.zip > > > With using the <requireReleaseDeps> the enforcer throws a RuntimeException > due to the following error: > {code} > Caused by: > org.apache.maven.shared.dependency.graph.DependencyGraphBuilderException: > Could not resolve following dependencies: > [nl.myshared.datafiles:runtime_data:selector:0.0.1-SNAPSHOT (runtime?)] > at > org.apache.maven.shared.dependency.graph.internal.Maven31DependencyGraphBuilder.resolveDependencies > (Maven31DependencyGraphBuilder.java:133) > at > org.apache.maven.shared.dependency.graph.internal.Maven31DependencyGraphBuilder.buildDependencyGraph > (Maven31DependencyGraphBuilder.java:113) > at > org.apache.maven.shared.dependency.graph.internal.DefaultDependencyGraphBuilder.buildDependencyGraph > (DefaultDependencyGraphBuilder.java:91) > at > org.apache.maven.shared.dependency.graph.internal.DefaultDependencyGraphBuilder.buildDependencyGraph > (DefaultDependencyGraphBuilder.java:66) > at > org.apache.maven.plugins.enforcer.AbstractBanDependencies.getDependenciesToCheck > (AbstractBanDependencies.java:122) > at org.apache.maven.plugins.enforcer.AbstractBanDependencies.execute > (AbstractBanDependencies.java:86) > at org.apache.maven.plugins.enforcer.RequireReleaseDeps.execute > (RequireReleaseDeps.java:105) > at org.apache.maven.plugins.enforcer.EnforceMojo.execute > (EnforceMojo.java:205){code} > This file is an optional dependency and the POM is sometimes not available. I > have given the optional parameter in the POM > {code} > <dependency> > <groupId>nl.myshared.datafiles</groupId> > <artifactId>runtime_data</artifactId> > <version>${project.version}</version> > <type>selector</type> > <scope>runtime</scope> > <optional>true</optional> > </dependency> > {code} > I report this as a bug, since the <optional> parameter is long supported in > maven. > In my opinion "AbstractBanDependencies.getDependenciesToCheck" line 139 > should have a 'if present and if optional' check. If so, no RuntimeException > should be thrown. I'll leave it to you if <scope>runtime should also be > excused from the RuntimeException. > I have no other option (no workaround) than to skip the Enforcer for this > project. -- This message was sent by Atlassian Jira (v8.20.10#820010)