Skip to content

Commit c71b234

Browse files
committed
Small review changes.
1 parent 37f7159 commit c71b234

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

Documentation/guides/AndroidMavenLibrary.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ This will do two things at build time:
2121
- Download the Java [artifact](https://central.sonatype.com/artifact/com.squareup.okhttp3/okhttp/4.9.3) with group id `com.squareup.okhttp3`, artifact id `okhttp`, and version `4.9.3` from [Maven Central](https://central.sonatype.com/) to a local cache (if not already cached).
2222
- Add the cached package to the .NET Android bindings build as an [`<AndroidLibrary>`](https://github.com/xamarin/xamarin-android/blob/main/Documentation/guides/building-apps/build-items.md#androidlibrary).
2323

24+
Note that only the requested Java artifact is added to the .NET Android bindings build. Any artifact dependencies are not added. If the requested artifact has dependencies, they must be fulfilled individually.
25+
2426
### Options
2527

2628
`<AndroidMavenLibrary>` defaults to using Maven Central, however it should support any Maven repository that does not require authentication. This can be controlled with the `Repository` attribute.

src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Bindings.Maven.targets

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ This file contains MSBuild targets used to enable @(AndroidMavenLibrary) support
1313

1414
<PropertyGroup>
1515
<!-- Maven cache directory, locations copied from XBD which should be sufficiently battle-tested -->
16-
<MavenCacheDirectory Condition="'$(OS)'=='Unix' and '$(MavenCacheDirectory)'==''">$(HOME)\Library\Caches\MavenCacheDirectory\</MavenCacheDirectory>
17-
<MavenCacheDirectory Condition="'$(OS)'!='Unix' and '$(MavenCacheDirectory)'==''">$(LocalAppData)\MavenCacheDirectory\</MavenCacheDirectory>
16+
<MavenCacheDirectory Condition="'$(OS)'=='Unix' and '$(MavenCacheDirectory)'==''">$(HOME)/Library/Caches/dotnet-android/MavenCacheDirectory/</MavenCacheDirectory>
17+
<MavenCacheDirectory Condition="'$(OS)'!='Unix' and '$(MavenCacheDirectory)'==''">$(LocalAppData)\dotnet-android\MavenCacheDirectory\</MavenCacheDirectory>
1818
<MavenCacheDirectory Condition="'$(MavenCacheDirectory)' != '' and !HasTrailingSlash('$(MavenCacheDirectory)')">$(MavenCacheDirectory)\</MavenCacheDirectory>
1919
</PropertyGroup>
2020

src/Xamarin.Android.Build.Tasks/Utilities/MavenExtensions.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ namespace Xamarin.Android.Tasks;
1818
static class MavenExtensions
1919
{
2020
static readonly char [] separator = [':'];
21+
static XmlSerializer pom_serializer = new XmlSerializer (typeof (Project));
2122

2223
/// <summary>
2324
/// Shortcut for !string.IsNullOrWhiteSpace (s)
@@ -27,7 +28,7 @@ static class MavenExtensions
2728
// Helps to 'foreach' into a possibly null array
2829
public static T [] OrEmpty<T> (this T []? value)
2930
{
30-
return value ?? Enumerable.Empty<T> ().ToArray ();
31+
return value ?? Array.Empty<T> ();
3132
}
3233

3334
public static Artifact? ParseArtifact (string id, string version, TaskLoggingHelper log)
@@ -48,10 +49,8 @@ public static Project ParsePom (string pomFile)
4849
{
4950
Project result = null;
5051

51-
var serializer = new XmlSerializer (typeof (Project));
52-
5352
using (var sr = File.OpenRead (pomFile))
54-
result = (Project) serializer.Deserialize (new XmlTextReader (sr) {
53+
result = (Project) pom_serializer.Deserialize (new XmlTextReader (sr) {
5554
Namespaces = false,
5655
});
5756

0 commit comments

Comments
 (0)