From 858148e91b07630d64e360deda3fee164d318782 Mon Sep 17 00:00:00 2001 From: Ben Liblit Date: Sun, 8 Jul 2018 18:17:06 -0500 Subject: [PATCH] Reorganize how we deal with shared JavaScript test examples When IntelliJ IDEA imports WALA's Gradle configuration, it creates what is calls a "module" for each sourceSet of each Gradle subproject. In so doing, it automatically picks up the source and resource directories used by each of these sourceSets. Unfortunately, IntelliJ IDEA does not allow multiple modules to share a single root directory as their source or resource directories, and that's exactly what was going on with the "example-src" subdirectory under "com.ibm.wala.cast.js.test.data". This revised Gradle configuration still has is copying the necessary "example-src" resources to the appropriate locations for use as test resources. But IntelliJ IDEA no longer treats "example-src" as a root directory for resources in the automatically-generated modules. So now we get along nicer with IntelliJ IDEA while keeping everything working with Gradle as well. --- build.gradle | 1 - com.ibm.wala.cast.js.html.nu_validator/build.gradle | 11 +++++++---- com.ibm.wala.cast.js.rhino.test/build.gradle | 11 +++++++---- com.ibm.wala.cast.js.test.data/build.gradle | 6 +++--- com.ibm.wala.cast.js.test/build.gradle | 11 ++++++----- 5 files changed, 23 insertions(+), 17 deletions(-) diff --git a/build.gradle b/build.gradle index 2bfe0fc7c..2756fe90e 100644 --- a/build.gradle +++ b/build.gradle @@ -57,7 +57,6 @@ version '1.5.0-SNAPSHOT' subprojects { subproject -> // skip generic Java setup for the few projects that have no Java code whatsoever switch (subproject.name) { - case 'com.ibm.wala.cast.js.test.data': case 'com.ibm.wala-repository': case ~/.*_feature/: return diff --git a/com.ibm.wala.cast.js.html.nu_validator/build.gradle b/com.ibm.wala.cast.js.html.nu_validator/build.gradle index aa1a76da1..08fc0b6b8 100644 --- a/com.ibm.wala.cast.js.html.nu_validator/build.gradle +++ b/com.ibm.wala.cast.js.html.nu_validator/build.gradle @@ -1,9 +1,6 @@ sourceSets { main.java.srcDirs = ['src'] - test { - java.srcDirs = ['tests'] - resources.srcDirs = [project(':com.ibm.wala.cast.js.test.data').file('examples-src')] - } + test.java.srcDirs = ['tests'] } dependencies { @@ -21,6 +18,12 @@ dependencies { ) } +processTestResources { + def data = project(':com.ibm.wala.cast.js.test.data') + dependsOn data.processTestResources + from data.sourceSets.test.resources +} + test { maxHeapSize = '800M' } diff --git a/com.ibm.wala.cast.js.rhino.test/build.gradle b/com.ibm.wala.cast.js.rhino.test/build.gradle index 44c9f1677..21ad888b3 100644 --- a/com.ibm.wala.cast.js.rhino.test/build.gradle +++ b/com.ibm.wala.cast.js.rhino.test/build.gradle @@ -2,10 +2,7 @@ plugins { id 'com.github.hauner.jarTest' } -sourceSets.test { - java.srcDirs = ['harness-src'] - resources.srcDirs = [project(':com.ibm.wala.cast.js.test.data').file('examples-src')] -} +sourceSets.test.java.srcDirs = ['harness-src'] dependencies { testCompile( @@ -22,6 +19,12 @@ dependencies { ) } +processTestResources { + def data = project(':com.ibm.wala.cast.js.test.data') + dependsOn data.processTestResources + from data.sourceSets.test.resources +} + test { environment 'TRAVIS', 1 maxHeapSize = '800M' diff --git a/com.ibm.wala.cast.js.test.data/build.gradle b/com.ibm.wala.cast.js.test.data/build.gradle index 0f3d1ad90..89232a1e8 100644 --- a/com.ibm.wala.cast.js.test.data/build.gradle +++ b/com.ibm.wala.cast.js.test.data/build.gradle @@ -1,6 +1,4 @@ -plugins { - id 'base' -} +sourceSets.test.resources.srcDirs = ['examples-src'] task downloadAjaxslt(type: VerifiedDownload) { def version = '0.8.1' @@ -21,3 +19,5 @@ task unpackAjaxslt(type: Sync, dependsOn: downloadAjaxslt) { } clean.dependsOn cleanUnpackAjaxslt + +processTestResources.dependsOn(unpackAjaxslt) diff --git a/com.ibm.wala.cast.js.test/build.gradle b/com.ibm.wala.cast.js.test/build.gradle index 350c43d03..37007296f 100644 --- a/com.ibm.wala.cast.js.test/build.gradle +++ b/com.ibm.wala.cast.js.test/build.gradle @@ -2,10 +2,7 @@ plugins { id 'com.github.hauner.jarTest' } -sourceSets.test { - java.srcDirs = ['harness-src'] - resources.srcDirs = [project(':com.ibm.wala.cast.js.test.data').file('examples-src')] -} +sourceSets.test.java.srcDirs = ['harness-src'] dependencies { testCompile( @@ -21,7 +18,11 @@ dependencies { ) } -processTestResources.dependsOn ':com.ibm.wala.cast.js.test.data:unpackAjaxslt' +processTestResources { + def data = project(':com.ibm.wala.cast.js.test.data') + dependsOn data.processTestResources + from data.sourceSets.test.resources +} test { maxHeapSize = '800M'