Skip to content

Commit 797f53b

Browse files
authored
fix: Fixed Failed to find the closing bracket for custom gradle files (#1359)
1 parent f751732 commit 797f53b

5 files changed

Lines changed: 69 additions & 2 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Fixes
66

7+
- Fixed an issue triggering an error `Failed to find the closing bracket` when using custom gradle files ([#1359](https://github.com/getsentry/sentry-unity/pull/1359))
78
- Fixes Android native integration in the gradle output project for builds with Unity 2022.3 and newer ([#1354](https://github.com/getsentry/sentry-unity/pull/1354))
89

910
### Dependencies

‎src/Sentry.Unity.Editor/Android/GradleSetup.cs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,13 @@ private static int FindClosingBracket(string[] lines, int startIndex)
134134

135135
for (var i = startIndex + 1; i < lines.Length; i++)
136136
{
137-
if (lines[i].Contains("{"))
137+
var line = lines[i];
138+
if (line.Contains("{"))
138139
{
139140
openBrackets++;
140141
}
141-
else if (lines[i].Contains("}"))
142+
143+
if (line.Contains("}"))
142144
{
143145
if (openBrackets == 0)
144146
{

‎test/Sentry.Unity.Editor.Tests/Android/GradleSetupTests.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ public void ClearGradleProject_GradleFilesModified_RemovesModification(string un
120120
[TestCase("build.gradle_test_2.txt", "build.gradle_test_2_expected.txt")]
121121
[TestCase("build.gradle_test_3.txt", "build.gradle_test_3_expected.txt")]
122122
[TestCase("build.gradle_test_4.txt", "build.gradle_test_4_expected.txt")]
123+
[TestCase("build.gradle_test_5.txt", "build.gradle_test_5_expected.txt")]
123124
public void InsertIntoScope_ResultMatchesExpected(string testCaseFileName, string testCaseExpectedFileName)
124125
{
125126
var assemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
allprojects {
2+
buildscript {
3+
repositories {**ARTIFACTORYREPOSITORY**
4+
google()
5+
jcenter()
6+
maven { url 'https://plugins.gradle.org/m2/' }
7+
}
8+
9+
dependencies {
10+
// If you are changing the Android Gradle Plugin version, make sure it is compatible with the Gradle version preinstalled with Unity
11+
// See which Gradle version is preinstalled with Unity here https://docs.unity3d.com/Manual/android-gradle-overview.html
12+
// See official Gradle and Android Gradle Plugin compatibility table here https://developer.android.com/studio/releases/gradle-plugin#updating-gradle
13+
// To specify a custom Gradle version in Unity, go do "Preferences > External Tools", uncheck "Gradle Installed with Unity (recommended)" and specify a path to a custom Gradle version
14+
classpath 'com.android.tools.build:gradle:4.0.0'
15+
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.6, 0.99.99]'
16+
**BUILD_SCRIPT_DEPS**
17+
}
18+
}
19+
20+
repositories {**ARTIFACTORYREPOSITORY**
21+
google()
22+
jcenter()
23+
flatDir {
24+
dirs "${project(':unityLibrary').projectDir}/libs"
25+
}
26+
}
27+
}
28+
29+
task clean(type: Delete) {
30+
delete rootProject.buildDir
31+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
allprojects {
2+
buildscript {
3+
repositories {**ARTIFACTORYREPOSITORY**
4+
google()
5+
jcenter()
6+
maven { url 'https://plugins.gradle.org/m2/' }
7+
}
8+
9+
dependencies {
10+
// If you are changing the Android Gradle Plugin version, make sure it is compatible with the Gradle version preinstalled with Unity
11+
// See which Gradle version is preinstalled with Unity here https://docs.unity3d.com/Manual/android-gradle-overview.html
12+
// See official Gradle and Android Gradle Plugin compatibility table here https://developer.android.com/studio/releases/gradle-plugin#updating-gradle
13+
// To specify a custom Gradle version in Unity, go do "Preferences > External Tools", uncheck "Gradle Installed with Unity (recommended)" and specify a path to a custom Gradle version
14+
classpath 'com.android.tools.build:gradle:4.0.0'
15+
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.6, 0.99.99]'
16+
**BUILD_SCRIPT_DEPS**
17+
}
18+
}
19+
20+
repositories {**ARTIFACTORYREPOSITORY**
21+
maven { url "${project(':unityLibrary').projectDir}/android-sdk-repository" }
22+
google()
23+
jcenter()
24+
flatDir {
25+
dirs "${project(':unityLibrary').projectDir}/libs"
26+
}
27+
}
28+
}
29+
30+
task clean(type: Delete) {
31+
delete rootProject.buildDir
32+
}

0 commit comments

Comments
 (0)