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

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

Open
lalitkhandal opened this issue May 27, 2019 · 0 comments
Open

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

lalitkhandal opened this issue May 27, 2019 · 0 comments

Comments

@lalitkhandal
Copy link

lalitkhandal commented May 27, 2019

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();
}

@lalitkhandal lalitkhandal changed the title Gradle DSL method not found: 'execute()'? How I can fix? Gradle DSL method not found: 'execute()'. Any solution? May 27, 2019
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

No branches or pull requests

1 participant