使用 gradle 复制构建工件

Copy build artifacts with gradle

我使用 gradle 构建 android 库并将其推送到远程 Maven 存储库。有什么方法可以获取 pomaar 文件并将其复制到项目的根目录?

这是发布到 maven 的任务(它在库项目 build.gradle 中)

uploadArchives {
    configuration = configurations.archives
    repositories.mavenDeployer {

        repository(url: constants.snapshotUrl) {
            authentication(userName: userName, password: password)
            pom.groupId = constants.groupId
            pom.artifactId = constants.libUIArtifactIdName
            pom.version = constants.projectVersion
        }

        pom.whenConfigured { pom ->
            pom.dependencies.forEach { dep ->
                if (dep.getVersion() == "unspecified") {
                    dep.setGroupId(constants.groupId)
                    dep.setVersion(constants.projectVersion)
                }
            }
        }

    }
}

您在使用 maven 插件吗?如果是这样,您会在 ${project.buildDir}/poms 下找到生成的 poms 和工件,例如来自 install 任务配置。

另外 doLast for uploadArchives 也可以使用。