Is it possible to use only 1 import class statement for all groovy scripts if I am using file-based?

46 views
Skip to first unread message

Taras Fog

unread,
May 29, 2017, 5:19:50 AM5/29/17
to job-dsl-plugin
Hi guys,
I have a directory with multiple folders.
E.G. DEV, TST, PROD
and directory with the static class of common methods: helpers. 

In a SEED job I have file-based approach. 
E.G. I provide files and directories wit the scripts.
Then I provide classpath of where helper class is.

Then in each script I use import statement:
import static helpers.JobHelper.*

And then I can use all those methods and everything is fine.

The issue I see is that I am importing this class 300+ times. Because this import statement should be present in each script in order to use those common methods.

Is there possibility somehow import it once in a SEED job and then just use those methods in my groovy-scripts?

I believe it will dramatically improve time for jobs generation taking into consideration that we have 300+ jobs.

Regards,
Taras.

Daniel Spilker

unread,
Jul 6, 2017, 4:29:38 PM7/6/17
to job-dsl...@googlegroups.com
The import statement must be present in every Groovy file that uses the methods from your helpers.

You can try to pre-compile your helpers so that they do not need to be compiled for every script. The Job DSL Gradle example shows how to do that: https://github.com/sheehan/job-dsl-gradle-example.

Daniel

--
You received this message because you are subscribed to the Google Groups "job-dsl-plugin" group.
To unsubscribe from this group and stop receiving emails from it, send an email to job-dsl-plugin+unsubscribe@googlegroups.com.
To post to this group, send email to job-dsl-plugin@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/job-dsl-plugin/5fec7b39-54b5-4232-b024-9ed6b60adc08%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Taras Fog

unread,
Dec 8, 2017, 3:49:26 AM12/8/17
to job-dsl...@googlegroups.com
Thank you, Daniel, for your reply and help on it.

Regards,
Taras.

On Thu, Jul 6, 2017 at 11:29 PM, Daniel Spilker <ma...@daniel-spilker.com> wrote:
The import statement must be present in every Groovy file that uses the methods from your helpers.

You can try to pre-compile your helpers so that they do not need to be compiled for every script. The Job DSL Gradle example shows how to do that: https://github.com/sheehan/job-dsl-gradle-example.

Daniel
On Mon, May 29, 2017 at 11:19 AM, Taras Fog <tarant...@gmail.com> wrote:
Hi guys,
I have a directory with multiple folders.
E.G. DEV, TST, PROD
and directory with the static class of common methods: helpers. 

In a SEED job I have file-based approach. 
E.G. I provide files and directories wit the scripts.
Then I provide classpath of where helper class is.

Then in each script I use import statement:
import static helpers.JobHelper.*

And then I can use all those methods and everything is fine.

The issue I see is that I am importing this class 300+ times. Because this import statement should be present in each script in order to use those common methods.

Is there possibility somehow import it once in a SEED job and then just use those methods in my groovy-scripts?

I believe it will dramatically improve time for jobs generation taking into consideration that we have 300+ jobs.

Regards,
Taras.

--
You received this message because you are subscribed to the Google Groups "job-dsl-plugin" group.
To unsubscribe from this group and stop receiving emails from it, send an email to job-dsl-plugin+unsubscribe@googlegroups.com.

To post to this group, send email to job-dsl...@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "job-dsl-plugin" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/job-dsl-plugin/YYnnOMU8I4I/unsubscribe.
To unsubscribe from this group and all its topics, send an email to job-dsl-plugin+unsubscribe@googlegroups.com.

To post to this group, send email to job-dsl-plugin@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages