2 Replies Latest reply: Oct 28, 2008 11:17 AM by 843793 RSS

    Call apt with multiple arguments

    843793
      Is it possible to call apt inside a java class and pass multiple .class files?
      For example:
      String[] args = new String[5];
      args[0] = "-nowarn";
      args[1] = "-XclassesAsDecls";
      args[2] = "-classpath";
      args[3] = System.getProperty("java.class.path");          
      args[4] = "packageName.FirstClass packageName.SecondClass";
      
      return Main.process(new MyAnnotationProcessorFactory(),args);
      Result of the above example is:
      error: Could not find class file for packageName.FirstClass packageName.SecondClass
      1 error
        • 1. Re: Call apt with multiple arguments
          843793
          SlipBLR wrote:
          Is it possible to call apt inside a java class and pass multiple .class files?
          That sort of arrangement should be able to work; I suggest verifying the class path is as intended.
          • 2. Re: Call apt with multiple arguments
            843793
            The class path contains classes that we need.
            This example works:
            String[] args = new String[6];
            args[0] = "-nowarn";
            args[1] = "-XclassesAsDecls";
            args[2] = "-classpath";
            args[3] = System.getProperty("java.class.path");     
            args[4] = "packageName.FirstClass";
            args[5] = "packageName.SecondClass";
            return Main.process(new IapiAnnotationProcessorFactory(),args);
            I replaced
            args[4] = "packageName.FirstClass packageName.SecondClass";
            with a
            args[4] = "packageName.FirstClass";
            args[5] = "packageName.SecondClass";