Я пытаюсь опубликовать библиотеку в репозитории AWS S3 Maven, используя это руководство.После того, как я наконец-то получил его для загрузки артефактов в корзину S3 без ошибок, я сделал это зависимостью от нового проекта согласно руководству.
Когда я попытался построить новый проект, произошла ошибка, в которой говорилось, что он не можетне могу найти первую из зависимостей моей библиотеки.Конечно же, не было сгенерированного файла pom.xml, который включал бы эту зависимость (и другие).
Не слишком много зная о том, как программировать задачи Gradle, я думаю, что проблема в pom.withXml {}часть сценария.Или проблема может возникнуть до этого, поскольку нет даже пустого файла pom.xml.
Вот весь сценарий:
apply plugin: 'com.android.library'
apply plugin: 'maven-publish'
// update these next lines to fit your submodule
group = 'com.myproject'
version = '1.0'
// Add sources as an artifact
task sourceJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier "source"
}
// Loop over all variants
android.libraryVariants.all { variant ->
variant.outputs.all { output ->
// This creates a publication for each variant
publishing.publications.create(variant.name, MavenPublication) {
// The sources artifact from earlier
artifact sourceJar
// Variant dependent artifact, e.g. release, debug
artifact source: output.outputFile, classifier: output.name
// Go through all the dependencies for each variant and add them to the POM
// file as dependencies
pom.withXml {
def dependencies = asNode().appendNode('dependencies')
// Filter out anything that's not an external dependency. You shouldn't
// be publishing artifacts that depend on local (e.g. project) dependencies,
// but who knows...
configurations.getByName(variant.name + "CompileClasspath").allDependencies
.findAll { it instanceof ExternalDependency }
.each {
def dependency = dependencies.appendNode('dependency')
dependency.appendNode('groupId', it.group)
dependency.appendNode('artifactId', it.name)
dependency.appendNode('version', it.version)
}
}
}
}
}
// Ensure that the publish task depends on assembly
tasks.all { task ->
if (task instanceof AbstractPublishToMaven) {
task.dependsOn assemble
}
}
// Configure the destination repository with
// S3 URL and access credentials
publishing {
repositories {
maven {
url "s3://sdk.myproject.com.s3.amazonaws.com"
credentials(AwsCredentials) {
accessKey AWS_ACCESS_KEY
secretKey AWS_SECRET_KEY
}
}
}
}
Есть идеи о том, что происходит не так?Спасибо!