# Export as a component

Module:
Tags: export component

What is a component ? Component is reuse at highest level. Component is a group of modules which can be packaged together to be re-used in any other project. We can export all/any modules in a project as a component.

# How to export a component ?

Module:
Tags: export component

In .ksmile file we need to mention a component's name, version and module name (one or more which needs to be packaged as component)

  • Add a component in Lottery.ksmile

component <component_name>-<version>(<module_name_1> , <module_name_2>)

component release_api-0.1(LotteryPlay, LotteryProcess, LotteryQuery)
  • Export component and upload to repository Exporting a component creates a zip file with a name > <project_name>-<component_name>-<version>-smile-<smile_version>.zip inside /<project_directory>/component/ folder
 [Lottery] $ smile // As we touched .ksmile file
 [Lottery] $ export-component `<component_name>`

Then we upload the component so that it can be downloaded/installed and then imported by other projects.

# Upload a component

Module:
Tags: export component
  • To upload to repository,

upload-to-repo /<project_directory>/component/<project_name>-<component_name>-<version>-smile-<smile_version>.zip

 [Lottery] $ upload-to-repo /Users/vishnuv/metastay/lottery/component/lottery-release_api-0.1-smile-3.5.2.zip

NOTE

We can also test the component without uploading it to the repository.

  • To use the component without uploading, Go to the /<project_directory>/component/ folder to find <project_name>-<component_name>-<version>-smile-<smile_version>.zip and extract it.

  • Inside the unzipped folder, copy everything inside the modules folder and paste it in the modules folder of the project in which we want to use this component.

# Import a component

Module:
Tags: export component

To import a component, we need all the dependent libs and components. So, they should also be added

  • $ add-component <component_name>-<version> and follow the guided steps (if any).
[Lotto] $ add-component lottery-release_api-0.1
[error] add the following dependent components and try again : add-component bread-release-0.4
[Lotto] $ add-component bread-release-0.4
[error] add the following dependent libs and try again : add-lib common-0.1
[Lotto] $ add-lib common-0.1
[info] common-0.1 is added to the project
[info] add the import-lib  'import-lib common-0.1' to /Users/vishnuv/metastay/lotto/k/Lotto.ksmile and smile.
[Lotto] $ add-component bread-release-0.4
[info] bread-release-0.4 is added to the project
[info] refresh eclipse project
[info] add the import  'import-component bread-release-0.4(BreadData,BreadDomain,NotifierProcess)' to /Users/vishnuv/metastay/lotto/k/Lotto.ksmile and smile.
[Lotto] $ add-component lottery-release_api-0.1
[info] lottery-release_api-0.1 is added to the project
[info] refresh eclipse project
[info] add the import  'import-component lottery-release_api-0.1(LotteryData,LotteryDomain,LotteryMongo,LotteryPlay,LotteryProcess,LotteryQuery,LotteryReadMongo,LotteryStream)' to /Users/vishnuv/metastay/lotto/k/Lotto.ksmile and smile.
  1. Import the project and the components to Eclipse and edit .ksmile (dependent components and libs should also be imported).

import-component <component_name>-<version>(<module_name_1> , <module_name_2>)

import-lib common-0.1
import-component bread-release-0.4(NotifierProcess)
import-component lottery-release_api-0.1(LotteryPlay, LotteryProcess, LotteryQuery)

  1. smile (as we touched the .ksmile file)
$ smile