From 5c6d65ad19a5f5a34a10dc37b0e5797c0290b046 Mon Sep 17 00:00:00 2001 From: noisyfox Date: Tue, 26 Dec 2017 15:04:14 +1100 Subject: [PATCH] Fix signing identity missing during manual signing --- .../java/org/moe/gradle/tasks/IpaBuild.java | 38 +++++++++++++++---- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/moe/gradle/tasks/IpaBuild.java b/src/main/java/org/moe/gradle/tasks/IpaBuild.java index 66e736a2..e86cbbea 100644 --- a/src/main/java/org/moe/gradle/tasks/IpaBuild.java +++ b/src/main/java/org/moe/gradle/tasks/IpaBuild.java @@ -81,6 +81,7 @@ public class IpaBuild extends AbstractBaseTask { private static final String CONVENTION_BUNDLE_IDENTIFIER = "bundleIdentifier"; private static final String CONVENTION_PROVISIONING_PROFILE_SPECIFIER = "provisioningProfileSpecifier"; private static final String CONVENTION_PROVISIONING_PROFILE = "provisioningProfile"; + private static final String CONVENTION_SIGNING_IDENTITY = "signingIdentity"; public static final String BUNDLE_IDENTIFIER_KEY = "PRODUCT_BUNDLE_IDENTIFIER"; @@ -480,6 +481,21 @@ public void setProvisioningProfile(@Nullable String provisioningProfile) { this.provisioningProfileSpecifier = provisioningProfile; } + @Nullable + private String signingIdentity; + + @Input + @Optional + @Nullable + public String getSigningIdentity() { + return nullableGetOrConvention(signingIdentity, CONVENTION_SIGNING_IDENTITY); + } + + @IgnoreUnused + public void setSigningIdentity(@Nullable String signingIdentity) { + this.signingIdentity = signingIdentity; + } + @Nullable private String target; @@ -663,12 +679,9 @@ protected final void setupMoeTask() { }); addConvention(CONVENTION_ADDITIONAL_PARAMETERS, () -> new ArrayList<>(Arrays.asList("MOE_GRADLE_EXTERNAL_BUILD=YES", "ONLY_ACTIVE_ARCH=NO"))); - addConvention(CONVENTION_PROVISIONING_PROFILE_SPECIFIER, () -> { - return ext.signing.getProvisioningProfileSpecifier(); - }); - addConvention(CONVENTION_PROVISIONING_PROFILE, () -> { - return ext.signing.getProvisioningProfile(); - }); + addConvention(CONVENTION_PROVISIONING_PROFILE_SPECIFIER, ext.signing::getProvisioningProfileSpecifier); + addConvention(CONVENTION_PROVISIONING_PROFILE, ext.signing::getProvisioningProfile); + addConvention(CONVENTION_SIGNING_IDENTITY, ext.signing::getSigningIdentity); addConvention(CONVENTION_LOG_FILE, () -> resolvePathInBuildDir(out, "IpaBuild.log")); } @@ -750,6 +763,12 @@ private List calculateArchiveArgs() { if (provProf != null && !provProf.isEmpty()) { args.add("PROVISIONING_PROFILE=" + provProf); } + + String signingId = getSigningIdentity(); + if(signingId != null && !signingId.isEmpty()) { + args.add("CODE_SIGN_IDENTITY=" + signingId); + } + return args; } @@ -905,10 +924,15 @@ private void generateExportOptionsPlist() { throw new GradleException("Bundle id is null"); } - if (bundleId != null && !bundleId.isEmpty() && provisioningProf != null && !provisioningProf.isEmpty()) { + if (provisioningProf != null && !provisioningProf.isEmpty()) { manager.setProvisioningProfiles(bundleId, provisioningProf); } + String signingId = getSigningIdentity(); + if (signingId != null && !signingId.isEmpty()) { + manager.setSigningCertificate(signingId); + } + manager.save(); } catch (Throwable t) {