私は異なる環境のビルドスクリプトを書こうとしています。しかし、グローバルプロパティは特定のタスクのために更新されません。ここ はスクリプトです:gradleのグローバルextプロパティを変更する
ext {
springProfilesActive = 'development'
angularAppBasePath = '/test/'
}
task setActiveProfiles {
doLast {
if (project.hasProperty('activeProfiles')) {
springProfilesActive = project.property('activeProfiles')
}
}
}
task setProperties(dependsOn: ':setActiveProfiles') {
doLast {
if (springProfilesActive != 'development') {
angularAppBasePath = '/'
}
println springProfilesActive
println angularAppBasePath
}
}
task buildAngular(type: Exec, dependsOn: ':setProperties') {
workingDir angularPath
commandLine 'cmd', '/c', "npm run build.prod -- --base ${angularAppBasePath}"
}
私はbuildAngular -PactiveProfiles=integration
を実行する場合properiesが正しく設定されています。しかし、angularAppBasePath
は、npmコマンドの古い/test/
の値です。出力:properyはsetProperties
タスクに変更はなくbuildAngular
タスク内の古い値のままされているのはなぜ
Executing external task 'buildAngular -PactiveProfiles=integration'...
:setActiveProfiles
:setProperties
integration
/
:buildAngular
> [email protected] build.prod C:\myapp\src\main\angular
> gulp build.prod --color --env-config prod --build-type prod "--base" "/test/"
?
残念ながら、この変更は効果がありませんでした。 – deve
確かに、 'setProperties'タスクは設定時にも実行されるべきです。コードスニペットにそれを追加するのを忘れてしまった – Stanislav
ありがとう、それはトリックでした。 – deve