我有一个android库项目,当我打包并将其上传到maven存储库时,我发现此pom具有依赖项节点:
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.multi.maven</groupId>
<artifactId>app-release</artifactId>
<version>1.0.2</version>
<packaging>aar</packaging>
<name>testName</name>
<dependencies>
<dependency>
<groupId>io.flutter.plugins.urllauncher</groupId>
<artifactId>url_launcher</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.flutter.plugins.imagepicker</groupId>
<artifactId>image_picker</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.android.support</groupId>
<artifactId>support-v13</artifactId>
<version>27.1.1</version>
</dependency>
<dependency>
<groupId>com.android.support</groupId>
<artifactId>support-annotations</artifactId>
<version>27.1.1</version>
</dependency>
</dependencies>
</project>
因为io.flutter.plugins.imagepicker
依赖库将作为本地AAR构建,所以我想将main aar和io.flutter.plugins.imagepicker
aar上传到maven,但是仅使用main aar
uploadArchives {
repositories {
mavenDeployer {
repository(url: uri('../../build/'))
android.libraryVariants.all { variant ->
def _flavorBuildTypeName = "release"
addFilter(_flavorBuildTypeName) { artifact, file ->
true
}
pom(_flavorBuildTypeName).artifactId = project.archivesBaseName + "-" + _flavorBuildTypeName
pom(_flavorBuildTypeName).version = "1.0.2"
pom(_flavorBuildTypeName).groupId = "com.multi.maven"
pom(_flavorBuildTypeName).name = "testName"
pom(_flavorBuildTypeName).packaging = 'aar'
pom(_flavorBuildTypeName).withXml {
def root = asNode()
def depsNode = root["dependencies"][0] ?: root.appendNode("dependencies")
def addDep = {
if (it.group == null) return // Avoid empty dependency nodes
def dependencyNode = depsNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
if (it.hasProperty('optional') && it.optional) {
dependencyNode.appendNode('optional', 'true')
}
}
// Add deps that everyone has
configurations.api.allDependencies.each addDep
configurations.implementation.allDependencies.each addDep
// Add flavor specific deps
// if (isFlavor) {
// configurations["${_flavorBuildTypeName}Implementation"].allDependencies.each addDep
// def flavorName = variant.flavorName
// configurations["${flavorName}Implementation"].allDependencies.each addDep
// configurations["${_flavorBuildTypeName}Api"].allDependencies.each addDep
// configurations["${flavorName}Api"].allDependencies.each addDep
// }
}
}
}
}
}
那么,我如何上传这两个文件呢?