You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2022/05/27 07:47:59 UTC

[GitHub] [maven-enforcer] josephw commented on a diff in pull request #152: MENFORCER-420: cache dependencies across rules

josephw commented on code in PR #152:
URL: https://github.com/apache/maven-enforcer/pull/152#discussion_r883358525


##########
enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/AbstractBanDependencies.java:
##########
@@ -120,6 +120,36 @@ protected CharSequence getErrorMessage( Artifact artifact )
         return "Found Banned Dependency: " + artifact.getId() + System.lineSeparator();
     }
 
+    private Set<Artifact> getDependenciesToCheck( EnforcerRuleHelper helper, ProjectBuildingRequest buildingRequest )
+    {
+        if ( helper == null )
+        {
+            return getDependenciesToCheck( buildingRequest );
+        }
+
+        String cacheKey = buildingRequest.getProject().getId() + "_" + searchTransitive;
+
+        // check in the cache
+        if ( helper.getContainer().getContext().contains( cacheKey ) )

Review Comment:
   This behaviour works for us, but I'm not clear whether it's a suitable place for a cache. [This post from the mailing list](https://lists.apache.org/thread/12vv716gcxo97nyzcb00qt19wx10l2m4) suggests:
   > Most of these cache would seem to be relevant at the "MavenExecution"
   level, i.e. we could choose to ditch all of this at the end of each
   build without loosing any real performance.
   
   Is there a better place now to get a cache with that lifecycle?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org