Skip to content

Commit b3fce8d

Browse files
[Xamarin.Android.Build.Tasks] simplify inputs to _CompileToDalvik
Recently I've been discovering more and more places where usage of `**\*.*` can hurt the performance of our build. In this case, the `_FindCompiledJavaFiles` target: <Target Name="_FindCompiledJavaFiles" DependsOnTargets="_CompileJava"> <CreateItem Include="$(IntermediateOutputPath)android\bin\classes\\**\*.class"> <Output TaskParameter="Include" ItemName="_CompiledJavaFiles" /> </CreateItem> </Target> This target is running even in builds with no changes, so we are *always* recursing directories and finding `*.class` files. But since we are using a `classes.zip` file now, we don't need to recurse and find the `*.class` files at all anymore! I was able to remove this target completely, and change `$(_CompileToDalvikInputs)` to use `$(IntermediateOutputPath)android\bin\classes.zip`. Less inputs also help build times, because MSBuild won't have to evaluate timestamps on all the `*.class` files. It can just look at the single `classes.zip` file. To see the difference, a build with no changes was taking: 51 ms _FindCompiledJavaFiles 1 calls 30 ms _CompileToDalvikWithDx 1 calls Total time: 3.524s After these changes: 2 ms _CompileToDalvikWithDx 1 calls Total time: 2.386s `_FindCompiledJavaFiles` is gone completely. You can see there is some time savings in general here, I'm not sure how MSBuild logs the time it is taking to compute `Inputs` and `Outputs` of targets.
1 parent 970da9e commit b3fce8d

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2470,16 +2470,8 @@ because xbuild doesn't support framework reference assemblies.
24702470
</CreateItem>
24712471
</Target>
24722472

2473-
<Target Name="_FindCompiledJavaFiles" DependsOnTargets="_CompileJava">
2474-
<CreateItem
2475-
Include="$(IntermediateOutputPath)android\bin\classes\\**\*.class">
2476-
<Output TaskParameter="Include" ItemName="_CompiledJavaFiles" />
2477-
</CreateItem>
2478-
</Target>
2479-
24802473
<PropertyGroup>
24812474
<_CompileToDalvikDependsOnTargets>
2482-
_FindCompiledJavaFiles;
24832475
_GetMonoPlatformJarPath;
24842476
_GetAdditionalResourcesFromAssemblies;
24852477
_CreateAdditionalResourceCache;
@@ -2489,7 +2481,7 @@ because xbuild doesn't support framework reference assemblies.
24892481
$(MSBuildAllProjects)
24902482
;@(_JavaLibrariesToCompileForAppDx)
24912483
;@(AndroidExternalJavaLibrary)
2492-
;@(_CompiledJavaFiles)
2484+
;$(IntermediateOutputPath)android\bin\classes.zip
24932485
;@(ProguardConfiguration)
24942486
;@(MultiDexMainDexList)
24952487
;$(_AndroidBuildPropertiesCache)

0 commit comments

Comments
 (0)