prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Script to build each component from manifest and assemble bundle.
  This script should read a manifest and output all artifacts ready for upload.
  Example.
  /build/opensearch-dashboards-min-1.0.0-SNAPSHOT-linux-arm64-198.tar.gz <- min bundle
  /build/opensearch-dashboards-1.0.0-SNAPSHOT-linux-arm64-198.tar.gz. <-- full bundle
  /build/opensearch-sql-1.0.0.0-rc1.zip
  /build/org/opensearch... <- maven artifacts
  
  Input: to the script should be a manifest file location - format defined here #111 
  Output: all required artifacts are written to ./build
  
  - [x] Clone each component repository defined in the manifest
  - [x] Build each component. This includes plugin zips and maven artifacts and place under a new folder with build id.  Note: We need to know if the version of a particular component is already published to maven central.  If this is the case we do not need to rebuild and include that artifact.
  - [ ] Assemble the bundle itself and add to the /build directory. This is dependent on being able to write manifests - #134 
  
  To make assembling maven artifacts easier, each repo can be published to maven local and copied from that location into /build.  All artifacts will be under org/opensearch.
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `tools/bundle-build/lib/component.py`
  Content:
  ```
  1 import os
  2 import tempfile
  3 import subprocess
  4 from lib.git import GitRepository
  5 
  6 class Component:
  7     def __init__(self, data):
  8         self._name = data['name']
  9         self._repository = data['repository']
  10         self._ref = data['ref']
  11 
  12     def name(self):
  13         return self._name
  14 
  15     def repository(self):
  16         return self._repository
  17 
  18     def git_repository(self):
  19         return self._git_repository
  20 
  21     def ref(self):
  22         return self._ref
  23 
  24     def checkout(self):
  25         self._git_repository = GitRepository(self.repository(), self.ref())
  26 
  27     # script overridden in this repo
  28     def custom_component_script_path(self):
  29         dirname = os.path.dirname(os.path.abspath(__file__))      
  30         return os.path.realpath(os.path.join(dirname, '../../../scripts/bundle-build/components', self.name(), 'build.sh'))
  31 
  32     # script inside the component repo
  33     def component_script_path(self):
  34         dirname = self.git_repository().dir()     
  35         return os.path.realpath(os.path.join(dirname, 'scripts/build.sh'))
  36 
  37     # default gradle script
  38     def default_script_path(self):
  39         dirname = os.path.dirname(os.path.abspath(__file__))      
  40         return os.path.realpath(os.path.join(dirname, '../../../scripts/bundle-build/standard-gradle-build/build.sh'))
  41 
  42     def build_script(self):
  43         paths = [self.component_script_path(), self.custom_component_script_path(), self.default_script_path()]
  44         return next(filter(lambda path: os.path.exists(path), paths), None)
  45 
  46     def build(self, version, arch):
  47         build_script = f'{self.build_script()} {version} {arch}' 
  48         print(f'Running {build_script} ...')
  49         self.git_repository().execute(build_script)
  50 
  51     def artifacts_path(self):
  52         dirname = self.git_repository().dir()
  53         return os.path.realpath(os.path.join(dirname, 'artifacts'))
  54 
  55     def export(self, dest):
  56         artifacts_path = self.artifacts_path()
  57         if os.path.exists(artifacts_path):
  58             print(f'Publishing artifacts from {artifacts_path} into {dest} ...')
  59             self.git_repository().execute(f'cp -r "{artifacts_path}/"* "{dest}"')
  60         else:
  61             print(f'No artifacts found in {artifacts_path}, skipping.')
  62 
  63     def dict(self):
  64         return {
  65             'name': self.name(),
  66             'repository': self.repository(),
  67             'ref': self.ref(),
  68             'sha': self.git_repository().sha()
  69         }
  70
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/tools/bundle-build/lib/component.py b/tools/bundle-build/lib/component.py
  --- a/tools/bundle-build/lib/component.py
  +++ b/tools/bundle-build/lib/component.py
  @@ -21,6 +21,9 @@
       def ref(self):
           return self._ref
   
  +    def artifacts(self):
  +        return self._artifacts
  +
       def checkout(self):
           self._git_repository = GitRepository(self.repository(), self.ref())
   
  @@ -57,13 +60,29 @@
           if os.path.exists(artifacts_path):
               print(f'Publishing artifacts from {artifacts_path} into {dest} ...')
               self.git_repository().execute(f'cp -r "{artifacts_path}/"* "{dest}"')
  +            self.set_artifacts()
           else:
               print(f'No artifacts found in {artifacts_path}, skipping.')
   
  +    def set_artifacts(self):
  +       self._artifacts = {key: self.file_paths(key) for key in ["maven", "plugins", "bundle", "libs"] if self.file_paths(key)}
  +
  +    def file_paths(self, dir_name):
  +      artifacts_path = self.artifacts_path()
  +      sub_dir = os.path.join(artifacts_path, dir_name)
  +      file_paths = []
  +      if os.path.exists(sub_dir):
  +        for dir, dirs, files in os.walk(sub_dir):
  +          for file_name in files:
  +            path = os.path.relpath(os.path.join(dir, file_name), artifacts_path)
  +            file_paths.append(path)
  +      return file_paths
  +
       def dict(self):
           return {
               'name': self.name(),
               'repository': self.repository(),
               'ref': self.ref(),
  -            'sha': self.git_repository().sha()
  +            'sha': self.git_repository().sha(),
  +            'artifacts': self.artifacts()
           }
  
verification_info: {"golden_diff": "diff --git a/tools/bundle-build/lib/component.py b/tools/bundle-build/lib/component.py\n--- a/tools/bundle-build/lib/component.py\n+++ b/tools/bundle-build/lib/component.py\n@@ -21,6 +21,9 @@\n     def ref(self):\n         return self._ref\n \n+    def artifacts(self):\n+        return self._artifacts\n+\n     def checkout(self):\n         self._git_repository = GitRepository(self.repository(), self.ref())\n \n@@ -57,13 +60,29 @@\n         if os.path.exists(artifacts_path):\n             print(f'Publishing artifacts from {artifacts_path} into {dest} ...')\n             self.git_repository().execute(f'cp -r \"{artifacts_path}/\"* \"{dest}\"')\n+            self.set_artifacts()\n         else:\n             print(f'No artifacts found in {artifacts_path}, skipping.')\n \n+    def set_artifacts(self):\n+       self._artifacts = {key: self.file_paths(key) for key in [\"maven\", \"plugins\", \"bundle\", \"libs\"] if self.file_paths(key)}\n+\n+    def file_paths(self, dir_name):\n+      artifacts_path = self.artifacts_path()\n+      sub_dir = os.path.join(artifacts_path, dir_name)\n+      file_paths = []\n+      if os.path.exists(sub_dir):\n+        for dir, dirs, files in os.walk(sub_dir):\n+          for file_name in files:\n+            path = os.path.relpath(os.path.join(dir, file_name), artifacts_path)\n+            file_paths.append(path)\n+      return file_paths\n+\n     def dict(self):\n         return {\n             'name': self.name(),\n             'repository': self.repository(),\n             'ref': self.ref(),\n-            'sha': self.git_repository().sha()\n+            'sha': self.git_repository().sha(),\n+            'artifacts': self.artifacts()\n         }\n", "issue": "Script to build each component from manifest and assemble bundle.\nThis script should read a manifest and output all artifacts ready for upload.\r\nExample.\r\n/build/opensearch-dashboards-min-1.0.0-SNAPSHOT-linux-arm64-198.tar.gz <- min bundle\r\n/build/opensearch-dashboards-1.0.0-SNAPSHOT-linux-arm64-198.tar.gz. <-- full bundle\r\n/build/opensearch-sql-1.0.0.0-rc1.zip\r\n/build/org/opensearch... <- maven artifacts\r\n\r\nInput: to the script should be a manifest file location - format defined here #111 \r\nOutput: all required artifacts are written to ./build\r\n\r\n- [x] Clone each component repository defined in the manifest\r\n- [x] Build each component. This includes plugin zips and maven artifacts and place under a new folder with build id.  Note: We need to know if the version of a particular component is already published to maven central.  If this is the case we do not need to rebuild and include that artifact.\r\n- [ ] Assemble the bundle itself and add to the /build directory. This is dependent on being able to write manifests - #134 \r\n\r\nTo make assembling maven artifacts easier, each repo can be published to maven local and copied from that location into /build.  All artifacts will be under org/opensearch.\r\n\n", "before_files": [{"content": "import os\nimport tempfile\nimport subprocess\nfrom lib.git import GitRepository\n\nclass Component:\n    def __init__(self, data):\n        self._name = data['name']\n        self._repository = data['repository']\n        self._ref = data['ref']\n\n    def name(self):\n        return self._name\n\n    def repository(self):\n        return self._repository\n\n    def git_repository(self):\n        return self._git_repository\n\n    def ref(self):\n        return self._ref\n\n    def checkout(self):\n        self._git_repository = GitRepository(self.repository(), self.ref())\n\n    # script overridden in this repo\n    def custom_component_script_path(self):\n        dirname = os.path.dirname(os.path.abspath(__file__))      \n        return os.path.realpath(os.path.join(dirname, '../../../scripts/bundle-build/components', self.name(), 'build.sh'))\n\n    # script inside the component repo\n    def component_script_path(self):\n        dirname = self.git_repository().dir()     \n        return os.path.realpath(os.path.join(dirname, 'scripts/build.sh'))\n\n    # default gradle script\n    def default_script_path(self):\n        dirname = os.path.dirname(os.path.abspath(__file__))      \n        return os.path.realpath(os.path.join(dirname, '../../../scripts/bundle-build/standard-gradle-build/build.sh'))\n\n    def build_script(self):\n        paths = [self.component_script_path(), self.custom_component_script_path(), self.default_script_path()]\n        return next(filter(lambda path: os.path.exists(path), paths), None)\n\n    def build(self, version, arch):\n        build_script = f'{self.build_script()} {version} {arch}' \n        print(f'Running {build_script} ...')\n        self.git_repository().execute(build_script)\n\n    def artifacts_path(self):\n        dirname = self.git_repository().dir()\n        return os.path.realpath(os.path.join(dirname, 'artifacts'))\n\n    def export(self, dest):\n        artifacts_path = self.artifacts_path()\n        if os.path.exists(artifacts_path):\n            print(f'Publishing artifacts from {artifacts_path} into {dest} ...')\n            self.git_repository().execute(f'cp -r \"{artifacts_path}/\"* \"{dest}\"')\n        else:\n            print(f'No artifacts found in {artifacts_path}, skipping.')\n\n    def dict(self):\n        return {\n            'name': self.name(),\n            'repository': self.repository(),\n            'ref': self.ref(),\n            'sha': self.git_repository().sha()\n        }\n", "path": "tools/bundle-build/lib/component.py"}], "after_files": [{"content": "import os\nimport tempfile\nimport subprocess\nfrom lib.git import GitRepository\n\nclass Component:\n    def __init__(self, data):\n        self._name = data['name']\n        self._repository = data['repository']\n        self._ref = data['ref']\n\n    def name(self):\n        return self._name\n\n    def repository(self):\n        return self._repository\n\n    def git_repository(self):\n        return self._git_repository\n\n    def ref(self):\n        return self._ref\n\n    def artifacts(self):\n        return self._artifacts\n\n    def checkout(self):\n        self._git_repository = GitRepository(self.repository(), self.ref())\n\n    # script overridden in this repo\n    def custom_component_script_path(self):\n        dirname = os.path.dirname(os.path.abspath(__file__))      \n        return os.path.realpath(os.path.join(dirname, '../../../scripts/bundle-build/components', self.name(), 'build.sh'))\n\n    # script inside the component repo\n    def component_script_path(self):\n        dirname = self.git_repository().dir()     \n        return os.path.realpath(os.path.join(dirname, 'scripts/build.sh'))\n\n    # default gradle script\n    def default_script_path(self):\n        dirname = os.path.dirname(os.path.abspath(__file__))      \n        return os.path.realpath(os.path.join(dirname, '../../../scripts/bundle-build/standard-gradle-build/build.sh'))\n\n    def build_script(self):\n        paths = [self.component_script_path(), self.custom_component_script_path(), self.default_script_path()]\n        return next(filter(lambda path: os.path.exists(path), paths), None)\n\n    def build(self, version, arch):\n        build_script = f'{self.build_script()} {version} {arch}' \n        print(f'Running {build_script} ...')\n        self.git_repository().execute(build_script)\n\n    def artifacts_path(self):\n        dirname = self.git_repository().dir()\n        return os.path.realpath(os.path.join(dirname, 'artifacts'))\n\n    def export(self, dest):\n        artifacts_path = self.artifacts_path()\n        if os.path.exists(artifacts_path):\n            print(f'Publishing artifacts from {artifacts_path} into {dest} ...')\n            self.git_repository().execute(f'cp -r \"{artifacts_path}/\"* \"{dest}\"')\n            self.set_artifacts()\n        else:\n            print(f'No artifacts found in {artifacts_path}, skipping.')\n\n    def set_artifacts(self):\n       self._artifacts = {key: self.file_paths(key) for key in [\"maven\", \"plugins\", \"bundle\", \"libs\"] if self.file_paths(key)}\n\n    def file_paths(self, dir_name):\n      artifacts_path = self.artifacts_path()\n      sub_dir = os.path.join(artifacts_path, dir_name)\n      file_paths = []\n      if os.path.exists(sub_dir):\n        for dir, dirs, files in os.walk(sub_dir):\n          for file_name in files:\n            path = os.path.relpath(os.path.join(dir, file_name), artifacts_path)\n            file_paths.append(path)\n      return file_paths\n\n    def dict(self):\n        return {\n            'name': self.name(),\n            'repository': self.repository(),\n            'ref': self.ref(),\n            'sha': self.git_repository().sha(),\n            'artifacts': self.artifacts()\n        }\n", "path": "tools/bundle-build/lib/component.py"}]}