Search code examples
androidandroid-gradle-pluginaar

Show annotations in main project


I have a library with methods to which I wrote annotations. Here is one method:

/**
     * Delete Connection.
     * Result is returned through callback.
     *
     * @param customerSecret - current Customer secret code
     * @param connectionSecret - secret code of the Connection which should be deleted if exist
     * @param callback - callback for request result
     */
    public void deleteConnection(String customerSecret,
                                 String connectionSecret,
                                 DeleteEntryResult callback) {
        new ConnectionDeleteConnector(callback).deleteConnection(customerSecret, connectionSecret);
    }

But when I use this method in my main project, I don't see this annotation:

public void deleteConnection(String customerSecret, String connectionSecret, DeleteEntryResult callback) {
    (new ConnectionDeleteConnector(callback)).deleteConnection(customerSecret, connectionSecret);
}

Q: How can I display my annotations in a project?


Solution

  • Resolved my problem with this post

    Recipe is simple:

    Annotate methods to which you want to see annotations

    Write task in build.gradle to choose which classes to document:

    task sourcesJar(type: Jar) {
        from android.sourceSets.main.java.srcDirs
        classifier = 'sources'
    
        include("**/SomeClass.java")
    }
    artifacts {
        archives sourcesJar
    }
    

    After that, rebuild your library and everything should work.