Skip to content

Commit 66f30ca

Browse files
chore: bump compile sdk (#1739)
* feat: settings.gradle plugin (#1731) * chore: bump compile sdk Co-authored-by: Ammar Ahmed <40239442+ammarahm-ed@users.noreply.github.com>
1 parent 3415e5c commit 66f30ca

File tree

2 files changed

+73
-2
lines changed

2 files changed

+73
-2
lines changed

build-artifacts/project-template-gradle/settings.gradle

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,74 @@ include ':app'//, ':runtime', ':runtime-binding-generator'
55
//project(':runtime-binding-generator').projectDir = new File("${System.env.ANDROID_RUNTIME_HOME}/test-app/runtime-binding-generator")
66

77
file("google-services.json").renameTo(file("./app/google-services.json"))
8+
9+
import org.gradle.internal.logging.text.StyledTextOutputFactory
10+
11+
import java.nio.file.Paths
12+
13+
import org.gradle.internal.logging.text.StyledTextOutputFactory
14+
import groovy.json.JsonSlurper
15+
import static org.gradle.internal.logging.text.StyledTextOutput.Style
16+
17+
def USER_PROJECT_ROOT = "$rootDir/../../"
18+
def outLogger = services.get(StyledTextOutputFactory).create("colouredOutputLogger")
19+
def ext = {
20+
appResourcesPath = getProperty("appResourcesPath")
21+
appPath = getProperty("appPath")
22+
}
23+
24+
def getAppPath = { ->
25+
def relativePathToApp = "app"
26+
def nsConfigFile = file("$USER_PROJECT_ROOT/nsconfig.json")
27+
def nsConfig
28+
29+
if (nsConfigFile.exists()) {
30+
nsConfig = new JsonSlurper().parseText(nsConfigFile.getText("UTF-8"))
31+
}
32+
33+
if (ext.appPath) {
34+
// when appPath is passed through -PappPath=/path/to/app
35+
// the path could be relative or absolute - either case will work
36+
relativePathToApp = ext.appPath
37+
} else if (nsConfig != null && nsConfig.appPath != null) {
38+
relativePathToApp = nsConfig.appPath
39+
}
40+
41+
return Paths.get(USER_PROJECT_ROOT).resolve(relativePathToApp).toAbsolutePath()
42+
}
43+
44+
45+
def getAppResourcesPath = { ->
46+
def relativePathToAppResources
47+
def absolutePathToAppResources
48+
def nsConfigFile = file("$USER_PROJECT_ROOT/nsconfig.json")
49+
def nsConfig
50+
51+
if (nsConfigFile.exists()) {
52+
nsConfig = new JsonSlurper().parseText(nsConfigFile.getText("UTF-8"))
53+
}
54+
if (ext.appResourcesPath) {
55+
// when appResourcesPath is passed through -PappResourcesPath=/path/to/App_Resources
56+
// the path could be relative or absolute - either case will work
57+
relativePathToAppResources = ext.appResourcesPath
58+
absolutePathToAppResources = Paths.get(USER_PROJECT_ROOT).resolve(relativePathToAppResources).toAbsolutePath()
59+
} else if (nsConfig != null && nsConfig.appResourcesPath != null) {
60+
relativePathToAppResources = nsConfig.appResourcesPath
61+
absolutePathToAppResources = Paths.get(USER_PROJECT_ROOT).resolve(relativePathToAppResources).toAbsolutePath()
62+
} else {
63+
absolutePathToAppResources = "${getAppPath()}/App_Resources"
64+
}
65+
return absolutePathToAppResources
66+
}
67+
68+
def applySettingsGradleConfiguration = { ->
69+
def appResourcesPath = getAppResourcesPath()
70+
def pathToSettingsGradle = "$appResourcesPath/Android/settings.gradle"
71+
def settingsGradle = file(pathToSettingsGradle)
72+
if (settingsGradle.exists()) {
73+
outLogger.withStyle(Style.SuccessHeader).println "\t + applying user-defined configuration from ${settingsGradle}"
74+
apply from: pathToSettingsGradle
75+
}
76+
}
77+
78+
applySettingsGradleConfiguration()

test-app/gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ android.enableJetifier=true
2020
android.useAndroidX=true
2121

2222
# Default versions used throughout the gradle configurations
23-
NS_DEFAULT_BUILD_TOOLS_VERSION=32.0.0
24-
NS_DEFAULT_COMPILE_SDK_VERSION=32
23+
NS_DEFAULT_BUILD_TOOLS_VERSION=33.0.0
24+
NS_DEFAULT_COMPILE_SDK_VERSION=33
2525
NS_DEFAULT_MIN_SDK_VERSION=17
2626
NS_DEFAULT_ANDROID_BUILD_TOOLS_VERSION=7.3.0
2727

0 commit comments

Comments
 (0)