1111 limitations under the License.
1212 */
1313 plugins {
14- id ' java'
14+ id ' java'
1515}
1616
1717group = ' ch.xxx'
1818version = ' 0.0.1-SNAPSHOT'
1919
2020task cleanAngular {
21- if (project. hasProperty(' withAngular' )) {
22- println (' Task cleanAngular' )
23- delete(' src/angular/node_modules' )
24- }
21+ onlyIf {
22+ project. hasProperty(' withAngular' )
23+ }
24+ doLast {
25+ println (' Task cleanAngular' )
26+ delete(' src/angular/node_modules' )
27+ }
28+ }
29+
30+ task cleanDist {
31+ onlyIf {
32+ project. hasProperty(' withAngular' )
33+ }
34+ doLast {
35+ delete(' src/angular/dist' )
36+ }
37+ }
38+
39+ task createDist {
40+ onlyIf {
41+ project. hasProperty(' withAngular' )
42+ }
43+ doLast {
44+ mkdir(' src/angular/dist' )
45+ }
46+ }
47+
48+ task npmInstall (type : Exec ) {
49+ onlyIf {
50+ project. hasProperty(' withAngular' )
51+ }
52+ workingDir = file(' src/angular' )
53+ if (System . getProperty(" os.name" ). toUpperCase(). contains(" WINDOWS" )){
54+ commandLine ' npm.cmd' , ' install'
55+ } else {
56+ commandLine ' npm' , ' install'
57+ }
58+ dependsOn cleanAngular
59+ }
60+
61+ task npmBuild (type : Exec ) {
62+ onlyIf {
63+ project. hasProperty(' withAngular' )
64+ }
65+ workingDir = file(' src/angular' )
66+ if (System . getProperty(" os.name" ). toUpperCase(). contains(" WINDOWS" )){
67+ commandLine ' npm.cmd' , ' run' , ' build'
68+ } else {
69+ commandLine ' npm' , ' run' , ' build'
70+ }
71+ dependsOn npmInstall, cleanDist, createDist
72+ }
73+
74+ task testAngular (type : Exec ) {
75+ onlyIf {
76+ project. hasProperty(' withAngular' )
77+ }
78+ workingDir = file(' src/angular' )
79+ if (System . getProperty(" os.name" ). toUpperCase(). contains(" WINDOWS" )){
80+ commandLine ' npm.cmd' , ' run' , ' test'
81+ } else {
82+ if (project. hasProperty(" useChromium" )) {
83+ commandLine ' npm' , ' run' , ' test-chromium'
84+ } else {
85+ commandLine ' npm' , ' run' , ' test'
86+ }
87+ }
88+ dependsOn npmInstall
89+ doFirst {
90+ println (" Running ${ commandLine.join(' ')} " )
91+ }
2592}
2693
2794task buildAngular {
28- if (project. hasProperty(' withAngular' )) {
29- exec {
30- println (' Task buildAngular - npm install' )
31- workingDir ' src/angular'
32- if (System . getProperty(" os.name" ). toUpperCase(). contains(" WINDOWS" )){
33- commandLine(' npm.cmd' , ' install' )
34- } else {
35- commandLine(' npm' , ' install' )
36- }
37- }
38- exec {
39- println (' Task buildAngular - npm run build' )
40- workingDir ' src/angular'
41- if (System . getProperty(" os.name" ). toUpperCase(). contains(" WINDOWS" )){
42- commandLine(' npm.cmd' , ' run' , ' build' )
43- } else {
44- commandLine(' npm' , ' run' , ' build' )
45- }
46- }
47- }
95+ dependsOn npmBuild, testAngular
4896}
4997
50- task testAngular {
51- if (project. hasProperty(' withAngular' )) {
52- exec {
53- workingDir ' src/angular'
54- if (System . getProperty(" os.name" ). toUpperCase(). contains(" WINDOWS" )){
55- println (' Task buildAngular - npm run test' )
56- commandLine(' npm.cmd' , ' run' , ' test' )
57- } else {
58- if (project. hasProperty(" useChromium" )) {
59- println (' Task buildAngular - npm run test-chromium' )
60- commandLine(' npm' , ' run' , ' test-chromium' )
61- } else {
62- logger. info(' Task buildAngular - npm run test' )
63- commandLine(' npm' , ' run' , ' test' )
64- }
65- }
66- }
67- }
68- }
98+ // Make sure the main build task depends on buildAngular
99+ build. dependsOn buildAngular
0 commit comments