4 Replies Latest reply on Sep 13, 2012 7:47 AM by nimo22

    prevent from compiling and packaging classes

    nimo22

      I have a lot of classes in my project and I am wondering how I can prevent from compiling and packaging classes via seam solder.

       

      For example, according to solder documentation (http://docs.jboss.org/seam/3/3.1.0.Final/reference/en-US/html/solder-programmingmodel.html#d0e343),

      when I use this:

      @Veto 
      class Utilities {
         ...
      }

      or

      @Veto 
      package com.example; 
      import org.jboss.solder.core.Veto;

       

      then these classes are also compiled and packaged within my project.

       

      How can I force that a whole class or method is not compiled and packaged within my project? Is there a appropriate annotation for such use cases?

       

      If not, would it be nice to include a solder annotation, such as @ExcludeClass or @ExcludeMethod ?

        • 1. Re: prevent from compiling and packaging classes
          mkouba

          Hi,

          this is not a task for Weld, Solder or any other extension but rather for your build tool (Ant, Maven, Gradle, ...). @Veto will just cause the type to be ignored during bean discovery.

          1 of 1 people found this helpful
          • 2. Re: prevent from compiling and packaging classes
            nimo22

            yes, I know, I can exclude packages or classes by maven (but not methods).

            However, I have thought solder can do that job, too.

            • 3. Re: prevent from compiling and packaging classes
              mkouba

              Well, normally you just can't do any packaging/compilation tasks at runtime, it's simply too late . I believe it's possible but would require some magic bytecode manipulation... (like JRebel, Byteman, etc. do). Nevertheless I wonder what use-case are you're thinking of?

              • 4. Re: prevent from compiling and packaging classes
                nimo22

                Yes, you are right, It is best to use build tool. With Maven I can exclude files (classes). However, look at the following use case:

                 

                 

                @Exclude(value=true)

                public void test(){

                }

                 

                This can be achieved by commenting the method "test" (The compiler does not insert comments within the compiled code):

                /*

                public void test(){

                }

                */

                 

                I can imagine to use this to decide on-the-air compilation of needed/unused methods because of "precompiling".

                Or I can use permutations of my compilations. But I guess, the best is to use build tools.