Status Update
Comments
uc...@google.com <uc...@google.com>
je...@google.com <je...@google.com>
rp...@google.com <rp...@google.com> #2
ku...@google.com <ku...@google.com> #3
Below is the comment from the CL, that we can get some idea what is current behavior.
"we only explicityly build:
a. App modules
b. Non-app modules that no other module depends on
This way, both the IDE and Gradle perform less work",
xa...@google.com <xa...@google.com> #4
Justin, what do you think?
xa...@google.com <xa...@google.com>
so...@google.com <so...@google.com> #5
I have run onto this several times. Compilers are often used to find code dependent on a change you have just made. There is no easy way to recompile all sources in the project in Android Studio.
It makes sense that when you build to launch an app the IDE builds only sources required for the target, but since Ctrl+F9 already builds all modules it is clear that its intention is not to make the least possible number of targets and thus it seems reasonable to build all tests too. Moreover, IDEA usually builds all sources on Ctrl+F9 but only required targets on run/debug.
Alternatively, we can add another build action which can be bound to a custom keyboard shortcut if anyone wants to.
xa...@google.com <xa...@google.com> #6
There are 3 options in the Build
Menu:
- Make Project
- Make Module X
- Recompile Y
The last 2 options are contextual, based on the currently active file opened in the editor, where X is the module, and Y is the file itself.
Option 1 will do:
assemble<Variant>
on the android app module, no matter which file is active in the editor. (It does this for all app modules currently in the project, and also all non-app modules that are not consumed by the current app modules).
Option 2 will do:
- On a java library:
assemble
andtestClasses
, even if the current active file is not a test file - On an android module:
assemble<Variant>
, even if the current active file is a test file
Option 3 will do:
- On a java library:
clean
andtestClasses
, even if the current active file is not a test file - On an android module:
clean
andassemble<Variant>
, even if the current active file is a test file
Proposal
We need to at least have consistent behavior between option 1 and 2 since they should only differ in which modules get build, not how they build them. I would recommend to build:
- fully build the current production variant
- compile the unit-test, code if present
- compile the androidTest, code if present.
For option, 1 this will require manually listing the test and androidTest tasks for each module. This can become a really long list for very large project. We should try it and see if there are scalability issue anywhere.
For option 3, we need to:
- not call
assemble
. The menu item saysRecompile Foo.kt
, notassemble module
. So we just need to call the compilation task. - we should also only clean the compilation task itself, not the full module (ie if call
testClasses
we prepend withcleanTestClasses
) - actually run the compilation task that will compile the current file. Right now it seems to always run a specific one (that is even different for java and android modules), and therefore it can be wrong because it does not actually recompile the current file.
Juan, does this make sense to you?
ju...@google.com <ju...@google.com> #7
di...@gmail.com <di...@gmail.com> #9
Not sure if some of this was already committed, but I have just upgraded to Studio 2020.3.1 Beta 2
+ AGP 7.0.0-beta02
, and getting the following errors when invoking "Make Project" (Ctrl + F9):
e: /path/to/project/lib/lint-checks/src/test/kotlin/ru/kode/base/lint/issue/LambdaTooLongForItTest.kt: (5, 12): Unresolved reference: junit
e: /path/to/project/lib/lint-checks/src/test/kotlin/ru/kode/base/lint/issue/LambdaTooLongForItTest.kt: (9, 4): Unresolved reference: Test
e: /path/to/project/lib/lint-checks/src/test/kotlin/ru/kode/base/lint/issue/LambdaTooLongForItTest.kt: (13, 9): Cannot access 'junit.framework.TestCase' which is a supertype of 'com.android.tools.lint.checks.infrastructure.LintDetectorTest'. Check your module classpath for missing or conflicting dependencies
e: /path/to/project/lib/lint-checks/src/test/kotlin/ru/kode/base/lint/issue/LambdaTooLongForItTest.kt: (26, 4): Unresolved reference: Test
e: /path/to/project/lib/lint-checks/src/test/kotlin/ru/kode/base/lint/issue/LambdaTooLongForItTest.kt: (30, 9): Cannot access 'junit.framework.TestCase' which is a supertype of 'com.android.tools.lint.checks.infrastructure.LintDetectorTest'. Check your module classpath for missing or conflicting dependencies
e: /path/to/project/lib/lint-checks/src/test/kotlin/ru/kode/base/lint/issue/LambdaTooLongForItTest.kt: (43, 4): Unresolved reference: Test
e: /path/to/project/lib/lint-checks/src/test/kotlin/ru/kode/base/lint/issue/LambdaTooLongForItTest.kt: (47, 9): Cannot access 'junit.framework.TestCase' which is a supertype of 'com.android.tools.lint.checks.infrastructure.LintDetectorTest'. Check your module classpath for missing or conflicting dependencies
The classes above are lint-based tests for my custom lint checks.
Here are deps from this module's build.gradle:
dependencies {
compileOnly Deps.coreLibs
compileOnly "com.android.tools.lint:lint-api:$lintVersion"
compileOnly "com.android.tools.lint:lint-checks:$lintVersion"
testCompileOnly "com.android.tools.lint:lint:$lintVersion"
testCompileOnly "com.android.tools.lint:lint-tests:$lintVersion"
}
If I downgrade to Studio 4.2.1 and corresponding AGP version, compilation goes without an error.
xa...@google.com <xa...@google.com> #10
Can you file a separate bug? This bug is about whether the make Project action even trigger a build. Your issues seems to be more about a project dependency setup issue. thank you.
so...@google.com <so...@google.com> #11
We can now better control what tasks are invoked in which case, but we haven't come to agreement on that.
je...@google.com <je...@google.com> #13
make sense, assigning to Sergio.
so...@google.com <so...@google.com> #14
Also related:
sm...@google.com <sm...@google.com>
je...@google.com <je...@google.com>
ga...@google.com <ga...@google.com> #15
Current state is different than one from #6. For Android app and lib (Java lib):
- Build project: this step should select top-level apps and top-level modules (all of these are
main
), and for every top-level module it should also add its tests. Then it proceeds to run as option 2) below. - Build selected modules (
app
andlib
holder modules): it runs[:app:assembleDebug, :app:assembleDebugUnitTest, :app:assembleDebugAndroidTest, :lib:assemble, :lib:testClasses]
. Note: we always run all available assemble tasks on the holder module. - Recompile
$SOURCE
:- If source is in
app
: it runs[:app:clean, :app:assembleDebug, :app:assembleDebugUnitTest, :app:assembleDebugAndroidTest]
- If source is in
lib
: it runs[:lib:clean, :lib:assemble, :lib:testClasses]
- If source is in
Similar to #6, I propose that 1) and 2) behave the same:
- Build project: it runs
[:app:assembleDebug, :app:assembleDebugUnitTest, :app:assembleDebugAndroidTest, :lib:assemble, :lib:testClasses]
- Build selected module:
- the set of modules to build is determined by: adding the "leaf" modules, and for every non-leaf modules we get it's children. E.g. for
app
we'd getapp.main
,app.test
,app.androidTest
. ForMyApplication
(root module), we'd getapp.main
,app.test
,app.androidTest
,lib.main
,lib.test
- for each of the modules from the 1st step we run assemble task
- the set of modules to build is determined by: adding the "leaf" modules, and for every non-leaf modules we get it's children. E.g. for
- we recompile the module that contains the
$SOURCE
file. E.g. if it belongs tolib.test
we run:lib:compileTestJava
, if it belongs toapp.test
we runcompileDebugUnitTestJavaWithJavac
.
Please let me know if you have any concerns with this approach, otherwise I'll start working on it next week.
ga...@google.com <ga...@google.com> #16
Removing from G blocking bugs as it is not a regression.
ga...@google.com <ga...@google.com> #17
Make Project
now triggers assemble for all modules in the IDE, and so does "Rebuild project".
Fixed in ag/I2b36b8b05f80e10869b036f7a94e4f30f45a2e28, which will land in Studio I canary 2.
Description
Android Studio 3.0.1
Build #AI-171.4443003, built on November 9, 2017
JRE: 1.8.0_152-release-915-b01 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.13.12-1-ARCH
Version of Gradle Plugin: 3.0.1
Version of Gradle: 4.1
Steps to Reproduce:
1. Create a basic Kotlin based project (I guess Java one would do too)
2. Add some unit test using some class from project
3. Change that class in ':app' project so that it compiles, but do not adapt unit tests to those changes. For example I create MyClass(val i: Int), write a test for it, then change it to MyClass(val i: Int, val j: Int), but do not edit unit test.
4. Hit Ctrl+F9
As a result "assembleDebug" task is executed and compilation finishes *successfully* despite there's an error in test class now.
But if I manually execute "testDebugUnitTest", then compilation error appears.
Earlier versions of Android Studio used to execute unit testing tasks on Ctrl+F9 and it was highly convenient, because I could catch all the errors at once during refactoring.
Currently there's no easy way to issue something like "compile everyting" from the GUI which leads to the fact that these errors are usually discovered by CI rather than by a developer...