美文网首页
Android Studio(Gradle)中的java lib

Android Studio(Gradle)中的java lib

作者: 有何不可_b7e1 | 来源:发表于2018-10-11 20:40 被阅读0次

    参考:

    https://stackoverflow.com/questions/40616077/using-proguard-in-java-modules-android-studio

    https://segmentfault.com/a/1190000010338331

    Project:

        -app (android application)

        -common (java library)

            -build.gradle

            import proguard.gradle.ProGuardTask

            buildscript {

                classpath"net.sf.proguard:proguard-gradle:5.3.3"

            }

            task proguardFiles(type: ProGuardTask,dependsOn: compileJava) {

                // make jar task wait for proguardFiles task finish

                tasks.jar.dependsOn.add(proguardFiles)

                println"proguarding"

                // build\classes\java\main

                println"${sourceSets.main.java.outputDir}"

                // main classes

                println"${sourceSets.main.output}"

                printmapping"$buildDir/mapping.txt"

                configuration'proguard-rules.pro'

                libraryjars files(configurations.compile.findAll {}.collect())

                injarssourceSets.main.output

                // setup proguard output classes: output not .jar

                outjars"$buildDir/libs/${project.name}"

                // delete previous outputs

                delete"$buildDir/libs/${project.name}"

                // replace the original classes

                doLast {

                    println"copying product"

                    // delete original classes in "${sourceSets.main.java.outputDir}"

                    delete"${sourceSets.main.java.outputDir}"  //"${sourceSets.main.output.classesDir}"

                    copy {

                        from"$buildDir/libs/${project.name}"

                        // copy proguard outputs into "${sourceSets.main.java.outputDir}"

                        into"${sourceSets.main.java.outputDir}"  //"${sourceSets.main.output.classesDir}"

                    }

                }

            }

    依赖的jar需不需要打包进来,如果需要怎么搞?

    如何在该模块内区分release/debug,让debug不混淆?

    相关文章

      网友评论

          本文标题:Android Studio(Gradle)中的java lib

          本文链接:https://www.haomeiwen.com/subject/qujiaftx.html