Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Spring AI is not in a release version yet. Given that there are companies that don't allow the use of milestone versions in their projects, they lost the ability of upgrading to the latest version of Redis OM Spring. To give them back the ability to keep using the latest version of Redis OM Spring, it was decided that the dependencies related to Spring AI were going to become optional.
To make them optional, we have two options:
Example in Gradle KTS:
Example in Gradle KTS:
Regardless of the choice we decide to go with, we will need to make sure that the Beans related to AI features are only created in case these dependencies are added to the project. To do so, I decided to:
This allowed me to set a Conditional to the whole configuration class. Unfortunately, adding the condition to the beans itself wasn't an option because SpringBoot would load the whole Configuration class before evaluating the condition for each Bean and resulting in a ClassNotFoundException.
Because of this same reason, I decided to split the RedisOMProperties into itself and RedisOMAiProperties too.
We cannot have two Configuration classes with the same prefix. This forced me to use "redis.om.spring.ai" as the prefix for the new RedisOMAiProperties class.
Besides that I also added a warning to BasicSentinelTest because I spent some time trying to figure out why it was failing until I finally understood that for this specific test I had to manually start the Redis Container.
Moreover, I didn't know if the name or location of the new files are correct.
I tested this by loading Redis OM Spring library in a separate project and testing it with and without the dependencies. I couldn't find a way to test it without the dependencies with the existing testing configuration.
When running the project without the required dependencies and the conditional set to true it will throw a ClassNotFoundException at startup due to the missing classes during Bean creation.
If running without the required dependencies and the conditional set to false, it will normally start.