-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
107 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Mobile.BuildTools.Models | ||
{ | ||
public class GoogleConfig | ||
{ | ||
public string ServicesJson { get; set; } | ||
|
||
public string InfoPlist { get; set; } | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using Microsoft.Build.Framework; | ||
using Microsoft.Build.Utilities; | ||
using Mobile.BuildTools.Build; | ||
using Mobile.BuildTools.Configuration; | ||
using Mobile.BuildTools.Utils; | ||
|
||
namespace Mobile.BuildTools.Tasks | ||
{ | ||
public class GoogleTask : BuildToolsTaskBase | ||
{ | ||
private List<ITaskItem> _outputs = new List<ITaskItem>(); | ||
[Output] | ||
public ITaskItem[] GoogleOutput => _outputs.ToArray(); | ||
|
||
internal override void ExecuteInternal(IBuildConfiguration config) | ||
{ | ||
if (config.Platform == Platform.Android && !string.IsNullOrEmpty(config.Configuration.Google?.ServicesJson)) | ||
{ | ||
GetGoogleServicesJson(config); | ||
} | ||
else if (config.Platform == Platform.iOS && !string.IsNullOrEmpty(config.Configuration.Google?.InfoPlist)) | ||
{ | ||
GetGoogleInfoPlist(config); | ||
} | ||
} | ||
|
||
private void GetGoogleServicesJson(IBuildConfiguration buildConfig) | ||
{ | ||
var json = Environment.GetEnvironmentVariable(buildConfig.Configuration.Google.ServicesJson); | ||
if (string.IsNullOrEmpty(json)) | ||
return; | ||
|
||
var path = Path.Combine(buildConfig.IntermediateOutputPath, "aritchie-sucks", "google-services.json"); | ||
File.WriteAllText(path, json); | ||
// Output to GoogleServicesJson Include="path" | ||
var item = new TaskItem(path); | ||
item.SetMetadata("LogicalName", "google-services.json"); | ||
_outputs.Add(item); | ||
} | ||
|
||
private void GetGoogleInfoPlist(IBuildConfiguration buildConfig) | ||
{ | ||
var json = Environment.GetEnvironmentVariable(buildConfig.Configuration.Google.InfoPlist); | ||
if (string.IsNullOrEmpty(json)) | ||
return; | ||
|
||
var path = Path.Combine(buildConfig.IntermediateOutputPath, "aritchie-sucks", "GoogleService-Info.plist"); | ||
File.WriteAllText(path, json); | ||
// Output to BundleResource Include="path" | ||
var item = new TaskItem(path); | ||
item.SetMetadata("LogicalName", "GoogleService-Info.plist"); | ||
_outputs.Add(item); | ||
} | ||
} | ||
} |
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