안드로이드 프로젝트를jar 패키지로 만들기

1. 메인 프로젝트는library에 의존
2、library에 있는build.gradle 파일에서 설정
def SDK_BASENAME = "idcardcamera";
def SDK_VERSION = "_v1.0";
def OUTPUT_PATH = "build";
def INPUT_PATH = file('build/intermediates/packaged-classes/release/classes.jar')

//    
task deleteBuild(type: Delete) {
    delete OUTPUT_PATH + SDK_BASENAME + SDK_VERSION + ".jar"
}
//    
task makeJar(type: Jar) {
    //       classes.jar
    from zipTree(INPUT_PATH)
    // assets    jar 
    from fileTree(dir: 'src/main',include: ['assets/**'])
    from fileTree(dir: 'src/main',include: ['res/**'])
    from fileTree(dir: 'src/main',include: ['AndroidManifest.xml'])
    //             
    exclude('test/', 'BuildConfig.class')
    //      
    baseName = SDK_BASENAME + SDK_VERSION
    //  
    destinationDir = file(OUTPUT_PATH)
}

makeJar.dependsOn(deleteBuild, build)

 
3,gradle/library/other/makeJar를 클릭하면jar패키지 생성

좋은 웹페이지 즐겨찾기