Bug 1123416 - 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.
--- a/.hgignore
+++ b/.hgignore
@@ -50,16 +50,19 @@
# Ignore the files and directory that Eclipse IDE creates
\.project$
\.cproject$
\.settings/
# Ignore the directory that JetBrains IDEs create
\.idea/
+# 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
@@ -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/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.