Transforms on Library projects can only apply to Scope.PROJECT
and Scope.PROJECT_LOCAL_DEPS. If you apply to more scopes it'll fail to
apply (and should display an error).

On Thu, Apr 14, 2016 at 12:12 AM, 郭霖 <sinyu890...@gmail.com> wrote:

> I wrote a custom Transform implementation, and it can do the transform
> logic:
>
> public class MyTransform extends Transform {
>
>     private Project project
>
>     public MyTransform(Project project) {
>         this.project = project
>     }
>
>     @Override
>     public String getName() {
>         return "MyTransform"
>     }
>
>     @Override
>     public Set<QualifiedContent.ContentType> getInputTypes() {
>         return EnumSet.of(QualifiedContent.DefaultContentType.CLASSES)
>     }
>
>     @Override
>     public Set<QualifiedContent.Scope> getScopes() {
>         return EnumSet.of(QualifiedContent.Scope.PROJECT,
>                 QualifiedContent.Scope.PROJECT_LOCAL_DEPS,
>                 QualifiedContent.Scope.SUB_PROJECTS,
>                 QualifiedContent.Scope.SUB_PROJECTS_LOCAL_DEPS,
>                 QualifiedContent.Scope.EXTERNAL_LIBRARIES,
>                 )
>     }
>
>
>     @Override
>     public boolean isIncremental() {
>         return false
>     }
>
>     @Override
>     public void transform(TransformInvocation transformInvocation) throws 
> TransformException, InterruptedException, IOException {
>         super.transform(transformInvocation)
>         transformInvocation.inputs.each { input ->
>             input.directoryInputs.each { dirInput ->
>                 File dirOutput = 
> transformInvocation.outputProvider.getContentLocation(dirInput.name, 
> dirInput.contentTypes, dirInput.scopes, Format.DIRECTORY)
>                 // Do transform logic here
>                 FileUtils.copyDirectory(dirInput.file, dirOutput)
>             }
>             input.jarInputs.each { jarInput ->
>
>             }
>         }
>
>     }
>
> }
>
>
> But now I met another problem. Cause this could only do the transform
> logic for codes in the app module or jar dependencies. My project still has
> some library modules. I want these codes in the library modules could be
> transformed as well.
>
> Is it possible to do that?
>
> --
> 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 adt-dev+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Xavier Ducrohet
Android SDK Tech Lead
Google Inc.
http://developer.android.com | http://tools.android.com

Please do not send me questions directly. Thanks!

-- 
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 adt-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to