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

🍒 #8190 - Fix source and destination folders computation for Android Gradle projects #8194

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import org.gradle.api.logging.Logger
import org.gradle.api.logging.Logging
import org.gradle.api.tasks.testing.Test

import java.nio.file.Files
import java.nio.file.Paths

class AndroidGradleUtils {

private static final Logger LOGGER = Logging.getLogger(AndroidGradleUtils)
Expand All @@ -29,7 +32,10 @@ class AndroidGradleUtils {
}

private static getVariant(Project project, Test task) {
def androidPlugin = project.plugins.findPlugin('android') ?: project.plugins.findPlugin('android-library')
def androidPlugin = project.plugins.findPlugin('android')
?: project.plugins.findPlugin('android-library')
?: project.plugins.findPlugin('com.android.application')
?: project.plugins.findPlugin('com.android.library')

def variants
if (androidPlugin.class.simpleName == 'LibraryPlugin') {
Expand All @@ -39,7 +45,7 @@ class AndroidGradleUtils {
}

for (def v : variants) {
if (task.path.endsWith("test${v.name.capitalize()}UnitTest")) {
if (task.path.endsWith("test${v.name.capitalize()}UnitTest") || task.path.endsWith("test${v.name.capitalize()}")) {
return v
}
}
Expand Down Expand Up @@ -75,8 +81,8 @@ class AndroidGradleUtils {
FileTree javaTree = project.fileTree(dir: javaDestinations, excludes: EXCLUDES)

FileTree destinationsTree
if (project.plugins.findPlugin('kotlin-android') != null) {
def kotlinDestinations = "${project.buildDir}/tmp/kotlin-classes/${variant.name}"
def kotlinDestinations = "${project.buildDir}/tmp/kotlin-classes/${variant.name}"
if (Files.exists(Paths.get(kotlinDestinations))) {
def kotlinTree = project.fileTree(dir: kotlinDestinations, excludes: EXCLUDES)
destinationsTree = javaTree + kotlinTree
} else {
Expand Down
Loading