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

gplus:execude does not find dependent scripts in same folder #80

Open
Bassinator opened this issue Aug 31, 2017 · 3 comments
Open

gplus:execude does not find dependent scripts in same folder #80

Bassinator opened this issue Aug 31, 2017 · 3 comments

Comments

@Bassinator
Copy link

I have two scripts, where one script depends on the other as it initializes an object of ist class.
This is explained in this blog:
https://www.jmdawson.net/blog/2014/08/18/using-functions-from-one-groovy-script-in-another/
this does not work with mvn gplus:execude.

@keeganwitt
Copy link
Member

keeganwitt commented Sep 10, 2017

One option you could do is parse the dependent script in the script that depends on it, as described here (https://stackoverflow.com/a/15904699/160256).

I'm not sure there's a great way to execute them within GMavenPlus in the way described in the link. The Groovy scripts aren't directly compiled by GMavenPlus before they are executed, it's just run with groovy.lang.GroovyShell. To do as that author suggests, I think I'd have to write the compiled scripts to a temp directory (not hard), then execute them by dropping into the system shell with java.lang.ProcessBuilder and use whatever JAVA_HOME Maven was invoked with to execute the classes (which seems fairly messy). If you have a better idea for how this could be done, let me know.

@Bassinator
Copy link
Author

Thanks for your answer. I think the most elegant way would be to switch from the GroovyShell to GroovyScriptEngine. The GroovyScriptEngine loads depending classes dynamically from the scripts in the same folder. What do you think? Would it be a huge effort?
Is the project setup complex to contribute to the GMavenPlus Project? Perhaps I can take a look into it?

@keeganwitt
Copy link
Member

keeganwitt commented Sep 14, 2017

Any help is most welcome. There's no real setup, just have Maven and JDK. Project is pretty straight-forward. The only thing that makes it a bit hard to read is that we have to use reflection to access Groovy classes so that the plugin will work with all Groovy versions and not have to have the "providers" GMaven had.

GMavenPlus allows executing scripts defined in the POM itself without needing a script file, so I guess we'd also have to be able to choose between GroovyScriptEngine and GroovyShell at runtime. It also looks like there's no way to bind properties with GroovyScriptEngine, so all the things like project and so forth would be inaccessible with this method. I'll have to look at that class more closely to see whether that's something Groovy could add.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants