Skip to content

Gradle DSL method not found: 'execute()'. Any solution? #26

@lalitkhandal

Description

@lalitkhandal

FAILURE: Build failed with an exception.

Where:
Script '/Users/la20073037/AndroidStudioProjects/Telstra_24x7/telstra-24x7-android/app/buildscripts/copy_test_resources.gradle' line: 32

What went wrong:
Could not find method execute() for arguments [] on task ':app:copyTestSqiObfuscatedReleaseResources' of type org.gradle.api.tasks.Copy.

Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings

Code:

gradle.projectsEvaluated {
// Base path which is recognized by android studio.
def testClassesPath = "${buildDir}/intermediates/classes/test/"
// Copy must be done for each variant.
def variants = android.applicationVariants.collect()

variants.each { variant ->
    def variationName = variant.name.capitalize()

    // Get the flavor and also merge flavor groups.
    def productFlavorNames = variant.productFlavors.collect { it.name.capitalize() }
    if (productFlavorNames.isEmpty()) {
        productFlavorNames = [""]
    }
    productFlavorNames = productFlavorNames.join('')

    // Base path addition for this specific variant.
    def variationPath = variant.buildType.name;
    if (productFlavorNames != null && !productFlavorNames.isEmpty()) {
        variationPath = uncapitalize(productFlavorNames) + "/${variationPath}"
    }

    // Specific copy task for each variant
    def copyTestResourcesTask = project.tasks.create("copyTest${variationName}Resources", Copy)
    copyTestResourcesTask.from("${projectDir}/src/test/resources")
    copyTestResourcesTask.into("${testClassesPath}/${variationPath}")
    copyTestResourcesTask.execute()
}

}

def uncapitalize(String str) {
int strLen;
if (str == null || (strLen = str.length()) == 0) {
return str;
}
return new StringBuffer(strLen)
.append(Character.toLowerCase(str.charAt(0)))
.append(str.substring(1))
.toString();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions