mojohaus / extra-enforcer-rules

Extra Enforcer Rules
https://www.mojohaus.org/extra-enforcer-rules/
Apache License 2.0
73 stars 47 forks source link

BanDuplicateClasses trying to download artifacts #251

Open delanym opened 1 year ago

delanym commented 1 year ago

This rule seems to be very troublesome, but recently it became unbearable.

With this configuration

<banDuplicateClasses>
  <ignoreClasses/>
  <scopes/>
  <findAllDuplicates>false</findAllDuplicates>
  <ignoreWhenIdentical>false</ignoreWhenIdentical>
</banDuplicateClasses>

It tries to download an artifact already downloaded (why is it even downloading artifacts?) and outputs a whopping 25 lines for every missing dependency.

Downloading from maven-releases: https://nexus.segway.com/repository/maven-releases/com.segway.driver/java-modules/3.3.0/java-modules-3.3.0.pom
Downloaded from maven-releases: https://nexus.segway.com/repository/maven-releases/com.segway.driver/java-modules/3.3.0/java-modules-3.3.0.pom (425 B at 604 B/s)                                                                                                                                 
Downloading from maven-releases: https://nexus.segway.com/repository/maven-releases/com.segway.driver/java-modules/3.3.0/java-modules-3.3.0.jar
Downloaded from maven-releases: https://nexus.segway.com/repository/maven-releases/com.segway.driver/java-modules/3.3.0/java-modules-3.3.0.jar (7.3 MB at 2.2 MB/s)
[INFO] Building com.segway.msgfactories:segwaymsgfactory:1.2.16-SNAPSHOT
Downloading from pronto-public: https://nexus.segway.com/repository/maven-public/com.segway.driver/java-modules/3.3.0/java-modules-3.3.0.jar
[WARNING] Missing:
----------
1) com.segway.driver:java-modules:jar:3.3.0

  Try downloading the file manually from the project website.

  Then, install it using the command: 
      mvn install:install-file -DgroupId=com.segway.driver -DartifactId=java-modules -Dversion=3.3.0 -Dpackaging=jar -Dfile=/path/to/file

  Alternatively, if you host your own repository you can deploy the file there: 
      mvn deploy:deploy-file -DgroupId=com.segway.driver -DartifactId=java-modules -Dversion=3.3.0 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

  Path to dependency: 
        1) com.segway.driver:java-modules:jar:3.3.0

----------
1 required artifact is missing.

for artifact: 
  com.segway.driver:java-modules:jar:3.3.0

from the specified remote repositories:
  pronto-public (https://nexus.segway.com/repository/maven-public/, releases=true, snapshots=false)
Path to dependency: 
        1) com.segway.driver:java-modules:jar:3.3.0
slawekjaranowski commented 1 year ago

Can you provide a simple project for reproduce? Which version of extra rules and enforcer plugin do you use?

delanym commented 7 months ago

I updated to extra-enforcer-rules v1.8.0 but now the ban applies to third-party artifacts and not just the classes in my code. There are ignores, but it would be tedious to have to define all of them, so I'm just going to turn the rule off. Is this really such a bad situation?

09:55:33  Rule 7: org.codehaus.mojo.extraenforcer.dependencies.BanDuplicateClasses failed with message:
09:55:33  Duplicate class found:
09:55:33  
09:55:33    Found in:
09:55:33      jakarta.activation:jakarta.activation-api:jar:2.1.2:compile
09:55:33      org.glassfish.metro:webservices-api:jar:4.0.2:compile
09:55:33    Duplicate classes:
09:55:33      jakarta/activation/ActivationDataFlavor.class

Another example of being able to blacklist but not whitelist: https://issues.apache.org/jira/browse/MDEP-808

slawekjaranowski commented 7 months ago

... interesting does version 1.7.0 don't check classes in external library ....? What is your code?

delanym commented 7 months ago

Unfortunately its not open source. It built with 1.7.0. I haven't changed dependencies since upgrading to 1.8.0

Does adding jakarta.activation-api and webservices-api to your project with v1.8.0 cause it to fail?