From 1ac4ca94758bc41e9f094248c0b126f01e45c662 Mon Sep 17 00:00:00 2001 From: Ben Liblit Date: Thu, 12 Jul 2018 13:53:37 -0500 Subject: [PATCH] Tweaks and instructions for WALA as an IntelliJ IDEA project We already had some IntelliJ IDEA project metadata files in ".idea". I've revisited and updated those now that I have more experience with Gradle + IntelliJ IDEA + Git. I think this now represents a better set of decisions regarding what does and does not belong in version control. This commit also extends "README-Gradle.md" with clear instructions on how to bringup WALA as a top-level IntelliJ IDEA project. The instructions are of a similar flavor to the Eclipse instructions that were already present, though the details vary. Most notably, with IntelliJ IDEA you should *open* WALA as an existing project, not *import* it as a new Gradle project derived from "build.gradle". This is exactly the reverse of what one should and shouldn't do for WALA in Eclipse. --- .idea/.gitignore | 7 ++- .idea/.name | 1 - .idea/gradle.xml | 51 +++++++++++++++++ .../After_Opening_Pristine_Project.xml | 20 +++++++ .idea/vcs.xml | 2 +- README-Gradle.md | 57 +++++++++++++++++++ build.gradle | 2 +- com.ibm.wala.cast.test/build.gradle | 2 +- com.ibm.wala.dalvik.test/build.gradle | 2 +- 9 files changed, 137 insertions(+), 7 deletions(-) delete mode 100644 .idea/.name create mode 100644 .idea/gradle.xml create mode 100644 .idea/runConfigurations/After_Opening_Pristine_Project.xml diff --git a/.idea/.gitignore b/.idea/.gitignore index 72de84271..65f86d623 100644 --- a/.idea/.gitignore +++ b/.idea/.gitignore @@ -1,3 +1,6 @@ -/gradle.xml -/modules +*.iml +/libraries/*.xml +/modules.xml +/tasks.xml +/usage.statistics.xml /workspace.xml diff --git a/.idea/.name b/.idea/.name deleted file mode 100644 index f15c23b30..000000000 --- a/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -com.ibm.wala \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 000000000..147050681 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,51 @@ + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations/After_Opening_Pristine_Project.xml b/.idea/runConfigurations/After_Opening_Pristine_Project.xml new file mode 100644 index 000000000..c3277521c --- /dev/null +++ b/.idea/runConfigurations/After_Opening_Pristine_Project.xml @@ -0,0 +1,20 @@ + + + + + + + + + diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 94a25f7f4..35eb1ddfb 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/README-Gradle.md b/README-Gradle.md index ab712a9eb..e2f26e400 100644 --- a/README-Gradle.md +++ b/README-Gradle.md @@ -141,6 +141,63 @@ plugin](https://docs.gradle.org/current/userguide/eclipse_plugin.html). A few WALA sub-projects already use this: look for `eclipse.project` in `*/build.gradle` for examples. +## IntelliJ IDEA + +### Opening WALA in IntelliJ IDEA + +WALA comes preconfigured as an openable IntelliJ IDEA project. Open +the top-level WALA directory as a project; it should have a +distinctive badge on its folder icon marking it as a directory +containing a recognized IntelliJ IDEA project. Do *not* open the +top-level WALA `build.gradle` in that directory as a project: this +will begin an “Import Project from Gradle” process that is *not* the +recommended way to bring WALA up in IntelliJ IDEA. + +The first time you open the WALA project, IntelliJ IDEA will +synchronize its project model with the Gradle build configuration, +including downloading some large supporting libraries. After the +lengthy import process completes, **use “Run → Run… → After Opening +Pristine Project” to perform some post-import configuration.** This +also can take tens of minutes, but is only necessary in a clean, +never-previously-built tree. Immediately after importing, you may see +some Java compilation errors in the IntelliJ IDEA “Messages” view. +These should all go away after running the “After Opening Pristine +Project” step. [Be +patient](#external-dependencies-patience-is-a-virtue) during the +initial project open and also during the “After Opening Pristine +Project” step, especially if you have a slow network connection. + +If you prefer a non-interactive approach, instead of using “After +Opening Pristine Project” you can run `./gradlew prepareIntelliJIDEA` +either before or after opening WALA in IntelliJ IDEA. + +### Benign Warning About Non-Managed Maven Project + +Each time you open the WALA project, IntelliJ IDEA may report +“Non-managed pom.xml file found” in its event log. This arises +because WALA supports both Gradle and Maven, but WALA in IntelliJ IDEA +needs only the Gradle configuration. You can safely ignore this +notification, permanently disable it using the offered “Disable +notification” link, or even disable the IntelliJ IDEA Maven plugin +entirely if you have no other need for it. + +### Project Configuration as Derived Model + +IntelliJ IDEA automatically derives its project models from the Gradle +build configuration, including all information about both internal and +external build dependencies. However, this synchronization only goes +in one direction: from Gradle to IntelliJ IDEA, not from IntelliJ IDEA +back into Gradle. If you manipulate the project structure using the +IntelliJ IDEA’s user interface, your changes will likely be +overwritten the next time IntelliJ IDEA scans the Gradle build +configuration. + +This particularly applies to settings found in the “Modules” and +“Libraries” sections of the “Project Structure” dialog. The right way +to change module and library settings is to change the Gradle +configuration such that the *derived* IntelliJ IDEA model is what you +want it to be. + ## Gradle Command Line You do not need to install Gradle separately. **WALA includes its own diff --git a/build.gradle b/build.gradle index 2756fe90e..50fc956e0 100644 --- a/build.gradle +++ b/build.gradle @@ -78,7 +78,7 @@ subprojects { subproject -> jar.manifest.from('META-INF/MANIFEST.MF') task afterEclipseBuildshipImport(dependsOn: processTestResources) - task afterIntelliJIDEAOpen + task prepareIntelliJIDEA test { include '**/*Test.class' diff --git a/com.ibm.wala.cast.test/build.gradle b/com.ibm.wala.cast.test/build.gradle index 0c2d4f35a..0ce96cbc5 100644 --- a/com.ibm.wala.cast.test/build.gradle +++ b/com.ibm.wala.cast.test/build.gradle @@ -6,7 +6,7 @@ plugins { } eclipse.project.natures 'org.eclipse.pde.PluginNature' -afterIntelliJIDEAOpen.dependsOn jarTest +prepareIntelliJIDEA.dependsOn jarTest sourceSets.test.java.srcDirs = ['harness-src/java'] diff --git a/com.ibm.wala.dalvik.test/build.gradle b/com.ibm.wala.dalvik.test/build.gradle index 7cbae0395..8aacf1445 100644 --- a/com.ibm.wala.dalvik.test/build.gradle +++ b/com.ibm.wala.dalvik.test/build.gradle @@ -93,7 +93,7 @@ clean.dependsOn cleanCopyDxJar compileTestJava.dependsOn copyDxJar afterEclipseBuildshipImport.dependsOn copyDxJar -afterIntelliJIDEAOpen.dependsOn copyDxJar +prepareIntelliJIDEA.dependsOn copyDxJar task copyAndroidJar(type: Sync, dependsOn: installAndroidSdk) { from "${installAndroidSdk.destinationDir}/platforms/${installAndroidSdk.components['platforms']}/android.jar"