@@ -15,9 +15,6 @@ const downloadRC = () => {
1515 const os = require ( 'os' ) ;
1616 const { spawnSync} = require ( 'child_process' ) ;
1717
18- const ON_WINDOWS = os . platform ( ) === 'win32' ;
19- const HAZELCAST_ENTERPRISE_KEY = process . env . HAZELCAST_ENTERPRISE_KEY ? process . env . HAZELCAST_ENTERPRISE_KEY : '' ;
20-
2118 let REPO ;
2219 let ENTERPRISE_REPO ;
2320 let TEST_REPO ;
@@ -36,118 +33,41 @@ const downloadRC = () => {
3633 TEST_REPO = RELEASE_REPO ;
3734 }
3835
39- if ( fs . existsSync ( `hazelcast-remote-controller-${ HAZELCAST_RC_VERSION } .jar` ) ) {
40- console . log ( 'remote controller already exists, not downloading from maven.' ) ;
41- } else {
42- console . log ( 'Downloading: remote-controller jar com.hazelcast:hazelcast-remote-controller:'
43- + HAZELCAST_RC_VERSION ) ;
44- const subprocess = spawnSync ( 'mvn' ,
45- [
46- '-q' ,
47- 'org.apache.maven.plugins:maven-dependency-plugin:2.10:get' ,
48- '-Dtransitive=false' ,
49- `-DremoteRepositories=${ ENTERPRISE_SNAPSHOT_REPO } ` ,
50- `-Dartifact=com.hazelcast:hazelcast-remote-controller:${ HAZELCAST_RC_VERSION } ` ,
51- `-Ddest=hazelcast-remote-controller-${ HAZELCAST_RC_VERSION } .jar`
52- ] , {
53- stdio : 'inherit' ,
54- shell : ON_WINDOWS
55- } ) ;
56- if ( subprocess . status !== 0 ) {
57- const subprocessTrace = subprocess . error ? subprocess . error . stack : '' ;
58- throw 'Failed download remote-controller jar '
59- + `com.hazelcast:hazelcast-remote-controller:${ HAZELCAST_RC_VERSION } ${ subprocessTrace } ` ;
60- }
61- }
36+ downloadArtifact ( ENTERPRISE_SNAPSHOT_REPO , 'hazelcast-remote-controller' , HAZELCAST_RC_VERSION ) ;
37+ downloadArtifact ( TEST_REPO , 'hazelcast' , HAZELCAST_TEST_VERSION , 'tests' ) ;
38+ downloadArtifact ( REPO , 'hazelcast-sql' , HAZELCAST_VERSION ) ;
6239
63- if ( fs . existsSync ( `hazelcast- ${ HAZELCAST_TEST_VERSION } -tests.jar` ) ) {
64- console . log ( 'hazelcast-test.jar already exists, not downloading from maven.' ) ;
40+ if ( process . env . HAZELCAST_ENTERPRISE_KEY ) {
41+ downloadArtifact ( ENTERPRISE_REPO , 'hazelcast-enterprise' , HAZELCAST_ENTERPRISE_VERSION ) ;
6542 } else {
66- console . log ( `Downloading: hazelcast test jar com.hazelcast:hazelcast:${ HAZELCAST_TEST_VERSION } :jar:tests` ) ;
67- const subprocess = spawnSync ( 'mvn' ,
68- [
69- '-q' ,
70- 'org.apache.maven.plugins:maven-dependency-plugin:2.10:get' ,
71- '-Dtransitive=false' ,
72- `-DremoteRepositories=${ TEST_REPO } ` ,
73- `-Dartifact=com.hazelcast:hazelcast:${ HAZELCAST_TEST_VERSION } :jar:tests` ,
74- `-Ddest=hazelcast-${ HAZELCAST_TEST_VERSION } -tests.jar`
75- ] , {
76- stdio : 'inherit' ,
77- shell : ON_WINDOWS
78- } ) ;
79- if ( subprocess . status !== 0 ) {
80- const subprocessTrace = subprocess . error ? subprocess . error . stack : '' ;
81- throw 'Failed download hazelcast test jar com.hazelcast:hazelcast:'
82- + `${ HAZELCAST_TEST_VERSION } :jar:tests ${ subprocessTrace } ` ;
83- }
43+ downloadArtifact ( REPO , 'hazelcast' , HAZELCAST_VERSION ) ;
8444 }
8545
86- if ( fs . existsSync ( `hazelcast-sql-${ HAZELCAST_VERSION } .jar` ) ) {
87- console . log ( 'hazelcast-sql.jar already exists, not downloading from maven.' ) ;
88- } else {
89- console . log ( `Downloading: hazelcast sql jar com.hazelcast:hazelcast-sql:${ HAZELCAST_VERSION } ` ) ;
90- const subprocess = spawnSync ( 'mvn' , [
91- '-q' ,
92- 'org.apache.maven.plugins:maven-dependency-plugin:2.10:get' ,
93- '-Dtransitive=false' ,
94- `-DremoteRepositories=${ REPO } ` ,
95- `-Dartifact=com.hazelcast:hazelcast-sql:${ HAZELCAST_VERSION } ` ,
96- `-Ddest=hazelcast-sql-${ HAZELCAST_VERSION } .jar`
97- ] , {
98- stdio : 'inherit' ,
99- shell : ON_WINDOWS
100- } ) ;
101- if ( subprocess . status !== 0 ) {
102- const subprocessTrace = subprocess . error ? subprocess . error . stack : '' ;
103- throw 'Failed download hazelcast sql jar'
104- + `com.hazelcast:hazelcast-sql:${ HAZELCAST_VERSION } ${ subprocessTrace } ` ;
46+ function downloadArtifact ( repo , artifactId , version , classifier = '' ) {
47+ const filename = classifier ? `${ artifactId } -${ version } -${ classifier } .jar` : `${ artifactId } -${ version } .jar` ;
48+ let artifact = `com.hazelcast:${ artifactId } :${ version } :jar` ;
49+ if ( classifier ) {
50+ artifact += `:${ classifier } ` ;
10551 }
106- }
10752
108- if ( HAZELCAST_ENTERPRISE_KEY ) {
109- if ( fs . existsSync ( `hazelcast-enterprise-${ HAZELCAST_ENTERPRISE_VERSION } .jar` ) ) {
110- console . log ( 'hazelcast-enterprise.jar already exists, not downloading from maven.' ) ;
111- } else {
112- console . log ( 'Downloading: hazelcast enterprise jar '
113- + `com.hazelcast:hazelcast-enterprise:${ HAZELCAST_ENTERPRISE_VERSION } ` ) ;
114- const subprocess = spawnSync ( 'mvn' , [
115- '-q' ,
116- 'org.apache.maven.plugins:maven-dependency-plugin:2.10:get' ,
117- '-Dtransitive=false' ,
118- `-DremoteRepositories=${ ENTERPRISE_REPO } ` ,
119- `-Dartifact=com.hazelcast:hazelcast-enterprise:${ HAZELCAST_ENTERPRISE_VERSION } ` ,
120- `-Ddest=hazelcast-enterprise-${ HAZELCAST_ENTERPRISE_VERSION } .jar`
121- ] , {
122- stdio : 'inherit' ,
123- shell : ON_WINDOWS
124- } ) ;
125- if ( subprocess . status !== 0 ) {
126- const subprocessTrace = subprocess . error ? subprocess . error . stack : '' ;
127- throw 'Failed download hazelcast enterprise jar '
128- + `com.hazelcast:hazelcast-enterprise:${ HAZELCAST_ENTERPRISE_VERSION } ${ subprocessTrace } ` ;
129- }
130- }
131- console . log ( 'Starting Remote Controller ... enterprise ...' ) ;
132- } else {
133- if ( fs . existsSync ( `hazelcast-${ HAZELCAST_VERSION } .jar` ) ) {
134- console . log ( 'hazelcast.jar already exists, not downloading from maven.' ) ;
53+ if ( fs . existsSync ( filename ) ) {
54+ console . log ( '${filename} already exists, download not required' ) ;
13555 } else {
136- console . log ( `Downloading: hazelcast jar com.hazelcast:hazelcast: ${ HAZELCAST_VERSION } ` ) ;
56+ console . log ( `Downloading: ${ artifact } to ${ filename } ` ) ;
13757 const subprocess = spawnSync ( 'mvn' , [
13858 '-q' ,
13959 'org.apache.maven.plugins:maven-dependency-plugin:2.10:get' ,
14060 '-Dtransitive=false' ,
141- `-DremoteRepositories=${ REPO } ` ,
142- `-Dartifact=com.hazelcast:hazelcast: ${ HAZELCAST_VERSION } ` ,
143- `-Ddest=hazelcast- ${ HAZELCAST_VERSION } .jar `
61+ `-DremoteRepositories=${ repo } ` ,
62+ `-Dartifact=${ artifact } ` ,
63+ `-Ddest=${ filename } `
14464 ] , {
14565 stdio : 'inherit' ,
146- shell : ON_WINDOWS
66+ shell : os . platform ( ) === 'win32'
14767 } ) ;
14868 if ( subprocess . status !== 0 ) {
14969 const subprocessTrace = subprocess . error ? subprocess . error . stack : '' ;
150- throw `Failed download hazelcast jar com.hazelcast:hazelcast: ${ HAZELCAST_VERSION } ${ subprocessTrace } ` ;
70+ throw `Failed to download ${ artifact } to ${ filename } - ${ subprocessTrace } ` ;
15171 }
15272 }
15373 }
0 commit comments