Skip to content
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

Add ability to load include scripts from non-classpath locations #7

Merged
merged 1 commit into from
Apr 19, 2017

Conversation

fromanator
Copy link
Contributor

This is a pretty simple solution to the problem described in #4

@fromanator
Copy link
Contributor Author

Being able to provide any absolute path makes this library a lot more flexible than just being able to provide your own ClassLoader as suggested in #4.

This means you can use Cassalog for doing schema migrations outside of an actual codebase by providing a thin CLI wrapper. Or in my use case I am writing a standalone gradle plugin, where it's a challenge to have the required ClassLoader for retrieving the include scripts.

@jsanda
Copy link
Contributor

jsanda commented Apr 17, 2017

Thanks for the PR. Would you mind adding a unit test for your change?

In Hawkular Metrics we have adopted a convention of a separate script per release when we have schema changes, so we make extensive use of the include function. It probably would not make a whole lot of sense to mix including classpath and non-classpath scripts, but in the even someone does, how do we resolve the path? Do we need to also update the include function?

@fromanator
Copy link
Contributor Author

Just updated my PR to include tests for loading the include scripts from an absolute file path.

Also currently you can do a non-classpath script already if you do not use any include within the first script that you pass to Cassalog.execute(URI script), since you can pass a URI to a non-classpath location and it will load properly. The issue arises when your initial script uses include which only knows how to load files on the classpath. My change simply looks to see if a baseScriptsPath is set, if it is files are loaded from within that absolute path, otherwise they are classpath loaded.

@jsanda
Copy link
Contributor

jsanda commented Apr 19, 2017

Thanks for the PR!

@jsanda jsanda merged commit 33423ed into hawkular:master Apr 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants