Status: in development
This component automates installation (deployment) of products which are represented by artifacts in maven repositories. download and install are different actions, and if we want to install product without network connection we must download product and all dependencies before installation. If scm4j-deployer-engine can't find valid repository in portable or working folder then they downloads from network.
product list: artifact (yaml file) which listsproductsand maven repositoriesproduct: jar-artifact whose main class has public methodgetProductStructurewhich returnsproduct structureproduct structure: listscomponent'sanddependent productsif they are existsdependent products: without which it is impossible to install the current productcomponent: represented by artifact coordinates (<groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>) and one or fewdeployment proceduredeployment procedure: listsactionsaction: represented bycomponent deployerclass andparamscomponent deployer: is instantiated duringdeployment procedure, action paremeters are passed usinginitmethodworking folder: used to keep downloaded components and internal data structuresportable folder: if specified used as a target fordownloadcommand and as an implicit repository. Scenario: download all components to aportable folder(normally located at the USB flash drive), go to a place where internet is not presented and install products there usingportable folderas a sourcelegacy version: product version who deploys withoutscm4j-installerimmutable product: product, each version of which is a separate product
Thus all dependencies of product artifact are "deployers" and their dependencies i.e. implement deployment logic. Deployment "data" is represented by artifacts which are listed by IProductStructure interface.
Ref. data-structure.md
Scenarious are represeneted by methods of DeployerEngine
DeployerEngine: Constructor does NOT do any network operationlistProducts: gets data from offline cache ofproduct listrefreshProducts: refreshes cache forlistProductslistProductVersions: gets data from offline cache (products-versions.yml)refreshProductVersions: refreshes offline cachedownload: downloads given productdeploy: deploys given product. Downgrade disabled. To downgradeproductneed undeployproductand install older versionlistDeployedProducts: lists all deployed product fromdeployed-products.yml
- Deployment result: OK, NEWER_VERSION_EXISTS, NEED_REBOOT(only for Inno Setup .exe who provide param /restartexitcode={value}), REEBOOT_CONTINUE, INCOMPATIBLE_API_VERSION, ALREADY_INSTALLED, FAILED
- INCOMPATIBLE_API_VERSION: Product should depend on
deployer-apiwhich is compatible with one used by engine - NEED_REBOOT: Only for Inno Setup .exe who provide param /restartexitcode=$restartexitcode. It means that installation succesfully but PC need to restart before work with installed
product - DP - deployed product. Contains IProductStructure, Coords, and deployment URL
- RP - required product
Steps
- API compatibility is checked
- Previously
DPversion is queried (deployed-products.yml), if not found and product implementILegacyProductinterface, ILegacyProduct.queryLegacyDeployedProductis used to getDP - Install dependencies (If product has
dependency products)- all
dependency productsare installed recursively - if one of
dependency productsinstallation fails -DPinstallation fails - if
dependency productinstallation returnsREBOOT_CONTINUE-DPreturnsREBOOT_CONTINUE
- all
- If
DP.version equals toRP.version thenALREADY_INSTALLEDis returned - If
DP.version greater thenRP.version thenNEWER_VERSION_EXISTSis returned - Stop
DPDPdeployers and components are downloaded- All
DPcomponents are stopped in reverse order - If
stopfails allDP-components aredisabled,REBOOT_CONTINUEreturns
- Deployment
- Components which does not exist anymore are undeployed, updated components redeployed (stop/undeploy/deploy), new components deployed
- Start
- All components started
- If
portable folderis specified it is implicitly used as a main repository (before all repos listed inproduct list)
- product which uses
scm4j-deployer-enginemust implementIImmutable - new product deploys in
IProduct.getDefaultDeploymentPathand creates child directory, which is called the same as the product version - file
latestwith latest product version writes inIProduct.getDefaultDeploymentPathdirectory
scm4j-deployer-engine works with scm4j-deployer-api and scm4j-deployer-installers. installers is a project with few classes who knows how to run specific deployer(for example Copy, Unzip, Exec).
Main class in scm4j-deployer-engine is DeployerEngine who describes in # Scenarious Overview. He invokes methods from
Downloader- checks API compatibility and downloads products and their depsDeployer- deploys product and returns deployment result
We create a repository in temporary folder and write test artifacts there. After we download them and their deps from this repository and check equality. To test deployment procedure we use test products (from directory org.scm4j.deployer.engine.products) and test deployers(from directory org.scm4j.deployer.engine.deployers) and mocked IDownloader.