weex 0.20-sdk-build.gradle

2023-02-21 14:45:33 阅读:3 编辑
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

buildscript {
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
        classpath 'com.vanniktech:gradle-android-junit-jacoco-plugin:0.5.0'
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
    }
}
plugins {
    id "com.github.hierynomus.license" version "0.14.0"
}

apply plugin: 'com.android.library'
apply plugin: 'checkstyle'
/*
ext.disableCov = project.hasProperty('disableCov') ? project.getProperty('disableCov') : 'false'
if(!disableCov.toBoolean()){
    apply plugin: 'com.vanniktech.android.junit.jacoco'
    junitJacoco {
        excludes = ['com/taobao/weex/dom/flex/**','com/taobao/weex/ui/view/refresh/circlebar/**']
    }
}
*/

task checkstyle(type: Checkstyle) {
    configFile file("${project.rootDir}/sdk/config/quality/checkstyle.xml") // Where my checkstyle config is...
    // configProperties.checkstyleSuppressionsPath = file("${project.rootDir}/config/quality/checkstyle/suppressions.xml").absolutePath // Where is my suppressions file for checkstyle is...
    source 'src'
    include '**/*.java'
    exclude '**/gen/**'
    exclude '**/test/**'
    exclude '**/com/taobao/weex/dom/flex/**'
    classpath = files()

}

checkstyle {
    toolVersion = '6.9'
}

version = "0.20.0.1"

android {

    compileSdkVersion COMPILE_SDK_VERSION as int
    buildToolsVersion BUILD_TOOLS_VERSION
    resourcePrefix "weex"
    useLibrary 'org.apache.http.legacy'
    copy {
        from '../../pre-build'
        into new File(projectDir,"assets")
        include 'native-bundle-main.js'
        rename('native-bundle-main.js','main.js')
    }
    def line
    new File(projectDir,"assets/main.js").withReader { line = it.readLine() }
    def m = line =~ /[A-Z\s]+\s+([0-9\.]+),\s+Build\s+[0-9]+/;
    def jsfmVersion // = m[0][1]
    println jsfmVersion

    copy {
        from '../../pre-build'
        into new File(projectDir,"assets")
        include 'weex-main-jsfm.js'
        rename('weex-main-jsfm.js','weex-main-jsfm.js')
    }

    copy {
        from '../../pre-build'
        into new File(projectDir,"assets")
        include 'weex-rax-api.js'
    }

//    copy {
//        from '../../pre-build'
//        into new File(projectDir,"assets")
//        include 'weex-rax-extra-api.js'
//    }

    if(project.hasProperty('asfRelease')){
        //download so file if not exist, when compile in source release
        download{
            src 'https://gitbox.apache.org/repos/asf?p=incubator-weex.git;a=blob_plain;f=android/sdk/libs/armeabi/libweexcore.so;hb=refs/heads/master'
            dest "${projectDir}/libs/armeabi/libweexcore.so"
            overwrite false
        }
        download{
            src 'https://gitbox.apache.org/repos/asf?p=incubator-weex.git;a=blob_plain;f=android/sdk/libs/x86/libweexcore.so;hb=refs/heads/master'
            dest "${projectDir}/libs/x86/libweexcore.so"
            overwrite false
        }
    }

    def ARMEABI_Size = new File(projectDir,"libs/armeabi/libweexcore.so").length();
    def ARMEABIV7_Size = new File(projectDir,"libs/armeabi-v7/libweexcore.so").length();
    def X86_Size = new File(projectDir,"libs/x86/libweexcore.so").length();
    println "ARMEABI_Size: "+ARMEABI_Size;
    println "ARMEABIV7_Size:" + ARMEABIV7_Size;
    println "X86_Size:" + X86_Size;

    defaultConfig {
        buildConfigField "long", "ARMEABI_Size", "${ARMEABI_Size}"
        buildConfigField "long", "ARMEABIV7_Size", "${ARMEABIV7_Size}"
        buildConfigField "long", "X86_Size", "${X86_Size}"
        buildConfigField "String", "buildJavascriptFrameworkVersion", "\"${jsfmVersion}\""
        buildConfigField "String", "buildVersion", "\"${version}\""
        minSdkVersion 16
        targetSdkVersion TARGET_SDK_VERSION as int

        multiDexEnabled true

        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a","x86"
        }

        externalNativeBuild {
            cmake {
                arguments '-DANDROID_PLATFORM=android-14',
                    '-DANDROID_TOOLCHAIN=gcc',
                    '-DANDROID_STL=gnustl_static',
                    '-DCMAKE_BUILD_TYPE=Release'
            }
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            buildConfigField "boolean", "ENABLE_TRACE", "false"
          //  consumerProguardFiles 'proguard-rules.pro'
        }

        debug {
            buildConfigField "boolean", "ENABLE_TRACE", "true"
            jniDebuggable true
            debuggable true
           // testCoverageEnabled disableCov.toBoolean()
            //consumerProguardFiles 'proguard-rules.pro'
        }
    }

    sourceSets {
        main {
            assets.srcDirs = ['assets']
            jniLibs.srcDir(['libs'])
            java {
                srcDirs = ["src/main/java"];
            }
        }
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }

    compileOptions.encoding = "UTF-8"
    lintOptions {
        abortOnError false
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
    testOptions {
        unitTests.all {
            maxHeapSize = "1024m"
            jvmArgs += ['-XX:-UseSplitVerifier', '-noverify','-Xverify:none']/* fix VerifyError  */
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    provided "com.android.support:recyclerview-v7:${PROJECT_SUPPORTLIBVERSION}"
    provided "com.android.support:support-v4:${PROJECT_SUPPORTLIBVERSION}"
    provided "com.android.support:appcompat-v7:${PROJECT_SUPPORTLIBVERSION}"
    provided "com.alibaba:fastjson:1.1.46.android"

    testCompile "com.alibaba:fastjson:1.1.46.android"
    testCompile 'junit:junit:4.12'
    testCompile 'org.hamcrest:hamcrest-core:1.3'
    testCompile 'org.javassist:javassist:3.20.0-GA'
    testCompile 'org.mockito:mockito-core:1.10.19'
    testCompile 'org.objenesis:objenesis:2.1'
    testCompile 'org.powermock:powermock-core:1.6.4'
    testCompile 'org.powermock:powermock-api-mockito:1.6.4'
    testCompile 'org.powermock:powermock-module-junit4-common:1.6.4'
    testCompile 'org.powermock:powermock-module-junit4:1.6.4'
    testCompile 'org.powermock:powermock-module-junit4-legacy:1.6.4'
    testCompile 'org.powermock:powermock-module-testng:1.6.4'
    testCompile 'org.powermock:powermock-classloading-xstream:1.6.4'
    testCompile "org.powermock:powermock-module-junit4-rule:1.6.4"
    testCompile 'org.robolectric:robolectric:3.3.2'
    testCompile "org.robolectric:shadows-httpclient:3.3.2"
    testCompile 'org.json:json:20160212'
}

apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.github.dcendents.android-maven'
def siteUrl = 'http://weex.incubator.apache.org'
def gitUrl = 'https://github.com/apache/incubator-weex.git'
group = "com.taobao.android"
install {
    repositories.mavenInstaller {
        // This generates POM.xml with proper parameters
        pom {
            project {
                packaging 'aar'
                name 'weex_sdk'
                url siteUrl
                licenses {
                    license {
                        name 'The Apache Software License, Version 2.0'
                        url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                    }
                }
                developers {
                    developer {
                        id 'weex alibaba'
                        name 'weex alibaba'
                        email 'alibabaweex@gmail.com'
                    }
                }
                scm {
                    connection gitUrl
                    developerConnection gitUrl
                    url siteUrl
                }
            }
        }
    }
}

task sourcesJar(type: Jar) {
    from android.sourceSets.main.java.srcDirs
    classifier = 'sources'
}

artifacts {
    archives sourcesJar
}

bintray {
    configurations = ['archives']
    user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
    key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
    pkg {
        repo = "maven"
        name = "weex_sdk"
        websiteUrl = siteUrl
        vcsUrl = gitUrl
        licenses = ["Apache-2.0"]
        publish = true
        version {
            //这里填写需要发布的版本号
            name = "1.2.8"
        }
    }
}