LppEdd
LppEdd

Reputation: 21134

Change external annotations location in IDEA 2019.3+

IntelliJ IDEA lets you add external annotations.

enter image description here

However, the files go straight into the project's root directory.

enter image description here

How do I change the folder?
I can't find a setting.

Upvotes: 4

Views: 1033

Answers (2)

LppEdd
LppEdd

Reputation: 21134

This behavior is extremely confusing, and took me a long IDEA debug session to understand.
Let's say we start with a clean situation, and we add an external Annotation to a method of a library.

enter image description here

A popup appears, letting us choose the external Annotations root directory.

enter image description here

And we choose untitled3, the project's root directory. But ops, we made a mistake!
Now how can we change this directory? Where is it stored?
Well, actually not under any $projectRoot$/.idea/* XML file...

Let's debug IDEA. The "call" hierarchy is:

> AnnotateIntentionAction
  > AddAnnotationPsiFix#invoke
    > ExternalAnnotationsManagerImpl#annotateExternally

The last method annotateExternally calls AnnotationOrderRootType.getFiles(entry), where entry is a LibraryOrderEntry.

enter image description here

Here orderEntry.getRootFiles(getInstance()) gets called and the resulting VirtualFile(s) are used as library's external Annotations roots.

Where are they stored?

Project Example

> Project structure
   > Modules
     > *your main module*
       > Paths
         > External Annotations <DELETE HERE>

Gradle Library Example

> Project structure
  > Modules
    > *your main module with dependencies*
      > *your library*
        > DOUBLE LEFT CLICK

enter image description here

Now press CANC over the Annotations entry.


And you're done... Finally. You can restart over.

Upvotes: 3

Olga Klisho
Olga Klisho

Reputation: 1394

You may drag'n'drop the annotations.xml file in the Project pane and move it to the desired location or change the path explicitly in Project Structure | Project Settings | Modules -> module Paths | External Annotations

Upvotes: 0

Related Questions