Skip to content

Commit 1805c2b

Browse files
author
Stewart Miles
committed
Baked version into each plugin and surfaced via settings menus.
Bug: 132072231 Change-Id: I4d6de053e515ff94cff4b86b08366d323b45b046
1 parent 7746d37 commit 1805c2b

10 files changed

+178
-4
lines changed

build.gradle

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,10 +575,41 @@ Task createXbuildTask(String taskName, String taskDescription,
575575
Iterable<File> outputFilesInBinaryOutputDir = outputFiles.collect {
576576
return new File(binaryOutputDir, it.path)
577577
}
578+
Iterable<Task> dependsOnTasks = dependsOn ? dependsOn : []
579+
Iterable<Task> patchVersionFilesTasks = inputFiles.findResults {
580+
if (it.name == "VersionNumber.cs") {
581+
File versionFile = it
582+
Task patchVersionTask = tasks.create(
583+
name: taskName + "AddVersionTo" + it.name,
584+
description: "Add version to " + it.path,
585+
type: Task,
586+
dependsOn: dependsOnTasks)
587+
patchVersionTask.with {
588+
inputs.files files([versionFile])
589+
outputs.files files([versionFile])
590+
doLast {
591+
String[] lines = versionFile.text.split("\n")
592+
List<String> outputLines = lines.collect {
593+
it.replaceAll(
594+
/(^.*VERSION_STRING[ ]*=[ ]*\")([^\"]+)(\".*)/,
595+
'$1' + project.ext.pluginVersion + '$3')
596+
}
597+
String patchedFileString = (outputLines.join("\n") + "\n")
598+
if (versionFile.text != patchedFileString) {
599+
print("Patch " + versionFile.name)
600+
versionFile.write(patchedFileString)
601+
}
602+
}
603+
}
604+
return patchVersionTask
605+
}
606+
}
578607
Task task = tasks.create(name: taskName,
579608
description: taskDescription,
580609
type: Exec,
581-
dependsOn: dependsOn ? dependsOn : []).with {
610+
dependsOn: patchVersionFilesTasks ?
611+
patchVersionFilesTasks :
612+
dependsOnTasks).with {
582613
inputs.files inputFiles
583614
outputs.files files(outputFilesInBinaryOutputDir)
584615
executable project.ext.xbuildExe

source/IOSResolver/IOSResolver.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
<ItemGroup>
6969
<Compile Include="src\IOSResolver.cs" />
7070
<Compile Include="src\IOSResolverSettingsDialog.cs" />
71+
<Compile Include="src\VersionNumber.cs" />
7172
<Compile Include="Properties\AssemblyInfo.cs" />
7273
</ItemGroup>
7374
<ItemGroup>

source/IOSResolver/src/IOSResolverSettingsDialog.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
namespace Google {
1818

19+
using System;
1920
using System.IO;
2021
using UnityEditor;
2122
using UnityEngine;
@@ -93,7 +94,7 @@ private static int FindIndexFromCocoapodsIntegrationMethod(
9394
}
9495

9596
public void Initialize() {
96-
minSize = new Vector2(400, 370);
97+
minSize = new Vector2(400, 360);
9798
position = new Rect(UnityEngine.Screen.width / 3, UnityEngine.Screen.height / 3,
9899
minSize.x, minSize.y);
99100
}
@@ -115,6 +116,10 @@ public void OnEnable() {
115116
public void OnGUI() {
116117
GUI.skin.label.wordWrap = true;
117118
GUILayout.BeginVertical();
119+
GUILayout.Label(String.Format("iOS Resolver (version {0}.{1}.{2})",
120+
IOSResolverVersionNumber.Value.Major,
121+
IOSResolverVersionNumber.Value.Minor,
122+
IOSResolverVersionNumber.Value.Build));
118123

119124
GUILayout.BeginHorizontal();
120125
GUILayout.Label("Podfile Generation", EditorStyles.boldLabel);
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// <copyright file="VersionNumber.cs" company="Google Inc.">
2+
// Copyright (C) 2019 Google Inc. All Rights Reserved.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
// </copyright>
16+
17+
namespace Google {
18+
using System;
19+
20+
using UnityEditor;
21+
22+
/// <summary>
23+
/// Get the version number of this plugin.
24+
/// </summary>
25+
public class IOSResolverVersionNumber {
26+
27+
/// <summary>
28+
/// Version number, patched by the build process.
29+
/// </summary>
30+
private const string VERSION_STRING = "1.2.108.0";
31+
32+
/// <summary>
33+
/// Cached version structure.
34+
/// </summary>
35+
private static Version value = new Version(VERSION_STRING);
36+
37+
/// <summary>
38+
/// Get the version number.
39+
/// </summary>
40+
public static Version Value { get { return value; } }
41+
}
42+
}

source/PlayServicesResolver/PlayServicesResolver.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
<Compile Include="src\SettingsDialog.cs" />
7070
<Compile Include="src\TextAreaDialog.cs" />
7171
<Compile Include="src\UnityCompat.cs" />
72+
<Compile Include="src\VersionNumber.cs" />
7273
<Compile Include="src\XmlDependencies.cs" />
7374
<Compile Include="..\JarResolverLib\src\Google.JarResolver\Dependency.cs">
7475
<Link>Google.JarResolver\Dependency.cs</Link>

source/PlayServicesResolver/src/SettingsDialog.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ internal static string ValidatePackageDir(string directory) {
243243
}
244244

245245
public void Initialize() {
246-
minSize = new Vector2(425, 445);
246+
minSize = new Vector2(425, 455);
247247
position = new Rect(UnityEngine.Screen.width / 3, UnityEngine.Screen.height / 3,
248248
minSize.x, minSize.y);
249249
}
@@ -262,6 +262,10 @@ public void OnEnable() {
262262
public void OnGUI() {
263263
GUI.skin.label.wordWrap = true;
264264
GUILayout.BeginVertical();
265+
GUILayout.Label(String.Format("Android Resolver (version {0}.{1}.{2})",
266+
AndroidResolverVersionNumber.Value.Major,
267+
AndroidResolverVersionNumber.Value.Minor,
268+
AndroidResolverVersionNumber.Value.Build));
265269

266270
GUILayout.BeginHorizontal();
267271
GUILayout.Label("Use Gradle Daemon", EditorStyles.boldLabel);
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// <copyright file="VersionNumber.cs" company="Google Inc.">
2+
// Copyright (C) 2019 Google Inc. All Rights Reserved.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
// </copyright>
16+
17+
namespace Google {
18+
using System;
19+
20+
using UnityEditor;
21+
22+
/// <summary>
23+
/// Get the version number of this plugin.
24+
/// </summary>
25+
public class AndroidResolverVersionNumber {
26+
27+
/// <summary>
28+
/// Version number, patched by the build process.
29+
/// </summary>
30+
private const string VERSION_STRING = "1.2.108.0";
31+
32+
/// <summary>
33+
/// Cached version structure.
34+
/// </summary>
35+
private static Version value = new Version(VERSION_STRING);
36+
37+
/// <summary>
38+
/// Get the version number.
39+
/// </summary>
40+
public static Version Value { get { return value; } }
41+
}
42+
}

source/VersionHandlerImpl/VersionHandlerImpl.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
<Compile Include="src\ProjectSettings.cs" />
5959
<Compile Include="src\RunOnMainThread.cs" />
6060
<Compile Include="src\SettingsDialog.cs" />
61+
<Compile Include="src\VersionNumber.cs" />
6162
<Compile Include="src\VersionHandlerImpl.cs" />
6263
<Compile Include="src\XmlUtilities.cs" />
6364
<Compile Include="Properties\AssemblyInfo.cs" />

source/VersionHandlerImpl/src/SettingsDialog.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
namespace Google {
1818

19+
using System;
1920
using UnityEditor;
2021
using UnityEngine;
2122

@@ -98,7 +99,7 @@ private void LoadSettings() {
9899
/// Setup the window's initial position and size.
99100
/// </summary>
100101
public void Initialize() {
101-
minSize = new Vector2(300, 250);
102+
minSize = new Vector2(300, 265);
102103
position = new Rect(UnityEngine.Screen.width / 3,
103104
UnityEngine.Screen.height / 3,
104105
minSize.x, minSize.y);
@@ -117,6 +118,10 @@ public void OnEnable() {
117118
public void OnGUI() {
118119
GUI.skin.label.wordWrap = true;
119120
GUILayout.BeginVertical();
121+
GUILayout.Label(String.Format("Version Handler (version {0}.{1}.{2})",
122+
VersionHandlerVersionNumber.Value.Major,
123+
VersionHandlerVersionNumber.Value.Minor,
124+
VersionHandlerVersionNumber.Value.Build));
120125

121126
GUILayout.BeginHorizontal();
122127
GUILayout.Label("Enable version management", EditorStyles.boldLabel);
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// <copyright file="VersionNumber.cs" company="Google Inc.">
2+
// Copyright (C) 2019 Google Inc. All Rights Reserved.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
// </copyright>
16+
17+
namespace Google {
18+
using System;
19+
20+
using UnityEditor;
21+
22+
/// <summary>
23+
/// Get the version number of this plugin.
24+
/// </summary>
25+
public class VersionHandlerVersionNumber {
26+
27+
/// <summary>
28+
/// Version number, patched by the build process.
29+
/// </summary>
30+
private const string VERSION_STRING = "1.2.108.0";
31+
32+
/// <summary>
33+
/// Cached version structure.
34+
/// </summary>
35+
private static Version value = new Version(VERSION_STRING);
36+
37+
/// <summary>
38+
/// Get the version number.
39+
/// </summary>
40+
public static Version Value { get { return value; } }
41+
}
42+
}

0 commit comments

Comments
 (0)