opensearch-mcp-server 2.0.0__tar.gz → 2.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. {opensearch_mcp_server-2.0.0 → opensearch_mcp_server-2.0.2}/.env.example +2 -0
  2. {opensearch_mcp_server-2.0.0 → opensearch_mcp_server-2.0.2}/.gitignore +4 -0
  3. opensearch_mcp_server-2.0.2/CONTRIBUTING.md +76 -0
  4. {opensearch_mcp_server-2.0.0 → opensearch_mcp_server-2.0.2}/Makefile +1 -0
  5. {opensearch_mcp_server-2.0.0 → opensearch_mcp_server-2.0.2}/PKG-INFO +13 -13
  6. {opensearch_mcp_server-2.0.0 → opensearch_mcp_server-2.0.2}/README.md +4 -4
  7. {opensearch_mcp_server-2.0.0 → opensearch_mcp_server-2.0.2}/docker-compose-elasticsearch.yml +5 -5
  8. opensearch_mcp_server-2.0.2/mcp_client/spring-ai/README.md +54 -0
  9. opensearch_mcp_server-2.0.2/mcp_client/spring-ai/build.gradle +44 -0
  10. opensearch_mcp_server-2.0.2/mcp_client/spring-ai/gradle/wrapper/gradle-wrapper.jar +0 -0
  11. opensearch_mcp_server-2.0.2/mcp_client/spring-ai/gradle/wrapper/gradle-wrapper.properties +7 -0
  12. opensearch_mcp_server-2.0.2/mcp_client/spring-ai/gradle.properties +1 -0
  13. opensearch_mcp_server-2.0.2/mcp_client/spring-ai/gradlew +251 -0
  14. opensearch_mcp_server-2.0.2/mcp_client/spring-ai/gradlew.bat +94 -0
  15. opensearch_mcp_server-2.0.2/mcp_client/spring-ai/settings.gradle +1 -0
  16. opensearch_mcp_server-2.0.2/mcp_client/spring-ai/src/main/java/spring/ai/mcp/spring_ai_mcp/Application.java +48 -0
  17. opensearch_mcp_server-2.0.2/mcp_client/spring-ai/src/main/resources/application.yml +16 -0
  18. opensearch_mcp_server-2.0.2/mcp_client/spring-ai/src/main/resources/mcp-servers-config.json +15 -0
  19. opensearch_mcp_server-2.0.2/mcp_client/spring-ai/src/test/java/spring/ai/mcp/spring_ai_mcp/SpringAiMcpApplicationTests.java +13 -0
  20. {opensearch_mcp_server-2.0.0 → opensearch_mcp_server-2.0.2}/pyproject.toml +9 -9
  21. {opensearch_mcp_server-2.0.0 → opensearch_mcp_server-2.0.2}/uv.lock +306 -306
  22. {opensearch_mcp_server-2.0.0 → opensearch_mcp_server-2.0.2}/.github/workflows/pypi-publish.yaml +0 -0
  23. {opensearch_mcp_server-2.0.0 → opensearch_mcp_server-2.0.2}/.github/workflows/release.yml +0 -0
  24. {opensearch_mcp_server-2.0.0 → opensearch_mcp_server-2.0.2}/.python-version +0 -0
  25. {opensearch_mcp_server-2.0.0 → opensearch_mcp_server-2.0.2}/Dockerfile +0 -0
  26. {opensearch_mcp_server-2.0.0 → opensearch_mcp_server-2.0.2}/LICENSE +0 -0
  27. {opensearch_mcp_server-2.0.0 → opensearch_mcp_server-2.0.2}/cliff.toml +0 -0
  28. {opensearch_mcp_server-2.0.0 → opensearch_mcp_server-2.0.2}/docker-compose-opensearch.yml +0 -0
  29. {opensearch_mcp_server-2.0.0/mcp_client → opensearch_mcp_server-2.0.2/mcp_client/python-sdk-anthropic}/.gitignore +0 -0
  30. {opensearch_mcp_server-2.0.0/mcp_client → opensearch_mcp_server-2.0.2/mcp_client/python-sdk-anthropic}/__init__.py +0 -0
  31. {opensearch_mcp_server-2.0.0/mcp_client → opensearch_mcp_server-2.0.2/mcp_client/python-sdk-anthropic}/client.py +0 -0
  32. {opensearch_mcp_server-2.0.0/mcp_client → opensearch_mcp_server-2.0.2/mcp_client/python-sdk-anthropic}/config.py +0 -0
  33. {opensearch_mcp_server-2.0.0 → opensearch_mcp_server-2.0.2}/smithery.yaml +0 -0
  34. {opensearch_mcp_server-2.0.0 → opensearch_mcp_server-2.0.2}/src/__init__.py +0 -0
  35. {opensearch_mcp_server-2.0.0 → opensearch_mcp_server-2.0.2}/src/clients/__init__.py +0 -0
  36. {opensearch_mcp_server-2.0.0 → opensearch_mcp_server-2.0.2}/src/clients/base.py +0 -0
  37. {opensearch_mcp_server-2.0.0 → opensearch_mcp_server-2.0.2}/src/clients/common/__init__.py +0 -0
  38. {opensearch_mcp_server-2.0.0 → opensearch_mcp_server-2.0.2}/src/clients/common/alias.py +0 -0
  39. {opensearch_mcp_server-2.0.0 → opensearch_mcp_server-2.0.2}/src/clients/common/client.py +0 -0
  40. {opensearch_mcp_server-2.0.0 → opensearch_mcp_server-2.0.2}/src/clients/common/cluster.py +0 -0
  41. {opensearch_mcp_server-2.0.0 → opensearch_mcp_server-2.0.2}/src/clients/common/document.py +0 -0
  42. {opensearch_mcp_server-2.0.0 → opensearch_mcp_server-2.0.2}/src/clients/common/index.py +0 -0
  43. {opensearch_mcp_server-2.0.0 → opensearch_mcp_server-2.0.2}/src/clients/exceptions.py +0 -0
  44. {opensearch_mcp_server-2.0.0 → opensearch_mcp_server-2.0.2}/src/server.py +0 -0
  45. {opensearch_mcp_server-2.0.0 → opensearch_mcp_server-2.0.2}/src/tools/__init__.py +0 -0
  46. {opensearch_mcp_server-2.0.0 → opensearch_mcp_server-2.0.2}/src/tools/alias.py +0 -0
  47. {opensearch_mcp_server-2.0.0 → opensearch_mcp_server-2.0.2}/src/tools/cluster.py +0 -0
  48. {opensearch_mcp_server-2.0.0 → opensearch_mcp_server-2.0.2}/src/tools/document.py +0 -0
  49. {opensearch_mcp_server-2.0.0 → opensearch_mcp_server-2.0.2}/src/tools/index.py +0 -0
  50. {opensearch_mcp_server-2.0.0 → opensearch_mcp_server-2.0.2}/src/tools/register.py +0 -0
@@ -2,8 +2,10 @@
2
2
  ELASTICSEARCH_HOSTS=https://localhost:9200
3
3
  ELASTICSEARCH_USERNAME=elastic
4
4
  ELASTICSEARCH_PASSWORD=test123
5
+ ELASTICSEARCH_VERIFY_CERTS=false
5
6
 
6
7
  # OpenSearch connection settings
7
8
  OPENSEARCH_HOSTS=https://localhost:9200
8
9
  OPENSEARCH_USERNAME=admin
9
10
  OPENSEARCH_PASSWORD=admin
11
+ OPENSEARCH_VERIFY_CERTS=false
@@ -10,3 +10,7 @@ __pycache__
10
10
 
11
11
  # Configuration and Credentials
12
12
  .env
13
+
14
+ # Spring AI
15
+ .gradle/
16
+ build
@@ -0,0 +1,76 @@
1
+ # Contributing to Elasticsearch/OpenSearch MCP Server
2
+
3
+ Thank you for your interest in contributing to the Elasticsearch/OpenSearch MCP Server! All kinds of contributions are welcome.
4
+
5
+ ## Bug reports
6
+
7
+ If you think you've found a bug in the Elasticsearch/OpenSearch MCP Server, we welcome your report. It's very helpful if you can provide steps to reproduce the bug, as it makes it easier to identify and fix the issue.
8
+
9
+ ## Feature requests
10
+
11
+ If you find yourself wishing for a feature that doesn't exist in the Elasticsearch/OpenSearch MCP Server, you are probably not alone. Don't be hesitate to open an issue which describes the feature you would like to see, why you need it, and how it should work.
12
+
13
+ ## Pull requests
14
+
15
+ If you have a fix or a new feature, we welcome your pull requests. You can follow the following steps:
16
+
17
+ 1. Fork your own copy of the repository to your GitHub account by clicking on
18
+ `Fork` button on [elasticsearch-mcp-server's GitHub repository](https://github.com/cr7258/elasticsearch-mcp-server).
19
+ 2. Clone the forked repository on your local setup.
20
+
21
+ ```bash
22
+ git clone https://github.com/$user/elasticsearch-mcp-server
23
+ ```
24
+
25
+ Add a remote upstream to track upstream `elasticsearch-mcp-server` repository.
26
+
27
+ ```bash
28
+ git remote add upstream https://github.com/cr7258/elasticsearch-mcp-server
29
+ ```
30
+
31
+ 3. Create a topic branch.
32
+
33
+ ```bash
34
+ git checkout -b <branch-name>
35
+ ```
36
+
37
+ 4. Make changes and commit it locally.
38
+
39
+ ```bash
40
+ git add <modifiedFile>
41
+ git commit
42
+ ```
43
+
44
+ Commit message could help reviewers better understand what is the purpose of submitted PR. It could help accelerate the code review procedure as well. We encourage contributors to use **EXPLICIT** commit message rather than ambiguous message. In general, we advocate the following commit message type:
45
+ - Features: commit message start with `feat`, For example: "feat: add user authentication module"
46
+ - Bug Fixes: commit message start with `fix`, For example: "fix: resolve null pointer exception in user service"
47
+ - Documentation, commit message start with `doc`, For example: "doc: update API documentation for user endpoints"
48
+ - Performance: commit message start with `perf`, For example: "perf: improve the performance of user service"
49
+ - Refactor: commit message start with `refactor`, For example: "refactor: refactor user service to improve code readability"
50
+ - Test: commit message start with `test`, For example: "test: add unit test for user service"
51
+ - Chore: commit message start with `chore`, For example: "chore: update dependencies in pom.xml"
52
+ - Style: commit message start with `style`, For example: "style: format the code in user service"
53
+ - Revert: commit message start with `revert`, For example: "revert: revert the changes in user service"
54
+
55
+ 5. Push local branch to your forked repository.
56
+
57
+ ```bash
58
+ git push
59
+ ```
60
+
61
+ 6. Create a Pull request on GitHub.
62
+ Visit your fork at `https://github.com/$user/elasticsearch-mcp-server` and click
63
+ `Compare & Pull Request` button next to your `<branch-name>`.
64
+
65
+
66
+ ## Keeping branch in sync with upstream
67
+
68
+ Click `Sync fork` button on your forked repository to keep your forked repository in sync with the upstream repository.
69
+
70
+ If you have already created a branch and want to keep it in sync with the upstream repository, follow the below steps:
71
+
72
+ ```bash
73
+ git checkout <branch-name>
74
+ git fetch upstream
75
+ git rebase upstream/main
76
+ ```
@@ -12,6 +12,7 @@ release:
12
12
  tomli_w.dump(data, open("pyproject.toml", "wb"))'
13
13
  @git add pyproject.toml
14
14
  @git commit -m "release: update version to $(version:v%=%)"
15
+ @uv sync
15
16
  @git push origin main
16
17
  @git tag $(version)
17
18
  @git push origin $(version)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: opensearch-mcp-server
3
- Version: 2.0.0
3
+ Version: 2.0.2
4
4
  Summary: MCP Server for interacting with Elasticsearch and OpenSearch
5
5
  License: Apache License
6
6
  Version 2.0, January 2004
@@ -205,14 +205,14 @@ License: Apache License
205
205
  limitations under the License.
206
206
  License-File: LICENSE
207
207
  Requires-Python: >=3.10
208
- Requires-Dist: anthropic>=0.49.0
209
- Requires-Dist: elasticsearch>=8.0.0
210
- Requires-Dist: fastmcp>=0.4.0
211
- Requires-Dist: mcp>=1.0.0
212
- Requires-Dist: opensearch-py>=2.0.0
213
- Requires-Dist: python-dotenv>=1.0.0
214
- Requires-Dist: tomli-w>=1.2.0
215
- Requires-Dist: tomli>=2.2.1
208
+ Requires-Dist: anthropic==0.49.0
209
+ Requires-Dist: elasticsearch==8.17.2
210
+ Requires-Dist: fastmcp==0.4.1
211
+ Requires-Dist: mcp==1.6.0
212
+ Requires-Dist: opensearch-py==2.8.0
213
+ Requires-Dist: python-dotenv==1.1.0
214
+ Requires-Dist: tomli-w==1.2.0
215
+ Requires-Dist: tomli==2.2.1
216
216
  Description-Content-Type: text/markdown
217
217
 
218
218
  # Elasticsearch/OpenSearch MCP Server
@@ -302,7 +302,7 @@ Using `uvx` will automatically install the package from PyPI, no need to clone t
302
302
  "elasticsearch-mcp-server"
303
303
  ],
304
304
  "env": {
305
- "ELASTICSEARCH_HOST": "https://localhost:9200",
305
+ "ELASTICSEARCH_HOSTS": "https://localhost:9200",
306
306
  "ELASTICSEARCH_USERNAME": "elastic",
307
307
  "ELASTICSEARCH_PASSWORD": "test123"
308
308
  }
@@ -319,7 +319,7 @@ Using `uvx` will automatically install the package from PyPI, no need to clone t
319
319
  "opensearch-mcp-server"
320
320
  ],
321
321
  "env": {
322
- "OPENSEARCH_HOST": "https://localhost:9200",
322
+ "OPENSEARCH_HOSTS": "https://localhost:9200",
323
323
  "OPENSEARCH_USERNAME": "admin",
324
324
  "OPENSEARCH_PASSWORD": "admin"
325
325
  }
@@ -345,7 +345,7 @@ Using `uv` requires cloning the repository locally and specifying the path to th
345
345
  "elasticsearch-mcp-server"
346
346
  ],
347
347
  "env": {
348
- "ELASTICSEARCH_HOST": "https://localhost:9200",
348
+ "ELASTICSEARCH_HOSTS": "https://localhost:9200",
349
349
  "ELASTICSEARCH_USERNAME": "elastic",
350
350
  "ELASTICSEARCH_PASSWORD": "test123"
351
351
  }
@@ -365,7 +365,7 @@ Using `uv` requires cloning the repository locally and specifying the path to th
365
365
  "opensearch-mcp-server"
366
366
  ],
367
367
  "env": {
368
- "OPENSEARCH_HOST": "https://localhost:9200",
368
+ "OPENSEARCH_HOSTS": "https://localhost:9200",
369
369
  "OPENSEARCH_USERNAME": "admin",
370
370
  "OPENSEARCH_PASSWORD": "admin"
371
371
  }
@@ -85,7 +85,7 @@ Using `uvx` will automatically install the package from PyPI, no need to clone t
85
85
  "elasticsearch-mcp-server"
86
86
  ],
87
87
  "env": {
88
- "ELASTICSEARCH_HOST": "https://localhost:9200",
88
+ "ELASTICSEARCH_HOSTS": "https://localhost:9200",
89
89
  "ELASTICSEARCH_USERNAME": "elastic",
90
90
  "ELASTICSEARCH_PASSWORD": "test123"
91
91
  }
@@ -102,7 +102,7 @@ Using `uvx` will automatically install the package from PyPI, no need to clone t
102
102
  "opensearch-mcp-server"
103
103
  ],
104
104
  "env": {
105
- "OPENSEARCH_HOST": "https://localhost:9200",
105
+ "OPENSEARCH_HOSTS": "https://localhost:9200",
106
106
  "OPENSEARCH_USERNAME": "admin",
107
107
  "OPENSEARCH_PASSWORD": "admin"
108
108
  }
@@ -128,7 +128,7 @@ Using `uv` requires cloning the repository locally and specifying the path to th
128
128
  "elasticsearch-mcp-server"
129
129
  ],
130
130
  "env": {
131
- "ELASTICSEARCH_HOST": "https://localhost:9200",
131
+ "ELASTICSEARCH_HOSTS": "https://localhost:9200",
132
132
  "ELASTICSEARCH_USERNAME": "elastic",
133
133
  "ELASTICSEARCH_PASSWORD": "test123"
134
134
  }
@@ -148,7 +148,7 @@ Using `uv` requires cloning the repository locally and specifying the path to th
148
148
  "opensearch-mcp-server"
149
149
  ],
150
150
  "env": {
151
- "OPENSEARCH_HOST": "https://localhost:9200",
151
+ "OPENSEARCH_HOSTS": "https://localhost:9200",
152
152
  "OPENSEARCH_USERNAME": "admin",
153
153
  "OPENSEARCH_PASSWORD": "admin"
154
154
  }
@@ -1,6 +1,6 @@
1
1
  services:
2
2
  setup:
3
- image: docker.elastic.co/elasticsearch/elasticsearch:8.6.1
3
+ image: docker.elastic.co/elasticsearch/elasticsearch:8.17.2
4
4
  volumes:
5
5
  - certs:/usr/share/elasticsearch/config/certs
6
6
  user: "0"
@@ -61,7 +61,7 @@ services:
61
61
  depends_on:
62
62
  setup:
63
63
  condition: service_healthy
64
- image: docker.elastic.co/elasticsearch/elasticsearch:8.6.1
64
+ image: docker.elastic.co/elasticsearch/elasticsearch:8.17.2
65
65
  volumes:
66
66
  - certs:/usr/share/elasticsearch/config/certs
67
67
  - esdata01:/usr/share/elasticsearch/data
@@ -106,7 +106,7 @@ services:
106
106
  es02:
107
107
  depends_on:
108
108
  - es01
109
- image: docker.elastic.co/elasticsearch/elasticsearch:8.6.1
109
+ image: docker.elastic.co/elasticsearch/elasticsearch:8.17.2
110
110
  volumes:
111
111
  - certs:/usr/share/elasticsearch/config/certs
112
112
  - esdata02:/usr/share/elasticsearch/data
@@ -148,7 +148,7 @@ services:
148
148
  es03:
149
149
  depends_on:
150
150
  - es02
151
- image: docker.elastic.co/elasticsearch/elasticsearch:8.6.1
151
+ image: docker.elastic.co/elasticsearch/elasticsearch:8.17.2
152
152
  volumes:
153
153
  - certs:/usr/share/elasticsearch/config/certs
154
154
  - esdata03:/usr/share/elasticsearch/data
@@ -195,7 +195,7 @@ services:
195
195
  condition: service_healthy
196
196
  es03:
197
197
  condition: service_healthy
198
- image: docker.elastic.co/kibana/kibana:8.6.1
198
+ image: docker.elastic.co/kibana/kibana:8.17.2
199
199
  volumes:
200
200
  - certs:/usr/share/kibana/config/certs
201
201
  - kibanadata:/usr/share/kibana/data
@@ -0,0 +1,54 @@
1
+ ## Start MCP Client
2
+
3
+ ```bash
4
+ export OPENAI_API_KEY=<your-openai-api-key>
5
+ export OPENAI_BASE_URL=<your-openai-base-url>
6
+ ./gradlew bootRun
7
+ ```
8
+
9
+ ## Ask Questions
10
+
11
+ ```bash
12
+ USER: List the indices in the cluster.
13
+ ASSISTANT: Here are the indices currently present in the cluster:
14
+
15
+ 1. `.internal.alerts-default.alerts-default-000001`
16
+ 2. `.internal.alerts-observability.threshold.alerts-default-000001`
17
+ 3. `.internal.alerts-ml.anomaly-detection-health.alerts-default-000001`
18
+ 4. `.internal.alerts-observability.metrics.alerts-default-000001`
19
+ 5. `.internal.alerts-stack.alerts-default-000001`
20
+ 6. `.internal.alerts-security.alerts-default-000001`
21
+ 7. `.internal.alerts-observability.slo.alerts-default-000001`
22
+ 8. `.internal.alerts-ml.anomaly-detection.alerts-default-000001`
23
+ 9. `.internal.alerts-transform.health.alerts-default-000001`
24
+ 10. `student`
25
+ 11. `.internal.alerts-observability.logs.alerts-default-000001`
26
+ 12. `.internal.alerts-observability.uptime.alerts-default-000001`
27
+ 13. `.internal.alerts-observability.apm.alerts-default-000001`
28
+
29
+ If you need more information about any specific index, feel free to ask!
30
+
31
+ USER: Get student index's mapping.
32
+ ASSISTANT: The mapping for the `student` index is as follows:
33
+
34
+ - **Mappings:**
35
+ - **Properties:**
36
+ - **age:** Type is `long`
37
+ - **major:** Type is `text` with a sub-field `keyword` of type `keyword`, and `ignore_above` set to 256.
38
+ - **name:** Type is `text` with a sub-field `keyword` of type `keyword`, and `ignore_above` set to 256.
39
+
40
+ - **Settings:**
41
+ - **Index:**
42
+ - Routing:
43
+ - Allocation:
44
+ - Include:
45
+ - `_tier_preference`: `data_content`
46
+ - Number of shards: `1`
47
+ - Provided name: `student`
48
+ - Creation date: `1745300793755`
49
+ - Number of replicas: `1`
50
+ - UUID: `RIsbajmcSwKr8DGFjL0sMQ`
51
+ - Version created: `8521000`
52
+
53
+ If you need further details or have any other questions, feel free to ask!
54
+ ```
@@ -0,0 +1,44 @@
1
+ plugins {
2
+ id 'java'
3
+ id 'org.springframework.boot' version '3.4.4'
4
+ id 'io.spring.dependency-management' version '1.1.7'
5
+ }
6
+
7
+ group = 'spring.ai.mcp'
8
+ version = '0.0.1-SNAPSHOT'
9
+
10
+ java {
11
+ toolchain {
12
+ languageVersion = JavaLanguageVersion.of(24)
13
+ }
14
+ }
15
+
16
+ repositories {
17
+ mavenCentral()
18
+ }
19
+
20
+ ext {
21
+ set('springAiVersion', "1.0.0-M7")
22
+ }
23
+
24
+ dependencies {
25
+ implementation 'org.springframework.boot:spring-boot-starter-web'
26
+ implementation 'org.springframework.ai:spring-ai-starter-model-openai'
27
+ implementation 'org.springframework.ai:spring-ai-starter-mcp-client'
28
+ testImplementation 'org.springframework.boot:spring-boot-starter-test'
29
+ testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
30
+ }
31
+
32
+ dependencyManagement {
33
+ imports {
34
+ mavenBom "org.springframework.ai:spring-ai-bom:${springAiVersion}"
35
+ }
36
+ }
37
+
38
+ tasks.named('test') {
39
+ useJUnitPlatform()
40
+ }
41
+
42
+ bootRun {
43
+ standardInput = System.in
44
+ }
@@ -0,0 +1,7 @@
1
+ distributionBase=GRADLE_USER_HOME
2
+ distributionPath=wrapper/dists
3
+ distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
4
+ networkTimeout=10000
5
+ validateDistributionUrl=true
6
+ zipStoreBase=GRADLE_USER_HOME
7
+ zipStorePath=wrapper/dists
@@ -0,0 +1 @@
1
+ org.gradle.console = plain
@@ -0,0 +1,251 @@
1
+ #!/bin/sh
2
+
3
+ #
4
+ # Copyright © 2015-2021 the original authors.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # https://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+ # SPDX-License-Identifier: Apache-2.0
19
+ #
20
+
21
+ ##############################################################################
22
+ #
23
+ # Gradle start up script for POSIX generated by Gradle.
24
+ #
25
+ # Important for running:
26
+ #
27
+ # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
28
+ # noncompliant, but you have some other compliant shell such as ksh or
29
+ # bash, then to run this script, type that shell name before the whole
30
+ # command line, like:
31
+ #
32
+ # ksh Gradle
33
+ #
34
+ # Busybox and similar reduced shells will NOT work, because this script
35
+ # requires all of these POSIX shell features:
36
+ # * functions;
37
+ # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
38
+ # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
39
+ # * compound commands having a testable exit status, especially «case»;
40
+ # * various built-in commands including «command», «set», and «ulimit».
41
+ #
42
+ # Important for patching:
43
+ #
44
+ # (2) This script targets any POSIX shell, so it avoids extensions provided
45
+ # by Bash, Ksh, etc; in particular arrays are avoided.
46
+ #
47
+ # The "traditional" practice of packing multiple parameters into a
48
+ # space-separated string is a well documented source of bugs and security
49
+ # problems, so this is (mostly) avoided, by progressively accumulating
50
+ # options in "$@", and eventually passing that to Java.
51
+ #
52
+ # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
53
+ # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
54
+ # see the in-line comments for details.
55
+ #
56
+ # There are tweaks for specific operating systems such as AIX, CygWin,
57
+ # Darwin, MinGW, and NonStop.
58
+ #
59
+ # (3) This script is generated from the Groovy template
60
+ # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
61
+ # within the Gradle project.
62
+ #
63
+ # You can find Gradle at https://github.com/gradle/gradle/.
64
+ #
65
+ ##############################################################################
66
+
67
+ # Attempt to set APP_HOME
68
+
69
+ # Resolve links: $0 may be a link
70
+ app_path=$0
71
+
72
+ # Need this for daisy-chained symlinks.
73
+ while
74
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
75
+ [ -h "$app_path" ]
76
+ do
77
+ ls=$( ls -ld "$app_path" )
78
+ link=${ls#*' -> '}
79
+ case $link in #(
80
+ /*) app_path=$link ;; #(
81
+ *) app_path=$APP_HOME$link ;;
82
+ esac
83
+ done
84
+
85
+ # This is normally unused
86
+ # shellcheck disable=SC2034
87
+ APP_BASE_NAME=${0##*/}
88
+ # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
89
+ APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
90
+
91
+ # Use the maximum available, or set MAX_FD != -1 to use that value.
92
+ MAX_FD=maximum
93
+
94
+ warn () {
95
+ echo "$*"
96
+ } >&2
97
+
98
+ die () {
99
+ echo
100
+ echo "$*"
101
+ echo
102
+ exit 1
103
+ } >&2
104
+
105
+ # OS specific support (must be 'true' or 'false').
106
+ cygwin=false
107
+ msys=false
108
+ darwin=false
109
+ nonstop=false
110
+ case "$( uname )" in #(
111
+ CYGWIN* ) cygwin=true ;; #(
112
+ Darwin* ) darwin=true ;; #(
113
+ MSYS* | MINGW* ) msys=true ;; #(
114
+ NONSTOP* ) nonstop=true ;;
115
+ esac
116
+
117
+ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
118
+
119
+
120
+ # Determine the Java command to use to start the JVM.
121
+ if [ -n "$JAVA_HOME" ] ; then
122
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
123
+ # IBM's JDK on AIX uses strange locations for the executables
124
+ JAVACMD=$JAVA_HOME/jre/sh/java
125
+ else
126
+ JAVACMD=$JAVA_HOME/bin/java
127
+ fi
128
+ if [ ! -x "$JAVACMD" ] ; then
129
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
130
+
131
+ Please set the JAVA_HOME variable in your environment to match the
132
+ location of your Java installation."
133
+ fi
134
+ else
135
+ JAVACMD=java
136
+ if ! command -v java >/dev/null 2>&1
137
+ then
138
+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
139
+
140
+ Please set the JAVA_HOME variable in your environment to match the
141
+ location of your Java installation."
142
+ fi
143
+ fi
144
+
145
+ # Increase the maximum file descriptors if we can.
146
+ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
147
+ case $MAX_FD in #(
148
+ max*)
149
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
150
+ # shellcheck disable=SC2039,SC3045
151
+ MAX_FD=$( ulimit -H -n ) ||
152
+ warn "Could not query maximum file descriptor limit"
153
+ esac
154
+ case $MAX_FD in #(
155
+ '' | soft) :;; #(
156
+ *)
157
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
158
+ # shellcheck disable=SC2039,SC3045
159
+ ulimit -n "$MAX_FD" ||
160
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
161
+ esac
162
+ fi
163
+
164
+ # Collect all arguments for the java command, stacking in reverse order:
165
+ # * args from the command line
166
+ # * the main class name
167
+ # * -classpath
168
+ # * -D...appname settings
169
+ # * --module-path (only if needed)
170
+ # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
171
+
172
+ # For Cygwin or MSYS, switch paths to Windows format before running java
173
+ if "$cygwin" || "$msys" ; then
174
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
175
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
176
+
177
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
178
+
179
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
180
+ for arg do
181
+ if
182
+ case $arg in #(
183
+ -*) false ;; # don't mess with options #(
184
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
185
+ [ -e "$t" ] ;; #(
186
+ *) false ;;
187
+ esac
188
+ then
189
+ arg=$( cygpath --path --ignore --mixed "$arg" )
190
+ fi
191
+ # Roll the args list around exactly as many times as the number of
192
+ # args, so each arg winds up back in the position where it started, but
193
+ # possibly modified.
194
+ #
195
+ # NB: a `for` loop captures its iteration list before it begins, so
196
+ # changing the positional parameters here affects neither the number of
197
+ # iterations, nor the values presented in `arg`.
198
+ shift # remove old arg
199
+ set -- "$@" "$arg" # push replacement arg
200
+ done
201
+ fi
202
+
203
+
204
+ # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
205
+ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
206
+
207
+ # Collect all arguments for the java command:
208
+ # * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
209
+ # and any embedded shellness will be escaped.
210
+ # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
211
+ # treated as '${Hostname}' itself on the command line.
212
+
213
+ set -- \
214
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
215
+ -classpath "$CLASSPATH" \
216
+ org.gradle.wrapper.GradleWrapperMain \
217
+ "$@"
218
+
219
+ # Stop when "xargs" is not available.
220
+ if ! command -v xargs >/dev/null 2>&1
221
+ then
222
+ die "xargs is not available"
223
+ fi
224
+
225
+ # Use "xargs" to parse quoted args.
226
+ #
227
+ # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
228
+ #
229
+ # In Bash we could simply go:
230
+ #
231
+ # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
232
+ # set -- "${ARGS[@]}" "$@"
233
+ #
234
+ # but POSIX shell has neither arrays nor command substitution, so instead we
235
+ # post-process each arg (as a line of input to sed) to backslash-escape any
236
+ # character that might be a shell metacharacter, then use eval to reverse
237
+ # that process (while maintaining the separation between arguments), and wrap
238
+ # the whole thing up as a single "set" statement.
239
+ #
240
+ # This will of course break if any of these variables contains a newline or
241
+ # an unmatched quote.
242
+ #
243
+
244
+ eval "set -- $(
245
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
246
+ xargs -n1 |
247
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
248
+ tr '\n' ' '
249
+ )" '"$@"'
250
+
251
+ exec "$JAVACMD" "$@"