天天看点

SAP Hybris(Commerce)安装recipe包含的三个任务,setup, initialize和start

SAP Hybris(Commerce)安装recipe包含的三个任务,setup, initialize和start

 Setup = Invoked by default if no task is specified with install command. It installs recipe & copies files.

(2) Initialize = Initializes the recipes application.

(3) Start = Start the application.

https://www.novusedu.com/wp-content/uploads/2017/12/4-Hybris-Install.pdf

在recipe文件夹里看到的build.gradle内容里包含的setup任务:

SAP Hybris(Commerce)安装recipe包含的三个任务,setup, initialize和start

使用的两个plugin:

installer-platform-plugin

installer-addon-plugin

https://stackoverflow.com/questions/32352816/what-the-difference-in-applying-gradle-plugin#:~:text=The%20plugins%20block%20is%20the%20newer%20method%20of,method%20of%20adding%20a%20plugin%20to%20your%20build.

两种声明plugin使用的方式:

SAP Hybris(Commerce)安装recipe包含的三个任务,setup, initialize和start
apply plugin: 'someplugin1'
apply plugin: 'maven'

and other one:
plugins {
   id 'org.hidetake.ssh' version '1.1.2'
}      
SAP Hybris(Commerce)安装recipe包含的三个任务,setup, initialize和start

给一个Gradle项目应用plugin,可以扩展该project的功能:

(1) Extend the Gradle model (e.g. add new DSL elements that can be configured)

(2) Configure the project according to conventions (e.g. add new tasks or configure sensible defaults)

(3) Apply specific configuration (e.g. add organizational repositories or enforce standards)

plugin的类型

There are two general types of plugins in Gradle, binary plugins and script plugins - 分为二进制插件和脚本插件两类。

Binary plugins are written either programmatically by implementing Plugin interface or declaratively using one of Gradle’s DSL languages. Binary plugins can reside within a build script, within the project hierarchy or externally in a plugin jar.

Script plugins are additional build scripts that further configure the build and usually implement a declarative approach to manipulating the build. They are typically used within a build although they can be externalized and accessed from a remote location.

https://docs.gradle.org/current/userguide/plugins.html

plugin的解析

SAP Hybris(Commerce)安装recipe包含的三个任务,setup, initialize和start

一旦插件解析成功之后,在build script内可以使用其API.

Script plugins are self-resolving in that they are resolved from the specific file path or URL provided when applying them. - 脚本插件是自动解析的。

Core binary plugins provided as part of the Gradle distribution are automatically resolved. Gradle发行版里自带的核心二进制插件自动被解析。

再回过头来看Hybris recipe文件夹下的build.gradle的三个任务:

setup任务使用了插件installer-platform-plugin的setup方法:

SAP Hybris(Commerce)安装recipe包含的三个任务,setup, initialize和start
SAP Hybris(Commerce)安装recipe包含的三个任务,setup, initialize和start

setup实现的源代码:

void setup() {
        try {
            beforeSetup.each { it() }
            copyDriverJarIfNeeded()
            storeLocalProperties()
            storeLocalExtensions()
            setupDone = true
            log '>>>>>>>>>> Setting up platform properties/extensions ...... DONE'
        } finally {
            afterSetup.each { it() }
        }
    }      
SAP Hybris(Commerce)安装recipe包含的三个任务,setup, initialize和start
SAP Hybris(Commerce)安装recipe包含的三个任务,setup, initialize和start
SAP Hybris(Commerce)安装recipe包含的三个任务,setup, initialize和start
SAP Hybris(Commerce)安装recipe包含的三个任务,setup, initialize和start

config文件夹:It has all config files. Instead modifying files in platform folder, modify them in the config folder (localextensions.xml / local.properties). If you are sure what you doing, then you can also do in platform folder.

为什么Hybris第一次启动前需要先build?

(1) Hybris is extendable complex solution. During build, all referenced components are integrated. (2) Runtime files and configuration files are created, prepared, and validated.

(3) Some parts of Hybris are compiled, such as: - Service Layer & Other Hybris Components

使用ant和maven进行build:

(1) Compiling Source code into Binary code

(2) Generates & compiles Model classes based on definitions in “*-items.xml” file

(3) Running tests

(4) Deployment to production systems

(5) It builds every extension listed (or) referenced by “localextensions.xml”