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 lists- productsand maven repositories
- product: jar-artifact whose main class has public method- getProductStructurewhich returns- product structure
- product structure: lists- component'sand- dependent productsif they are exists
- dependent products: without which it is impossible to install the current product
- component: represented by artifact coordinates (- <groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>) and one or few- deployment procedure
- deployment procedure: lists- actions
- action: represented by- component deployerclass and- params
- component deployer: is instantiated during- deployment procedure, action paremeters are passed using- initmethod
- working folder: used to keep downloaded components and internal data structures
- portable folder: if specified used as a target for- downloadcommand and as an implicit repository. Scenario: download all components to a- portable folder(normally located at the USB flash drive), go to a place where internet is not presented and install products there using- portable folderas a source
- legacy version: product version who deploys without- scm4j-installer
- immutable 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 operation
- listProducts: gets data from offline cache of- product list
- refreshProducts: refreshes cache for- listProducts
- listProductVersions: gets data from offline cache (products-versions.yml)
- refreshProductVersions: refreshes offline cache
- download: downloads given product
- deploy: deploys given product. Downgrade disabled. To downgrade- productneed undeploy- productand install older version
- listDeployedProducts: lists all deployed product from- deployed-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 DP- DPdeployers 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 deps
- Deployer- 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.