2
2
3
3
import org .gradle .api .Plugin ;
4
4
import org .gradle .api .Project ;
5
+ import org .gradle .api .tasks .options .Option ;
5
6
import org .gradle .nativeplatform .tasks .AbstractLinkTask ;
6
7
import org .gradle .nativeplatform .tasks .LinkExecutable ;
7
8
8
9
public class WPINativeUtils implements Plugin <Project > {
10
+ private String developerID = null ;
11
+
12
+ @ Option (option = "sign" , description = "Sign with developer ID (MacOS only)" )
13
+ public void sign (String developerID ) {
14
+ if (!System .getProperty ("os.name" ).startsWith ("Mac" )) {
15
+ throw new RuntimeException ("Can't sign binaries on non mac platforms" );
16
+ }
17
+
18
+ this .developerID = developerID ;
19
+ }
20
+
9
21
@ Override
10
22
public void apply (Project project ) {
11
23
project .getPluginManager ().apply (NativeUtils .class );
@@ -17,7 +29,7 @@ public void apply(Project project) {
17
29
project .getPluginManager ().apply (RpathRules .class );
18
30
19
31
if (System .getProperty ("os.name" ).startsWith ("Mac" )) {
20
- if (project . hasProperty ( " developerID" ) ) {
32
+ if (developerID != null ) {
21
33
project .getTasks ().withType (AbstractLinkTask .class ).forEach ((task ) -> {
22
34
// Don't sign any executables because codesign complains
23
35
// about relative rpath.
@@ -26,7 +38,7 @@ public void apply(Project project) {
26
38
String path = task .getLinkedFile ().getAsFile ().get ().getAbsolutePath ();
27
39
ProcessBuilder builder = new ProcessBuilder ();
28
40
var codesigncommand = String .format ("codesign --force --strict --timestamp --options=runtime "
29
- + "--version -s %s %s" , project . findProperty ( " developerID" ) , path );
41
+ + "--version -s %s %s" , developerID , path );
30
42
builder .command ("sh" , "-c" , codesigncommand );
31
43
builder .directory (project .getRootDir ());
32
44
}
0 commit comments