我想用一个命令(任务)将我的AndroID库的多个变种(风味构建类型)安装到本地Maven存储库.
目前AndroID Gradle插件0.13.2允许我将publishNonDefault标志设置为发布所有变体,但正如文档所述,它将使用与Maven Repository不兼容的分类器发布变体.
我现在的解决方法是使用defaultPublishConfig“myVariant”并为我的每个变体更改它.
apply plugin: 'com.androID.library'apply plugin: 'maven'androID { defaultPublishConfig "myVariant" . . .}task installArchives(type: Upload) { repositorIEs.mavenInstaller { configuration = configurations.getByname(Dependency.DEFAulT_CONfigURATION) pom.groupID = "com.company" pom.artifactID = "mylibrary" pom.version = "1.0.0-myVariant" }}
我想有一个任务可以正确地将所有变种发布到本地Maven存储库.
解决方法 为了解决这个问题,我必须为每个变体创建一个上载任务,并使它们相互依赖,并依赖于启动该过程的主任务.apply plugin: 'com.androID.library'apply plugin: 'maven'androID { . . .}// Master task that will publish all variantsdef DefaultTask masterTask = project.tasks.create("installArchives",DefaultTask)androID.libraryVariants.all { variant -> variant.outputs.each { output -> // Configuration defines which artifacts will be published,create one configuration for each variant output (artifact) def Configuration variantConfiguration = project.configurations.create("${variant.name}Archives") project.artifacts.add(variantConfiguration.name,output.packagelibrary) // Create one Upload type task for each configuration def Upload variantTask = project.tasks.create("${variant.name}Install",Upload) variantTask.configuration = variantConfiguration variantTask.repositorIEs.mavenInstaller { pom.groupID = "com.yourcompany" pom.artifactID = "yourlibrary" pom.version = "1.0.0-${variant.name}" //Give a different version for each variant pom.packaging = "aar" } // Make all tasks depend on each other and on master task masterTask.dependsOn variantTask masterTask = variantTask }}
任务installArchives将所有变体发布到本地Maven存储库.
./gradlew installArchives总结
以上是内存溢出为你收集整理的Android库 – 使用Gradle将多个变体发布到本地Maven存储库全部内容,希望文章能够帮你解决Android库 – 使用Gradle将多个变体发布到本地Maven存储库所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)