-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
消除大量重复的配置代码。 PR时原本VERSION_NAME是null,添加rlespinasse/github-slug-action@v3.x修复。
- Loading branch information
Showing
22 changed files
with
126 additions
and
409 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
apply plugin: 'java-gradle-plugin' | ||
|
||
apply plugin: 'kotlin' | ||
|
||
group 'com.tencent.shadow.coding' | ||
|
||
gradlePlugin { | ||
plugins { | ||
shadow { | ||
id = "com.tencent.shadow.internal.common-aar-settings" | ||
implementationClass = "com.tencent.shadow.coding.common_aar_settings.CommonAarSettingsPlugin" | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" | ||
implementation "com.android.tools.build:gradle:$build_gradle_version" | ||
implementation "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" | ||
testImplementation 'junit:junit:4.12' | ||
testImplementation gradleTestKit() | ||
|
||
} |
75 changes: 75 additions & 0 deletions
75
.../src/main/kotlin/com/tencent/shadow/coding/common_aar_settings/CommonAarSettingsPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package com.tencent.shadow.coding.common_aar_settings | ||
|
||
import com.android.build.gradle.BaseExtension | ||
import org.gradle.api.JavaVersion | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.api.plugins.ExtensionAware | ||
import org.gradle.api.plugins.ExtraPropertiesExtension | ||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions | ||
|
||
class CommonAarSettingsPlugin : Plugin<Project> { | ||
|
||
override fun apply(project: Project) { | ||
project.pluginManager.apply("com.android.library") | ||
project.pluginManager.apply("com.tencent.shadow.internal.aar-to-jar") | ||
|
||
val android = project.extensions.getByName("android") as BaseExtension | ||
|
||
configVersions(project, android) | ||
|
||
keepOldAGPBehavior(android, project) | ||
|
||
addCommonDependencies(project) | ||
} | ||
|
||
private fun addCommonDependencies(project: Project) { | ||
project.dependencies.add("implementation", "com.tencent.shadow.coding:lint") | ||
} | ||
|
||
private fun keepOldAGPBehavior( | ||
android: BaseExtension, | ||
project: Project | ||
) { | ||
// Starting in version 4.2, AGP will use the Java 8 language level by default. | ||
// To keep the old behavior, specify Java 7 explicitly. | ||
// https://developer.android.com/studio/releases/gradle-plugin?hl=lt#java-8-default | ||
android.compileOptions { | ||
it.sourceCompatibility = JavaVersion.VERSION_1_7 | ||
it.targetCompatibility = JavaVersion.VERSION_1_7 | ||
} | ||
|
||
// For Kotlin projects, compile to Java 6 instead of 7 | ||
project.afterEvaluate { | ||
val kotlinOptions = (it.extensions.getByName("android") as ExtensionAware).extensions | ||
.findByType(KotlinJvmOptions::class.java) | ||
kotlinOptions?.apply { | ||
jvmTarget = "1.6" | ||
} | ||
} | ||
|
||
android.defaultConfig.buildConfigField( | ||
"String", | ||
"VERSION_NAME", | ||
"\"${android.defaultConfig.versionName}\"" | ||
) | ||
} | ||
|
||
private fun configVersions( | ||
project: Project, | ||
android: BaseExtension | ||
) { | ||
val ext = project.extensions.getByName("ext") as ExtraPropertiesExtension | ||
|
||
android.compileSdkVersion(ext["COMPILE_SDK_VERSION"] as Int) | ||
|
||
android.defaultConfig { | ||
it.minSdk = ext["MIN_SDK_VERSION"] as Int | ||
it.targetSdk = ext["TARGET_SDK_VERSION"] as Int | ||
it.versionCode = ext["VERSION_CODE"] as Int | ||
it.versionName = ext["VERSION_NAME"] as String | ||
it.testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner" | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
include 'checks', 'lint' | ||
include 'code-generator' | ||
include 'aar-to-jar-plugin' | ||
include 'aar-to-jar-plugin' | ||
include 'common-aar-settings' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,11 @@ | ||
apply plugin: 'com.android.library' | ||
apply plugin: 'com.tencent.shadow.internal.aar-to-jar' | ||
apply plugin: 'com.tencent.shadow.internal.common-aar-settings' | ||
|
||
group 'com.tencent.shadow.core' | ||
|
||
android { | ||
compileSdkVersion project.COMPILE_SDK_VERSION | ||
|
||
defaultConfig { | ||
minSdkVersion project.MIN_SDK_VERSION | ||
targetSdkVersion project.TARGET_SDK_VERSION | ||
versionCode project.VERSION_CODE | ||
versionName project.VERSION_NAME | ||
buildConfigField("String","VERSION_NAME","\"${defaultConfig.versionName}\"") | ||
|
||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
|
||
} | ||
|
||
sourceSets { | ||
main.java.srcDirs += project(':generate-delegate-code').buildDir.path + '/generated/DelegateCode/activity_container' | ||
} | ||
|
||
// Starting in version 4.2, AGP will use the Java 8 language level by default. | ||
// To keep the old behavior, specify Java 7 explicitly. | ||
// https://developer.android.com/studio/releases/gradle-plugin?hl=lt#java-8-default | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_7 | ||
targetCompatibility JavaVersion.VERSION_1_7 | ||
} | ||
} | ||
|
||
dependencies{ | ||
implementation 'com.tencent.shadow.coding:lint' | ||
} | ||
|
||
preBuild.dependsOn(project(":generate-delegate-code").getTasksByName("generateDelegateCode", false).first()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,3 @@ | ||
apply plugin: 'com.android.library' | ||
apply plugin: 'com.tencent.shadow.internal.aar-to-jar' | ||
apply plugin: 'com.tencent.shadow.internal.common-aar-settings' | ||
|
||
group 'com.tencent.shadow.core' | ||
|
||
android { | ||
compileSdkVersion project.COMPILE_SDK_VERSION | ||
|
||
defaultConfig { | ||
minSdkVersion project.MIN_SDK_VERSION | ||
targetSdkVersion project.TARGET_SDK_VERSION | ||
versionCode project.VERSION_CODE | ||
versionName project.VERSION_NAME | ||
|
||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
|
||
} | ||
|
||
// Starting in version 4.2, AGP will use the Java 8 language level by default. | ||
// To keep the old behavior, specify Java 7 explicitly. | ||
// https://developer.android.com/studio/releases/gradle-plugin?hl=lt#java-8-default | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_7 | ||
targetCompatibility JavaVersion.VERSION_1_7 | ||
} | ||
} | ||
|
||
dependencies{ | ||
implementation 'com.tencent.shadow.coding:lint' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,3 @@ | ||
apply plugin: 'com.android.library' | ||
apply plugin: 'com.tencent.shadow.internal.common-aar-settings' | ||
|
||
group 'com.tencent.shadow.core' | ||
|
||
android { | ||
compileSdkVersion project.COMPILE_SDK_VERSION | ||
|
||
|
||
defaultConfig { | ||
minSdkVersion project.MIN_SDK_VERSION | ||
targetSdkVersion project.TARGET_SDK_VERSION | ||
versionCode project.VERSION_CODE | ||
versionName project.VERSION_NAME | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
} | ||
} | ||
|
||
// Starting in version 4.2, AGP will use the Java 8 language level by default. | ||
// To keep the old behavior, specify Java 7 explicitly. | ||
// https://developer.android.com/studio/releases/gradle-plugin?hl=lt#java-8-default | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_7 | ||
targetCompatibility JavaVersion.VERSION_1_7 | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation 'com.tencent.shadow.coding:lint' | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.