-
Notifications
You must be signed in to change notification settings - Fork 535
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[XABT] Break BuildApk into individual tasks for each content type.
- Loading branch information
Showing
6 changed files
with
317 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/Xamarin.Android.Build.Tasks/Tasks/CollectDalvikFilesForArchive.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#nullable enable | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using Microsoft.Android.Build.Tasks; | ||
using Microsoft.Build.Framework; | ||
using Microsoft.Build.Utilities; | ||
|
||
namespace Xamarin.Android.Tasks; | ||
|
||
/// <summary> | ||
/// Collects Dalvik classes to be added to the final archive. | ||
/// </summary> | ||
public class CollectDalvikFilesForArchive : AndroidTask | ||
{ | ||
public override string TaskPrefix => "CDF"; | ||
|
||
public string AndroidPackageFormat { get; set; } = ""; | ||
|
||
[Required] | ||
public ITaskItem [] DalvikClasses { get; set; } = []; | ||
|
||
[Output] | ||
public ITaskItem [] FilesToAddToArchive { get; set; } = []; | ||
|
||
public override bool RunTask () | ||
{ | ||
var dalvikPath = AndroidPackageFormat.Equals ("aab", StringComparison.InvariantCultureIgnoreCase) ? "dex/" : ""; | ||
var files = new List<ITaskItem> (); | ||
|
||
foreach (var dex in DalvikClasses) { | ||
var apkName = dex.GetMetadata ("ApkName"); | ||
var dexPath = string.IsNullOrWhiteSpace (apkName) ? Path.GetFileName (dex.ItemSpec) : apkName; | ||
|
||
var item = new TaskItem (dex.ItemSpec); | ||
item.SetMetadata ("ArchivePath", dalvikPath + dexPath); | ||
|
||
files.Add (item); | ||
} | ||
|
||
FilesToAddToArchive = files.ToArray (); | ||
|
||
return !Log.HasLoggedErrors; | ||
} | ||
} |
Oops, something went wrong.