@@ -18,51 +18,82 @@ group = '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+ }
2528}
2629
27- task buildAngular (type :Exec ) {
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- }
30+ task cleanDist {
31+ onlyIf {
32+ project. hasProperty(' withAngular' )
33+ }
34+ doLast {
35+ delete(' src/angular/dist' )
36+ }
4837}
4938
50- task testAngular (type :Exec ) {
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- println (' Task buildAngular - npm run test' )
63- commandLine ' npm' , ' run' , ' test'
64- }
65- }
66- }
67- }
39+ task createDist {
40+ onlyIf {
41+ project. hasProperty(' withAngular' )
42+ }
43+ doLast {
44+ mkdir(' src/angular/dist' )
45+ }
6846}
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+ }
92+ }
93+
94+ task buildAngular {
95+ dependsOn npmBuild, testAngular
96+ }
97+
98+ // Make sure the main build task depends on buildAngular
99+ build. dependsOn buildAngular
0 commit comments