Skip to content

Commit d3ad544

Browse files
dellis1972jonpryor
authored andcommitted
[Xamarin.Android.Build.Tasks] Update CalculateProjectDependencies to match spec (#1323)
The `GetAndroidDependencies` target (f9b2c97) is intended to be called by an IDE on project-load, so that the IDE can install project dependencies "in the background," and ideally have the dependencies installed before the project is actually built. As such, the semantics of the `@(AndroidDependency)` output item group need to be agreed upon by xamarin-android, the IDEs, and whatever the IDEs use to actually install the dependencies. The `%(AndroidDependency.Identity)` values need to be well-defined and consistent across these three different libraries. In commit f9b2c97, certain values would have a version number "embedded" within `%(AndroidDependency.Identity)`, using a `;` to separate the name from the version, e.g. `build-tools;26.0.1`. Use of `;` was chosen because that made it easier for the package installation code to use (e.g. it would be identical to what the Android SDK `sdkmanager` utility expects). Unfortunately, the use of `;` was counter to the [spec][spec], and also looks "weird" in the context of MSBuild, as `;` is *also* the item group separator. Change the version separator to instead be a `/`. This "looks" better and is also consistent with the [installer manifest][manifest] schema that we will use, wherein `%(AndroidDependency.Identity)` matches a `//xamarin-android/*/@filesystem-path` attribute value: <xamarin-android sdk-version="0.0.0" generated-on="Tue, 20 Feb 2018 21:16:01 GMT"> <platform-tools filesystem-path="platform-tools" path="platform-tools" revision="27.0.1" manifest-url="https://dl.google.com/android/repository/repository2-1.xml" description="Android SDK Platform-Tools" obsolete="False" preview="False" license="android-sdk-license" original-type="generic:genericDetailsType"> <!-- ... --> </platform-tools> <build-tool filesystem-path="build-tools/27.0.3" path="build-tools;27.0.3" revision="27.0.3" manifest-url="https://dl.google.com/android/repository/repository2-1.xml" description="Android SDK Build-Tools 27.0.3" obsolete="False" preview="False" license="android-sdk-license" original-type="generic:genericDetailsType"> </build-tool> <!-- ... --> </xamarin-android> `@(AndroidDependency)` could be equivalent to: <ItemGroup> <AndroidDependency Include="build-tools/27.0.3"> <Version>27.0.3</Version> </AndroidDependency> <AndroidDependency Include="platform-tools"> <Version>$(AndroidSdkPlatformToolsVersion)</Version> </AndroidDependency> <AndroidDependency Include="platforms/android-27"> <Version>27</Version> </AndroidDependency> <AndroidDependency Include="tools"> <Version>$(AndroidSdkToolsVersion)</Version> </AndroidDependency> </ItemGroup> [manifest]: https://gist.github.com/dellis1972/08ba76cc19cdce3dec89c68684664299 [spec]: https://microsoft-my.sharepoint.com/:w:/r/personal/mhutch_microsoft_com/_layouts/15/WopiFrame.aspx?sourcedoc=%7B0436dd38-c9ff-4cf2-b33c-ee4515b68546%7D&action=edit&wdPid=64869a58
1 parent e489aae commit d3ad544

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/Xamarin.Android.Build.Tasks/Tasks/CalculateProjectDependencies.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ public override bool Execute ()
5151
manifestApiLevel = manifest.TargetSdkVersion ?? manifest.MinSdkVersion ?? DefaultMinSDKVersion;
5252
}
5353
var sdkVersion = Math.Max (targetApiLevel.Value, manifestApiLevel);
54-
dependencies.Add (CreateAndroidDependency ($"platforms;android-{sdkVersion}", $""));
55-
dependencies.Add (CreateAndroidDependency ($"build-tools;{BuildToolsVersion}", BuildToolsVersion));
54+
dependencies.Add (CreateAndroidDependency ($"platforms/android-{sdkVersion}", $""));
55+
dependencies.Add (CreateAndroidDependency ($"build-tools/{BuildToolsVersion}", BuildToolsVersion));
5656
if (!string.IsNullOrEmpty (PlatformToolsVersion)) {
5757
dependencies.Add (CreateAndroidDependency ("platform-tools", PlatformToolsVersion));
5858
}

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/GetDependenciesTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ public void CheckNdkBundle ([Values(true, false)] bool ndkRequred)
3737
Assert.IsTrue (task.Execute ());
3838
Assert.IsNotNull (task.Dependencies);
3939
Assert.AreEqual (ndkRequred ? 5 : 4, task.Dependencies.Length);
40-
Assert.IsNotNull (task.Dependencies.FirstOrDefault (x => x.ItemSpec == "build-tools;26.0.1" && x.GetMetadata ("Version") == "26.0.1"),
40+
Assert.IsNotNull (task.Dependencies.FirstOrDefault (x => x.ItemSpec == "build-tools/26.0.1" && x.GetMetadata ("Version") == "26.0.1"),
4141
"Dependencies should contains a build-tools version 26.0.1");
4242
Assert.IsNotNull (task.Dependencies.FirstOrDefault (x => x.ItemSpec == "tools" && x.GetMetadata ("Version") == "26.0.1"),
4343
"Dependencies should contains a tools version 26.0.1");
44-
Assert.IsNotNull (task.Dependencies.FirstOrDefault (x => x.ItemSpec == "platforms;android-26" && x.GetMetadata ("Version") == ""),
44+
Assert.IsNotNull (task.Dependencies.FirstOrDefault (x => x.ItemSpec == "platforms/android-26" && x.GetMetadata ("Version") == ""),
4545
"Dependencies should contains a platform version android-26");
4646
Assert.IsNotNull (task.Dependencies.FirstOrDefault (x => x.ItemSpec == "platform-tools" && x.GetMetadata ("Version") == "26.0.3"),
4747
"Dependencies should contains a platform-tools version 26.0.3");
@@ -77,11 +77,11 @@ public void ManifestFileDoesNotExist ()
7777
Assert.IsTrue (task.Execute ());
7878
Assert.IsNotNull (task.Dependencies);
7979
Assert.AreEqual (5, task.Dependencies.Length);
80-
Assert.IsNotNull (task.Dependencies.FirstOrDefault (x => x.ItemSpec == "build-tools;26.0.1" && x.GetMetadata ("Version") == "26.0.1"),
80+
Assert.IsNotNull (task.Dependencies.FirstOrDefault (x => x.ItemSpec == "build-tools/26.0.1" && x.GetMetadata ("Version") == "26.0.1"),
8181
"Dependencies should contains a build-tools version 26.0.1");
8282
Assert.IsNotNull (task.Dependencies.FirstOrDefault (x => x.ItemSpec == "tools" && x.GetMetadata ("Version") == "26.0.1"),
8383
"Dependencies should contains a tools version 26.0.1");
84-
Assert.IsNotNull (task.Dependencies.FirstOrDefault (x => x.ItemSpec == "platforms;android-26" && x.GetMetadata ("Version") == ""),
84+
Assert.IsNotNull (task.Dependencies.FirstOrDefault (x => x.ItemSpec == "platforms/android-26" && x.GetMetadata ("Version") == ""),
8585
"Dependencies should contains a platform version android-26");
8686
Assert.IsNotNull (task.Dependencies.FirstOrDefault (x => x.ItemSpec == "platform-tools" && x.GetMetadata ("Version") == "26.0.3"),
8787
"Dependencies should contains a platform-tools version 26.0.3");
@@ -120,11 +120,11 @@ public void ManifestFileExists ()
120120
Assert.IsTrue(task.Execute ());
121121
Assert.IsNotNull (task.Dependencies);
122122
Assert.AreEqual (5, task.Dependencies.Length);
123-
Assert.IsNotNull (task.Dependencies.FirstOrDefault (x => x.ItemSpec == "build-tools;26.0.1" && x.GetMetadata ("Version") == "26.0.1"),
123+
Assert.IsNotNull (task.Dependencies.FirstOrDefault (x => x.ItemSpec == "build-tools/26.0.1" && x.GetMetadata ("Version") == "26.0.1"),
124124
"Dependencies should contains a build-tools version 26.0.1");
125125
Assert.IsNotNull (task.Dependencies.FirstOrDefault (x => x.ItemSpec == "tools" && x.GetMetadata ("Version") == "26.0.1"),
126126
"Dependencies should contains a tools version 26.0.1");
127-
Assert.IsNotNull (task.Dependencies.FirstOrDefault (x => x.ItemSpec == "platforms;android-26" && x.GetMetadata ("Version") == ""),
127+
Assert.IsNotNull (task.Dependencies.FirstOrDefault (x => x.ItemSpec == "platforms/android-26" && x.GetMetadata ("Version") == ""),
128128
"Dependencies should contains a platform version android-26");
129129
Assert.IsNotNull (task.Dependencies.FirstOrDefault (x => x.ItemSpec == "platform-tools" && x.GetMetadata ("Version") == "26.0.3"),
130130
"Dependencies should contains a platform-tools version 26.0.3");

0 commit comments

Comments
 (0)