Giter Site home page Giter Site logo

I feel like having non-test scoped <dependencies/> in a pom packaging project is something that could be checked by maven lint about lint-maven-plugin HOT 2 OPEN

lewisd32 avatar lewisd32 commented on August 15, 2024
I feel like having non-test scoped in a pom packaging project is something that could be checked by maven lint

from lint-maven-plugin.

Comments (2)

lkwg82 avatar lkwg82 commented on August 15, 2024

Sry, I dont understand your issue.

from lint-maven-plugin.

lewisd32 avatar lewisd32 commented on August 15, 2024

This is actually something idcmp and I discussed elsewhere, that I asked him to raise as an issue here. I'll explain the reasoning.

In a pom-type Maven project, that is the parent of other modules, listing versions and scopes in <dependencyManagement> is the recommended way of maintaining versions in single place, in a multi-module project.
However, it is rare to include <dependencies> (as opposed to <dependencyManagement>) in these parent projects. The sole legitimate use of this I've seen is to add things like junit, jmock, mockito, hamcrest, etc, in the test scope. Since test scope dependencies won't become transitive dependencies when other projects depend on yours, this doesn't create a mess. Including, for example, spring, in the <dependencies> of a pom-type parent project would mean every single project that uses it as a parent, and any project that depends on those children, would all end up with a dependency or transitive dependency on spring. Unless all modules in the multi-module project truly require spring (which I've found to be rare), including spring in the <dependencies> of the parent leads to unnecessary dependencies, a bit of a mess.

The lint maven plugin could easily enforce that all dependencies that aren't in <dependencyManagement>, in pom-type projects, are in the test scope.

In the rare case where one might actually want to do that (eg. log4j, slf4j, etc) it's easy enough to add a NOLINT comment in the pom to allow it.

from lint-maven-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.