Ryan Gabbard
Ryan Gabbard

Reputation: 2299

IntelliJ "Find Usages" and Maven artifacts

Our team manages Java projects using Maven. We have a policy that all code on the master branch of a repository should:

  1. itself have a -SNAPSHOT version (releases are created using the Maven Release plugin)
  2. have Maven dependencies only on releases and never on -SNAPSHOTs.

This has an unfortunate consequence in IntelliJ IDEA (version 15, build 143.1821.5). Suppose Maven artifact A depends on some release version of Maven artifact B, say 1.2.3. The current code for B on master, though, will be something like 1.2.4-SNAPSHOT. If I load the source for both A and B in IDEA, go to a class in B which is used in A, and do a Find Usages (Ctrl-click the class name or Alt-7), no results are found. If, however, I navigate in the IDE to the decompiled class file for the 1.2.4 release and do Find Usages, it finds the usages in A.

I understand why this happens --- the -SNAPSHOT version of the code really isn't being used by A --- but this degree of pickiness makes Find Usages nearly useless across Maven artifacts. However, I seem to remember at some point in the recent past IDEA's Find Usages wasn't so picky. Unfortunately Googling hasn't turned up anyone else mentioning this problem or a mention of a change in IDEA behavior, so now we are thinking we just imagined the previous behavior.

So, does anyone know how to get IDEA to ignore version mismatches on Maven modules when doing Find Usages? Was there some setting we had enabled before that we now can't find?

Upvotes: 9

Views: 1471

Answers (1)

vikingsteve
vikingsteve

Reputation: 40408

I think you're doing this incorrectly.

By definition, the MASTER branch should be a released version (no -SNAPSHOT).

You want to talk to your team and review your build and release processes.

Have a read about the git-flow branching model for some more information about branching strategies.

Upvotes: 1

Related Questions