Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Documentation/docs-mobile/messages/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,6 @@ Either change the value in the AndroidManifest.xml to match the $(SupportedOSPla
+ [XA4250](xa4250.md): Manifest-referenced type '{type}' was not found in any scanned assembly. It may be a framework type.
+ [XA4252](xa4252.md): Insecure HTTP Maven repository URL '{url}' is not allowed. Use an HTTPS URL, or set AllowInsecureHttp="true" metadata on the item to override this check.
+ [XA4253](xa4253.md): Generated Java callable wrapper code changed: '{path}'
+ [XA4254](xa4254.md): Trimmable type map Java source input directory '{input}' and output directory '{output}' must be different.
+ [XA4255](xa4255.md): Generated trimmable type map Java source '{path}' was not found.
+ XA4300: Native library '{library}' will not be bundled because it has an unsupported ABI.
+ [XA4301](xa4301.md): Apk already contains the item `xxx`.
+ [XA4302](xa4302.md): Unhandled exception merging \`AndroidManifest.xml\`: {ex}
Expand Down
25 changes: 0 additions & 25 deletions Documentation/docs-mobile/messages/xa4254.md

This file was deleted.

27 changes: 0 additions & 27 deletions Documentation/docs-mobile/messages/xa4255.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ public TrimmableTypeMapResult Execute (
ManifestConfig? manifestConfig = null,
XDocument? manifestTemplate = null,
string? packageNamingPolicy = null,
int maxArrayRank = 0,
bool generateTypeMapAssemblies = true)
int maxArrayRank = 0)
{
_ = assemblies ?? throw new ArgumentNullException (nameof (assemblies));
_ = systemRuntimeVersion ?? throw new ArgumentNullException (nameof (systemRuntimeVersion));
Expand All @@ -55,9 +54,7 @@ public TrimmableTypeMapResult Execute (
PropagateDeferredRegistrationToBaseClasses (allPeers);
PropagateCannotRegisterToDescendants (allPeers);

var generatedAssemblies = generateTypeMapAssemblies
? GenerateTypeMapAssemblies (allPeers, systemRuntimeVersion, useSharedTypemapUniverse, maxArrayRank)
: [];
var generatedAssemblies = GenerateTypeMapAssemblies (allPeers, systemRuntimeVersion, useSharedTypemapUniverse, maxArrayRank);
var jcwPeers = allPeers.Where (ShouldGenerateJcw).ToList ();
logger.LogGeneratingJcwFilesInfo (jcwPeers.Count, allPeers.Count);
var generatedJavaSources = GenerateJcwJavaSources (jcwPeers);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,45 +48,6 @@
OutputFile="$(_ProguardProjectConfiguration)" />
</Target>

<Target Name="_GeneratePostTrimTrimmableTypeMapJavaSources"
Condition=" '$(_AndroidTypeMapImplementation)' == 'trimmable' and '$(PublishTrimmed)' == 'true' and Exists('$(IntermediateOutputPath)linked/Link.semaphore') "
AfterTargets="ILLink"
BeforeTargets="_GenerateJavaStubs;_CompileJava;_CompileToDalvik"
Inputs="$(IntermediateOutputPath)linked/Link.semaphore"
Outputs="$(_PostTrimTrimmableTypeMapJavaStamp)">
<ItemGroup>
<_PostTrimTrimmableTypeMapInputAssemblies Include="@(ResolvedFileToPublish)"
Condition=" '%(Extension)' == '.dll' " />
</ItemGroup>

<GenerateTrimmableTypeMap
ResolvedAssemblies="@(_PostTrimTrimmableTypeMapInputAssemblies)"
FrameworkAssemblyNames="@(ResolvedFrameworkAssemblies->'%(Filename)')"
OutputDirectory="$(_TypeMapOutputDirectory)"
JavaSourceOutputDirectory="$(_PostTrimTypeMapJavaOutputDirectory)"
JavaSourceInputDirectory="$(_TypeMapJavaOutputDirectory)"
TargetFrameworkVersion="$(TargetFrameworkVersion)"
PackageNamingPolicy="$(_TrimmableTypeMapPackageNamingPolicy)"
MaxArrayRank="$(_AndroidTrimmableTypeMapMaxArrayRank)"
GenerateTypeMapAssemblies="false"
CleanJavaSourceOutputDirectory="true"
AcwMapOutputFile="$(IntermediateOutputPath)acw-map.txt"
ApplicationRegistrationOutputFile="$(IntermediateOutputPath)android/src/net/dot/android/ApplicationRegistration.java">
<Output TaskParameter="GeneratedJavaFiles" ItemName="_PostTrimGeneratedJavaFiles" />
</GenerateTrimmableTypeMap>

<MakeDir Directories="$([System.IO.Path]::GetDirectoryName('$(_PostTrimTrimmableTypeMapJavaStamp)'))" />
<Touch Files="$(_PostTrimTrimmableTypeMapJavaStamp)" AlwaysCreate="true" />

<ItemGroup>
<FileWrites Include="@(_PostTrimGeneratedJavaFiles)" />
<FileWrites Include="$(IntermediateOutputPath)acw-map.txt" />
<FileWrites Include="$(IntermediateOutputPath)android/src/net/dot/android/ApplicationRegistration.java" />
<FileWrites Include="$(_PostTrimTrimmableTypeMapJavaStamp)" />
<_PostTrimTrimmableTypeMapInputAssemblies Remove="@(_PostTrimTrimmableTypeMapInputAssemblies)" />
<_PostTrimGeneratedJavaFiles Remove="@(_PostTrimGeneratedJavaFiles)" />
</ItemGroup>
</Target>
<!-- Add linked TypeMap DLLs to the normal publish assembly pipeline. The SDK R2R
target only compiles ResolvedFileToPublish items with PostprocessAssembly=true. -->
<Target Name="_AddTrimmableTypeMapToResolvedFileToPublish"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,7 @@
<_TypeMapOutputDirectory>$(_TypeMapBaseOutputDir)typemap/</_TypeMapOutputDirectory>
<_TypeMapJavaOutputDirectory>$(_TypeMapBaseOutputDir)typemap/java</_TypeMapJavaOutputDirectory>
<_TypeMapAssembliesListFile>$(_TypeMapOutputDirectory)typemap-assemblies.txt</_TypeMapAssembliesListFile>
<_PostTrimTypeMapJavaOutputDirectory>$(_TypeMapBaseOutputDir)typemap/linked-java</_PostTrimTypeMapJavaOutputDirectory>
<_TypeMapJavaStubsSourceDirectory Condition=" '$(_TypeMapJavaStubsSourceDirectory)' == '' and '$(_AndroidRuntime)' == 'CoreCLR' and '$(PublishTrimmed)' == 'true' ">$(_PostTrimTypeMapJavaOutputDirectory)</_TypeMapJavaStubsSourceDirectory>
<_TypeMapJavaStubsSourceDirectory Condition=" '$(_TypeMapJavaStubsSourceDirectory)' == '' ">$(_TypeMapJavaOutputDirectory)</_TypeMapJavaStubsSourceDirectory>
<_PostTrimTrimmableTypeMapJavaStamp>$(_TypeMapBaseOutputDir)stamp/_GeneratePostTrimTrimmableTypeMapJavaSources.stamp</_PostTrimTrimmableTypeMapJavaStamp>
<_TrimmableJavaSourceStamp Condition=" '$(_TrimmableJavaSourceStamp)' == '' and '$(_AndroidRuntime)' == 'CoreCLR' and '$(PublishTrimmed)' == 'true' ">$(_PostTrimTrimmableTypeMapJavaStamp)</_TrimmableJavaSourceStamp>
<_TrimmableJavaSourceStamp Condition=" '$(_TrimmableJavaSourceStamp)' == '' ">$(_TypeMapOutputDirectory)$(_TypeMapAssemblyName).dll</_TrimmableJavaSourceStamp>
<_TrimmableTypeMapOutputStamp>$(_TypeMapOutputDirectory)_GenerateTrimmableTypeMap.stamp</_TrimmableTypeMapOutputStamp>
<!-- Max array rank for __ArrayMapRank{N} sentinel emission. Defaults to 3 when
dynamic code is unavailable, so array creation uses the typemap path;
defaults to 0 otherwise, where dynamic code can use Array.CreateInstance directly. -->
Expand Down Expand Up @@ -82,7 +77,7 @@
Condition=" '$(_AndroidTypeMapImplementation)' == 'trimmable' and '@(ReferencePath->Count())' != '0' and '$(_OuterIntermediateOutputPath)' == '' "
AfterTargets="CoreCompile"
Inputs="@(ReferencePath);$(IntermediateOutputPath)$(TargetFileName);$(_AndroidManifestAbs);$(_AndroidBuildPropertiesCache)"
Outputs="$(_TypeMapOutputDirectory)$(_TypeMapAssemblyName).dll;$(_TypeMapAssembliesListFile)">
Outputs="$(_TypeMapOutputDirectory)$(_TypeMapAssemblyName).dll;$(_TypeMapAssembliesListFile);$(_TrimmableTypeMapOutputStamp)">

<ItemGroup>
<_TypeMapInputAssemblies Include="@(ReferencePath)" />
Expand Down Expand Up @@ -121,13 +116,25 @@
ApplicationRegistrationOutputFile="$(IntermediateOutputPath)android/src/net/dot/android/ApplicationRegistration.java">
<Output TaskParameter="GeneratedAssemblies" ItemName="_GeneratedTypeMapAssemblies" />
<Output TaskParameter="GeneratedJavaFiles" ItemName="_GeneratedJavaFiles" />
<Output TaskParameter="DeletedJavaFiles" ItemName="_DeletedJavaFiles" />
<Output TaskParameter="AdditionalProviderSources" ItemName="_AdditionalProviderSources" />
</GenerateTrimmableTypeMap>

<ItemGroup>
<_DeletedCopiedJavaFiles Remove="@(_DeletedCopiedJavaFiles)" />
<_DeletedCopiedJavaFiles Include="@(_DeletedJavaFiles->'$(IntermediateOutputPath)android/src/%(RelativePath)')" />
</ItemGroup>
<Delete Files="@(_DeletedCopiedJavaFiles)" />
<Delete Files="$(_AndroidCompileJavaStampFile)" Condition=" '@(_DeletedCopiedJavaFiles->Count())' != '0' " />

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 💡 MSBuild targets — Nice cascading cleanup design: stale generated Java → stale android/src copies → Java compilation invalidation. The ->Count() condition on the stamp delete (line 128) avoids unnecessary recompilation when nothing was cleaned, which is correct.

One observation: if the deleted stale .java files had corresponding stale .class outputs under android/bin/classes/, those would only be cleaned if _CompileJava cleans its output directory before recompilation. If javac doesn't do a clean compilation, stale .class files could persist. Worth verifying that _CompileJava handles this, or adding stale .class deletion alongside the stale copy deletion here.

Rule: Incremental build correctness

<Touch Files="$(_TrimmableTypeMapOutputStamp)" AlwaysCreate="true" />

<ItemGroup>
<FileWrites Remove="@(_DeletedJavaFiles)" />
<FileWrites Remove="@(_DeletedCopiedJavaFiles)" />
<FileWrites Include="@(_GeneratedTypeMapAssemblies)" />
<FileWrites Include="@(_GeneratedJavaFiles)" />
<FileWrites Include="$(_TypeMapAssembliesListFile)" />
<FileWrites Include="$(_TrimmableTypeMapOutputStamp)" />
<FileWrites Include="$(_TypeMapBaseOutputDir)AndroidManifest.xml" />
<FileWrites Include="$(IntermediateOutputPath)acw-map.txt" />
<FileWrites Include="$(IntermediateOutputPath)android/src/net/dot/android/ApplicationRegistration.java" />
Expand Down Expand Up @@ -180,6 +187,7 @@
<FileWrites Include="@(_TypeMapJavaFilesForFileWrites)" />
<FileWrites Include="@(_TypeMapJavaFilesForFileWrites->'$(IntermediateOutputPath)android/src/%(RecursiveDir)%(Filename)%(Extension)')" />
<FileWrites Include="$(_TypeMapAssembliesListFile)" />
<FileWrites Include="$(_TrimmableTypeMapOutputStamp)" Condition="Exists('$(_TrimmableTypeMapOutputStamp)')" />
<FileWrites Include="$(_TypeMapBaseOutputDir)AndroidManifest.xml" Condition="Exists('$(_TypeMapBaseOutputDir)AndroidManifest.xml')" />
<FileWrites Include="$(IntermediateOutputPath)AndroidManifest.xml" Condition="Exists('$(IntermediateOutputPath)AndroidManifest.xml')" />
<FileWrites Include="$(IntermediateOutputPath)acw-map.txt" Condition="Exists('$(IntermediateOutputPath)acw-map.txt')" />
Expand Down Expand Up @@ -245,21 +253,21 @@
so this target only handles JCW file copying, manifest, assembly store setup, and native config.
We keep the name _GenerateJavaStubs because BuildOrder.targets references it.

Inputs uses the TypeMap DLL as a focused sentinel — _GenerateTrimmableTypeMap regenerates
the DLL whenever any of its own inputs (assemblies, manifest, etc.) change, so the DLL
timestamp is a reliable proxy for "something changed that requires re-copying".
Inputs uses the TypeMap output stamp as a focused sentinel — _GenerateTrimmableTypeMap
touches it whenever any of its own inputs (assemblies, manifest, etc.) change. The
Copy task below then updates android/src only for Java sources whose content changed.
We keep _GetGenerateJavaStubsInputs in DependsOnTargets so that downstream targets
(_GetGeneratePackageManagerJavaInputs) can still read @(_GenerateJavaStubsInputs).
-->
<Target Name="_GenerateJavaStubs"
DependsOnTargets="_SetLatestTargetFrameworkVersion;_CleanIntermediateIfNeeded;_PrepareAssemblies;_GetGenerateJavaStubsInputs;_DefineBuildTargetAbis;_PrepareNativeAssemblySources"
Inputs="$(_TypeMapOutputDirectory)$(_TypeMapAssemblyName).dll;@(_EnvironmentFiles)"
Inputs="$(_TrimmableTypeMapOutputStamp);@(_EnvironmentFiles)"
Outputs="$(_AndroidStampDirectory)_GenerateJavaStubs.stamp">

<ItemGroup>
<_TypeMapJavaFiles Include="$(_TypeMapJavaStubsSourceDirectory)/**/*.java" />
<_TypeMapJavaFiles Include="$(_TypeMapJavaOutputDirectory)/**/*.java" />
</ItemGroup>
<Copy SourceFiles="@(_TypeMapJavaFiles)" DestinationFolder="$(IntermediateOutputPath)android/src/%(RecursiveDir)" />
<Copy SourceFiles="@(_TypeMapJavaFiles)" DestinationFolder="$(IntermediateOutputPath)android/src/%(RecursiveDir)" SkipUnchangedFiles="true" />

<ItemGroup>
<FileWrites Include="@(_TypeMapJavaFiles->'$(IntermediateOutputPath)android/src/%(RecursiveDir)%(Filename)%(Extension)')" />
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 0 additions & 11 deletions src/Xamarin.Android.Build.Tasks/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1145,17 +1145,6 @@ To use a custom JDK path for a command line build, set the 'JavaSdkDirectory' MS
<value>Generated Java callable wrapper code changed: '{0}'</value>
<comment>{0} - The path to the generated Java callable wrapper file</comment>
</data>
<data name="XA4254" xml:space="preserve">
<value>Trimmable type map Java source input directory '{0}' and output directory '{1}' must be different.</value>
<comment>The following are literal names and should not be translated: Trimmable type map, Java.
{0} - Full path to the Java source input directory
{1} - Full path to the Java source output directory</comment>
</data>
<data name="XA4255" xml:space="preserve">
<value>Generated trimmable type map Java source '{0}' was not found.</value>
<comment>The following are literal names and should not be translated: trimmable type map, Java.
{0} - Full path to the generated Java source file</comment>
</data>
<data name="XA0142" xml:space="preserve">
<value>Command '{0}' failed.\n{1}</value>
<comment>'{0}' is a failed command name (potentially with path) followed by all the arguments passed to it. {1} is the combined output on the standard error and standard output streams.</comment>
Expand Down
Loading
Loading