From 742cad58e97a028bf4e884048462e6ad76ebbcd1 Mon Sep 17 00:00:00 2001 From: Ben Liblit Date: Tue, 17 Apr 2018 11:00:05 -0500 Subject: [PATCH] Use Gradle to create selected Eclipse metadata before Maven builds The Eclipse metadata files created in this way are not identical to those that Buildship would create when importing into Eclipse. The tests in com.ibm.wala.cast.java.test.JDTJava15IRTests and com.ibm.wala.cast.java.test.JDTJavaIRTests seem to pass using either the Gradle-generated or the Buildship-generated versions. As an aside, if you generate these files using Gradle first and *then* import using Buildship, you end up with metadata that is identical to what you would have had if you'd only imported with Buildship. (There's one irrelevant difference in an unimportant "" element.) So Maven's tests should run fine under any wacky mix of Gradle- and Buildship-generated Eclipse metadata files. That being said, I recommend not mixing build systems. WALA can be built using either Maven, Gradle, or Eclipse+Buildship, but you're probably better off only using one of these in any given build tree. A mixed tree *should* probably work, but I haven't tested it thoroughly, and consider better to avoid doing. Incidentally, if there are other Maven-preparation steps that we'd like Gradle to automate for us, that can now be done easily by creating more "prepareMavenBuild" Gradle tasks in other subprojects and adding the appropriate dependencies. For example, it would be trivial to use this to automate downloading "/tmp/DroidBench", installing the Android SDK, etc. --- README-Gradle.md | 10 ++++++++++ com.ibm.wala.cast.java.test.data/build.gradle | 13 +++++++++++++ travis/install-maven | 1 + 3 files changed, 24 insertions(+) diff --git a/README-Gradle.md b/README-Gradle.md index 8bc742e3d..ab712a9eb 100644 --- a/README-Gradle.md +++ b/README-Gradle.md @@ -39,6 +39,16 @@ things the Gradle way](#eclipse). Fortunately, this is rather seamless; I see no reason why an Eclipse-using WALA developer should need to avoid this switch. +As noted [below](#classpath-and-project-as-generated-files), Eclipse +`.classpath` and `.project` files are now generated rather than being +repository-tracked source files. However, a few Maven-run tests +depend on having certain of these files present. One way to create +them is to [import WALA into +Eclipse](#importing-wala-projects-into-eclipse) before starting your +Maven tests. If you prefer a non-interactive approach, you can +instead run `./gradlew prepareMavenBuild` before starting your Maven +tests. + # Getting Started ## External Dependencies: Patience is a Virtue diff --git a/com.ibm.wala.cast.java.test.data/build.gradle b/com.ibm.wala.cast.java.test.data/build.gradle index 6b3bcc0e9..62a55350f 100644 --- a/com.ibm.wala.cast.java.test.data/build.gradle +++ b/com.ibm.wala.cast.java.test.data/build.gradle @@ -1,3 +1,5 @@ +apply plugin: 'eclipse' + sourceSets.test.java.srcDirs = ['src'] @@ -18,3 +20,14 @@ task cleanDownloadJLex(type: Delete) { compileTestJava.dependsOn downloadJLex clean.dependsOn cleanDownloadJLex + + +//////////////////////////////////////////////////////////////////////// +// +// create Eclipse metadata for use by Maven when running +// com.ibm.wala.cast.java.test.JDTJavaIRTests and +// com.ibm.wala.cast.java.test.JDTJava15IRTests tests +// + +task prepareMavenBuild(dependsOn: [eclipseClasspath, eclipseProject]) { +} diff --git a/travis/install-maven b/travis/install-maven index 5977652b0..2796b95c2 100644 --- a/travis/install-maven +++ b/travis/install-maven @@ -1,3 +1,4 @@ # -*- mode: sh; sh-shell: sh -*- +./gradlew prepareMavenBuild mvn clean verify -DskipTests=true -B -q