【问题标题】:Release multi module project to artifactory stopped working after updating gradle更新gradle后将多模块项目发布到工件停止工作
【发布时间】:2021-03-08 00:57:56
【问题描述】:

我有一个包含 4 个模块的库(它们都是 aar 的)。 在为每个模块更新到最新的 gradle 之前,我需要运行 artifactoryPublish 任务。现在我需要在触发每个发布任务之前清理和重建项目。

> Task :module-1:generatePomFileForAarPublication
> Task :module-1:artifactoryPublish

> Task :extractModuleInfo
No publisher config found for project: android-integration-sdk-light

> Task :module-1:extractModuleInfo
> Task :module-2:extractModuleInfo
> Task :module-3:extractModuleInfo
> Task :module-4:extractModuleInfo
[pool-4-thread-1] Deploying artifact: https://xxx.yyy
[pool-4-thread-1] Deploying artifact: https://xxx.yyy
> Task :artifactoryDeploy

BUILD SUCCESSFUL in 6s

第一个任务运行

> Task :module-1:generatePomFileForAarPublication
> Task :module-1:artifactoryPublish
> Task :extractModuleInfo UP-TO-DATE
> Task :module-1:extractModuleInfo UP-TO-DATE
> Task :module-2:extractModuleInfo UP-TO-DATE
> Task :module-3:extractModuleInfo UP-TO-DATE
> Task :module-4:extractModuleInfo UP-TO-DATE
> Task :artifactoryDeploy

BUILD SUCCESSFUL in 2s

第二次任务运行

Config for artifactory:

apply plugin: 'com.jfrog.artifactory'
apply plugin: 'maven-publish'
apply from: "../artifactory/config.gradle"

publishing {
    publications {
        aar(MavenPublication) {
            groupId project.groupId
            version project.versionName
            artifactId project.name
            artifact("$buildDir/outputs/aar/${project.getName()}-release.${project.fileExtension}")

            pom.withXml {
                def node = asNode()
                // ugly hack to set the packaging property in the POM as 'aar'
                ((NodeList) node.get('packaging')).get(0).value = project.fileExtension
                def dependenciesNode = node.appendNode('dependencies')
                def cl = { Dependency dep ->
                    if (dep.group == null || dep.name == null || dep.name == "unspecified") {
                        return // ignore invalid dependencies
                    }
                    def dependencyVersion
                    //Only a temporary hack - need more investigation
                    def dependencyGroup
                    if (dep.group == "mobile-library") {
                        dependencyGroup = groupId
                    } else {
                        dependencyGroup = dep.group
                    }

                    //"fix" for compile projects
                    if (dep.version == "unspecified" || dep.version == null) {
                        dependencyVersion = project.versionName
                    } else {
                        dependencyVersion = dep.version
                    }

                    def dependencyNode = dependenciesNode.appendNode('dependency')
                    dependencyNode.appendNode('groupId', dependencyGroup)
                    dependencyNode.appendNode('artifactId', dep.name)
                    dependencyNode.appendNode('version', dependencyVersion)

                    if (!dep.transitive) {
                        // If this dependency is transitive, we should force exclude all its dependencies them from the POM
                        def exclusionNode = dependencyNode.appendNode('exclusions').appendNode('exclusion')
                        exclusionNode.appendNode('groupId', '*')
                        exclusionNode.appendNode('artifactId', '*')
                    } else if (!dep.properties.excludeRules.empty) {
                        // Otherwise add specified exclude rules
                        def exclusionsNode = dependencyNode.appendNode('exclusions')
                        dep.properties.excludeRules.each { ExcludeRule rule ->
                            def exclusion = exclusionsNode.appendNode('exclusion')
                            exclusion.appendNode('groupId', rule.group ?: '*')
                            exclusion.appendNode('artifactId', rule.module ?: '*')
                        }
                    }
                }

                // List all dependencies and write to POM
                configurations.api.getAllDependencies().each cl
                configurations.implementation.getAllDependencies().each cl
            }

        }
    }
}




artifactory {
    contextUrl = repositoryPath

    publish {
        repository {
            repoKey = repositoryName
            username = repositoryUserName
            password = repositoryPassword
            maven = true
        }

        defaults {
            publications('aar')
            publishArtifacts = true

            // Publish generated POM files to Artifactory (true by default)
        }
    }
}

文件在子模块中的使用,每个模块都有自己的名字:

project.ext {
    name = "module-1"
    fileExtension = "aar"
}

apply plugin: 'com.android.library'
apply from: "../artifactory/release.gradle"

我应该在每次发布之前强制执行清理任务和重建任务吗? 或者我应该尝试在主 gradle 文件中为每个模块设置一个入口点?

【问题讨论】:

  • 你的 Gradle Artifactory 插件版本是多少?
  • 版本:4.16.0

标签: android maven gradle artifactory aar


【解决方案1】:

这个问题应该已经在 Gradle Artifactory 插件 4.18.0 中解决了。

您可以在此处找到有关此问题的更多信息: https://github.com/jfrog/build-info/issues/383

请升级您的 Gradle Artifactory 插件。

【讨论】:

  • 您好,感谢您提供此信息。更新到 4.18.0/4.18.1 后,我无法上传任何库。所有任务在 0 秒内执行。所以更新没有帮助。
  • 你能打开一个更详细的问题吗? github.com/jfrog/build-info/issues/new/choose
  • 我应该添加什么样的附加信息?
  • 免责声明 - 我是 JFrog 的生态系统开发人员。请在 GitHub 问题中提供最新 Gradle Artifactory 插件版本的输出。此外,如果可能的话,最小的可重现示例不是必须的,但它会很棒。谢谢!
猜你喜欢
  • 2021-04-24
  • 2016-06-21
  • 2021-06-19
  • 2022-11-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-11-03
  • 1970-01-01
相关资源
最近更新 更多