Home > Software design >  Use Intellij or Eclipse to develop Groovy scripts for Hybris
Use Intellij or Eclipse to develop Groovy scripts for Hybris

Time:08-25

Developing Groovy scripts within the HAC in Hybris doesn't have any code completion or as-you-type syntax checking, so I'd like to develop Groovy scripts for Hybris in Intellij (preferably) or Eclipse. Intellij supports Groovy projects, and Intellij is what I use for other Hybris development. I tried creating a Groovy project in Intellij (outside of my Hybris project - is that the problem?) and pasted the script I had started in HAC, but it seems like I'm missing some jar files, since all the import statements have Cannot resolve symbol 'de' errors.

import de.hybris.platform.servicelayer.search.FlexibleSearchService

, for example.

flexibleSearchService = spring.getBean("flexibleSearchService") gives me a Cannot resolve symbol 'spring' error.

I wouldn't necessarily need to run the Groovy scripts in Intellij - although if that were possible, it would be very useful for debugging them. I'd just like to be able to catch all my syntax errors and use code completion in Intellij at least, then paste them into HAC to run.

Is this possible? What jar files do I need? Can I copy them from my local Hybris installation?

CodePudding user response:

I will answer the following questions:

1.I tried creating a Groovy project in Intellij (outside of my Hybris project - is that the problem?)

Yes, that is the problem. By creating the groovy script in the same Hybris project you have access to all hybris classes and Intellij will suggest imports and code completion.

2.flexibleSearchService = spring.getBean("flexibleSearchService") gives me a Cannot resolve symbol 'spring' error.

Use Registry.getApplicationContext().getBean("flexibleSearchService") instead

3.Is this possible?

Yes, it is possible and, as already implied in the question, this helps a lot by fixing syntax and also warnings that Intellij shows. Please see below: enter image description here

  • Related