Java Annotations and Constants Do Not Compile Automatically

I have a groovy class that represents a Bean and is uses the Jackson Faster XML library, specifically the com.fasterxml.jackson.annotation.JsonProperty annotation.

What I noticed is that when I use an interface and reference the constants in the annotation the Katalon Studio environment treats it as an error because the interface class has not been instantiated.

When I update anything in the Bean class, revert and save the file, the errors are removed.

Is there are a way to build automatically on launch?
Is there a way to force build the project?

NOTE: I am placing these files in the Inlcudes/scripts/groovy path. If there is a better location, please let me know.

ContactDetailsBean.groovy

@JsonIgnoreProperties(ignoreUnknown = true)
public class ContactDetailsBean implements ContactDetails {

	@JsonProperty(ContactDetails.ID_FIELD)
	private String id;
	@JsonProperty(ContactDetails.PROFILE_FIELD)
	private String profile;
	@JsonProperty(ContactDetails.EMAIL_FIELD)
	private String email;
...

ContactDetails.groovy

public interface ContactDetails {

	public static final String ID_FIELD = "id";
	public static final String PROFILE_FIELD = "profile";
	public static final String EMAIL_FIELD = "email";
...

SOLUTION:
Groovy interface is a trait

public interface ContactDetails {

[updated to]

trait ContactDetails {

I also had to make each method abstract or the Katalon Studio IDE treats them as errors as well.

Reference Groovy Traits

2 Likes