SAP-HybrisCommerce安装recipe包含的三个任务setup-initialize和start

8次阅读

共计 3964 个字符,预计需要花费 10 分钟才能阅读完成。

(1) 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-c…

在 recipe 文件夹里看到的 build.gradle 内容里蕴含的 setup 工作:

应用的两个 plugin:

  • installer-platform-plugin
  • installer-addon-plugin

https://stackoverflow.com/que…:~:text=The%20plugins%20block%20is%20the%20newer%20method%20of,method%20of%20adding%20a%20plugin%20to%20your%20build.

两种申明 plugin 应用的形式:

apply plugin: 'someplugin1'
apply plugin: 'maven'

and other one:
plugins {id 'org.hidetake.ssh' version '1.1.2'}

The plugins block is the newer method of applying plugins, and they must be available in the Gradle plugin repository. The apply approach is the older, yet more flexible method of adding a plugin to your build.
The new plugins method does not work in multi-project configurations (subprojects, allprojects), but will work on the build configuration for each child project.

区别在于后者的语法要求申明的 plugin 必须在 gradle plugin repository 里可用:

Keep in mind, that applying a plugin using the plugins DSL (plugins {…}) does not work for your private plugins or company plugins which are not published to the official Gradle plugin repo. That’s why I hope the old approach will at least survive until the new one does support searching in private repositories.

plugin 的定义

Gradle at its core intentionally provides very little for real world automation. All of the useful features, like the ability to compile Java code, are added by plugins. Plugins add new tasks (e.g. JavaCompile), domain objects (e.g. SourceSet), conventions (e.g. Java source is located at src/main/java) as well as extending core objects and objects from other plugins.

给一个 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/curre…

plugin 的解析

Resolving a plugin means finding the correct version of the jar which contains a given plugin and adding it the script classpath. Once a plugin is resolved, its API can be used in a build script.

一旦插件解析胜利之后,在 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 办法:

插件 installer-platform-plugin 的实现位于 installer 文件夹的 libs 文件夹上面:

setup 实现的源代码:

    void setup() {
        try {beforeSetup.each { it() }
            copyDriverJarIfNeeded()
            storeLocalProperties()
            storeLocalExtensions()
            setupDone = true
            log '>>>>>>>>>> Setting up platform properties/extensions ...... DONE'
        } finally {afterSetup.each { it() }
        }
    }

对于 recipe 的更多阐明,能够查看文件夹下的 readme.txt:

执行完 setup 之后,bin 文件夹的父文件夹内,就会呈现很多平级的文件夹:config, data, log, roles 和 temp.

其中 data 文件夹寄存的是数据库相干的内容:

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”

要获取更多 Jerry 的原创文章,请关注公众号 ” 汪子熙 ”:

正文完
 0