Office Hours — Today, July 11

Tuesday, July 9

Jul 11
7:25 PM
Mark M.
has entered the room
Mark M.
turned on guest access
7:30 PM
Erik
has entered the room
Mark M.
hello, Erik!
how can I help you today?
Erik
hi mark!
how do I exclude a subdirectory in a gradle task?
Mark M.
a subdirectory of what?
source? resources? assets? something else?
Erik
I have 2 flavors, free and paid. tests for the paid flavor reside in 'src/testPaid'. When I run the gradle wrapper compileFreeDebugUnitTestKotlin fails because it tries to run tests in src/testPaid
Benny
has entered the room
Benny
Hello everyone
Erik
hello benny
Mark M.
(hello, Benny -- I will be with you shortly!)
compileFreeDebugUnitTestKotlin should not be running any tests, as it is just a compile task
7:35 PM
Erik
it fails to compile the test because it does not recognize classes exclusive to the other flavor
Mark M.
OK, that part is not surprising
if you run app code, tests don't need to successfully
er, successfully compile
once you start running tests, they all need to compile, IIRC
so, why do the src/testPaid tests not compile?
Erik
those compile in the other flavor
Mark M.
I don't think they do
Erik
let me try
Mark M.
are you sure?
let me take a question from Benny while you test your tests :-) -- I will be back with you in a little bit
Benny: your turn! how can I help you today?
Benny
I have a little problem with AutoCompleteTextView and the SimpleAdapter
7:40 PM
Benny
in the list given to the Adapter i have some names with firstname and lastname, but after I enter a space it will stop filtering
Is there any other solution than make a own Adapter?
Mark M.
you could try ArrayAdapter instead of SimpleAdapter and see if that helps, I suppose
I have not used AutoCompleteTextView much, and I think I only used it with ArrayAdapter
Benny
ok, I will try this, thank you
Erik
./gradlew compilePaidDebugUnitTestKotlin completes successfully. ./gradlew compileFreeDebugUnitTestKotlin does not because it is still trying to compile the tests in src/testPaid.
Mark M.
what sort of compile errors are you getting?
Erik
it does not recognize classes the test is using
7:45 PM
Erik
I dont even want it compiling those tests if im on that flavor.
Mark M.
do you have a sourceSets closure in your build.gradle file for this module?
Erik
yes
heree is what i tried so far
Mark M.
perhaps there is something in sourceSets that is convincing the free flavor to include the paid flavor's tests
can you post the sourceSets closure here?
Erik
View paste
sourceSets {
  main.java.srcDirs += 'src/main/kotlin'
  debug.java.srcDirs += 'src/debug/kotlin'
  release.java.srcDirs += 'src/release/kotlin'
  test.java.srcDirs += 'src/test/kotlin'
  
  free {
    java.srcDirs += 'src/free/kotlin'
    test.java.srcDirs += 'src/test/kotlin'
  }

  paid {
    java.srcDirs += 'src/paid/kotlin'
    test.java.srcDirs += 'src/testPaid/kotlin'
  }
7:50 PM
Mark M.
test.java.srcDirs += 'src/test/kotlin' does not look right -- shouldn't that be src/testFree/kotlin?
sorry, I am referring to the version of that line in the free {} closure
basically, I am wondering why your free and paid closures do not match, other than replacing "free" with "paid"
Erik
i dont have a testFree dir because i want to run the main tests. the paid flavor should run the main tests and the tests in testPaid, free should only run the tests in src/test
Mark M.
try commenting out the test.java.srcDirs += 'src/test/kotlin' line in your free closure, and see if your tests work
we can deal with figuring out how to get it to run other tests later -- right now, let's get a stable run of the free tests
in the meantime... Benny, do you have another question?
Benny
yes, but it is not direclty about android but about MVVM on android
7:55 PM
Mark M.
I am not a GUI architecture expert, though I can try to help
Benny
where would you recommend to put the business-logic in mvvm?
Mark M.
how are you defining "business logic"?
if you mean how business data gets displayed, that's some mix of the viewmodel and perhaps a presenter
Benny
like check the data from the server
Mark M.
depending on what you are checking, and what overall structure you have for your app, that might be in a repository or a use-case
I don't get into the use-case pattern in my books, as that tends to be for really big apps, though I am sure that it has been written about elsewhere
Benny
okay, thank you very much :)
8:00 PM
Mark M.
Erik: after commenting out that line, my hope is that either your desired tests run, or zero tests run, and that we get past the testPaid compile problem -- what are you seeing?
Erik
it still fails. the build variants related to the paid product flavor all compile OK
compileFreeDebugUnitTestKotlin and compileFreeReleaseUnitTestKotlin fail
Mark M.
and they are still failing on trying to compile the paid tests?
Erik
rather they fail to build because like you mention this is a compile task, not a test task
no they never failed to compile the paid tests
Mark M.
um, I thought that was the original probelm
er, problem
" ./gradlew compilePaidDebugUnitTestKotlin completes successfully. ./gradlew compileFreeDebugUnitTestKotlin does not because it is still trying to compile the tests in src/testPaid."
Erik
yes
that still happens
Mark M.
OK, that's what I was trying to confirm
I have no idea why that task is pulling in your src/testPaid source
Erik
so anything related to Paid builds. anything related to free does not build.
Mark M.
my best guess is that it is something tied to your sourceSets closure, as that is what tells Gradle what source to pull in
Erik
I tried exclude */testPaid/** and that didnt work either
8:05 PM
Mark M.
in times like this, I usually set up a scrap project and start slowly trying to mirror the real project's setup, until the problem appears in the scrap project
Benny
I have to leave, thank you very much for your help
Mark M.
Benny: have a pleasant day!
Erik: I only know the bits and pieces of your project that you have written here in the chat, so I cannot give you precise details of how to run that sort of experiment
Benny
you too, good bye
Benny
has left the room
Mark M.
if we focus solely on the free/paid flavors, I would create a project that had free/paid flavors, without sourceSets, and see if the tests build and run
then, I would slowly start trying to set up those kotlin/ directories and adding them, one at a time, until the tests stop building and exhibit the same problem that you are seeing
product flavors and tests definitely work
so my guess is that the scrap project will work at the outset, then start failing during some part of altering the sourceSets
8:10 PM
Erik
ok. is the dot notation the same as brackets? ie test.java.srcDirs is equivalent to test { java { srcDirs } }?
Mark M.
yes
at least, it is supposed to be
Erik
thanks
what do you think about gradle as a build system>
Mark M.
it is better than Ant :-)
I have not used Maven, Buck, or other up-to-date Android alternatives, and so I cannot draw comparisons
Erik
I find it convoluted and easy to make mistakes
Mark M.
some of that is tied to the use of Groovy
that's the language that we normally build Gradle scripts in
Erik
not groovy baby ;)
Mark M.
there is Kotlin support now
I have not tried it yet
but it should offer greater type safety
making it a bit less likely for us to screw things up
Erik
ok thanks
Mark M.
but, I agree: it is a bit too easy to make mistakes in a Gradle script, and the build process is too opaque to really understand where the mistake comes from
for example, it would be great if we had a way of asking Gradle, "why are you trying to use src/testPaid in this task?"
as that should quickly get you to the source of your difficulty
if Gradle has a way of doing that, I am not aware of it
Erik
there isnt a language i know of that can do that
maybe HAL-2000
8:15 PM
Mark M.
well, by "ask", I more meant "have a debug mode where we can see all the inputs to the various tasks and plugins as they are being performed"
Erik
ic
Mark M.
from there, "ask" turns into grep and similar tools, looking for src/testPaid/ and trying to see where it is starting to show up unexpectedly
Erik
like the source behind the compile task?
Mark M.
right -- we need to figure out where the compile task is getting its list of source directories from
as it is clearly confused
it's possible there is some combination of Gradle flags that you can use that would give you that output, but I do not know what they are
8:20 PM
Mark M.
do you have any other questions?
8:30 PM
Erik
has left the room
Mark M.
turned off guest access

Tuesday, July 9

 

Office Hours

People in this transcript

  • Benny
  • Erik
  • Mark Murphy