• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Looking for a Maven Plugin

 
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anyone know of a Maven plugin that will enforce design rules? I would like to be able to cause a build error when someone does things like throwing SQLException from DAO layer or when a method in Service object excepts a Hibernate specific Object.
 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem is this comes in the realm of Design Patterns, and Design Patterns aren't overly amenable to automated anything. Otherwise there'd be extortionately-priced software suites designed to exploit that. Instead what we have is mostly DIY, although the Iterator pattern is now built into Java itself.

There are some things that can help. A product that can scan for questionable usages whose exact name escapes me (it's something like BugBuddy). I think it is supported by a Maven plugin, but it's also something that can plug into an IDE.

Likewise, some of the UML tools try to help. I know that the open-source ArgoUML tool does. But that's all interactive critiquing, not batch-mode, so it's hard to make Maven work with it.
 
Kerry Wilson
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks,

I think the ideal solution would allow me to list packages that classes in a certain package cannot use. Ideally, it would have regular expression matching as well.

So I could say (in a config file) something like...



I know this would save me a bit of refactoring if these types of things were caught by developers.
 
Tim Holloway
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That wouldn't be a very difficult app to write. (ahem) "All You Have To Do Is..."

Well, seriously. Load up the XML file using apache digester or similar. Read the classfiles in the project, looking for violations by pattern-matching the signatures of method calls. Report them.

Easily done in less than a day.

Meaning that in Real Life, I'd put aside 2-3 weeks to get it all working, especially as a mojo. But still, at the conceptual level, it's fairly simple.
 
Kerry Wilson
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yea, that part of it would be simple enough. However, I would want the usage to be checked as well (if possible).
 
Ranch Hand
Posts: 433
Netbeans IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:
There are some things that can help. A product that can scan for questionable usages whose exact name escapes me (it's something like BugBuddy). I think it is supported by a Maven plugin, but it's also something that can plug into an IDE.


I guess you are referring to FindBugs (http://findbugs.sourceforge.net) or PMD (http://pmd.sourceforge.net/). Both tools can be extended by customized rules. But from top of my head I can't think of any rule, which would check for certain exceptions. But maybe it's a better starting point than writing a customized tool from scratch.
 
Kerry Wilson
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Joachim Rohde wrote:I guess you are referring to FindBugs (http://findbugs.sourceforge.net) or PMD (http://pmd.sourceforge.net/). Both tools can be extended by customized rules. But from top of my head I can't think of any rule, which would check for certain exceptions. But maybe it's a better starting point than writing a customized tool from scratch.



Thanks, I'll check these out. I am not talking about just checking for exceptions though. Any package usage at all and I would want it to fail. For instance, my DAO's should not be tightly coupled with a DB, so I would not want the DAO interfaces to use (return, throw, or accept as argument) any classes in the javax.sql package.
 
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you already have a look at checkstyle?
 
Yeah. What he said. Totally. Wait. What? Sorry, I was looking at this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic