1
0
-1

Hi,

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.

Thanks

Mark

    CommentAdd your comment...

    4 answers

    1.  
      1
      0
      -1

      Hi Ben,

      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)?

      Thanks

      Mark

      1. Ben Warner

        Can you provide your code?

         

      2. Mark Murray

        See code below:

        The use case I am working with is:

        • collect encrypted url
        • decrypt url
        • collect request parameters
        • manipulate parameters as required, e.g. date -> day, month, year
        • convert list of parameters to xml to use in Input XML Prefill Mapping

        Thanks

         

      3. Ben Warner

        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:

        http://melix.github.io/blog/2014/02/markuptemplateengine_part2.html

      4. Mark Murray

        Hi Ben,

        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.

        Thanks again.

        Mark

      5. Ben Warner

        Great to hear Mark! If you define your map as Map<String, String> you won't need to cast.

      6. Mark Murray

        Hey, I like that even better; neat and tidy. Thanks

      CommentAdd your comment...
    2.  
      2
      1
      0

      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.

        CommentAdd your comment...
      1.  
        1
        0
        -1

        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:

          CommentAdd your comment...
        1.  
          1
          0
          -1

          Hi Ben,

           

          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.

           

          Thanks

           

            CommentAdd your comment...