├── .gitignore
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── hm
│ │ └── iou
│ │ └── appconfig
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── hm
│ │ │ └── iou
│ │ │ └── appconfig
│ │ │ └── MainActivity.kt
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ └── ic_launcher_background.xml
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── hm
│ └── iou
│ └── appconfig
│ └── ExampleUnitTest.kt
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── library
├── .gitignore
├── build.gradle
└── src
│ └── main
│ ├── groovy
│ └── com
│ │ └── hm
│ │ └── iou
│ │ └── appconfig
│ │ └── plugin
│ │ ├── AnalyseDependencyTask.groovy
│ │ ├── CommConfigPlugin.groovy
│ │ ├── CompileConfigUtil.groovy
│ │ ├── DependencyInfo.groovy
│ │ ├── GitHooksUtil.groovy
│ │ ├── LibVersionUtil.groovy
│ │ └── ProguardRuleCheckUtil.groovy
│ └── resources
│ └── META-INF
│ └── gradle-plugins
│ └── com.hm.plugin.commconfig.properties
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 | /.idea
11 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 在Android开发中,通用配置 Gradle 插件。
2 |
3 | #### 1.插件用途
4 | 当我们开发 Android 项目时,随着组织庞大以后,现在一般会采用组件化架构的开发模式,
5 | 不同的人负责不同的组件,这样会造成很多问题,常见的有:
6 |
7 | 1. 第三方依赖库版本号不统一,合并打包时造成冲突;
8 | 2. 滥用第三方依赖库;
9 | 3. 编译时所用 sdk 版本不统一,合并打包时出现莫名其妙问题;
10 |
11 | 除此之外,我们还可以通过插件做很多通用配置,这样一是统一各种规范,二是强制所有开发人员遵循这一规范。
12 |
13 | #### 2.主要功能
14 |
15 | 1. 强制使用相同的 compileSdkVersion、targetSdkVersion、minSdkVersion;
16 | 2. 统一所有依赖的 com.android.support 库的版本号;
17 | 3. 统一 kotlin、GSON、multidex 库的版本号;
18 | 4. 统一 repositories 的路径为 libs 目录;
19 | 5. 打包时移除 META-INF/** 文件,例如:META-INF/*.kotlin_module;
20 | 6. 强制将 implementation 形式的依赖,改为 api 形式的依赖;
21 | 7. 增加 git hooks,规范 commit 提交信息
22 |
23 | #### 3. 使用方式
24 |
25 | 在根目录 build.gradle 中增加以下配置:
26 |
27 | ```
28 | buildscript {
29 | repositories {
30 | maven { url 'https://jitpack.io' }
31 | // 其他...
32 | }
33 | dependencies {
34 | // 其他...
35 | classpath 'com.github.houjinyun:android-comm-config-plugin:V1.0.1'
36 | }
37 | }
38 | ```
39 |
40 | 使用插件:
41 |
42 | ```
43 | apply plugin: 'com.hm.plugin.commconfig'
44 | ```
45 |
46 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | import org.apache.commons.io.FileUtils
2 |
3 | apply plugin: 'com.android.application'
4 |
5 | apply plugin: 'kotlin-android'
6 |
7 | apply plugin: 'kotlin-android-extensions'
8 |
9 | android {
10 | compileSdkVersion 26
11 | defaultConfig {
12 | applicationId "com.hm.iou.appconfig"
13 | minSdkVersion 19
14 | targetSdkVersion 26
15 | versionCode 1
16 | versionName "1.0"
17 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
18 | }
19 | buildTypes {
20 | release {
21 | minifyEnabled false
22 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
23 | }
24 | }
25 | }
26 |
27 | dependencies {
28 | implementation fileTree(dir: 'libs', include: ['*.jar'])
29 | implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
30 | implementation 'com.android.support:appcompat-v7:26.1.0'
31 | implementation 'com.android.support.constraint:constraint-layout:1.1.3'
32 | testImplementation 'junit:junit:4.12'
33 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
34 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
35 | }
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/hm/iou/appconfig/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.hm.iou.appconfig
2 |
3 | import android.support.test.InstrumentationRegistry
4 | import android.support.test.runner.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getTargetContext()
22 | assertEquals("com.hm.iou.appconfig", appContext.packageName)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hm/iou/appconfig/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.hm.iou.appconfig
2 |
3 | import android.support.v7.app.AppCompatActivity
4 | import android.os.Bundle
5 |
6 | class MainActivity : AppCompatActivity() {
7 |
8 | override fun onCreate(savedInstanceState: Bundle?) {
9 | super.onCreate(savedInstanceState)
10 | setContentView(R.layout.activity_main)
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
10 |
12 |
14 |
16 |
18 |
20 |
22 |
24 |
26 |
28 |
30 |
32 |
34 |
36 |
38 |
40 |
42 |
44 |
46 |
48 |
50 |
52 |
54 |
56 |
58 |
60 |
62 |
64 |
66 |
68 |
70 |
72 |
74 |
75 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/houjinyun/android-comm-config-plugin/4d38e97da2ce4bd1be1a342a91c9573f4fb4bb82/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/houjinyun/android-comm-config-plugin/4d38e97da2ce4bd1be1a342a91c9573f4fb4bb82/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/houjinyun/android-comm-config-plugin/4d38e97da2ce4bd1be1a342a91c9573f4fb4bb82/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/houjinyun/android-comm-config-plugin/4d38e97da2ce4bd1be1a342a91c9573f4fb4bb82/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/houjinyun/android-comm-config-plugin/4d38e97da2ce4bd1be1a342a91c9573f4fb4bb82/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/houjinyun/android-comm-config-plugin/4d38e97da2ce4bd1be1a342a91c9573f4fb4bb82/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/houjinyun/android-comm-config-plugin/4d38e97da2ce4bd1be1a342a91c9573f4fb4bb82/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/houjinyun/android-comm-config-plugin/4d38e97da2ce4bd1be1a342a91c9573f4fb4bb82/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/houjinyun/android-comm-config-plugin/4d38e97da2ce4bd1be1a342a91c9573f4fb4bb82/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/houjinyun/android-comm-config-plugin/4d38e97da2ce4bd1be1a342a91c9573f4fb4bb82/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #008577
4 | #00574B
5 | #D81B60
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | HM-AppConfigPlugin
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/hm/iou/appconfig/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.hm.iou.appconfig
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | ext.kotlin_version = '1.3.31'
5 | repositories {
6 | google()
7 | jcenter()
8 | maven { url 'https://jitpack.io' }
9 | }
10 | dependencies {
11 | classpath 'com.android.tools.build:gradle:3.4.1'
12 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
13 |
14 | classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
15 | }
16 | }
17 |
18 | allprojects {
19 | repositories {
20 | google()
21 | jcenter()
22 | maven { url 'https://jitpack.io' }
23 | }
24 | }
25 |
26 | task clean(type: Delete) {
27 | delete rootProject.buildDir
28 | }
29 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # Kotlin code style for this project: "official" or "obsolete":
15 | kotlin.code.style=official
16 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/houjinyun/android-comm-config-plugin/4d38e97da2ce4bd1be1a342a91c9573f4fb4bb82/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Aug 15 16:40:18 CST 2019
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/library/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/library/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'java-library'
2 | apply plugin: 'groovy'
3 |
4 | apply plugin: 'com.github.dcendents.android-maven'
5 | group='com.github.houjinyun'
6 |
7 | dependencies {
8 | implementation fileTree(dir: 'libs', include: ['*.jar'])
9 |
10 | compile gradleApi()
11 | compile localGroovy()
12 |
13 | compile 'com.android.tools.build:transform-api:1.5.0'
14 | compile 'com.android.tools.build:gradle:3.0.1'
15 |
16 |
17 | }
--------------------------------------------------------------------------------
/library/src/main/groovy/com/hm/iou/appconfig/plugin/AnalyseDependencyTask.groovy:
--------------------------------------------------------------------------------
1 | package com.hm.iou.appconfig.plugin
2 |
3 | import org.gradle.api.DefaultTask
4 | import org.gradle.api.Project
5 | import org.gradle.api.artifacts.Configuration
6 | import org.gradle.api.artifacts.result.DependencyResult
7 | import org.gradle.api.artifacts.result.ResolvedDependencyResult
8 | import org.gradle.api.tasks.TaskAction
9 |
10 | /**
11 | * 分析依赖树
12 | */
13 |
14 | class AnalyseDependencyTask extends DefaultTask {
15 |
16 | Project target
17 | List dependencyList = new ArrayList()
18 |
19 | AnalyseDependencyTask() {
20 | }
21 |
22 | @TaskAction
23 | void action() {
24 | Configuration apiConf = target.configurations.getByName("api")
25 |
26 | apiConf.incoming.resolutionResult.root.dependencies.each { DependencyResult dr ->
27 | collectDependencyInfo(dr, null)
28 | }
29 | //打印出所有库的依赖图
30 | dependencyList.each { DependencyInfo dependencyInfo ->
31 | println(dependencyInfo)
32 | }
33 | }
34 |
35 | /**
36 | * 递归收集依赖信息
37 | *
38 | * @param dr
39 | * @param info
40 | */
41 | private void collectDependencyInfo(DependencyResult dr, DependencyInfo info) {
42 | DependencyInfo dependInfo = new DependencyInfo(dr.requested.displayName)
43 | if (info == null) {
44 | dependencyList.add(dependInfo)
45 | } else {
46 | info.addSubDependInfo(dependInfo)
47 | dependInfo.setLevel(info.getLevel() + 1)
48 | }
49 | if (dr instanceof ResolvedDependencyResult) {
50 | ((ResolvedDependencyResult) dr).selected.dependencies.each { DependencyResult subDr ->
51 | collectDependencyInfo(subDr, dependInfo)
52 | }
53 | }
54 | }
55 |
56 | }
--------------------------------------------------------------------------------
/library/src/main/groovy/com/hm/iou/appconfig/plugin/CommConfigPlugin.groovy:
--------------------------------------------------------------------------------
1 | package com.hm.iou.appconfig.plugin
2 |
3 | import org.gradle.api.Plugin
4 | import org.gradle.api.Project
5 |
6 | /**
7 | * 组件通用配置插件,提供的功能有:
8 | *
9 | * 1. 强制使用相同的 compileSdkVersion、targetSdkVersion、minSdkVersion;
10 | * 2. 统一所有依赖的 com.android.support 库的版本号;
11 | * 3. 统一 kotlin、GSON、multidex 库的版本号;
12 | * 4. 统一 repositories 的路径为 libs 目录;
13 | * 5. 打包时移除 META-INF/** 文件,例如:META-INF/*.kotlin_module;
14 | * 6. 强制将 implementation 形式的依赖,改为 api 形式的依赖;
15 | * 7. 增加 git hooks,规范 commit 提交信息
16 | *
17 | */
18 | class CommConfigPlugin implements Plugin {
19 |
20 | @Override
21 | void apply(Project project) {
22 |
23 | try {
24 | GitHooksUtil.checkGitHookFile(project)
25 | } catch (IOException e) {
26 | e.printStackTrace()
27 | }
28 |
29 | //统一第三方依赖库的版本号,常见的有 com.android.support 包等
30 | LibVersionUtil.checkLibVersion(project)
31 |
32 | //检测 android 编译配置等
33 | CompileConfigUtil.checkCompileConfig(project)
34 |
35 | //增加检测 ProGuard 的task
36 | ProguardRuleCheckUtil.checkProguardFile(project)
37 | }
38 |
39 | }
--------------------------------------------------------------------------------
/library/src/main/groovy/com/hm/iou/appconfig/plugin/CompileConfigUtil.groovy:
--------------------------------------------------------------------------------
1 | package com.hm.iou.appconfig.plugin
2 |
3 | import com.android.build.gradle.LibraryExtension
4 | import com.android.build.gradle.internal.dsl.LintOptions
5 | import org.gradle.api.GradleException
6 | import org.gradle.api.Project
7 | import org.gradle.api.artifacts.Configuration
8 | import org.gradle.api.artifacts.Dependency
9 | import org.gradle.api.artifacts.ExternalModuleDependency
10 | import org.gradle.api.artifacts.ProjectDependency
11 | import org.gradle.api.artifacts.result.DependencyResult
12 | import org.gradle.api.artifacts.result.ResolvedDependencyResult
13 |
14 | /**
15 | * 编译配置
16 | */
17 | class CompileConfigUtil {
18 |
19 | static def MIN_SDK = 21
20 | static def TARGET_SDK = 28
21 | static def COMPILE_SDK = "android-28"
22 |
23 | static void checkCompileConfig(Project project) {
24 | //如果有 aar 依赖包,定义所有的 aar 包都放在 libs 目录下
25 | project.repositories {
26 | flatDir {
27 | dirs "libs"
28 | }
29 | }
30 |
31 | //收集 "implementation" configuration 里的依赖
32 | def dependencyMap = new HashMap()
33 | Configuration implementationConf = project.configurations.getByName("implementation")
34 | implementationConf.getAllDependencies().all { Dependency dependency ->
35 | dependencyMap.put("${dependency.group}:${dependency.name}:${dependency.version}", dependency)
36 | }
37 |
38 | project.afterEvaluate {
39 | com.android.build.gradle.BaseExtension android = project.extensions.getByName("android")
40 |
41 | //强制统一 compileSdkVersion、 minSdkVersion、targetSdkVersion
42 | String compileSdkVersion = android.compileSdkVersion
43 | int targetSdkVersion = android.defaultConfig.targetSdkVersion.apiLevel
44 | int minSdkVersion = android.defaultConfig.minSdkVersion.apiLevel
45 | if (compileSdkVersion != COMPILE_SDK) {
46 | throw new GradleException("请修改 compileSdkVersion,必须设置为 ${COMPILE_SDK}")
47 | }
48 | if (minSdkVersion != MIN_SDK) {
49 | throw new GradleException("请修改 minSdkVersion,必须设置为 ${MIN_SDK}")
50 | }
51 | if (targetSdkVersion != TARGET_SDK) {
52 | throw new GradleException("请修改 targetSdkVersion,必须设置为 ${TARGET_SDK}")
53 | }
54 |
55 | //使用kotlin 之后,会在 META-INF 下面产生很多 kotlin_module 文件
56 | android.getPackagingOptions().exclude("META-INF/*.kotlin_module")
57 | android.getPackagingOptions().exclude("META-INF/proguard/coroutines.pro")
58 |
59 | //禁止关闭 lint error 检测
60 | LintOptions lintOptions = android.getLintOptions()
61 | lintOptions.abortOnError = true
62 |
63 | //将 library 模块 implementation 里的依赖全部在 compile 里加进去
64 | if (android instanceof LibraryExtension) {
65 | Configuration compileConf = project.configurations.getByName("compile")
66 | compileConf.setCanBeResolved(true)
67 | for (Dependency dependency : dependencyMap.values()) {
68 | if (dependency instanceof ExternalModuleDependency) {
69 | compileConf.dependencies.add(dependency.copy())
70 | }
71 | }
72 | compileConf.dependencies.each { Dependency d ->
73 | if (d instanceof ProjectDependency) {
74 | throw new GradleException("请将直接工程依赖 compile project(':${d.name}') 改为 implementation project(':${d.name}')")
75 | }
76 | }
77 | //如果配置里有 compile project(':***') 这样的直接工程依赖,这里直接 resolve() 会报错
78 | compileConf.resolve()
79 |
80 | /*
81 | //TODO 检查第三方库,防止第三方库的滥用,如果出现这种情况直接终止
82 | List dependencyList = new ArrayList()
83 | compileConf.incoming.resolutionResult.root.dependencies.each { DependencyResult dr ->
84 | collectDependencyInfo(dr, null, dependencyList)
85 | }
86 |
87 | dependencyList.each { DependencyInfo dependencyInfo ->
88 | println(dependencyInfo)
89 | }
90 | */
91 |
92 | }
93 | }
94 | }
95 |
96 | /**
97 | * 递归收集依赖信息
98 | *
99 | * @param dr
100 | * @param info
101 | */
102 | private static void collectDependencyInfo(DependencyResult dr, DependencyInfo info, List dependencyList) {
103 | DependencyInfo dependInfo = new DependencyInfo(dr.requested.displayName)
104 | if (info == null) {
105 | dependencyList.add(dependInfo)
106 | } else {
107 | info.addSubDependInfo(dependInfo)
108 | dependInfo.setLevel(info.getLevel() + 1)
109 | }
110 | if (dr instanceof ResolvedDependencyResult) {
111 | ((ResolvedDependencyResult) dr).selected.dependencies.each { DependencyResult subDr ->
112 | collectDependencyInfo(subDr, dependInfo, dependencyList)
113 | }
114 | }
115 | }
116 |
117 | }
--------------------------------------------------------------------------------
/library/src/main/groovy/com/hm/iou/appconfig/plugin/DependencyInfo.groovy:
--------------------------------------------------------------------------------
1 | package com.hm.iou.appconfig.plugin
2 |
3 | /**
4 | * 依赖树
5 | */
6 | class DependencyInfo {
7 |
8 | private String displayName
9 | private List subDependInfoList
10 | private int level = 0 //表示依赖的深度,顶层的依赖为0,次一级的依次递归+1
11 |
12 | DependencyInfo(String displayName) {
13 | this.displayName = displayName
14 | }
15 |
16 | void addSubDependInfo(DependencyInfo dependInfo) {
17 | if (subDependInfoList == null)
18 | subDependInfoList = new ArrayList<>()
19 | subDependInfoList.add(dependInfo)
20 | }
21 |
22 | void setLevel(int level) {
23 | this.level = level
24 | }
25 |
26 | int getLevel() {
27 | return level
28 | }
29 |
30 | @Override
31 | String toString() {
32 | StringBuilder sb = new StringBuilder()
33 | for (int i = 0; i < level; i++) {
34 | sb.append("|---")
35 | }
36 | sb.append(displayName).append("\n")
37 | if (subDependInfoList != null && !subDependInfoList.isEmpty()) {
38 | for (DependencyInfo dr : subDependInfoList) {
39 | sb.append(dr.toString())
40 | }
41 | }
42 | return sb.toString()
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/library/src/main/groovy/com/hm/iou/appconfig/plugin/GitHooksUtil.groovy:
--------------------------------------------------------------------------------
1 | package com.hm.iou.appconfig.plugin
2 |
3 | import org.gradle.api.Project
4 |
5 | /**
6 | * 为 git 自动添加 git hooks
7 | */
8 | class GitHooksUtil {
9 |
10 | /**
11 | * 对 git 提交信息提交时进行检测,采用 groovy 脚本来运行,需要支持 groovy 运行环境
12 | * TODO 改成bash脚本,运行效率更好
13 | */
14 | private static final String GIT_COMMIT_MSG_CONFIG = '''#!/usr/bin/env groovy
15 | import static java.lang.System.exit
16 |
17 | //要提交的信息保存在该文件里
18 | def commitMsgFileName = args[0]
19 | def msgFile = new File(commitMsgFileName)
20 | //读出里面的提交信息
21 | def commitMsg = msgFile.text
22 |
23 | //对要提交的信息做校验,如果不符合要求的,不允许提交
24 | def reg = ~"^(fix:|add:|update:|refactor:|perf:|style:|test:|docs:|revert:|build:)[\\\\w\\\\W]{5,100}"
25 | if (!commitMsg.matches(reg)) {
26 | StringBuilder sb = new StringBuilder()
27 | sb.append("================= Commit Error =================\\n")
28 | sb.append("===>Commit 信息不规范,描述信息字数范围为[5, 100],具体格式请按照以下规范:\\n")
29 | sb.append(" fix: 修复某某bug\\n")
30 | sb.append(" add: 增加了新功能\\n")
31 | sb.append(" update: 更新某某功能\\n")
32 | sb.append(" refactor: 某个已有功能重构\\n")
33 | sb.append(" perf: 性能优化\\n")
34 | sb.append(" style: 代码格式改变\\n")
35 | sb.append(" test: 增加测试代码\\n")
36 | sb.append(" docs: 文档改变\\n")
37 | sb.append(" revert: 撤销上一次的commit\\n")
38 | sb.append(" build: 构建工具或构建过程等的变动\\n")
39 | sb.append("================================================")
40 | println(sb.toString())
41 | exit(1)
42 | }
43 |
44 | exit(0)
45 | '''
46 |
47 | /**
48 | * 检查 git hook 文件
49 | *
50 | * @param project
51 | */
52 | static void checkGitHookFile(Project project) throws IOException {
53 | //在根目录的 .git/hooks 目录下,存在很多 .sample 文件,把相应的 .sample 后缀去掉,git hook 就生效了
54 | File rootDir = project.rootProject.getProjectDir()
55 | File gitHookDir = new File(rootDir, ".git/hooks")
56 |
57 | //如果该目录存在
58 | if (gitHookDir.exists()) {
59 | //将 commit-msg.sample 文件的后缀名去掉,git hook 就会生效
60 | File commitMsgSampleFile = new File(gitHookDir, "commit-msg.sample")
61 | File commitMsgFile = new File(gitHookDir, "commit-msg")
62 | if (!commitMsgFile.exists() && commitMsgSampleFile.exists()) {
63 | //重命名的方式,自己创建的文件可能没有可执行权限,需要手动加权限,故采用重命名原文件的方式,省去手动加权限的操作
64 | commitMsgSampleFile.renameTo(commitMsgFile)
65 | commitMsgFile.setText(GIT_COMMIT_MSG_CONFIG)
66 | println("-----自动配置 git hook 成功-----")
67 | } else {
68 | println("-----git hook 已经启用-----")
69 | }
70 | } else {
71 | println("-----没有找到.git目录----")
72 | }
73 | }
74 |
75 | }
--------------------------------------------------------------------------------
/library/src/main/groovy/com/hm/iou/appconfig/plugin/LibVersionUtil.groovy:
--------------------------------------------------------------------------------
1 | package com.hm.iou.appconfig.plugin
2 |
3 | import org.gradle.api.Project
4 | import org.gradle.api.artifacts.Configuration
5 | import org.gradle.api.artifacts.ConfigurationContainer
6 | import org.gradle.api.artifacts.ResolutionStrategy
7 |
8 | /**
9 | * 统一第三方库的版本号
10 | */
11 | class LibVersionUtil {
12 |
13 | static def SUPPORT_VERSION = "28.0.0"
14 | static def MULTIDEX_VERSION = "1.0.2"
15 | static def GSON_VERSION = "2.8.5"
16 | static def KOTLIN_VERSION = "1.3.50"
17 |
18 | static void checkLibVersion(Project project) {
19 | ConfigurationContainer container = project.configurations
20 | container.all { Configuration conf ->
21 | ResolutionStrategy rs = conf.resolutionStrategy
22 | rs.force 'com.google.code.findbugs:jsr305:2.0.1'
23 | //统一第三方库的版本号
24 | rs.eachDependency { details ->
25 | def requested = details.requested
26 | if (requested.group == "com.android.support") {
27 | //强制所有的 com.android.support 库采用固定版本
28 | if (requested.name.startsWith("multidex")) {
29 | details.useVersion(MULTIDEX_VERSION)
30 | } else {
31 | details.useVersion(SUPPORT_VERSION)
32 | }
33 | } else if (requested.group == "com.google.code.gson") {
34 | //统一 Gson 库的版本号
35 | details.useVersion(GSON_VERSION)
36 | } else if (requested.group == "org.jetbrains.kotlin") {
37 | //统一内部 kotlin 库的版本
38 | details.useVersion(KOTLIN_VERSION)
39 | } else if (requested.group == "com.heima.iou") {
40 | //内部的库版本
41 | details.useVersion("1.0.0")
42 | }
43 | }
44 | }
45 | }
46 |
47 | }
--------------------------------------------------------------------------------
/library/src/main/groovy/com/hm/iou/appconfig/plugin/ProguardRuleCheckUtil.groovy:
--------------------------------------------------------------------------------
1 | package com.hm.iou.appconfig.plugin
2 |
3 | import com.android.build.gradle.AppExtension
4 | import com.android.build.gradle.BaseExtension
5 | import com.android.build.gradle.api.ApplicationVariant
6 | import org.gradle.api.GradleException
7 | import org.gradle.api.Project
8 | import org.gradle.api.Task
9 |
10 | /**
11 | * Proguard 配置规则自动检测
12 | */
13 | class ProguardRuleCheckUtil {
14 |
15 | /**
16 | * 检测工程里配置的 Proguard 规则
17 | *
18 | * @param project
19 | */
20 | static void checkProguardFile(Project project) {
21 | project.afterEvaluate {
22 | BaseExtension android = project.extensions.getByName("android")
23 | if (!(android instanceof AppExtension)) {
24 | return
25 | }
26 | android.applicationVariants.all { ApplicationVariant variant ->
27 | if (!variant.buildType.minifyEnabled) {
28 | println("检测到没有开启混淆,不检查 ProGuard 混淆配置文件")
29 | return
30 | }
31 |
32 | String compileTaskName = "compile${variant.name.capitalize()}JavaWithJavac"
33 | Task compileTask = project.tasks.getByName(compileTaskName)
34 | if (compileTask != null) {
35 | Task checkTask = project.task("hm${variant.name.capitalize()}CheckProguardRule")
36 | checkTask.doLast {
37 | println("在 application 中,开始检测 proguard 文件配置规则")
38 | Collection list = variant.buildType.proguardFiles
39 | StringBuilder sb = new StringBuilder()
40 | if (list != null) {
41 | for (File file : list) {
42 | if (file.exists())
43 | sb.append(file.text)
44 | }
45 | }
46 |
47 | analyseProguardText(sb.toString())
48 | }
49 | compileTask.dependsOn(checkTask)
50 | }
51 | }
52 | }
53 | }
54 |
55 | /**
56 | * 逐行做检查,看看有没有不符合规范的规则
57 | *
58 | * @param content
59 | */
60 | static void analyseProguardText(String content) throws GradleException {
61 | String[] lines = content.split("\n")
62 | for (int i = 0; i < lines.length; i++) {
63 | String line = lines[i].trim()
64 | if (line == null || line.length() == 0 || line.startsWith("#")) {
65 | continue
66 | }
67 |
68 | if (line.matches(~"[\\s]*-ignorewarnings.*")) {
69 | throw new GradleException("违反 Proguard 规则:\n禁止使用 -ignorewarnings ")
70 | }
71 | if (line.matches(~"[\\s]*-dontshrink[\\s]*")) {
72 | throw new GradleException("违反 Proguard 规则:\n禁止使用 -dontshrink ")
73 | }
74 |
75 | //该选项如果开启,编译会很慢
76 | /*if (line.matches(~"[\\s]*-dontoptimize[\\s]*")) {
77 | throw new GradleException("违反 Proguard 规则:\n禁止使用 -dontoptimize ")
78 | }*/
79 |
80 | if (line.matches(~"[\\s]*-dontwarn[\\s]*\\*\\*[\\s]*")) {
81 | throw new GradleException("违反 Proguard 规则:\n禁止使用 -dontwarn ** ")
82 | }
83 | if (line.matches(~"[\\s]*-dontwarn[\\s]*(com|com\\.hm|com\\.hm\\.iou)\\.\\*\\*.*")) {
84 | throw new GradleException("违反 Proguard 规则:\n-dontwarn 错误,当前规则为: ${line},禁止使用 ** 的包为 [com | com.hm | com.hm.iou]")
85 | }
86 | if (line.matches(~"[\\s]*-keep[\\s]*class[\\s]*\\*\\*[\\s]*")) {
87 | throw new GradleException("违反 Proguard 规则:\n-keep 错误,当前规则为: ${line},禁止使用 **")
88 | }
89 | if (line.matches(~"[\\s]*-keep[\\s]*[public]*[\\s]*class[\\s]*(com|com\\.hm|com\\.hm\\.iou)\\.\\*\\*.*")) {
90 | throw new GradleException("违反 Proguard 规则:\n-keep 错误,当前规则为: ${line},禁止使用 ** 的包为 [com | com.hm | com.hm.iou]")
91 | }
92 |
93 | }
94 | }
95 | }
--------------------------------------------------------------------------------
/library/src/main/resources/META-INF/gradle-plugins/com.hm.plugin.commconfig.properties:
--------------------------------------------------------------------------------
1 | implementation-class=com.hm.iou.appconfig.plugin.CommConfigPlugin
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':library'
--------------------------------------------------------------------------------