我正在构建一个Java / angular项目,该项目实际上是要由其他项目导入和使用的。项目设置非常简单:
parent project
|- pom.xml
|- Java-backend
| |- pom.xml
|- webapp (in angular)
| |- pom.xml
我的webapp项目包含package.json,其中包含我的问题。在内部版本中,有一个--base-href
参数,对于每个导入我的项目的项目来说都是不同的。
{
"name": "my-webapp",
"version": "1.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --prod --output-path dist/META-INF/resources --base-href \"/${importing.project.contextroot}/\"",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^6.1.0",
"@angular/common": "^6.1.0",
"@angular/compiler": "^6.1.0",
"@angular/core": "^6.1.0",
"@angular/forms": "^6.1.0",
"@angular/http": "^6.1.0",
"@angular/platform-browser": "^6.1.0",
"@angular/platform-browser-dynamic": "^6.1.0",
"@angular/router": "^6.1.0",
"core-js": "^2.5.4",
"ngx-json-viewer": "^2.3.1",
"rxjs": "~6.2.0",
"zone.js": "~0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.8.0",
"@angular/cli": "~6.2.4",
"@angular/compiler-cli": "^6.1.0",
"@angular/language-service": "^6.1.0",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "~4.3.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~3.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~2.9.2"
}
}
现在,Web应用程序的打包jar包含一个带有标签<base href="/${importing.project.contextroot}/">
的html文件。
如何用适当的值替换此变量?
使用$npm_package_
的解决方案或maven的资源过滤似乎无法为这种情况提供解决方案。