3 Replies Latest reply on Dec 19, 2009 1:50 PM by Piotr Sobczyk

    Groovy doesn't seem Java classes?

    Piotr Sobczyk Newbie

      Hi. I'm using the standard seamgen build script. When I converted one of java files to groovy with eclipse groovy plugin I'm getting info that classes from my application are not visible:


      BUILD FAILED
      C:\Users\Piotrek\Desktop\Programowanie\workspaces\shopping_workspace\Shopping\build.xml:144: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, C:\Users\Piotrek\Desktop\Programowanie\workspaces\shopping_workspace\Shopping\src\main\pl\shopping\project\action\actions\FirstStepAction.groovy: 14: unable to resolve class pl.shopping.project.action.pagemodel.OrderedProductsRow
       @ line 14, column 1.
         import pl.shopping.project.action.pagemodel.OrderedProductsRow;
         ^
      C:\Users\Piotrek\Desktop\Programowanie\workspaces\shopping_workspace\Shopping\src\main\pl\shopping\project\action\actions\FirstStepAction.groovy: 15: unable to resolve class pl.shopping.project.action.OrdersStore
       @ line 15, column 1.
         import pl.shopping.project.action.OrdersStore;
         ^
      C:\Users\Piotrek\Desktop\Programowanie\workspaces\shopping_workspace\Shopping\src\main\pl\shopping\project\action\actions\FirstStepAction.groovy: 16: unable to resolve class pl.shopping.project.model.entities.Product
       @ line 16, column 1.
         import pl.shopping.project.model.entities.Product;
         ^



      and so on. None of java classes from my application are visible. Classes from external are visible. From what I know about groovy it should see all java classes with no problems.

        • 1. Re: Groovy doesn't seem Java classes?
          Ilya Dyoshin Novice

          Verify the classpath of your groovy build.


          it's seems to me that in seam-generated project firstly compiles groovy code. and then the java code. So if you're in the mixed-up environment where some model classes in java, and some in groovy... you should consider modify the compile part of the ant script...





          • 2. Re: Groovy doesn't seem Java classes?
            Piotr Sobczyk Newbie

            Thanks, Ilya.


            The problem was definitely with ant script. In Seam 2.2.0 CR1 the corresponding fragment of war buildfile was:


            <target name="groovy.compilemodel" if="groovy.present">
                 <!-- model is always compiled -->
                <classpathref="build.classpath"
                    destdir="${classes.model.dir}"
                    srcdir="${src.model.dir}" 
                 jointCompilationOptions="-j">
                </groovyc>
             </target>



            and in 2.2.0 GA there is:


            <target name="groovy.compilemodel" if="groovy.present">
                <!-- model is always compiled -->
                <groovyc classpathref="build.classpath"
                      destdir="${classes.model.dir}"
                      srcdir="${src.model.dir}" >
                </groovyc>
             </target>



            Because of

            jointCompilatinOptions="-j"

            in 2.2.0CR1 java classes were joint compiled with groovy classes (i.e groovyc delegated compiling java classes to java and all classes were compiled in correct order). But as it is stated in groovyc task documentation:



            Joint compilation is only available since 1.1-beta-2, jointCompilationOptions is no longer supported, use the nested javac instead

            And that is why Seam developers probably removed this piece in 2.2.0. But I don't know why they didn't put nested javac instead so I had to do it manually:


            <target name="groovy.compilemodel" if="groovy.present">
                    <!-- model is always compiled -->
                <groovyc classpathref="build.classpath"
                           destdir="${classes.model.dir}"
                           srcdir="${src.model.dir}">
                    <javac source="1.6" target="1.6"/>
               </groovyc>
            </target>

            • 3. Re: Groovy doesn't seem Java classes?
              Piotr Sobczyk Newbie

              However now I've got a new strange problem. When I invoke target that include compiling classes (i.e) explode directly from ant then everything works allright but when I activate custom Eclipse builder that invokes my explode target on I'm getting such exception when target is invoked:


              Buildfile: C:\Users\Piotrek\Desktop\Programowanie\workspaces\shopping_workspace\Shopping\build.xml
              
              init:
              
              groovy.compilemodel:
              
              BUILD FAILED
              C:\Users\Piotrek\Desktop\Programowanie\workspaces\shopping_workspace\Shopping\build.xml:144: groovyc doesn't support the "srcdir" attribute



              It may seem that task is not defined properly but there is proper task definition in init target:


               <taskdef name="groovyc"
                          classname ="org.codehaus.groovy.ant.Groovyc"
                          classpathref="build.classpath"/>



              and as you may see above, init target is being invoked before groovy.compilemodel. As I mentioned on the beginning, manually invoking this target works great and with no exception wchich makes this situation very strange :(.


              Anyone experienced such problem? Thanks in advance.