Skip to content
This repository was archived by the owner on Feb 11, 2020. It is now read-only.

Commit 7fe40cc

Browse files
committed
Use compose version 20190806
1 parent 7ec2fa3 commit 7fe40cc

File tree

4 files changed

+91
-52
lines changed

4 files changed

+91
-52
lines changed

app/build.gradle

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,15 @@ android {
3636

3737
dependencies {
3838
implementation fileTree(dir: "libs", include: ["*.jar"])
39-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.30"
39+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
40+
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
4041
implementation "androidx.appcompat:appcompat:1.0.0"
4142
implementation "androidx.core:core-ktx:1.0.2"
42-
implementation "androidx.compose:compose-runtime:1.0.0-alpha01"
43+
implementation "androidx.compose:compose-runtime:$ui_version"
4344

44-
implementation "androidx.ui:ui-framework:1.0.0-alpha01"
45-
implementation "androidx.ui:ui-material:1.0.0-alpha01"
46-
implementation "androidx.ui:ui-layout:1.0.0-alpha01"
45+
implementation "androidx.ui:ui-framework:$ui_version"
46+
implementation "androidx.ui:ui-material:$ui_version"
47+
implementation "androidx.ui:ui-layout:$ui_version"
4748

4849
testImplementation "junit:junit:4.12"
4950
androidTestImplementation "androidx.test:runner:1.1.1"

build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22
buildscript {
3-
ext.kotlin_version = "1.3.30-compose-20190520"
3+
ext.kotlin_version = "1.3.50-compose-20190806"
4+
ext.ui_version = "0.1.0-dev01"
45
ext.androidx_home = project.properties["androidx.home"] ?: "$projectDir/androidx_prebuilts"
56
repositories {
67
maven { url "$androidx_home/out/ui/build/support_repo/" }

studio_versions.properties

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
1-
# This file specifies the version of the Android Gradle Plugin and Android Studio to use
2-
3-
# version properties for studiow, which should correspond to the version of AGP
1+
# AGP override for the UI project. Normally we should be using the same version of AGP that is used
2+
# in AndroidX as a whole, but since we are currently using a separate studio build, we sometimes
3+
# end up updating one before the other. If this is specified, both ./studiow and ./gradlew will
4+
# use this version of AGP instead.
5+
#
6+
# If empty, the version of AGP from AndroidX will be used instead.
7+
#
8+
# Example value for this is: 3.5.0-beta05
9+
agp_override=3.5.0-beta05
10+
# Version properties for ./studiow, which should correspond to the version of AGP used either in
11+
# AndroidX, or specified above if overridden.
412
studio_version=3.5.0.13
513
idea_major_version=191
6-
studio_build_number=5677133
14+
idea_minor_version=7479.19.35
15+
studio_build_number=9626933

studiow

Lines changed: 70 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
#!/bin/bash
22
set -e
3+
set -m
34

45
# This is a wrapper script that runs the specific version of Android Studio that is recommended for developing in this repository.
56
# (This serves a similar purpose to gradlew)
7+
#
8+
# NOTE: if you are changing this file, consider applying the changes to ../studiow, used for the main AndroidX project.
69

710

8-
function getStudioUrl() {
9-
propertiesFile="${scriptDir}/studio_versions.properties"
11+
function getPrebuiltStudioZipPath() {
1012
version="$(grep "studio_version=" ${propertiesFile} | sed 's/[^=]*=//')"
1113
ideaMajorVersion="$(grep "idea_major_version=" ${propertiesFile} | sed 's/[^=]*=//')"
1214
buildNumber="$(grep "studio_build_number=" ${propertiesFile} | sed 's/[^=]*=//')"
@@ -16,8 +18,8 @@ function getStudioUrl() {
1618
else
1719
extension="zip"
1820
fi
19-
studioUrl="https://dl.google.com/dl/android/studio/ide-zips/${version}/android-studio-ide-${ideaMajorVersion}.${buildNumber}-${osName}.${extension}"
20-
echo "${studioUrl}"
21+
22+
echo "${scriptDir}/androidx_prebuilts/androidx/studio/android-studio-ide-${ideaMajorVersion}.${buildNumber}-${osName}.${extension}"
2123
}
2224

2325
acceptsLicenseAgreement="$1"
@@ -35,10 +37,20 @@ function getOsName() {
3537
echo "${osName}"
3638
}
3739
osName="$(getOsName)"
38-
studioUrl="$(getStudioUrl $osName)"
39-
studioDestName="$(basename ${studioUrl})"
40-
studioZipPath="${tempDir}/${studioDestName}"
41-
studioUnzippedPath="$(echo ${studioZipPath} | sed 's/\.zip$//' | sed 's/\.tar.gz$//')"
40+
propertiesFile="${scriptDir}/studio_versions.properties"
41+
prebuiltStudioZipPath="$(getPrebuiltStudioZipPath $osName)"
42+
studioDestName="$(basename ${prebuiltStudioZipPath})"
43+
studioUnzippedPath="${tempDir}/${studioDestName}"
44+
studioUnzippedPath="$(echo ${studioUnzippedPath} | sed 's/\.zip$//' | sed 's/\.tar.gz$//')"
45+
46+
# The version of AGP we should override with - may be empty if we should just use the default
47+
# version specified in AndroidX. See ui/studio_versions.properties.
48+
agp_override="$(grep "agp_override=" ${propertiesFile} | sed 's/[^=]*=//')"
49+
50+
# Set the env variable if we have a valid version to override with, else noop
51+
GRADLE_PLUGIN_VERSION_OVERRIDE=""
52+
[ ! -z "$agp_override" ] && GRADLE_PLUGIN_VERSION_OVERRIDE="GRADLE_PLUGIN_VERSION=${agp_override}"
53+
4254

4355
function error_exit {
4456
echo "$1" >&2 ## Send message to stderr.
@@ -115,6 +127,16 @@ function checkLicenseAgreement() {
115127
fi
116128
}
117129

130+
# Temporary fix. Remove this after fixing b/135183535
131+
function updateJvmHeapSize() {
132+
if [ "${osName}" == "mac" ]; then
133+
sed -i '' 's/-Xmx.*/-Xmx8g/' "$(findStudioMacAppPath)/Contents/bin/studio.vmoptions"
134+
else
135+
sed -i 's/-Xmx.*/-Xmx8g/' "${studioUnzippedPath}/android-studio/bin/studio64.vmoptions"
136+
sed -i 's/-Xmx.*/-Xmx4g/' "${studioUnzippedPath}/android-studio/bin/studio.vmoptions"
137+
fi
138+
}
139+
118140
function updateStudio() {
119141
# skip if already up-to-date
120142
if stat "${studioUnzippedPath}" >/dev/null 2>/dev/null; then
@@ -123,73 +145,79 @@ function updateStudio() {
123145
fi
124146

125147
mkdir -p "${tempDir}"
126-
downloadFile "${studioUrl}" "${studioZipPath}"
127-
echo
128148

129149
echo "Removing previous installations"
130150
ls "${tempDir}" | grep -v "^${studioDestName}\$" | sed "s|^|${tempDir}/|" | xargs rm -rf
131151

132152
echo "Unzipping"
133153
if [ "${osName}" == "linux" ]; then
134154
mkdir $studioUnzippedPath
135-
tar -xzf "${studioZipPath}" --directory "${studioUnzippedPath}"
155+
tar -xzf "${prebuiltStudioZipPath}" --directory "${studioUnzippedPath}"
136156
else
137-
unzip "${studioZipPath}" -d "${studioUnzippedPath}"
157+
unzip "${prebuiltStudioZipPath}" -d "${studioUnzippedPath}"
138158
fi
139159
}
140160

141-
function ensureComposeAt() {
142-
pluginPath=$1
143-
copyOption=$2
144-
idePluginJar="$pluginPath/r4a-ide-plugin.jar"
145-
compilerPluginJar="$pluginPath/r4a-compiler-plugin.jar"
146-
compilerPluginJarOutput="androidx_prebuilts/out/ui/build/support_repo/androidx/compose/compose-plugin-cli/1.0.0-alpha01/compose-plugin-cli-1.0.0-alpha01.jar"
147-
idePluginJarOutput="androidx_prebuilts/out/ui/build/support_repo/androidx/compose/compose-plugin-ide/1.0.0-alpha01/compose-plugin-ide-1.0.0-alpha01.jar"
148-
if [ ! -e "$idePluginJarOutput" ] || [ ! -e "$compilerPluginJarOutput" ]
149-
then
150-
echo "Building compose plugin"
151-
./gradlew :compose-plugin-ide:assemble :compose-plugin-cli:ideVersion
161+
# Copies the built compose-ide-plugin to the plugin directory of the studio installation. This
162+
# ensures that the compose plugin is used at startup
163+
function updateComposeIdePlugin() {
164+
if [ "${osName}" == "mac" ]; then
165+
composeIdePluginDirectory="$(findStudioMacAppPath)/Contents/plugins/compose-ide-plugin/"
166+
else
167+
composeIdePluginDirectory="${studioUnzippedPath}/android-studio/plugins/"
152168
fi
153-
cp $copyOption "$compilerPluginJarOutput" "$compilerPluginJar"
154-
cp $copyOption "$idePluginJarOutput" "$idePluginJar"
155-
}
169+
# this is the idea sandbox directory that the compose ide plugin is located in
170+
composePluginDirectory="${projectDir}/androidx_prebuilts/out/ui/compose/compose-ide-plugin/build/idea-sandbox/plugins/compose-ide-plugin/"
156171

157-
function ensureComposeLinux() {
158-
ensureComposeAt "${studioUnzippedPath}/android-studio/plugins/Kotlin/lib" "-u"
159-
}
160-
161-
function ensureComposeMac() {
162-
ensureComposeAt "$(findStudioMacAppPath)/Contents/plugins/Kotlin/lib"
172+
echo ""
173+
echo "Copying compose-ide-plugin to $composeIdePluginDirectory"
174+
echo ""
175+
mkdir -p "${composeIdePluginDirectory}"
176+
cp -f -R "${composePluginDirectory}" "${composeIdePluginDirectory}"
163177
}
164178

165179
function ensureCompose() {
166-
# ensure compose plugin is up-to-date
167-
if [ "${osName}" == "mac" ]; then
168-
ensureComposeMac
169-
else
170-
ensureComposeLinux
171-
fi
180+
# This gradle command will prepare a sandbox directory that we can point studio to that will
181+
# have all of the correct structure to load the compose plugin
182+
${scriptDir}/gradlew -p ${projectDir} :compose:compose-ide-plugin:prepareSandbox
172183
}
173184

185+
# ANDROID_LINT_NULLNESS_IGNORE_DEPRECATED environment variable prevents Studio from showing IDE
186+
# inspection warnings for nullability issues, if the context is deprecated
187+
# This environment variable is consumed by InteroperabilityDetector.kt
188+
174189
function runStudioLinux() {
175190
studioPath="${studioUnzippedPath}/android-studio/bin/studio.sh"
176-
echo "$studioPath &"
191+
updateComposeIdePlugin
192+
193+
echo ""
194+
echo "Launching Studio"
195+
# Override AGP version overridden because compose studio is behind androidx studio
177196
env STUDIO_PROPERTIES="${projectDir}/idea.properties" \
178197
STUDIO_VM_OPTIONS="${projectDir}/../development/studio/studio.vmoptions" \
179-
KOTLIN_OVERRIDE="1.3.30-compose-20190503" \
198+
ANDROID_LINT_NULLNESS_IGNORE_DEPRECATED="true" \
199+
KOTLIN_OVERRIDE="1.3.50-compose-20190806" \
200+
$GRADLE_PLUGIN_VERSION_OVERRIDE \
180201
"${studioPath}" "${projectDir}" &
181202
}
182203

183204
function runStudioMac() {
184205
appPath="$(findStudioMacAppPath)"
185-
echo "open ${appPath}"
206+
updateComposeIdePlugin
207+
208+
echo ""
209+
echo "Launching Studio"
210+
# Override AGP version overridden because compose studio is behind androidx studio
186211
env STUDIO_PROPERTIES="${projectDir}/idea.properties" \
187212
STUDIO_VM_OPTIONS="${projectDir}/../development/studio/studio.vmoptions" \
188-
KOTLIN_OVERRIDE="1.3.30-compose-20190503" \
213+
ANDROID_LINT_NULLNESS_IGNORE_DEPRECATED="true" \
214+
KOTLIN_OVERRIDE="1.3.50-compose-20190806" \
215+
$GRADLE_PLUGIN_VERSION_OVERRIDE \
189216
open -a "${appPath}" "${projectDir}"
190217
}
191218

192219
function runStudio() {
220+
updateJvmHeapSize
193221
if [ "${osName}" == "mac" ]; then
194222
runStudioMac
195223
else

0 commit comments

Comments
 (0)