-
Notifications
You must be signed in to change notification settings - Fork 275
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
Detect isAndroidProject based on plugin IDs #237
Conversation
Gradle wrapper to latest as android gradle 3.1.2 needs at minimum 4.4 Test cases to show false positive no longer occurs when parent project has an android extension
Looks like code narc is real upset with a bunch of files I didn't touch as well as with some that I did. My attempt was to hand match the style based on what was in the |
I downgraded the gradle wrapper from |
Glad you thought of that, didn't even cross my mind as a variable. I'll try to get this all touched up tonight. |
codenarc fixes for UtilsTest.groovy
So interesting thing. I can't even run the tests to completion locally unless I upgrade the gradle wrapper. I don't get any errors but it hangs after about 5 tests have ran. I am wondering if the current test suite shouldn't be reworked to minimize the time required? The majority of the time spent isn't even running anything related to this plugin. It should be possible to verify the critical plugin behaviors by analyzing the project and task graph after configuration phase without actually spending all the time required to run the project builds to completion? |
assert isAndroidProject | ||
} | ||
|
||
@Requires({ Version.ANDROID_GRADLE_PLUGIN_VERSION.startsWith("3.") }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be for only 3.x or for 3.x and up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
project.apply plugin:'com.android.base'
will only work from 3.x and up. they add that marker plugin for this exact use case. My thought is that when you can safely abandon pre 3.0 support that case would be all that is required. which is why I have it as the first thing the isAndroidProject checks for.
The problem though is this test will fail with a no such plugin error when the tests are built/ran with 2.+ plugin versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit concerned about the string matching here for the "and up" part of "3.x and up". Should we adapt Utils.compareGradleVersion
to be able to check any version string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea if you think it is worth while I would be happy to make the change. Was just trying to get a guard in there fast so that if someone needed to debug against 2.3.0 they still could.
build.gradle
Outdated
@@ -82,7 +83,7 @@ dependencies { | |||
// Add android plugin to the test classpath, so that we can jump into class definitions, | |||
// read their sources, set break points, etc while debugging android unit tests. | |||
// Change the version if necessary to match the specific unit test. | |||
testRuntime 'com.android.tools.build:gradle:2.3.0' | |||
testCompile 'com.android.tools.build:gradle:3.1.2' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if we follow the pattern in the existing android tests we can construct a project with an android version on a per test project basis. Then we can validate that the new code does not cause problems for android plugin 2.x.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if I follow correctly you are saying we take and create external projects at different android gradle plugin version to validate the utils class implementation?(similar to the way the other test files work)
It will be a decent bit more code and add some runtime overhead of the external gradle processes but should be the most robust way to validate backwards compat.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, validating backwards compat is a requirement for all versions we support. Maybe we some point we would drop support for 2.x but for now I think we should validate all new code for 2.x versions.
I think the tests would probably end up looking something like BuildLogicFunctionalTest.java
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've done tests that way in some other projects I was just trying to be too lazy here. I'll go revamp these tests to use the external run api's which should get rid of the need for the version check Require
on the 3.+ test as well.
ok hopefully that will get through travis without hanging. I want to say I really dislike how hacky the current test project classpath solution is. it doesn't allow gradle to resolve dependencies the way it does in a production environment. I don't know if it will work cleanly with travis but usually what I do is have the test task depend on the maven install task so that my test projects can reference the so fwiw I don't like what I had to do in I would love to help refactor the testing setup classpath config to be more straight forward but I don't think it is appropriate for the scope of this PR. here is an example of what that looks like: |
any hints on how to get the tests to not hang? If I run locally with the gradle wrapper it will deadlock, if I run with local install of 4.8 they run and pass in under 8 minutes |
For unknown reasons, the unit tests hang for Gradle 4.3 on this PR on Travis: google#237 I have confirmed that the code works fine on 4.8.
For unknown reasons, the unit tests hang for Gradle 4.3 on this PR on Travis: google#237 I have confirmed that the code works fine on 4.8.
I spent some time increasing the verbosity of the tests, but I couldn't figure out why it hangs in travis. FWIW the tests work fine for me locally even with gradle 4.3. I'll bump gradle to 4.8: |
For unknown reasons, the unit tests hang for Gradle 4.3 on this PR on Travis: google#237 I have confirmed that the code works fine on 4.8.
For unknown reasons, the unit tests hang for Gradle 4.3 on this PR on Travis: #237 I have confirmed that the code works fine on 4.8.
# Conflicts: # gradle/wrapper/gradle-wrapper.properties
Could the build failure be caused by a mismatch in build tools versions in build_base.gradle? |
yea it is license. with newer versions of gradle plugin they remove the need to specify build tools version. Seeing if I can do both version in travis file. do you want me to squash all these once it is passing or is that the merge policy? |
@zpencer Anything else I need to do for this to get merged? Wanting to do some workflow demo's on Friday morning which requires these changes. hoping I can avoid doing a local install to facilitate a smoke and mirrors demo. |
@trevjonez sorry I let this update slip past me! I've merged the PR now. |
For unknown reasons, the unit tests hang for Gradle 4.3 on this PR on Travis: google#237 I have confirmed that the code works fine on 4.8.
Check for android project by plugin ID
should fix #236