从aar中排除课程

时间:2015-11-02 07:28:55

标签: android gradle aar

我有一个"基地"库,提供纯Java代码,现在我想在其上创建一个Android库。让我们说两个库都有一个Log类。当我构建aar并将其嵌套在项目中时,我能够选择要导入的Log类(我试图阻止它,只显示来自Android库的Log类)。当aar构建时,是否有机会排除库? 这是gradle(我尝试了很多,但没有任何帮助)。

buildscript {

    repositories {
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:1.3.1'
    }
}

apply plugin: 'com.android.library'


repositories {
    jcenter()
}


android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 23
        versionCode 9
        versionName "0.0.9"
        project.archivesBaseName = "andcommon"
        project.version = android.defaultConfig.versionName
    }

    packagingOptions {
//        exclude 'res'
    }

//    configurations {
//        compile.exclude group: 'com.pepperonas.jbasx'
//    }
//    sourceSets {
//        main {
//            java {
//                exclude '**/Log.java'
//            }
//        }
//    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }



    buildTypes {
        all {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

    }
    libraryVariants.all { variant ->
        variant.outputs.each { output ->
            def outputFile = output.outputFile
            if (outputFile != null && outputFile.name.endsWith('.aar')) {
                def fileName = "${archivesBaseName}-${version}.aar"
                output.outputFile = new File(outputFile.parent, fileName)
                output.outputFile = new File("/home/pepperonas/IdeaProjects/Libraries/Base/testapp/libs", fileName)
            }
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:23.1.0'
    compile project(':jbasx')

//    compile files('libs/jbasx-0.0.9.jar')
}

0 个答案:

没有答案