xref: /aosp_15_r20/development/tools/idegen/README (revision 90c8c64db3049935a07c6143d7fd006e26f8ecca)
1*90c8c64dSAndroid Build Coastguard WorkerIDEGen automatically generates Android IDE configurations for IntelliJ IDEA
2*90c8c64dSAndroid Build Coastguard Workerand Eclipse. Your IDE should be able to compile everything in a reasonable
3*90c8c64dSAndroid Build Coastguard Workeramount of time with no errors.
4*90c8c64dSAndroid Build Coastguard Worker
5*90c8c64dSAndroid Build Coastguard WorkerIf you're using IntelliJ...
6*90c8c64dSAndroid Build Coastguard Worker
7*90c8c64dSAndroid Build Coastguard Worker    If this is your first time using IDEGen...
8*90c8c64dSAndroid Build Coastguard Worker
9*90c8c64dSAndroid Build Coastguard Worker        Android is large, thus IDEA needs a lot of memory. Add "-Xms1g -Xmx5g" to
10*90c8c64dSAndroid Build Coastguard Worker        your VM options in "Help > Edit Custom VM" and increase the
11*90c8c64dSAndroid Build Coastguard Worker        file size limit in "Help -> Edit custom properties" by adding
12*90c8c64dSAndroid Build Coastguard Worker        "idea.max.intellisense.filesize=100000". Make sure to restart the IDE for
13*90c8c64dSAndroid Build Coastguard Worker        the new settings to take effect.
14*90c8c64dSAndroid Build Coastguard Worker
15*90c8c64dSAndroid Build Coastguard Worker        Create a JDK configuration named "1.8 (No Libraries)" by adding a new
16*90c8c64dSAndroid Build Coastguard Worker        JDK like you normally would and then removing all of the jar entries
17*90c8c64dSAndroid Build Coastguard Worker        under the "Classpath" tab. This will ensure that you only get access to
18*90c8c64dSAndroid Build Coastguard Worker        Android's core libraries and not those from your desktop VM.
19*90c8c64dSAndroid Build Coastguard Worker
20*90c8c64dSAndroid Build Coastguard Worker    From the project's root directory...
21*90c8c64dSAndroid Build Coastguard Worker
22*90c8c64dSAndroid Build Coastguard Worker        Repeat these steps after each sync...
23*90c8c64dSAndroid Build Coastguard Worker
24*90c8c64dSAndroid Build Coastguard Worker        1) make (to produce generated .java source)
25*90c8c64dSAndroid Build Coastguard Worker        2) development/tools/idegen/idegen.sh
26*90c8c64dSAndroid Build Coastguard Worker        3) Open android.ipr in IntelliJ. If you already have the project open,
27*90c8c64dSAndroid Build Coastguard Worker           hit the sync button in IntelliJ, and it will automatically detect the
28*90c8c64dSAndroid Build Coastguard Worker           updated configuration.
29*90c8c64dSAndroid Build Coastguard Worker
30*90c8c64dSAndroid Build Coastguard Worker        If you get unexpected compilation errors from IntelliJ, try running
31*90c8c64dSAndroid Build Coastguard Worker        "Build -> Rebuild Project". Sometimes IntelliJ gets confused after the
32*90c8c64dSAndroid Build Coastguard Worker        project changes significantly.
33*90c8c64dSAndroid Build Coastguard Worker
34*90c8c64dSAndroid Build Coastguard WorkerIf you're using Eclipse...
35*90c8c64dSAndroid Build Coastguard Worker
36*90c8c64dSAndroid Build Coastguard Worker    If this is your first time using IDEGen...
37*90c8c64dSAndroid Build Coastguard Worker
38*90c8c64dSAndroid Build Coastguard Worker        Edit eclipse.ini ("Eclipse.app/Contents/MacOS/eclipse.ini" on OS X) and
39*90c8c64dSAndroid Build Coastguard Worker        add "-Xms748m -Xmx748m" to your VM options.
40*90c8c64dSAndroid Build Coastguard Worker
41*90c8c64dSAndroid Build Coastguard Worker        Configure a JRE named "1.7 (No Libraries)" under "Preferences -> Java ->
42*90c8c64dSAndroid Build Coastguard Worker        Installed JREs". Remove all of the jar entries underneath "JRE system
43*90c8c64dSAndroid Build Coastguard Worker        libraries". Eclipse will not let you save your configuration unless at
44*90c8c64dSAndroid Build Coastguard Worker        least one jar is present, so include a random jar that won't get in the
45*90c8c64dSAndroid Build Coastguard Worker        way.
46*90c8c64dSAndroid Build Coastguard Worker
47*90c8c64dSAndroid Build Coastguard Worker    From the project's root directory...
48*90c8c64dSAndroid Build Coastguard Worker
49*90c8c64dSAndroid Build Coastguard Worker        Repeat these steps after each sync...
50*90c8c64dSAndroid Build Coastguard Worker
51*90c8c64dSAndroid Build Coastguard Worker        1) make (to produce generated .java source)
52*90c8c64dSAndroid Build Coastguard Worker        2) development/tools/idegen/idegen.sh
53*90c8c64dSAndroid Build Coastguard Worker        3) Import the project root directory into your Eclipse workspace. If you
54*90c8c64dSAndroid Build Coastguard Worker           already have the project open, simply refresh it (F5).
55*90c8c64dSAndroid Build Coastguard Worker
56*90c8c64dSAndroid Build Coastguard WorkerExcluding source roots and jars
57*90c8c64dSAndroid Build Coastguard Worker
58*90c8c64dSAndroid Build Coastguard Worker    IDEGen keeps an exclusion list in the "excluded-paths" file. This file
59*90c8c64dSAndroid Build Coastguard Worker    has one regular expression per line that matches paths (relative to the
60*90c8c64dSAndroid Build Coastguard Worker    project root) that should be excluded from the IDE configuration. We
61*90c8c64dSAndroid Build Coastguard Worker    use Java's regular expression parser (see java.util.regex.Parser).
62*90c8c64dSAndroid Build Coastguard Worker
63*90c8c64dSAndroid Build Coastguard Worker    You can create your own additional exclusion list by creating an
64*90c8c64dSAndroid Build Coastguard Worker    "excluded-paths" file in the project's root directory or your vendor
65*90c8c64dSAndroid Build Coastguard Worker    directory. For example, you might exclude all apps except the Browser in your
66*90c8c64dSAndroid Build Coastguard Worker    IDE configuration with this regular expression: "^packages/apps/(?!Browser)".
67*90c8c64dSAndroid Build Coastguard Worker
68*90c8c64dSAndroid Build Coastguard WorkerControlling source root ordering (Eclipse)
69*90c8c64dSAndroid Build Coastguard Worker
70*90c8c64dSAndroid Build Coastguard Worker    You may want some source roots to come before others in Eclipse. Simply
71*90c8c64dSAndroid Build Coastguard Worker    create a file named "path-precedence" in your project's root directory.
72*90c8c64dSAndroid Build Coastguard Worker    Each line in the file is a regular expression that matches a source root
73*90c8c64dSAndroid Build Coastguard Worker    path (relative to the project's root directory). If a given source root's
74*90c8c64dSAndroid Build Coastguard Worker    path matches a regular expression that comes earlier in the file, that
75*90c8c64dSAndroid Build Coastguard Worker    source root will come earlier in the generated configuration. If a source
76*90c8c64dSAndroid Build Coastguard Worker    root doesn't match any of the expressions in the file, it will come last,
77*90c8c64dSAndroid Build Coastguard Worker    so you effectively have an implicit ".*" rule at the end of the file.
78*90c8c64dSAndroid Build Coastguard Worker
79*90c8c64dSAndroid Build Coastguard Worker    For example, if you want your applications's source root to come first,
80*90c8c64dSAndroid Build Coastguard Worker    you might add an expression like "^packages/apps/MyApp/src$" to the top
81*90c8c64dSAndroid Build Coastguard Worker    of the "path-precedence" file.  To make source roots under ./out come last,
82*90c8c64dSAndroid Build Coastguard Worker    add "^(?!out/)" (which matches all paths that don't start with "out/").
83