diff --git a/Documentation/docs-mobile/messages/index.md b/Documentation/docs-mobile/messages/index.md index 236cebd6193..bd4aea4ad92 100644 --- a/Documentation/docs-mobile/messages/index.md +++ b/Documentation/docs-mobile/messages/index.md @@ -133,7 +133,7 @@ or 'Help->Report a Problem' in Visual Studio for Mac. + XA1018: Specified AndroidManifest file does not exist: {file}. + XA1019: No longer emitted by current SDKs. + XA1020: At least one Java library is required for binding. Check that a Java library is included in the project and has the appropriate build action: 'LibraryProjectZip' (for AAR or ZIP), 'EmbeddedJar', 'InputJar' (for JAR), or 'LibraryProjectProperties' (project.properties). -+ XA1021: Specified source Java library not found: {file} ++ XA1021: No longer emitted by current SDKs. + XA1022: Specified reference Java library not found: {file} + [XA1023](xa1023.md): Using the DX DEX Compiler is deprecated. + XA1024: Removed in .NET 11. @@ -353,14 +353,11 @@ and `NNN` is a 3 digit number indicating the type of the unhandled `Exception`. * `GPM` - `GeneratePackageManagerJava` * `GRD` - `GenerateResourceDesigner` * `IAS` - `InstallApkSet` -* `JDC` - `JavaDoc` * `JVC` - `Javac` -* `JTX` - `JarToXml` * `KEY` - `KeyTool` * `LNK` - `LinkAssemblies` * `LNS` - `LinkAssembliesNoShrink` * `LNT` - `Lint` -* `MDC` - `MDoc` * `PAW` - `ParseAndroidWearProjectAndManifest` * `PRO` - `Proguard` * `PWA` - `PrepareWearApplicationFiles` diff --git a/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.AvailableItems.targets b/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.AvailableItems.targets index add88755918..46dd0cf0709 100644 --- a/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.AvailableItems.targets +++ b/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.AvailableItems.targets @@ -34,8 +34,6 @@ This item group populates the Build Action drop-down in IDEs. - - diff --git a/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Bindings.ClassParse.targets b/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Bindings.ClassParse.targets index 4e1b6e05063..77a7117265a 100644 --- a/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Bindings.ClassParse.targets +++ b/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Bindings.ClassParse.targets @@ -41,12 +41,10 @@ This file is only used by binding projects. <_AndroidDocumentationPath Include="@(_JavaSourceJavadocXml)" /> - <_AndroidDocumentationPath Include="@(JavaDocIndex->'%(RootDir)\%(Directory)')" /> <_AndroidDocumentationPath Include="$(JavaDocPaths)" /> <_AndroidDocumentationPath Include="$(Java7DocPaths)" /> <_AndroidDocumentationPath Include="$(Java8DocPaths)" /> <_AndroidDocumentationPath Include="$(DroidDocPaths)" /> - <_AndroidDocumentationPath Include="@(JavaDocJar->'$(IntermediateOutputPath)javadocs\%(FileName)')" /> + Condition=" '@(JavaSourceJar->Count())' != '0' "> @@ -95,7 +93,7 @@ This file is only used by binding projects. diff --git a/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Bindings.Core.targets b/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Bindings.Core.targets index 16640f2c9b3..3b8d0a6c920 100644 --- a/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Bindings.Core.targets +++ b/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Bindings.Core.targets @@ -32,7 +32,7 @@ It is shared between "legacy" binding projects and .NET 5 projects. <_OtherGeneratorStampFile Condition=" '$(_AndroidUnmanagedCallersOnlyCallbacksState)' != 'true' ">$(_GeneratorUcoCallbacksTrueStamp) - + $([MSBuild]::EnsureTrailingSlash('$(OutputPath)'))$(AssemblyName).xml $(NoWarn);CS1573;CS1591 diff --git a/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Bindings.Documentation.targets b/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Bindings.Documentation.targets deleted file mode 100644 index 8629347efb4..00000000000 --- a/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Bindings.Documentation.targets +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Bindings.JarToXml.targets b/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Bindings.JarToXml.targets deleted file mode 100644 index e9935bf8917..00000000000 --- a/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Bindings.JarToXml.targets +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - diff --git a/src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs b/src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs index 79410203347..9c9bb0667e0 100644 --- a/src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs +++ b/src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs @@ -589,15 +589,6 @@ public static string XA1020 { } } - /// - /// Looks up a localized string similar to Specified source Java library not found: {0}. - /// - public static string XA1021 { - get { - return ResourceManager.GetString("XA1021", resourceCulture); - } - } - /// /// Looks up a localized string similar to Specified reference Java library not found: {0}. /// diff --git a/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx b/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx index 3e5cadd7b31..e0e01eb5509 100644 --- a/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx +++ b/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx @@ -328,11 +328,6 @@ When it appears in the middle of a sentence, "lint" is not capitalized. At least one Java library is required for binding. Check that a Java library is included in the project and has the appropriate build action: 'LibraryProjectZip' (for AAR or ZIP), 'EmbeddedJar', 'InputJar' (for JAR), or 'LibraryProjectProperties' (project.properties). The following are literal names and should not be translated: LibraryProjectZip, EmbeddedJar, InputJar, LibraryProjectProperties, project.properties - - Specified source Java library not found: {0} - In this message, the term "source Java library" refers to the library that will be processed. In this case, the term "source" does not refer to "source code." -{0} - The file name of the library - Specified reference Java library not found: {0} In this message, the term "reference Java library" refers to a library that is included as a reference so that types from the library can be resolved during the build process. diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/JarToXml.cs b/src/Xamarin.Android.Build.Tasks/Tasks/JarToXml.cs deleted file mode 100644 index 6891ed06d58..00000000000 --- a/src/Xamarin.Android.Build.Tasks/Tasks/JarToXml.cs +++ /dev/null @@ -1,172 +0,0 @@ -// Copyright (C) 2012 Xamarin, Inc. All rights reserved. -#nullable enable -using System; -using System.Linq; -using System.IO; -using Microsoft.Build.Framework; -using Microsoft.Build.Utilities; -using Xamarin.Android.Tools; -using Microsoft.Android.Build.Tasks; - -namespace Xamarin.Android.Tasks -{ - public class JarToXml : AndroidToolTask - { - public override string TaskPrefix => "JTX"; - - [Required] - public string AndroidSdkDirectory { get; set; } = ""; - - [Required] - public string MonoAndroidToolsDirectory { get; set; } = ""; - - [Required] - public string JavaSdkDirectory { get; set; } = ""; - - [Required] - public string AndroidApiLevel { get; set; } = ""; - - public string []? ReferenceAssemblyPaths { get; set; } - - [Required] - public string OutputFile { get; set; } = ""; - - [Required] - public ITaskItem[] SourceJars { get; set; } = []; - - public ITaskItem[]? ReferenceJars { get; set; } - public string? DroidDocPaths { get; set; } - public string? JavaDocPaths { get; set; } - public string? Java7DocPaths { get; set; } - public string? Java8DocPaths { get; set; } - public ITaskItem[]? JavaDocs { get; set; } - - public ITaskItem[]? LibraryProjectJars { get; set; } - - public string? JavaOptions { get; set; } - - public string? JavaMaximumHeapSize { get; set; } - - public override bool RunTask () - { - if (SourceJars == null || SourceJars.Count () == 0) { - Log.LogCodedError ("XA1020", Properties.Resources.XA1020); - return false; - } - - // Ensure that the user has the platform they are targeting installed - var jarpath = MonoAndroidHelper.TryGetAndroidJarPath (Log, AndroidApiLevel, - MonoAndroidHelper.GetSupportedVersions (BuildEngine4, ReferenceAssemblyPaths), androidSdkDirectory: AndroidSdkDirectory); - if (jarpath == null) - return !Log.HasLoggedErrors; - - // Ensure that all requested jars exist - foreach (var jar in SourceJars) - if (!File.Exists (jar.ItemSpec)) - Log.LogCodedError ("XA1021", Properties.Resources.XA1021, jar.ItemSpec); - - if (ReferenceJars != null) - foreach (var jar in ReferenceJars) - if (!File.Exists (jar.ItemSpec)) - Log.LogCodedError ("XA1022", Properties.Resources.XA1022, jar.ItemSpec); - - if (Log.HasLoggedErrors) - return false; - - // Ensure our output directory exists - Directory.CreateDirectory (Path.GetDirectoryName (OutputFile)); - - return base.RunTask (); - } - - protected override string GenerateCommandLineCommands () - { - var cmd = new CommandLineBuilder (); - - // Add the JavaOptions if they are not null - // These could be any of the additional options - if (!JavaOptions.IsNullOrEmpty ()) { - cmd.AppendSwitch (JavaOptions); - } - - // Add the specific -XmxN to override the default heap size for the JVM - // N can be in the form of Nm or NGB (e.g 100m or 1GB ) - cmd.AppendSwitchIfNotNull("-Xmx", JavaMaximumHeapSize); - - // Arguments sent to java.exe - cmd.AppendSwitchIfNotNull ("-jar ", Path.Combine (MonoAndroidToolsDirectory, "jar2xml.jar")); - - foreach (var jar in SourceJars) - cmd.AppendSwitchIfNotNull ("--jar=", Path.GetFullPath (jar.ItemSpec)); - - var libraryProjectJars = MonoAndroidHelper.ExpandFiles (LibraryProjectJars); - - foreach (var jar in libraryProjectJars) { - if (MonoAndroidHelper.IsEmbeddedReferenceJar (jar)) - cmd.AppendSwitchIfNotNull ("--ref=", Path.GetFullPath (jar)); - else - cmd.AppendSwitchIfNotNull ("--jar=", Path.GetFullPath (jar)); - } - - // Arguments sent to jar2xml - var jarpath = MonoAndroidHelper.TryGetAndroidJarPath (Log, AndroidApiLevel, - MonoAndroidHelper.GetSupportedVersions (BuildEngine4, ReferenceAssemblyPaths), androidSdkDirectory: AndroidSdkDirectory); - if (jarpath != null) - cmd.AppendSwitchIfNotNull ("--ref=", Path.GetFullPath (jarpath)); - - cmd.AppendSwitchIfNotNull ("--out=", Path.GetFullPath (OutputFile)); - - if (ReferenceJars != null) - foreach (var jar in ReferenceJars) - cmd.AppendSwitchIfNotNull ("--ref=", Path.GetFullPath (jar.ItemSpec)); - - if (DroidDocPaths != null) - foreach (var path in DroidDocPaths.Split (';')) - cmd.AppendSwitchIfNotNull ("--droiddocpath=", Path.GetFullPath (path)); - - if (JavaDocPaths != null) - foreach (var path in JavaDocPaths.Split (';')) - cmd.AppendSwitchIfNotNull ("--javadocpath=", Path.GetFullPath (path)); - - if (Java7DocPaths != null) - foreach (var path in Java7DocPaths.Split (';')) - cmd.AppendSwitchIfNotNull ("--java7docpath=", Path.GetFullPath (path)); - - if (Java8DocPaths != null) - foreach (var path in Java8DocPaths.Split (';')) - cmd.AppendSwitchIfNotNull ("--java8docpath=", Path.GetFullPath (path)); - - if (JavaDocs != null) - foreach (var doc in JavaDocs) { - var opt = GetJavadocOption (doc.ItemSpec); - if (opt != null) - cmd.AppendSwitchIfNotNull (opt, Path.GetFullPath (Path.GetDirectoryName (doc.ItemSpec))); - } - return cmd.ToString (); - } - - string? GetJavadocOption (string file) - { - string rawHTML = File.ReadAllText (file); - if (rawHTML.Length < 500) - return null; - if (rawHTML.Substring (0, 500).IndexOf ("Generated by javadoc (build 1.6", StringComparison.Ordinal) > 0) - return "--javadocpath="; - if (rawHTML.Substring (0, 500).IndexOf ("Generated by javadoc (version 1.7", StringComparison.Ordinal) > 0) - return "--java7docpath="; - return "--droiddocpath="; - } - - protected override string ToolName { get { return "jar2xml"; } } - - public override string ToolExe { - get { return OS.IsWindows ? "java.exe" : "java"; } - set { base.ToolExe = value; } - } - - protected override string GenerateFullPathToTool () - { - return Path.Combine (JavaSdkDirectory, "bin", ToolExe); - } - } -} diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/JavaDoc.cs b/src/Xamarin.Android.Build.Tasks/Tasks/JavaDoc.cs deleted file mode 100644 index 9d7b37002c9..00000000000 --- a/src/Xamarin.Android.Build.Tasks/Tasks/JavaDoc.cs +++ /dev/null @@ -1,90 +0,0 @@ -#nullable enable - -using System; -using System.Linq; -using System.IO; -using Microsoft.Build.Framework; -using Microsoft.Build.Utilities; -using System.Text; -using System.Collections.Generic; -using Xamarin.Android.Tools; -using Xamarin.Android.Tools.Aidl; -using Microsoft.Android.Build.Tasks; - -namespace Xamarin.Android.Tasks -{ - - public class JavaDoc : JavaToolTask - { - public override string TaskPrefix => "JDC"; - - public string []? SourceDirectories { get; set; } - - public string []? DestinationDirectories { get; set; } - - public string []? ReferenceJars { get; set; } - - public string? JavaPlatformJar { get; set; } - - public string []? ExtraArgs { get; set; } - - protected override string ToolName { - get { return OS.IsWindows ? "javadoc.exe" : "javadoc"; } - } - - public override bool RunTask () - { - if (DestinationDirectories != null) { - foreach (var dir in DestinationDirectories) - if (!Directory.Exists (dir)) - Directory.CreateDirectory (dir); - } - - // Basically, javadoc will return non-zero return code with those expected errors. We have to ignore them. - if (SourceDirectories != null && DestinationDirectories != null) { - foreach (var pair in SourceDirectories.Zip (DestinationDirectories, (src, dst) => new { Source = src, Destination = dst })) { - context_src = pair.Source; - context_dst = pair.Destination; - base.RunTask (); - } - } - return true; - } - - string? context_src; - string? context_dst; - - protected override string GenerateCommandLineCommands () - { - var cmd = new CommandLineBuilder (); - - cmd.AppendSwitch ("-d"); - cmd.AppendFileNameIfNotNull (context_dst); - cmd.AppendSwitch ("-sourcepath"); - cmd.AppendFileNameIfNotNull (context_src); - cmd.AppendSwitch ("-subpackages"); - cmd.AppendSwitch ("."); - var cps = ReferenceJars?.ToList () ?? new List (); - if (JavaPlatformJar != null) - cps.Add (JavaPlatformJar); - if (cps.Any ()) { - if (OS.IsWindows) - cmd.AppendSwitch ("-cp " + string.Join (";", cps.Select (cp => '"' + cp + '"'))); - else - cmd.AppendSwitch ("-cp " + '"' + string.Join (":", cps) + '"'); - } - if (ExtraArgs != null) - foreach (var extraArg in ExtraArgs) - cmd.AppendSwitch (extraArg); - - return cmd.ToString (); - } - - // log them as is, regardless of message importance. Javadoc compilation errors should never be reported as errors. - protected override void LogEventsFromTextOutput (string singleLine, MessageImportance messageImportance) - { - Log.LogDebugMessage (singleLine); - } - } - -} diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/MDoc.cs b/src/Xamarin.Android.Build.Tasks/Tasks/MDoc.cs deleted file mode 100644 index 3a0d785313d..00000000000 --- a/src/Xamarin.Android.Build.Tasks/Tasks/MDoc.cs +++ /dev/null @@ -1,69 +0,0 @@ -#nullable enable -using System.Collections.Generic; -using System.IO; -using System.Linq; -using Microsoft.Build.Framework; -using Microsoft.Build.Utilities; -using Xamarin.Android.Tools; -using Xamarin.Android.Tools.Aidl; -using Microsoft.Android.Build.Tasks; - -namespace Xamarin.Android.Tasks -{ - public class MDoc : AndroidToolTask - { - public override string TaskPrefix => "MDC"; - - public string []? References { get; set; } - - [Required] - public string TargetAssembly { get; set; } = ""; - - [Required] - public string OutputDocDirectory { get; set; } = ""; - - public bool RunExport { get; set; } - - protected override string ToolName { - get { return "mdoc.exe"; } - } - - protected override string GenerateFullPathToTool () - { - return Path.Combine (ToolPath, ToolExe); - } - - protected override string GenerateCommandLineCommands () - { - Log.LogDebugMessage ("MDoc"); - Log.LogDebugMessage (" RunExport: {0}", RunExport); - Log.LogDebugMessage (" TargetAssembly: {0}", TargetAssembly); - Log.LogDebugMessage (" References"); - if (References != null) - foreach (var reference in References) - Log.LogDebugMessage (" {0}", reference); - Log.LogDebugMessage (" OutputDocDirectory: {0}", OutputDocDirectory); - if (RunExport) { - var cmd = new CommandLineBuilder (); - cmd.AppendSwitch ("--debug"); - cmd.AppendSwitch ("export-msxdoc"); - cmd.AppendSwitchIfNotNull ("-o", Path.ChangeExtension (TargetAssembly, ".xml")); - cmd.AppendSwitch (OutputDocDirectory); - return cmd.ToString (); - } else { - var refPaths = References.Select (Path.GetDirectoryName).Distinct (); - var cmd = new CommandLineBuilder (); - cmd.AppendSwitch ("--debug"); - cmd.AppendSwitch ("update"); - cmd.AppendSwitch ("--delete"); - cmd.AppendSwitchIfNotNull ("-L", Path.GetDirectoryName (TargetAssembly)); - foreach (var rp in refPaths) - cmd.AppendSwitchIfNotNull ("-L", rp); - cmd.AppendSwitchIfNotNull ("-o", OutputDocDirectory); - cmd.AppendSwitch (Path.GetFullPath (TargetAssembly)); - return cmd.ToString (); - } - } - } -} - diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/ResolveSdksTaskTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/ResolveSdksTaskTests.cs index 000422542d9..ce034d5fc9e 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/ResolveSdksTaskTests.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/ResolveSdksTaskTests.cs @@ -647,14 +647,6 @@ public void SdkConsumersUseExplicitPaths () var libraries = manifest.UsesLibraries; Assert.IsNotNull (libraries); Assert.AreEqual (optionalJar, libraries.Single ().ItemSpec); - var jarToXml = new JarToXmlCommandLine { - BuildEngine = engine, - AndroidSdkDirectory = sdk, - AndroidApiLevel = "37", - MonoAndroidToolsDirectory = resolveSdks.MonoAndroidToolsPath, - OutputFile = Path.Combine (Root, path, "api.xml"), - }; - StringAssert.Contains (platformJar, jarToXml.GetCommandLine ()); } } finally { Directory.Delete (Path.Combine (Root, path), recursive: true); @@ -668,20 +660,14 @@ public void PlatformJarWithMissingSdkDoesNotThrow (string sdkPath, string expect { var errors = new List (); var engine = new MockBuildEngine (TestContext.Out, errors); - var jarToXml = new JarToXml { + var platform = new GetJavaPlatformJar { BuildEngine = engine, AndroidSdkDirectory = sdkPath == "missing" ? Path.Combine (Root, "temp", TestName, "missing-sdk") : sdkPath, AndroidApiLevel = "37", - SourceJars = [new TaskItem ("source.jar")], + SupportedOSPlatformVersion = XABuildConfig.AndroidMinimumDotNetApiLevel.ToString (), }; - Assert.IsFalse (jarToXml.Execute ()); + Assert.IsFalse (platform.Execute ()); Assert.AreEqual (expectedError, errors.Single ().Code); } - - class JarToXmlCommandLine : JarToXml - { - public string GetCommandLine () => GenerateCommandLineCommands (); - } - } } diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets index f5bc2058ef8..00cfc6645b8 100644 --- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets +++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets @@ -34,16 +34,6 @@ PreserveNewest Xamarin.Android.Bindings.Core.targets - - PreserveNewest - Xamarin.Android.Bindings.Documentation.targets - - - PreserveNewest - Xamarin.Android.Bindings.JarToXml.targets - PreserveNewest