Skip to content

Commit 8d1bb33

Browse files
committed
Merge branch 'main' into dev/grendel/blobs-in-lib
* main: LEGO: Merge pull request 8665 [Xamarin.Android.Build.Tasks] parse JDK `release` file directly (#8663)
2 parents fa101bb + 2b2c6eb commit 8d1bb33

File tree

11 files changed

+179
-2
lines changed

11 files changed

+179
-2
lines changed

Localize/loc/cs/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx.lcl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,15 @@
765765
</Str>
766766
<Disp Icon="Str" />
767767
</Item>
768+
<Item ItemId=";XA1039" ItemType="0;.resx" PsrId="211" InstFlg="true" Leaf="true">
769+
<Str Cat="Text">
770+
<Val><![CDATA[The Android Support libraries are not supported in .NET 9 and later, please migrate to AndroidX. See https://aka.ms/xamarin/androidx for more details.]]></Val>
771+
<Tgt Cat="Text" Stat="Loc" Orig="New">
772+
<Val><![CDATA[Knihovny podpory pr Android se v .NET 9 a novějších verzích nepodporují. Migrujte prosím na AndroidX. Další podrobnosti najdete v https://aka.ms/xamarin/androidx.]]></Val>
773+
</Tgt>
774+
</Str>
775+
<Disp Icon="Str" />
776+
</Item>
768777
<Item ItemId=";XA2000" ItemType="0;.resx" PsrId="211" InstFlg="true" Leaf="true">
769778
<Str Cat="Text">
770779
<Val><![CDATA[Use of AppDomain.CreateDomain() detected in assembly: {0}. .NET 6 and higher will only support a single AppDomain, so this API will no longer be available in .NET Android once .NET 6 is released.]]></Val>

Localize/loc/es/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx.lcl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,15 @@
765765
</Str>
766766
<Disp Icon="Str" />
767767
</Item>
768+
<Item ItemId=";XA1039" ItemType="0;.resx" PsrId="211" InstFlg="true" Leaf="true">
769+
<Str Cat="Text">
770+
<Val><![CDATA[The Android Support libraries are not supported in .NET 9 and later, please migrate to AndroidX. See https://aka.ms/xamarin/androidx for more details.]]></Val>
771+
<Tgt Cat="Text" Stat="Loc" Orig="New">
772+
<Val><![CDATA[Las bibliotecas de compatibilidad con Android no se admiten en .NET 9 y versiones posteriores. Migre a AndroidX. Consulte https://aka.ms/xamarin/androidx para obtener más detalles.]]></Val>
773+
</Tgt>
774+
</Str>
775+
<Disp Icon="Str" />
776+
</Item>
768777
<Item ItemId=";XA2000" ItemType="0;.resx" PsrId="211" InstFlg="true" Leaf="true">
769778
<Str Cat="Text">
770779
<Val><![CDATA[Use of AppDomain.CreateDomain() detected in assembly: {0}. .NET 6 and higher will only support a single AppDomain, so this API will no longer be available in .NET Android once .NET 6 is released.]]></Val>

Localize/loc/fr/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx.lcl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,15 @@
765765
</Str>
766766
<Disp Icon="Str" />
767767
</Item>
768+
<Item ItemId=";XA1039" ItemType="0;.resx" PsrId="211" InstFlg="true" Leaf="true">
769+
<Str Cat="Text">
770+
<Val><![CDATA[The Android Support libraries are not supported in .NET 9 and later, please migrate to AndroidX. See https://aka.ms/xamarin/androidx for more details.]]></Val>
771+
<Tgt Cat="Text" Stat="Loc" Orig="New">
772+
<Val><![CDATA[Les bibliothèques Android Support ne sont pas prises en charge dans .NET 9 et les versions ultérieures, veuillez migrer vers AndroidX. Pour plus d’informations, consultez https://aka.ms/xamarin/androidx.]]></Val>
773+
</Tgt>
774+
</Str>
775+
<Disp Icon="Str" />
776+
</Item>
768777
<Item ItemId=";XA2000" ItemType="0;.resx" PsrId="211" InstFlg="true" Leaf="true">
769778
<Str Cat="Text">
770779
<Val><![CDATA[Use of AppDomain.CreateDomain() detected in assembly: {0}. .NET 6 and higher will only support a single AppDomain, so this API will no longer be available in .NET Android once .NET 6 is released.]]></Val>

Localize/loc/it/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx.lcl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,15 @@
765765
</Str>
766766
<Disp Icon="Str" />
767767
</Item>
768+
<Item ItemId=";XA1039" ItemType="0;.resx" PsrId="211" InstFlg="true" Leaf="true">
769+
<Str Cat="Text">
770+
<Val><![CDATA[The Android Support libraries are not supported in .NET 9 and later, please migrate to AndroidX. See https://aka.ms/xamarin/androidx for more details.]]></Val>
771+
<Tgt Cat="Text" Stat="Loc" Orig="New">
772+
<Val><![CDATA[Le librerie di supporto Android non sono supportate in .NET 9 e versioni successive. Esegui la migrazione ad AndroidX. Per altri dettagli, vedi https://aka.ms/xamarin/androidx.]]></Val>
773+
</Tgt>
774+
</Str>
775+
<Disp Icon="Str" />
776+
</Item>
768777
<Item ItemId=";XA2000" ItemType="0;.resx" PsrId="211" InstFlg="true" Leaf="true">
769778
<Str Cat="Text">
770779
<Val><![CDATA[Use of AppDomain.CreateDomain() detected in assembly: {0}. .NET 6 and higher will only support a single AppDomain, so this API will no longer be available in .NET Android once .NET 6 is released.]]></Val>

Localize/loc/ko/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx.lcl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,15 @@
765765
</Str>
766766
<Disp Icon="Str" />
767767
</Item>
768+
<Item ItemId=";XA1039" ItemType="0;.resx" PsrId="211" InstFlg="true" Leaf="true">
769+
<Str Cat="Text">
770+
<Val><![CDATA[The Android Support libraries are not supported in .NET 9 and later, please migrate to AndroidX. See https://aka.ms/xamarin/androidx for more details.]]></Val>
771+
<Tgt Cat="Text" Stat="Loc" Orig="New">
772+
<Val><![CDATA[Android 지원 라이브러리는 .NET 9 이상에서 지원되지 않습니다. AndroidX로 마이그레이션하세요. 자세한 내용은 https://aka.ms/xamarin/androidx 페이지를 참조하세요.]]></Val>
773+
</Tgt>
774+
</Str>
775+
<Disp Icon="Str" />
776+
</Item>
768777
<Item ItemId=";XA2000" ItemType="0;.resx" PsrId="211" InstFlg="true" Leaf="true">
769778
<Str Cat="Text">
770779
<Val><![CDATA[Use of AppDomain.CreateDomain() detected in assembly: {0}. .NET 6 and higher will only support a single AppDomain, so this API will no longer be available in .NET Android once .NET 6 is released.]]></Val>

Localize/loc/pl/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx.lcl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,15 @@
765765
</Str>
766766
<Disp Icon="Str" />
767767
</Item>
768+
<Item ItemId=";XA1039" ItemType="0;.resx" PsrId="211" InstFlg="true" Leaf="true">
769+
<Str Cat="Text">
770+
<Val><![CDATA[The Android Support libraries are not supported in .NET 9 and later, please migrate to AndroidX. See https://aka.ms/xamarin/androidx for more details.]]></Val>
771+
<Tgt Cat="Text" Stat="Loc" Orig="New">
772+
<Val><![CDATA[Biblioteki pomocy technicznej systemu Android nie są obsługiwane na platformie .NET 9 i nowszych. Przeprowadź migrację do systemu AndroidX. Aby uzyskać więcej informacji, zobacz https://aka.ms/xamarin/androidx.]]></Val>
773+
</Tgt>
774+
</Str>
775+
<Disp Icon="Str" />
776+
</Item>
768777
<Item ItemId=";XA2000" ItemType="0;.resx" PsrId="211" InstFlg="true" Leaf="true">
769778
<Str Cat="Text">
770779
<Val><![CDATA[Use of AppDomain.CreateDomain() detected in assembly: {0}. .NET 6 and higher will only support a single AppDomain, so this API will no longer be available in .NET Android once .NET 6 is released.]]></Val>

Localize/loc/tr/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx.lcl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,15 @@
765765
</Str>
766766
<Disp Icon="Str" />
767767
</Item>
768+
<Item ItemId=";XA1039" ItemType="0;.resx" PsrId="211" InstFlg="true" Leaf="true">
769+
<Str Cat="Text">
770+
<Val><![CDATA[The Android Support libraries are not supported in .NET 9 and later, please migrate to AndroidX. See https://aka.ms/xamarin/androidx for more details.]]></Val>
771+
<Tgt Cat="Text" Stat="Loc" Orig="New">
772+
<Val><![CDATA[Android Destek kitaplıkları .NET 9 ve sonraki sürümlerde desteklenmiyor, lütfen AndroidX'e geçin. Daha fazla ayrıntı için https://aka.ms/xamarin/androidx adresini ziyaret edin.]]></Val>
773+
</Tgt>
774+
</Str>
775+
<Disp Icon="Str" />
776+
</Item>
768777
<Item ItemId=";XA2000" ItemType="0;.resx" PsrId="211" InstFlg="true" Leaf="true">
769778
<Str Cat="Text">
770779
<Val><![CDATA[Use of AppDomain.CreateDomain() detected in assembly: {0}. .NET 6 and higher will only support a single AppDomain, so this API will no longer be available in .NET Android once .NET 6 is released.]]></Val>

Localize/loc/zh-Hans/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx.lcl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,15 @@
765765
</Str>
766766
<Disp Icon="Str" />
767767
</Item>
768+
<Item ItemId=";XA1039" ItemType="0;.resx" PsrId="211" InstFlg="true" Leaf="true">
769+
<Str Cat="Text">
770+
<Val><![CDATA[The Android Support libraries are not supported in .NET 9 and later, please migrate to AndroidX. See https://aka.ms/xamarin/androidx for more details.]]></Val>
771+
<Tgt Cat="Text" Stat="Loc" Orig="New">
772+
<Val><![CDATA[.NET 9 及更高版本不支持 Android 支持库,请迁移到 AndroidX。有关详细信息,请参阅 https://aka.ms/xamarin/androidx。]]></Val>
773+
</Tgt>
774+
</Str>
775+
<Disp Icon="Str" />
776+
</Item>
768777
<Item ItemId=";XA2000" ItemType="0;.resx" PsrId="211" InstFlg="true" Leaf="true">
769778
<Str Cat="Text">
770779
<Val><![CDATA[Use of AppDomain.CreateDomain() detected in assembly: {0}. .NET 6 and higher will only support a single AppDomain, so this API will no longer be available in .NET Android once .NET 6 is released.]]></Val>

src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.Tooling.targets

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ This file contains .NET 6+ calls to the <ValidateJavaVersion/> and
1616
<UsingTask TaskName="Xamarin.Android.Tasks.ValidateJavaVersion" AssemblyFile="$(_XamarinAndroidBuildTasksAssembly)" />
1717

1818
<Target Name="_ResolveAndroidTooling">
19+
<PropertyGroup>
20+
<_AndroidUseJavaExeVersion Condition=" '$(_AndroidUseJavaExeVersion)' == '' ">false</_AndroidUseJavaExeVersion>
21+
</PropertyGroup>
1922
<ValidateJavaVersion
2023
Condition=" '$(DesignTimeBuild)' != 'True' Or '$(AndroidUseManagedDesignTimeResourceGenerator)' != 'True' "
2124
ContinueOnError="$(_AndroidAllowMissingSdkTooling)"
@@ -24,7 +27,8 @@ This file contains .NET 6+ calls to the <ValidateJavaVersion/> and
2427
JavacToolExe="$(JavacToolExe)"
2528
TargetPlatformVersion="$(TargetPlatformVersion)"
2629
LatestSupportedJavaVersion="$(LatestSupportedJavaVersion)"
27-
MinimumSupportedJavaVersion="$(MinimumSupportedJavaVersion)">
30+
MinimumSupportedJavaVersion="$(MinimumSupportedJavaVersion)"
31+
UseJavaExeVersion="$(_AndroidUseJavaExeVersion)">
2832
<Output TaskParameter="JdkVersion" PropertyName="_JdkVersion" />
2933
<Output TaskParameter="MinimumRequiredJdkVersion" PropertyName="_DefaultJdkVersion" />
3034
</ValidateJavaVersion>

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

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ public class ValidateJavaVersion : AndroidTask
2929
[Required]
3030
public string MinimumSupportedJavaVersion { get; set; }
3131

32+
/// <summary>
33+
/// If true use the old method of calling `java -version` and `javac -version`
34+
/// $(_AndroidUseJavaExeVersion) is passed in from MSBuild targets and defaults to false.
35+
/// </summary>
36+
public bool UseJavaExeVersion { get; set; } = true;
37+
3238
[Output]
3339
public string MinimumRequiredJdkVersion { get; set; }
3440

@@ -63,7 +69,7 @@ bool ValidateJava ()
6369
var javac = JavacToolExe ?? (OS.IsWindows ? "javac.exe" : "javac");
6470

6571
return ValidateJava (java, JavaVersionRegex) &&
66-
ValidateJava (javac, JavacVersionRegex);
72+
(!UseJavaExeVersion || ValidateJava (javac, JavacVersionRegex));
6773
}
6874

6975
protected virtual bool ValidateJava (string javaExe, Regex versionRegex)
@@ -97,6 +103,12 @@ protected virtual bool ValidateJava (string javaExe, Regex versionRegex)
97103

98104
protected Version GetVersionFromTool (string javaExe, Regex versionRegex)
99105
{
106+
// New code path, reads directly from `release` text file
107+
if (!UseJavaExeVersion && GetVersionFromFile (javaExe, out var version)) {
108+
JdkVersion = version.ToString ();
109+
return version;
110+
}
111+
100112
// NOTE: this doesn't need to use GetRegisteredTaskObjectAssemblyLocal()
101113
// because the path to java/javac is the key and the value is a System.Version.
102114
var javaTool = Path.Combine (JavaSdkPath, "bin", javaExe);
@@ -128,5 +140,42 @@ protected Version GetVersionFromTool (string javaExe, Regex versionRegex)
128140
return null;
129141
}
130142
}
143+
144+
bool GetVersionFromFile (string javaExe, out Version version)
145+
{
146+
var path = Path.Combine (Path.GetDirectoryName (javaExe), "..", "release");
147+
if (!File.Exists (path)) {
148+
path = Path.Combine (JavaSdkPath, "release");
149+
}
150+
if (!File.Exists (path)) {
151+
Log.LogDebugMessage ($"{path} does not exist, falling back to `java -version`");
152+
version = new ();
153+
return false;
154+
}
155+
156+
using var stream = File.OpenRead (path);
157+
using var reader = new StreamReader (stream);
158+
159+
string line;
160+
while ((line = reader.ReadLine ()) != null) {
161+
const string JAVA_VERSION = "JAVA_VERSION=\"";
162+
int index = line.IndexOf (JAVA_VERSION, StringComparison.OrdinalIgnoreCase);
163+
if (index != -1) {
164+
var versionString = line.Substring (index + JAVA_VERSION.Length);
165+
index = versionString.IndexOf ('"');
166+
if (index != -1) {
167+
versionString = versionString.Substring (0, index);
168+
}
169+
if (Version.TryParse (versionString, out version)) {
170+
Log.LogDebugMessage ($"{path} contains JAVA_VERSION.");
171+
return true;
172+
}
173+
}
174+
}
175+
176+
Log.LogDebugMessage ($"{path} did not contain a valid JAVA_VERSION.");
177+
version = new ();
178+
return false;
179+
}
131180
}
132181
}

0 commit comments

Comments
 (0)