<commit_before>package net.wequick.gradle

import com.android.build.api.transform.Format
import com.android.build.gradle.api.BaseVariant
import com.android.build.gradle.internal.pipeline.IntermediateFolderUtils
import com.android.build.gradle.internal.pipeline.TransformTask
import com.android.build.gradle.internal.transforms.ProGuardTransform
import org.apache.commons.io.FileUtils
import org.gradle.api.Project

class LibraryPlugin extends AppPlugin {

    private File mBakBuildFile

    void apply(Project project) {
        super.apply(project)
        mBakBuildFile = new File(project.buildFile.parentFile, "${project.buildFile.name}~")
    }

    @Override
    protected PluginType getPluginType() {
        return PluginType.Library
    }

    @Override
    protected void configureProject() {
        super.configureProject()

        if (!isBuildingRelease()) {
            project.afterEvaluate {
                // Cause `isBuildingRelease()' return false, at this time, super's
                // `hookJavacTask' will not be triggered. Provided the necessary jars here.
                def smallJar = project.fileTree(
                        dir: rootSmall.preBaseJarDir, include: [SMALL_JAR_PATTERN])
                def libJars = project.fileTree(dir: rootSmall.preLibsJarDir,
                        include: mDependentLibProjects.collect { "$it.name-${it.version}.jar" })
                project.dependencies.add('provided', smallJar)
                project.dependencies.add('provided', libJars)

                if (isBuildingApps() || (mT != null && mT.startsWith(":$rootSmall.hostModuleName"))) {
                    // Dependently built by `buildBundle' or `:app.xx:assembleRelease'.
                    // To avoid transformNative_libsWithSyncJniLibsForRelease task error, skip it.
                    // FIXME: we'd better figure out why the task failed and fix it
                    project.preBuild.doLast {
                        def syncJniTaskName = 'transformNative_libsWithSyncJniLibsForRelease'
                        if (project.hasProperty(syncJniTaskName)) {
                            def syncJniTask = project.tasks[syncJniTaskName]
                            syncJniTask.onlyIf { false }
                        }
                        // FIXME: Temporary workaround
                        def syncLibTaskName = 'transformClassesAndResourcesWithSyncLibJarsForRelease'
                        if (project.hasProperty(syncLibTaskName)) {
                            def syncLibTask = project.tasks[syncLibTaskName]
                            syncLibTask.onlyIf { false }
                        }
                    }
                }
            }
            return
        }<commit_msg>Avoid sync task failed on transformNative_libsWithLibJars<commit_after>package net.wequick.gradle

import com.android.build.api.transform.Format
import com.android.build.gradle.api.BaseVariant
import com.android.build.gradle.internal.pipeline.IntermediateFolderUtils
import com.android.build.gradle.internal.pipeline.TransformTask
import com.android.build.gradle.internal.transforms.ProGuardTransform
import org.apache.commons.io.FileUtils
import org.gradle.api.Project

class LibraryPlugin extends AppPlugin {

    private File mBakBuildFile

    void apply(Project project) {
        super.apply(project)
        mBakBuildFile = new File(project.buildFile.parentFile, "${project.buildFile.name}~")
    }

    @Override
    protected PluginType getPluginType() {
        return PluginType.Library
    }

    @Override
    protected void configureProject() {
        super.configureProject()

        if (!isBuildingRelease()) {
            project.afterEvaluate {
                // Cause `isBuildingRelease()' return false, at this time, super's
                // `hookJavacTask' will not be triggered. Provided the necessary jars here.
                def smallJar = project.fileTree(
                        dir: rootSmall.preBaseJarDir, include: [SMALL_JAR_PATTERN])
                def libJars = project.fileTree(dir: rootSmall.preLibsJarDir,
                        include: mDependentLibProjects.collect { "$it.name-${it.version}.jar" })
                project.dependencies.add('provided', smallJar)
                project.dependencies.add('provided', libJars)

                // Dependently built by `buildBundle' or `:app.xx:assembleRelease'.
                // To avoid transformNative_libsWithSyncJniLibsForRelease task error, skip it.
                // FIXME: we'd better figure out why the task failed and fix it
                def isSyncByIDE = (mT != null && mT.startsWith(":$rootSmall.hostModuleName:generate"))
                def isBuildingAppBundle = isBuildingApps()
                def skipsSyncJniLibs = isSyncByIDE || isBuildingAppBundle
                def skipsSyncLibJars = isBuildingAppBundle
                if (skipsSyncJniLibs) {
                    project.preBuild.doLast {
                        def syncJniTaskName = 'transformNative_libsWithSyncJniLibsForRelease'
                        if (project.hasProperty(syncJniTaskName)) {
                            def syncJniTask = project.tasks[syncJniTaskName]
                            syncJniTask.onlyIf { false }
                        }
                    }
                }
                if (skipsSyncLibJars) {
                    project.preBuild.doLast {
                        def syncLibTaskName = 'transformClassesAndResourcesWithSyncLibJarsForRelease'
                        if (project.hasProperty(syncLibTaskName)) {
                            def syncLibTask = project.tasks[syncLibTaskName]
                            syncLibTask.onlyIf { false }
                        }
                    }
                }
            }
            return
        }
{'fraction_non_alphanumeric': 0.07950438822922044, 'fraction_numerical': 0.0, 'mean_word_length': 1.8987531172069825, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1698143', 'n_tokens_mistral': 1539, 'n_tokens_neox': 1433, 'n_words': 289}