Skip to content

Commit 9cda709

Browse files
committed
[build] Sign '*.node' files for MacOS
This PR has the goal to resolve issue #1403 by implementing the steps that are performed in Orbit to sign Mac '*.node' NPM modules for the WWD build.
1 parent 0e73b60 commit 9cda709

File tree

2 files changed

+97
-2
lines changed

2 files changed

+97
-2
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# This file tells the Maven build to sign the *.node contained in built jar
2+
# see the eclipse-sign-node profile defined in the parent pom
3+
jars.directory = target

pom.xml

Lines changed: 94 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,7 @@
211211
</plugins>
212212
</pluginManagement>
213213
</build>
214-
215-
214+
216215
<profiles>
217216
<profile>
218217
<id>packAndSign</id>
@@ -252,6 +251,99 @@
252251
</plugins>
253252
</build>
254253
</profile>
254+
255+
<profile>
256+
<id>signForMac</id>
257+
<activation>
258+
<activeByDefault>false</activeByDefault>
259+
<file>
260+
<exists>eclipse-sign-node.properties</exists>
261+
</file>
262+
<property>
263+
<name>profile.signForMac</name>
264+
</property>
265+
</activation>
266+
<!--
267+
To activate *.node signing for a bundle, create a file in the project called 'eclipse-sign-node.properties' and
268+
define as value of the key 'jars.directory' the directory that contains the jars whose *.node files have to be signed.
269+
The following ant-script then extracts all *.node files, sign them and repacks them into the jar file.
270+
-->
271+
<build>
272+
<plugins>
273+
<plugin>
274+
<groupId>org.apache.maven.plugins</groupId>
275+
<artifactId>maven-antrun-plugin</artifactId>
276+
<dependencies>
277+
<dependency>
278+
<groupId>ant-contrib</groupId>
279+
<artifactId>ant-contrib</artifactId>
280+
<version>1.0b3</version>
281+
<exclusions>
282+
<exclusion>
283+
<groupId>ant</groupId>
284+
<artifactId>ant</artifactId>
285+
</exclusion>
286+
</exclusions>
287+
</dependency>
288+
</dependencies>
289+
<executions>
290+
<execution>
291+
<id>sign-node-files</id>
292+
<goals>
293+
<goal>run</goal>
294+
</goals>
295+
<phase>verify</phase> <!-- Do this before extracting sources-->
296+
<configuration>
297+
<target>
298+
<!-- See last answer of https://stackoverflow.com/questions/4368243/maven-antrun-with-sequential-ant-contrib-fails-to-run/45958355 -->
299+
<!-- and http://ant-contrib.sourceforge.net/tasks/tasks/index.html -->
300+
<taskdef resource="net/sf/antcontrib/antlib.xml"
301+
classpathref="maven.plugin.classpath" />
302+
<loadproperties srcFile="${project.basedir}/eclipse-sign-node.properties" prefix="signProperties." />
303+
<for param="jarFile">
304+
<fileset dir="${project.basedir}/${signProperties.jars.directory}" includes="**/*.jar" />
305+
<sequential>
306+
<local name="jarFilename" />
307+
<basename property="jarFilename" file="@{jarFile}" suffix=".jar" />
308+
<local name="signingDir" />
309+
<property name="signingDir" value="${project.build.directory}/node-signing/${jarFilename}" />
310+
311+
<unzip src="@{jarFile}" dest="${signingDir}">
312+
<patternset includes="node_modules/**/*.node" />
313+
</unzip>
314+
315+
<for param="nodeFileAbsolute">
316+
<fileset dir="${signingDir}" includes="node_modules/**/*.node" erroronmissingdir="false" />
317+
<sequential>
318+
<echo level="info" message="Mac-sign @{nodeFileAbsolute}" />
319+
<local name="nodeFile" />
320+
<property name="nodeFile" value="@{nodeFileAbsolute}" relative="true" basedir="${signingDir}" />
321+
<move file="@{nodeFileAbsolute}" tofile="@{nodeFileAbsolute}-tosign" />
322+
<exec executable="curl" dir="${signingDir}" failonerror="true">
323+
<arg value="-o" />
324+
<arg value="${nodeFile}" />
325+
<arg value="-F" />
326+
<arg value="file=@${nodeFile}-tosign" />
327+
<arg value="https://cbi.eclipse.org/macos/codesign/sign" />
328+
</exec>
329+
<exec executable="jar" dir="${signingDir}" failonerror="true">
330+
<arg value="--update" />
331+
<arg value="--file=@{jarFile}" />
332+
<arg value="${nodeFile}" />
333+
</exec>
334+
</sequential>
335+
</for>
336+
</sequential>
337+
</for>
338+
</target>
339+
</configuration>
340+
</execution>
341+
</executions>
342+
</plugin>
343+
</plugins>
344+
</build>
345+
</profile>
346+
255347
<!-- Automatic profile for Mac-specific settings -->
256348
<profile>
257349
<id>macos</id>

0 commit comments

Comments
 (0)