-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Package extension.yml file #86
Comments
This is not as simple as just changing the directory paths. Both "file paths" are accessible with the current setup but neither file path will work in a compiled jar file. The file should be moved to // reads from the root of the classpath so will find something in src/main/resources
InputStream in = this.getClass().getClassLoader().getResourceAsStream("extension.yml");
// or get the filepath
String ymlPath = this.getClass().getClassLoader().getResource("extension.yml").getPath(); You can also get it from the class itself using NIO, but this is relative to the package, so if you're in the // reads from the root of the package
Path ymlPath = Paths.get(this.getClass().getResource("../../../extension.yml").toURI());
// or
File ymlFile = new File(this.getClass().getResource("../../../extension.yml").toURI());
// I think if you lead with a slash you can work around the relative package directory things, so try
Path ymlPath = Paths.get(this.getClass().getResource("/extension.yml").toURI());
// or
String ymlPath = this.getClass().getResource("../../config/dev/example.xml").getPath(); or variations of the above. One other complication for using the classpath: anyone else can have a same-named file on the class path and they will conflict. So a generic name like
|
See this commit for implementation for a different YAML file: 821d27f |
The changes in #109 may make this obsolete. Review discussion on that PR before spending any time on this. |
What is the bug?
Building and running the opensearch-sdk artifact would look for the
extension.yml
file within theopensearch-sdk/build/distributions/opensearch-sdk-1.0.0-SNAPSHOT/src/test/resources/
directory instead of theopensearch-sdk/src/test/resources
directoryHow can one reproduce the bug?
Run
./gradlew build
in theopensearch-sdk
directory to produce the artifact. Navigate toopensearch-sdk/build/distributions/
and untar the generated artifact usingtar -xvf opensearch-sdk-1.0.0-SNAPSHOT.tar
. Navigate toopensearch-sdk-1.0.0-SNAPSHOT/
and run./bin/opensearch-sdk
This will produce the following error :
Exception in thread "main" java.io.FileNotFoundException: src/test/resources/extension.yml (No such file or directory)
In order to fix this issue, we must create the directory within the package and generate the extension.yml file here so that the artifact has access.
EDIT: Following discussion, the extensions.yml file will be moved to the config directory where opensearch.yml is currently stored.
The text was updated successfully, but these errors were encountered: