i am trying to create (register) a gradle task tha...
# gradle
k
i am trying to create (register) a gradle task that modifies the configuration, but I only want this to happen when the task itself is executed. how can I achieve this?
Copy code
android.defaultConfig.testInstrumentationRunnerArguments.remove 'notClass'
        android.defaultConfig.testInstrumentationRunnerArguments 'class': 'com.boxer.sendHarness.SendMessageHarness'
t
because the notClass is going to be a part of the original task inputs you really shouldn't change it after the configuration phase. (agp in particular generates a ton of new models and tasks at the end of configuration so many times late changes don't work anyway) If the instrumentation runner args are backed by a gradle
Property<T>
you could replace it with a new one that is the output of a task which might give you lazy enough eval to do it without breaking the gradle input/output tracking system.
k
hmmm. I might want to find a different way to do this
maybe I'll just have the task execute the instrumentation directly
t
just trying to do a basic "run androidTest with these args"?
k
i want a gradle task that executes one specific instrumented test, which is normally not executed
👌 1
t
what about doing an additional invocation with an added cli argument for the runner argument?
k
the default configuration disables the class, so I need to invoke the instrumentation directly
t
right but what i mean is:
Copy code
./gradlew app:testVariantAndroidTest
./gradlew app:testVariantAndroidTest -PinstArgs="foo,bar"
nearly everything on the second round would be up-to-date
k
ah, I see what you mean
t
agp might already have a way to do that as well
not sure off the top of my head though
k
yeah was hoping for a self contained gradle task, but not a big deal to use a project property instead
t
there is also the
com.android.test
plugin to make additional test packages. maybe that could be useful
split up your suites to different modules or something like that
k
hmmm
will check that out. thanks!