简体   繁体   English

将多个库模块合并为一个

[英]Merge multiple library modules into one

I am trying to merge multiple modules of my android library into one single block of implementation.我正在尝试将我的 android 库的多个模块合并到一个单独的实现块中。 eg例如

I have 3 modules which when uploaded to Maven gives 3 implementation blocks:我有 3 个模块,当它们上传到 Maven 时,会给出 3 个实现块:

implementation 'com.example.sdk:core:1.0.2'
implementation 'com.example.sdk:feature1:1.0.2'
implementation 'com.example.sdk:feature2:1.0.2'

but I want to merge them into a single one like: implementation 'com.example.sdk:android-sdk:1.0.2'但我想将它们合并为一个,例如: implementation 'com.example.sdk:android-sdk:1.0.2'

So that users who want all, core and features can implement using a simple implementation line instead of multiple.这样想要全部、核心和功能的用户可以使用简单的实现线而不是多个实现线来实现。 Can this be possible?这可能吗?

I am using these classpaths in my main project:我在我的主项目中使用这些类路径:

classpath 'com.vanniktech:gradle-maven-publish-plugin:0.18.0'
classpath 'org.jetbrains.dokka:dokka-gradle-plugin:1.4.10.2'

Inside every library module adding a new gradle.properties file and adding the following segment of code in that:在每个库模块中添加一个新的 gradle.properties 文件并在其中添加以下代码段:

GROUP=com.example.sdk 
POM_ARTIFACT_ID=core 
VERSION_NAME=1.0.2 

POM_NAME=core 
POM_PACKAGING=aar 

POM_DESCRIPTION=Test for multi-module lib 
POM_INCEPTION_YEAR=2021 

POM_URL=GITHUB_URL 
POM_SCM_URL= GITHUB_URL 
POM_SCM_CONNECTION= GITHUB_URL.git 
POM_SCM_DEV_CONNECTION=scm:git@GITHUB_URL 

POM_LICENCE_NAME=The Apache Software License, Version 2.0
POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt 
POM_LICENCE_DIST=repo

and pushing to maven with ./gradlew publish --no-daemon --no-parallel并使用./gradlew publish --no-daemon --no-parallel推送到 maven

Please let me know if any more information is required.如果需要更多信息,请告诉我。

Try create a file named ./folder-deps/my-core.gradle with content bellow:尝试创建一个名为./folder-deps/my-core.gradle的文件,其内容如下:

dependencies{
  implementation 'com.example.sdk:core:1.0.2'
  implementation 'com.example.sdk:feature1:1.0.2'
  implementation 'com.example.sdk:feature2:1.0.2'
}

In all build.gradle import your module from file my-core.gradle :在所有build.gradle中,从文件my-core.gradle导入您的模块:

apply from: "$rootDir/folder-deps/my-core.gradle"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM