File tree Expand file tree Collapse file tree
src/main/groovy/cn/hx/plugin/junkcode/plugin Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ buildscript {
1111 mavenCentral()
1212 }
1313 dependencies {
14- classpath "com.github.qq549631030:android-junk-code:1.1.2 "
14+ classpath "com.github.qq549631030:android-junk-code:x.x.x "
1515 }
1616}
1717```
@@ -39,8 +39,6 @@ androidJunkCode {
3939}
4040```
4141
42- ** 原configMap配置方式已过时,1.0.8版以后请使用variantConfig配置方式"**
43-
4442如果有多个变体共用一个配置可以这样做
4543``` groovy
4644androidJunkCode {
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ buildscript {
1111 classpath " org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version "
1212 classpath " com.getkeepsafe.dexcount:dexcount-gradle-plugin:3.0.1"
1313// classpath project(":library")
14- classpath " com.github.qq549631030:android-junk-code:1.1.3 "
14+ classpath " com.github.qq549631030:android-junk-code:1.1.4 "
1515 // NOTE: Do not place your application dependencies here; they belong
1616 // in the individual module build.gradle files
1717 }
Original file line number Diff line number Diff line change 11# project
22GROUP =com.github.qq549631030
3- VERSION_NAME =1.1.3
3+ VERSION_NAME =1.1.4
44
55POM_ARTIFACT_ID =android-junk-code
66POM_NAME =AndroidJunkCode
Original file line number Diff line number Diff line change @@ -34,11 +34,24 @@ class AndroidJunkCodePlugin implements Plugin<Project> {
3434 def resDir = new File (dir, " res" )
3535 def javaDir = new File (dir, " java" )
3636 def manifestFile = new File (dir, " AndroidManifest.xml" )
37- // 从main/AndroidManifest.xml找到package name
38- def mainManifestFile = android. sourceSets. findByName(" main" ). manifest. srcFile
39- def parser = new XmlParser ()
40- def node = parser. parse(mainManifestFile)
41- def packageName = node. attribute(" package" )
37+ def packageName = android. namespace// AGP 7.3+
38+ if (! packageName) {// AGP under 7.3
39+ // 从AndroidManifest.xml找到package name
40+ for (int i = 0 ; i < variant. sourceSets. size(); i++ ) {
41+ def sourceSet = variant. sourceSets[i]
42+ if (sourceSet. manifestFile. exists()) {
43+ def parser = new XmlParser ()
44+ def node = parser. parse(sourceSet. manifestFile)
45+ packageName = node. attribute(" package" )
46+ if (packageName) {
47+ break
48+ }
49+ }
50+ }
51+ }
52+ if (! packageName) {
53+ packageName = " "
54+ }
4255 def generateJunkCodeTask = project. task(generateJunkCodeTaskName, type : AndroidJunkCodeTask ) {
4356 config = junkCodeConfig
4457 manifestPackageName = packageName
You can’t perform that action at this time.
0 commit comments