How do you use AnnotationProcessors.jar to generate component info?

Hi everyone, I'm going to build a new & modern extension builder. And here need help to generate component information. Here I want to use the AnnotationProcessors.jar to generate component information. See below compiled .class directory :arrow_down:

image

I've compiled the sources into build/classes directory. Now how to call AnnotationProcessors.jar to generate component information by Java?

You might also share java -jar AnnotationProcessors.jar <aguments> command if possible like that.

Please help me to generate component information using AnnotationProcessors.jar.

See What I've tried?

java -jar D:\ProjectCompiler\lib\appinventor\AnnotationProcessors.jar build\classes\simple_components.json build\classes\simple_components_build_info.json build\externalComponents build\classes deps


Advance thanks for your time and helps :+1:

2 Likes

try this

java -jar AnnotationProcessors.jar
--components build/classes
--output build/externalComponents
--componentInfo build/classes/simple_components.json
--buildInfo build/classes/simple_components_build_info.json
--deps build/classes/deps

The annotation processors are run as part of the Java compiler and you just need to include the JAR file in the classpath passed to javac. Here's the relevant part of the build.xml file:

Now I'm getting this error after added the AnnotationProcessors.jar to the classpath. Please take a look into the terminal logs and help me.

I'm trying to compile this test project. I could compile it before without the AnnotationProcessors.jar on classpath. But after added it to the classpath now getting the above error. Please help me to resolve this error.

package com.jewel.imagegenerator;

import com.google.appinventor.components.annotations.DesignerComponent;
import com.google.appinventor.components.annotations.SimpleEvent;
import com.google.appinventor.components.annotations.SimpleFunction;
import com.google.appinventor.components.annotations.SimpleObject;
import com.google.appinventor.components.common.ComponentCategory;
import com.google.appinventor.components.runtime.AndroidNonvisibleComponent;
import com.google.appinventor.components.runtime.ComponentContainer;
import com.google.appinventor.components.runtime.EventDispatcher;

@DesignerComponent(version = 1, description = "Test Extension", category = ComponentCategory.EXTENSION, nonVisible = true, iconName = "aiwebres/icon.png")
@SimpleObject(external = true)

public class ImageGenerator extends AndroidNonvisibleComponent {

    public ImageGenerator(ComponentContainer container) {
        super(container.$form());
    }

    @SimpleFunction(description = "Generate images using your keyword.")
    public void Generate(final String keyword) {
       Generated(keyword);
    }

    @SimpleEvent(description = "Triggered when generated images.")
    public void Generated(String testString) {
        EventDispatcher.dispatchEvent(this, "Generated", testString);
    }
}
1 Like

You need to make sure to include json.jar as well, otherwise it will pick up the copies in android.jar, which are just stubs.

1 Like

All jars are added from this directory,

And yes json.jar is added. I don't understand where I am doing wrong.

The order is important. In our build.xml, we have android.jar last so that every other JAR will be first considered.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.