New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TestKit failure: cannot find extension of type AppExtension #11338
Comments
I've attempted a couple of workaround based on a conversation in the community slack. This is the original code
it uses the Kotlin DSL. I tried replacing with
and got the error:
Which is ridiculous, as I then tried replacing with
and got the error
and now I don't even. |
Can I get some eyes on this? It's making it impossible to write any functional tests for a plugin designed to work on Android projects. I provided a build scan and a reproducer with clear steps. What else can I do? |
@autonomousapps , are you 100% sure the extension class is valid? The exception message says "Extension of type 'AppExtension' does not exist", and it does say "KotlinAndroidProjectExtension" is present. Are you sure the very same build succeeds and AppExtension indeed is present? PS. You can "wait" for both plugins by using nested calls like plugins.withId("...kotlin...") {
plugins.withId("...android...") {
/* this will be executed when both kotlin and android are activated*/
}
} |
Yes, I'm certain. This same code works when I apply the plugin to a real
android project.
…On Wed, Dec 18, 2019, 2:50 PM Vladimir Sitnikov ***@***.***> wrote:
@autonomousapps <https://github.com/autonomousapps> , are you 100% sure
the extension class is valid?
The exception message says "Extension of type 'AppExtension' does not
exist", and it does say "KotlinAndroidProjectExtension" is present.
Are you sure the very same build succeeds and AppExtension indeed is
present?
PS. You can "wait" for both plugins by using nested calls like
plugins.withId("...kotlin...") {
plugins.withId("...android...") {
/* this will be executed when both kotlin and android are activated*/
}
}
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#11338?email_source=notifications&email_token=ABJG5PMGLX44ZH74PD4NU4DQZKSMTA5CNFSM4JMHABN2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHHYIIA#issuecomment-567247904>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABJG5PPI7TZDUFK45C3UG5DQZKSMTANCNFSM4JMHABNQ>
.
|
I found a workaround, but it's highly unsatisfying. I still think there's a bug in TestKit somewhere. The workaround suggests that my plugin and AGP are loaded in different classloaders and can't see each other. If I add this to my functional test:
then it works. In other words, I'm adding a buildSrc dir to my fake project-under-test in order to force AGP and my plugin to share a classloader. And actually, I'm not sure what the implications are as I iterate on my plugin. Will it actually use my plugin-under-test, or will it use the binary version it is downloading from the gradle plugin portal? |
Unfortunately, it's really not a great workaround. It uses the version of the code hosted by the plugin portal, so I can't use it locally without publishing first. May as well just test manually. |
Finally able to really resolve this. I had
above my Suggestion: the |
@autonomousapps shouldn't you update the issue saying the workaround didn't work at all? |
That's what #11338 (comment) says. |
But your last comment says opposite |
That one does in fact work. It was an ordering issue. I was trying to add the compileOnly dependencies to the test kit classpath, but it was empty, because I did it BEFORE my dependencies declarations. |
Then we should CLOSE this issue. I should open a new one with the real issue that is not being able to test a plugin against multiple versions of the Android Gradle Plugin, which was my issue and as it fails with the same error I thought we where talking about the same. |
This issue has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be automatically closed if no further activity occurs. If you're interested in how we try to keep the backlog in a healthy state, please read our blog post on how we refine our backlog. If you feel this is something you could contribute, please have a look at our Contributor Guide. Thank you for your contribution. |
This issue has been automatically closed due to inactivity. If you can reproduce this on a recent version of Gradle or if you have a good use case for this feature, please feel free to reopen the issue with steps to reproduce, a quick explanation of your use case or a high-quality pull request. |
I am developing a Gradle plugin that reacts to various Android plugins (
com.android.application
andcom.android.library
) in order to report unused dependencies. You can find it here. I have added a stub TestKit functional test. I have actually been able to "build" my stub Android project with TestKit, but the moment I apply my plugin-under-test to theplugins {}
block in this stub project, there is a failure at TestKit-build time. More information in the "Context" section below.Expected Behavior
The functional test should pass.
Current Behavior
The test fails because it cannot find AppExtension. I presume it is failing at this line, but the failure stacktrace is too opaque to be certain.
Context
The issue is affecting me because I cannot write functional tests to validate end-to-end behavior and defend against regressions.
The failure is:
This is nonsensical, since the
com.android.application
plugin has been applied, andAppExtension
must exist at this point. Please note that manual tests of this plugin have succeeded, and the Android "app" defined in the TestKit context "builds" just fine. (You can remove the lineid('com.autonomousapps.dependency-analysis')
and re-run the test, and it will pass.)This issue might be tangentially related to this issue. But please note, I have encountered that particular issue before, and you can see the workaround here.
Steps to Reproduce
./gradlew funcTest
Your Environment
Build scan URL: https://scans.gradle.com/s/zwg5yeodiqauss (but I cannot view it)
The text was updated successfully, but these errors were encountered: