Skip to content

Commit

Permalink
enhancement: Added Xamarin Apple Target (#675)
Browse files Browse the repository at this point in the history
abstracted IHaveBundleIdentifier
abstracted IHaveInfoPlist
abstracted IXamarinAppleTarget
  • Loading branch information
RLittlesII authored Mar 26, 2022
1 parent 648abe4 commit 7641565
Show file tree
Hide file tree
Showing 13 changed files with 153 additions and 155 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Rocket.Surgery.Nuke;
/// <summary>
/// <see cref="GitVersion" /> extensions.
/// </summary>
public static class GitVersionEx
public static class GitVersionFunctions
{
/// <summary>
/// Gets the full semantic version from <see cref="GitVersion" />.
Expand Down
21 changes: 21 additions & 0 deletions src/Nuke/Xamarin/apple/IHaveBundleIdentifier.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// ReSharper disable once CheckNamespace

namespace Rocket.Surgery.Nuke.Xamarin;

/// <summary>
/// Has a bundle identifier.
/// </summary>
public interface IHaveBundleIdentifier : IHave
{
/// <summary>
/// Gets the path for the info plist.
/// </summary>
[Parameter("The application bundle identifier.")]
public string BundleIdentifier => "com.rocketbooster.nuke";

/// <summary>
/// Gets the suffix for the bundle identifier.
/// </summary>
[Parameter("The identifier suffix.")]
public string Suffix { get; set; }
}
16 changes: 16 additions & 0 deletions src/Nuke/Xamarin/apple/IHaveInfoPlist.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Nuke.Common.IO;

// ReSharper disable once CheckNamespace
namespace Rocket.Surgery.Nuke.Xamarin;

/// <summary>
/// Has an info.plist file.
/// </summary>
public interface IHaveInfoPlist : IHave
{
/// <summary>
/// Gets the path for the info plist.
/// </summary>
[Parameter("The path to the info.plist.")]
public AbsolutePath InfoPlist { get; }
}
39 changes: 39 additions & 0 deletions src/Nuke/Xamarin/apple/IXamarinAppleTarget.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using Serilog;

// ReSharper disable once CheckNamespace
namespace Rocket.Surgery.Nuke.Xamarin;

/// <summary>
/// Represents an application with a apple head, and associated concerns.
/// </summary>
public interface IXamarinAppleTarget : IHaveBundleIdentifier, IHaveGitVersion, IHaveInfoPlist
{
/// <summary>
/// modify info.plist
/// </summary>
public Target ModifyInfoPlist => _ => _
.Executes(
() =>
{
Log.Verbose("Info.plist Path: {InfoPlist}", InfoPlist);
var plist = Plist.Deserialize(InfoPlist);

Log.Verbose("Deserialized Plist:\n {@Plist}\n", plist);

plist["CFBundleIdentifier"] = $"{BundleIdentifier}.{Suffix.ToLower()}".TrimEnd('.');
Log.Information("CFBundleIdentifier: {CFBundleIdentifier}", plist["CFBundleIdentifier"]);

plist["CFBundleShortVersionString"] = $"{GitVersion?.Major}.{GitVersion?.Minor}.{GitVersion?.Patch}";
Log.Information(
"CFBundleShortVersionString: {CFBundleShortVersionString}",
plist["CFBundleShortVersionString"]
);

plist["CFBundleVersion"] = $"{GitVersion?.FullSemanticVersion()}";
Log.Information("CFBundleVersion: {CFBundleVersion}", plist["CFBundleVersion"]);

Plist.Serialize(InfoPlist, plist);
Log.Verbose("Serialized Plist:\n {@Plist}\n", plist);
}
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Nuke.Common.IO;
using Serilog;

// ReSharper disable once CheckNamespace
namespace Rocket.Surgery.Nuke.Xamarin;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ public interface ICanArchiveiOS : IHavePackTarget,
.SetProperty("Platform", iOSTargetPlatform)
.SetProperty("BuildIpa", "true")
.SetProperty("ArchiveOnBuild", "true")
.SetProperty("IpaPackageDir", ArtifactsDirectory / "ios")
.SetConfiguration(Configuration)
.SetDefaultLoggers(LogsDirectory / "package.log")
.SetGitVersionEnvironment(GitVersion)
.SetAssemblyVersion(GitVersion?.FullSemanticVersion())
.SetPackageVersion(GitVersion?.NuGetVersionV2)
.SetPackageVersion(GitVersion?.FullSemanticVersion())
)
);
}
Expand Down
37 changes: 37 additions & 0 deletions src/Nuke/Xamarin/apple/ios/ICanBuildXamariniOS.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using Nuke.Common.Tools.MSBuild;
using static Nuke.Common.Tools.MSBuild.MSBuildTasks;

#pragma warning disable CA1304
// ReSharper disable InconsistentNaming
// ReSharper disable once CheckNamespace
namespace Rocket.Surgery.Nuke.Xamarin;

/// <summary>
/// Xamarin iOS build
/// </summary>
public interface ICanBuildXamariniOS : IXamarinAppleTarget,
IHaveBuildTarget,
IHaveRestoreTarget,
IHaveSolution,
IHaveConfiguration,
IHaveOutputLogs,
IHaveiOSTargetPlatform,
ICan
{
/// <summary>
/// msbuild
/// </summary>
public Target BuildiPhone => _ => _
.DependsOn(Restore)
.Executes(
() => MSBuild(
settings => settings.SetSolutionFile(Solution)
.SetProperty("Platform", iOSTargetPlatform)
.SetConfiguration(Configuration)
.SetDefaultLoggers(LogsDirectory / "build.log")
.SetGitVersionEnvironment(GitVersion)
.SetAssemblyVersion(GitVersion?.FullSemanticVersion())
.SetPackageVersion(GitVersion?.NuGetVersionV2)
)
);
}
File renamed without changes.
36 changes: 36 additions & 0 deletions src/Nuke/Xamarin/apple/mac/ICanBuildXamarinMac.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Nuke.Common.Tools.MSBuild;
using static Nuke.Common.Tools.MSBuild.MSBuildTasks;

#pragma warning disable CA1304
// ReSharper disable once CheckNamespace
namespace Rocket.Surgery.Nuke.Xamarin;

/// <summary>
/// Xamarin mac build
/// </summary>
public interface ICanBuildXamarinMac : IXamarinAppleTarget,
IHaveBuildTarget,
IHaveRestoreTarget,
IHaveSolution,
IHaveConfiguration,
IHaveOutputLogs,
ICan
{
/// <summary>
/// msbuild
/// </summary>
public new Target Build => _ => _
.DependsOn(Restore)
.Executes(
() => MSBuild(
settings => settings
.SetSolutionFile(Solution)
.SetProperty("Platform", TargetPlatform.AnyCPU)
.SetConfiguration(Configuration)
.SetDefaultLoggers(LogsDirectory / "build.log")
.SetGitVersionEnvironment(GitVersion)
.SetAssemblyVersion(GitVersion?.FullSemanticVersion())
.SetPackageVersion(GitVersion?.NuGetVersionV2)
)
);
}
File renamed without changes.
79 changes: 0 additions & 79 deletions src/Nuke/Xamarin/ios/ICanBuildXamariniOS.cs

This file was deleted.

74 changes: 0 additions & 74 deletions src/Nuke/Xamarin/mac/ICanBuildXamarinMac.cs

This file was deleted.

0 comments on commit 7641565

Please sign in to comment.