Bug 1123416 - Part 1: Make topsrcdir a valid Gradle project root. r=sebastian
authorNick Alexander <nalexander@mozilla.com>
Wed, 21 Oct 2015 15:07:55 -0700
changeset 268853 3fa48c9d205bc6628b74caf93716338935b48689
parent 268852 396f9bde9b49a56c98721479afaa884b93406436
child 268854 fe2090d75defeed0132976b20b2f9d31a9d073eb
push id15804
push usernalexander@mozilla.com
push dateThu, 22 Oct 2015 02:21:45 +0000
treeherderfx-team@9b249dc7978b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian
bugs1123416
milestone44.0a1
Bug 1123416 - Part 1: Make topsrcdir a valid Gradle project root. r=sebastian The sub-project definitions are still in the object directory (and still installed by |mach gradle-install); over time, we'll migrate them out. The Gradle wrapper and {settings,build}.gradle in topsrcdir are identical to those in mobile/android/gradle. I don't like the duplication, but I also don't want the burden of keeping the two configurations identical. We'll move away from the configuration using mobile/android/gradle as quickly as we can.
.hgignore
build.gradle
gradle/wrapper/gradle-wrapper.jar
gradle/wrapper/gradle-wrapper.properties
gradlew
mobile/android/gradle/build.gradle
settings.gradle
--- a/.hgignore
+++ b/.hgignore
@@ -47,18 +47,22 @@
 # SVN directories
 \.svn/
 
 # Ignore the files and directory that Eclipse IDE creates
 \.project$
 \.cproject$
 \.settings/
 
-# Ignore the directory that JetBrains IDEs create
+# Ignore the files and directory that JetBrains IDEs create.
 \.idea/
+\.iml$
+
+# Gradle cache.
+^.gradle/
 
 # Python stuff installed at build time.
 ^python/psutil/.*\.so
 ^python/psutil/.*\.pyd
 ^python/psutil/build/
 
 # Git repositories
 .git/
copy from mobile/android/gradle/build.gradle
copy to build.gradle
--- a/mobile/android/gradle/build.gradle
+++ b/build.gradle
@@ -8,27 +8,27 @@ allprojects {
         topobjdir = gradle.mozconfig.topobjdir
     }
 
     repositories {
         jcenter()
     }
 }
 
-buildDir "${topobjdir}/mobile/android/gradle/build"
+buildDir "${topobjdir}/gradle/build"
 
 buildscript {
     repositories {
         jcenter()
 
         // For spoon-gradle-plugin SNAPSHOT release.  This needs to go before
         // the snapshots repository, otherwise we find a remote 1.0.3-SNAPSHOT
         // that doesn't include nalexander's local changes.
         maven {
-            url "file://${topsrcdir}/mobile/android/gradle/m2repo"
+            url "file://${gradle.mozconfig.topsrcdir}/mobile/android/gradle/m2repo"
         }
         // For spoon SNAPSHOT releases.
         maven {
             url 'https://oss.sonatype.org/content/repositories/snapshots'
         }
     }
 
     dependencies {
copy from mobile/android/gradle/gradle/wrapper/gradle-wrapper.jar
copy to gradle/wrapper/gradle-wrapper.jar
copy from mobile/android/gradle/gradle/wrapper/gradle-wrapper.properties
copy to gradle/wrapper/gradle-wrapper.properties
copy from mobile/android/gradle/gradlew
copy to gradlew
--- a/mobile/android/gradle/build.gradle
+++ b/mobile/android/gradle/build.gradle
@@ -18,17 +18,17 @@ buildDir "${topobjdir}/mobile/android/gr
 buildscript {
     repositories {
         jcenter()
 
         // For spoon-gradle-plugin SNAPSHOT release.  This needs to go before
         // the snapshots repository, otherwise we find a remote 1.0.3-SNAPSHOT
         // that doesn't include nalexander's local changes.
         maven {
-            url "file://${topsrcdir}/mobile/android/gradle/m2repo"
+            url "file://${gradle.mozconfig.topsrcdir}/mobile/android/gradle/m2repo"
         }
         // For spoon SNAPSHOT releases.
         maven {
             url 'https://oss.sonatype.org/content/repositories/snapshots'
         }
     }
 
     dependencies {
copy from mobile/android/gradle/settings.gradle
copy to settings.gradle
--- a/mobile/android/gradle/settings.gradle
+++ b/settings.gradle
@@ -1,17 +1,11 @@
-// If our root project is in the object directory, we expect to be given
-// topsrcdir from our environment via gradle.properties.  If we don't get it,
-// our root project is in the source directory, so we extract topsrcdir relative
-// to the location of this script.
-if (!hasProperty('topsrcdir')) {
-    // In the source directory, we're not worried about links crossing directories.
-    binding.variables['topsrcdir'] = new File("../../..").getCanonicalPath()
-    logger.warn("topsrcdir is undefined: assuming source directory Gradle invocation with topsrcdir=${topsrcdir}.")
-}
+// You might think topsrcdir is '.', but that's not true when the Gradle build
+// is launched from within IntelliJ.
+def topsrcdir = rootProject.projectDir.absolutePath
 
 def commandLine = ["${topsrcdir}/mach", "environment", "--format", "json", "--verbose"]
 def proc = commandLine.execute(null, new File(topsrcdir))
 def standardOutput = new ByteArrayOutputStream()
 proc.consumeProcessOutput(standardOutput, standardOutput)
 proc.waitFor()
 
 // Only show the output if something went wrong.