Skip to content
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

Fix AGP's new Kotlin sourceset not being recognised by default #57

Merged
merged 5 commits into from Mar 10, 2022

Conversation

Goooler
Copy link
Contributor

@Goooler Goooler commented Feb 19, 2022

Comment on lines 22 to 25
val srcDirs = sourceSet.java.srcDirs + runCatching {
// As sourceSet.kotlin doesn't exist before AGP 7
(sourceSet.kotlin as? DefaultAndroidSourceDirectorySet)?.srcDirs
}.getOrNull().orEmpty()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Catch the exception for compatibilities of older AGP.

@Goooler
Copy link
Contributor Author

Goooler commented Feb 19, 2022

unexpected (3): ktfmtCheckTestFixtures, ktfmtCheckTestFixturesRelease, ktfmtCheckTestFixturesDebug
---
expected      : [ktfmtCheckAndroidTestDebug, ktfmtCheckAndroidTestRelease, ktfmtCheckAndroidTest, ktfmtCheckTestDebug, ktfmtCheckTestRelease, ktfmtCheckTest, ktfmtCheckDebug, ktfmtCheckRelease, ktfmtCheckMain]
but was       : [ktfmtCheckTest, ktfmtCheckTestFixtures, ktfmtCheckTestFixturesRelease, ktfmtCheckAndroidTestDebug, ktfmtCheckTestDebug, ktfmtCheckMain, ktfmtCheckAndroidTestRelease, ktfmtCheckRelease, ktfmtCheckDebug, ktfmtCheckTestRelease, ktfmtCheckAndroidTest, ktfmtCheckTestFixturesDebug]

Comment on lines +134 to +146
assertThat(project.tasks.getByName("ktfmtCheckTestFixtures"))
.isInstanceOf(KtfmtCheckTask::class.java)
assertThat(project.tasks.getByName("ktfmtCheckTestFixturesRelease"))
.isInstanceOf(KtfmtCheckTask::class.java)
assertThat(project.tasks.getByName("ktfmtCheckTestFixturesDebug"))
.isInstanceOf(KtfmtCheckTask::class.java)
assertThat(project.tasks.getByName("ktfmtFormatTestFixtures"))
.isInstanceOf(KtfmtFormatTask::class.java)
assertThat(project.tasks.getByName("ktfmtFormatTestFixturesRelease"))
.isInstanceOf(KtfmtFormatTask::class.java)
assertThat(project.tasks.getByName("ktfmtFormatTestFixturesDebug"))
.isInstanceOf(KtfmtFormatTask::class.java)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure AGP 7.1 intro these tasks?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that's the case, but I wasn't able to find any reference.
Out of curiousity, would be able to println the source of those tasks? I'd like to know which directories they're actually pointing to.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can I print?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant if you run the test locally, and add a println inside KtfmtAndroidUtils.kt

Copy link
Contributor Author

@Goooler Goooler Mar 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +134 to +146
assertThat(project.tasks.getByName("ktfmtCheckTestFixtures"))
.isInstanceOf(KtfmtCheckTask::class.java)
assertThat(project.tasks.getByName("ktfmtCheckTestFixturesRelease"))
.isInstanceOf(KtfmtCheckTask::class.java)
assertThat(project.tasks.getByName("ktfmtCheckTestFixturesDebug"))
.isInstanceOf(KtfmtCheckTask::class.java)
assertThat(project.tasks.getByName("ktfmtFormatTestFixtures"))
.isInstanceOf(KtfmtFormatTask::class.java)
assertThat(project.tasks.getByName("ktfmtFormatTestFixturesRelease"))
.isInstanceOf(KtfmtFormatTask::class.java)
assertThat(project.tasks.getByName("ktfmtFormatTestFixturesDebug"))
.isInstanceOf(KtfmtFormatTask::class.java)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that's the case, but I wasn't able to find any reference.
Out of curiousity, would be able to println the source of those tasks? I'd like to know which directories they're actually pointing to.

@cortinico cortinico enabled auto-merge (squash) March 10, 2022 10:31
@cortinico cortinico merged commit ab393d5 into cortinico:main Mar 10, 2022
@Goooler Goooler deleted the sourceset branch March 10, 2022 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants