Heads up! On March 5, starting at 4:30 PM Central Time, our community will be undergoing scheduled maintenance for a few hours. During this time, you will find the site temporarily inaccessible. Thanks for your patience. Read more.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Looking for a better workflow when updating custom classes in the script editor

Tobias Wolff December 3, 2022

Hi,

I have created a custom class in the script editor. Let's assume it is "MyClass" in the package "my.package". When I go to the console, I can import that class with "import my.package.MyClass", instantiate it and run a method on it. So far so good.

What worries me is that when I chance the code in my class, it is not immediately visible to the console as the class is being cached. I learned that I need to clear the Groovy classloader, but when I do that my class actually completely vanishes. If I run the same code in the console (which worked before), it now says, that it cannot find the class.

I explicitly need to run the Groovy class file in the console to get it loaded again. After that the code will start working again.

I am not not sure what I am doing wrong. I do not have an issue with running the Groovy classloader, but the class should then be found again.

Can you help?
   Tobias.

 

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
PD Sheehan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 5, 2022

In my experience, you can cause the updated class to be re-compiled by changing the console script.

Even adding a space on a blank line suffices.

If your script points to MyClassA, and MyClassA has a dependency to MyClassB. This will only work if MyClassA change. It won't if only MyClassB changes. In this case, you want to make a change to MyClassA as well as the Console. The console change will cause MyClassA to be checked for changes. The change will cause MyClassB to be checked.

Tobias Wolff December 8, 2022

Stupid me. The groovy file names in the Script Editor need to carry the exact name of the class they are carrying, so my class needed to be on the file "my/package/MyClass.groovy". Sorry for the fuzz.

TAGS
AUG Leaders

Atlassian Community Events