Skip to content

Commit

Permalink
去掉module 单独打包
Browse files Browse the repository at this point in the history
  • Loading branch information
yatoooon committed Jan 24, 2024
1 parent 15c314f commit 75ed85c
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 35 deletions.
3 changes: 3 additions & 0 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions buildSrc/src/main/java/Dependencies.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
object Deploys {
const val isRunAlone = false
}

/**
* 版本信息
Expand Down
17 changes: 2 additions & 15 deletions buildSrc/src/main/java/com/common/plugin/CommonAndroid.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ import java.io.File
internal fun Project.configureAndroid(
isAppModule: Boolean = false,
isLibModule: Boolean = false,
isRunAlone: Boolean = false,
) {

val extension = when {
isAppModule || isRunAlone -> extensions.getByType<AppExtension>()
isAppModule -> extensions.getByType<AppExtension>()
isLibModule -> extensions.getByType<LibraryExtension>()
else -> extensions.getByType<LibraryExtension>()
}
Expand All @@ -45,18 +44,6 @@ internal fun Project.configureAndroid(
//生成apk位置选择 buildSrc/apk 路径
//生成渠道点击 Gradle->MVVMArms->Tasks->com.tencent.vasdolly->reBuildChannel
}

isRunAlone -> {
val appName = project.name // 应用名称
val versionName = defaultConfig.versionName
val versionCode = defaultConfig.versionCode
setProperty(
"archivesBaseName", "$appName-v$versionName-$versionCode-${buildTime()}"
)
applicationId = "com.arms.sample." + project.name
resValue("string", "app_name", project.name)
}

isLibModule -> {
consumerProguardFile(File("${project.rootDir}/buildSrc/consumer-rules.pro"))
}
Expand Down Expand Up @@ -132,7 +119,7 @@ internal fun Project.configureAndroid(
}
getByName("release") {
isMinifyEnabled = true
if (isAppModule || isRunAlone) {
if (isAppModule) {
isShrinkResources = true
}
setSigningConfig(signingConfigs.getByName("release"))
Expand Down
12 changes: 1 addition & 11 deletions buildSrc/src/main/java/com/common/plugin/CommonDependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,15 @@ import org.gradle.api.Project
internal fun Project.configureDependencies(
isAppModule: Boolean = false,
isLibModule: Boolean = false,
isRunAlone: Boolean = false,
) = dependencies.apply {
add("implementation", (fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar")))))
add("testImplementation", Deps.junit)
when {
isAppModule->{
isAppModule -> {
add("androidTestImplementation", Deps.extJunit)
add("androidTestImplementation", Deps.espressoCore)
add("implementation", Deps.codelocator)
add("implementation", project(":common:core"))

//一键生成的module放这里
add("implementation", project(":module:splash"))
add("implementation", project(":module:template"))
Expand All @@ -29,14 +27,6 @@ internal fun Project.configureDependencies(
add("implementation", project(":module:personal"))
add("implementation", project(":module:test"))
}
isRunAlone -> {
add("androidTestImplementation", Deps.extJunit)
add("androidTestImplementation", Deps.espressoCore)
add("implementation", Deps.codelocator)
add("implementation", project(":common:core"))
}



isLibModule -> {
add("implementation", project(":common:core"))
Expand Down
3 changes: 1 addition & 2 deletions buildSrc/src/main/java/com/common/plugin/CommonPlugins.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ import org.gradle.api.Project
internal fun Project.configurePlugins(
isAppModule: Boolean = false,
isLibModule: Boolean = false,
isRunAlone: Boolean = false,
) {
when {
isAppModule || isRunAlone -> {
isAppModule -> {
plugins.apply("com.android.application")
plugins.apply("com.tencent.vasdolly")
}
Expand Down
7 changes: 3 additions & 4 deletions buildSrc/src/main/java/com/common/plugin/PluginLib.kt
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package com.common.plugin

import Deploys.isRunAlone
import org.gradle.api.Plugin
import org.gradle.api.Project


class PluginLib : Plugin<Project> {
override fun apply(project: Project) {
project.configurePlugins(isLibModule = true, isRunAlone = isRunAlone)
project.configureAndroid(isLibModule = true,isRunAlone = isRunAlone)
project.configureDependencies(isLibModule = true,isRunAlone = isRunAlone)
project.configurePlugins(isLibModule = true)
project.configureAndroid(isLibModule = true)
project.configureDependencies(isLibModule = true)
}
}

0 comments on commit 75ed85c

Please sign in to comment.