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
"<comment>" 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.
This commit is contained in:
Ben Liblit 2018-04-17 11:00:05 -05:00
parent 89ffb96acf
commit 742cad58e9
3 changed files with 24 additions and 0 deletions

View File

@ -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

View File

@ -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]) {
}

View File

@ -1,3 +1,4 @@
# -*- mode: sh; sh-shell: sh -*-
./gradlew prepareMavenBuild
mvn clean verify -DskipTests=true -B -q