Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit90efbb4

Browse files
authored
[Xamarin.Android.Build.Tasks] Fix Aar directory resolution. (#2424)
* [Xamarin.Android.Build.Tasks] Fix Aar directory resolution.Fixed#2408As part of the speed up process when extracting resourcesfrom assemblies and Aar files, we dont re-extract ifthe stamp file is newer than the assembly.The problem with that was in the case of Aar files wewere NOT adding the `res` or `asset` directories tothe list of resolved directories when we skipped extraction.As a result we got less `res` directories on a secondbuild.This commit fixes that.* Add Unit Test* Fix Compile Error
1 parent6401d0a commit90efbb4

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

‎src/Xamarin.Android.Build.Tasks/Tasks/ResolveLibraryProjectImports.cs‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,16 @@ void Extract (
397397
stringassetsDir=Path.Combine(importsDir,"assets");
398398

399399
varstamp=newFileInfo(Path.Combine(outdir.FullName,Path.GetFileNameWithoutExtension(aarFile.ItemSpec)+".stamp"));
400-
if(stamp.Exists&&stamp.LastWriteTimeUtc>newFileInfo(aarFile.ItemSpec).LastWriteTimeUtc)
400+
if(stamp.Exists&&stamp.LastWriteTimeUtc>newFileInfo(aarFile.ItemSpec).LastWriteTimeUtc){
401+
if(Directory.Exists(resDir))
402+
resolvedResourceDirectories.Add(newTaskItem(resDir,newDictionary<string,string>{
403+
{OriginalFile,Path.GetFullPath(aarFile.ItemSpec)},
404+
{SkipAndroidResourceProcessing,"True"},
405+
}));
406+
if(Directory.Exists(assetsDir))
407+
resolvedAssetDirectories.Add(assetsDir);
401408
continue;
409+
}
402410
// temporarily extracted directory will look like:
403411
// _lp_/[aarFile]
404412
using(varzip=MonoAndroidHelper.ReadZipFile(aarFile.ItemSpec)){

‎src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2081,7 +2081,9 @@ public void AarContentExtraction ([Values (false, true)] bool useAapt2)
20812081
using(varbuilder=CreateApkBuilder(Path.Combine("temp",TestName),false,false)){
20822082
Assert.IsTrue(builder.Build(proj),"Build should have succeeded");
20832083
varassemblyMap=builder.Output.GetIntermediaryPath(Path.Combine("lp","map.cache"));
2084+
varcache=builder.Output.GetIntermediaryPath("libraryprojectimports.cache");
20842085
Assert.IsTrue(File.Exists(assemblyMap),$"{assemblyMap} should exist.");
2086+
Assert.IsTrue(File.Exists(cache),$"{cache} should exist.");
20852087
varassemblyIdentityMap=newList<string>();
20862088
foreach(varsinFile.ReadLines(assemblyMap)){
20872089
assemblyIdentityMap.Add(s);
@@ -2092,11 +2094,19 @@ public void AarContentExtraction ([Values (false, true)] bool useAapt2)
20922094
Assert.IsTrue(builder.Build(proj),"Build should have succeeded");
20932095
Assert.IsTrue(builder.Output.IsTargetSkipped("_ResolveLibraryProjectImports"),
20942096
"_ResolveLibraryProjectImports should not have run.");
2097+
2098+
vardoc=XDocument.Load(cache);
2099+
varexpectedCount=doc.Elements("Paths").Elements("ResolvedResourceDirectories").Count();
2100+
20952101
aar.Timestamp=DateTimeOffset.UtcNow.Add(TimeSpan.FromMinutes(2));
20962102
Assert.IsTrue(builder.Build(proj),"Build should have succeeded");
20972103
Assert.IsFalse(builder.Output.IsTargetSkipped("_ResolveLibraryProjectImports"),
20982104
"_ResolveLibraryProjectImports should have run.");
20992105

2106+
doc=XDocument.Load(cache);
2107+
varcount=doc.Elements("Paths").Elements("ResolvedResourceDirectories").Count();
2108+
Assert.AreEqual(expectedCount,count,"The same number of resource directories should have been resolved.");
2109+
21002110
}
21012111
}
21022112

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp