I read this on the release notes for Gradle plugin 0.7.0:

New API to add extra artifacts on variants. This will let you register Java 
or (later) Android artifacts, for instance for alternative test artifacts 
(e.g. robolectric)
See 'artifactApi' sample for the API (sample is not meant to be used 
directly, it's for testing and to demonstrate the API).

I've seen the example, but I still have my doubts about how this works.

Will I be able to specify if the source directory is a test directory? or 
will it be recognized as source?

>From what I see in the code, they are just registering a provider, but the 
provider interface is really confusing:

    File getManifestFile() {
        return new File(name)
    }

    Collection<File> getJavaDirectories() {
        return Collections.emptyList()
    }

    Collection<File> getResourcesDirectories() {
        return Collections.emptyList()
    }

    Collection<File> getAidlDirectories() {
        return Collections.emptyList()
    }

    Collection<File> getRenderscriptDirectories() {
        return Collections.emptyList()
    }

    Collection<File> getJniDirectories() {
        return Collections.emptyList()
    }

    Collection<File> getResDirectories() {
        return Collections.emptyList()
    }

    Collection<File> getAssetsDirectories() {
        return Collections.emptyList()
     }

Why do I need to specify an android manifest file? will it override the 
default flavor or build type manifest?

If I add a source directory through getJavaDirectories(), will those source 
be treated as part of the app? i.e. production code? can I specify that the 
sources are for test only? Also, since this SourceProviders are being added 
to the variant or build type directly, does that mean that it will affect 
the build itself or are this SourceProviders only for Android Studio to 
pick up and show them?

Also, how can one add a dependency to this?

I'll try to explain what I need to do, and see how it goes from here:

Currently I support a plugin that basically creates a Test task for each 
variant. this task will run JUnit tests. As all Test tasks, it needs the 
.class files of the tests to run. So I need to compile the tests first. So 
I add a Java SourceSet (which for some reason it has already a task 
assigned to it when you create it that compiles the source set) for each 
variant as well and specify the source dir for the tests (.java files) and 
the output dir of this task is the input dir for the test task.

Finally, I create some Configurations (similar to compileDebug, or 
compileFreeDebug) that can be used to add dependencies (like robolectric) 
and I add these configurations to the classpath of the sourceSet so it can 
compile correctly.

Now, Obviously since these tasks and source sets are Java and not part of 
the android model, then AS will not pick either the source directories, nor 
the dependencies.

My question is: How is this new API going to help in making AS recognize 
these source sets and its dependencies without injecting them in the 
production code?

Thank you very much.

-- 
You received this message because you are subscribed to the Google Groups 
"adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to