I am using IDEA to generate a service which uses an 'includeFile'.
I have managed to set the IDE to recognize the included file, so that it is available for all the IDE features. However, the type-check Ant task shows an error saying that the variable is not declared.
The code that is throwing the error is:
and the code in the Constants class file is:
I have been able to resolve other type-check issues, but not sure about how to solve this one.
Any ideas would be appreciated.
I added the file to the "includeFiles" and that resolved the "Constants" errors. I was on the right track, but I think I had the relative path set incorrectly.
However, now I am getting errors related to MarkupBuilder (NoClassDefFoundError groovy/lang/Object); I change this to a StreamingMarkupBuilder but I still get errors.
I am trying to use a Closure which takes a Map as input and converts it to xml; the map is a simple list of key:value pairs, only one layer, no nested data structure.
The static type-checker is complaining of various errors such as can't find matching method; cannot resolve dynamic method at run time; cannot assign value of type Object to Writable.
I've spent a while manipulating what I consider the various options, but each one presents the same or a new errors.
I've eliminated a lot of other static type-check errors, but this one is proving a challenge.
Any ideas about options to use other than markup builder(s)?
Can you provide your code?
See code below:
The use case I am working with is:
Hey Mark, I believe your code contains elements that will not resolve under static compilation:
You can however achieve the same result with the XmlDoc class provided in the Fluent API.
You may find this relevant:
Wow, that is quite some blog post.
XmlDoc was what I was looking for, something that would produce xml but be safe for the static type-checker.
I found I had to cast the value in the setText method to String:
But it works! "Ant build completed successfully".
Thanks for the input and ideas. Much appreciated.
Now I can make some more progress with the Fluent SDK; it's a long journey, but I'm taking small steps every day, and learning some tips and tricks as I go.
Great to hear Mark! If you define your map as Map<String, String> you won't need to cast.
Hey, I like that even better; neat and tidy. Thanks
I've replicated your situation and don't get errors in type check.
Can you confirm that your include file does not have a package declaration (i.e. it is in the default package)?
If so, can you provide more of your code please.
You need to add the Contants.groovy file to the fileIncludes attribute of the groovyScript parameter in your service-def.json file.
Ensure you enter a path that is relative to the service-def.json file itself. For example if your Constants.groovy file was in your sources root directory (src) then your file path would be:
Confirmed - the Constants class does not have a package declaration.
Here is the code from the class Constants:
and here is the code from the prefill service that references the Constants file:
and the type-check errors are as follows:
I have set up the IDE to have the file Constants as a module dependency, so that the reference to Constants in the prefill file is recognised; that avoids any IDE errors.