sorry for the delay in answering.

We don't have an API that allow you to register interest in either the
Bundle or APK at the moment but we are working on it.
I am not sure why you need to sign in IR mode, can you not use normal debug
signatures for debug builds ?

In the meantime, you can use a incubating API so it will definitely change
in the future :

            class APKAccessTask extends DefaultTask {

                @org.gradle.api.tasks.InputFiles
                FileCollection apkFile;

                @javax.inject.Inject
                MappingFileUserTask(FileCollection apkFile) {
                  this.apkFile = apkFile

                  doLast {
                      def file = apkFile.get().getSingleFile()
                      println "APK File  " + file
                      // sign here...

                   }
                }
            }

            android {

                buildTypes {
                  release {
                      minifyEnabled = true
                  }
                }

                // create the apk access task and register it if necessary.
                applicationVariants.all { variant ->
                      def apkFile =
variant.getFinalArtifact(com.android.build.gradle.internal.scope.InternalArtifactType.APK)
                                               // use
com.android.build.gradle.internal.scope.InternalArtifactType.BUNDLE
for bundles.
                      println "Creating signing task for " + variant.name
                      def mappingTask = tasks.create("remoteSign" +
variant.name.capitalize(), APKAccessTask, apkFile)
                }
            }

Like I said, it will change in 3.4 or 3.5 or both so be ready for some pain
when you upgrade. Eventually we will stabilize this.

On Thu, Nov 15, 2018 at 11:53 AM Tomáš Procházka <tomas.procha...@gmail.com>
wrote:

> Yes. I know that I should use lazy tasks. I'm on the way to rewrite it, it
> is because I'm asking if there is any better way.
> Would be great if build plugin provides some interface and allows to
> inject own implementation of it. And allows doing that without a care about
> task creating and it's dependency.
>
> The whole implementation of our tasks is here:
> https://gist.github.com/tprochazka/09bc1fdf6da0de7ad0830c911d10028d
>
> But it has several disadvantages currently:
> 1.) It does not sign app bundles now, just apk
> 2.) it doesn't work from Android Studio when the Instant run is enabled (
> project.android.applicationVariants.all is missing for some reason)
> 3.) It is not lazy enough
>
>
> Dne středa 14. listopadu 2018 18:40:40 UTC+1 Jerome Dochez napsal(a):
>>
>> you should use Lazy  tasks
>>
>> https://docs.gradle.org/current/userguide/lazy_configuration.html
>>
>> How do you express the dependency on the Bundle/APK file you want to sign
>> ?
>>
>> On Wed, Nov 14, 2018 at 5:10 AM Tomáš Procházka <tomas.p...@gmail.com>
>> wrote:
>>
>>> Hi.
>>>
>>> Is there already any more official way how to implement own sign
>>> mechanism which will be used for apk and app bundles?
>>>
>>> We are using a special server where we send the apk and it returns back
>>> signed version.
>>> Currenty we are creating a custom task for every variant which handle
>>> remote sign in this way
>>>
>>>
>>>
>>> project.android.applicationVariants.all { ApplicationVariant variant ->
>>>
>>>     if (!isReleaseBuildType(variant)) {
>>>         return
>>>     }
>>>
>>>     variant.outputs.each { ApkVariantOutput output ->
>>>         project.getLogger().info "Remote signing enabled for build variant: 
>>> $project.name $variant.name"
>>>
>>>         // create a signing task for this
>>>         project.tasks.create(
>>>                 "remoteSign${output.name.capitalize()}Apk", 
>>> RemoteSignApkTask,
>>>                 new RemoteSignApkTask.ConfigAction(variant, output)
>>>         )
>>>     }
>>>
>>>     variant.testVariant?.outputs?.each { ApkVariantOutput output ->
>>>         project.getLogger().info "Remote signing enabled for build test 
>>> variant: $project.name $variant.testVariant.name"
>>>
>>>         // create a signing task for this
>>>         project.tasks.create(
>>>                 "remoteSign${output.name.capitalize()}Apk", 
>>> RemoteSignApkTask,
>>>                 new RemoteSignApkTask.ConfigAction(variant, output)
>>>         )
>>>     }
>>> }
>>>
>>>
>>>
>>> But it starting to be obsolete, it should be rewritten to more lazy
>>> way.  So I'm asking if there is any better way already.
>>>
>>> --
>>> 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+u...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> 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.
>

-- 
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