Android AAR文物出版物在组装之前执行



我有一个Android库项目,我正在尝试使用Gradle将AAR文件发布到JFrog文物。一旦我拥有AAR文件,并且当执行构建任务时,发布就可以按预期工作,问题在于,如果AAR文件不存在,我将无法作为构建过程的一部分进行。

我想在可用的新文件时发布AAR文件。我试图将cousblemblented.finalized Broked(ArtifactoryPublish(放置,但这无济于事。在生成AAR之前,发布任务会触发。

mygradle.gradle->

apply plugin: 'com.jfrog.artifactory'
apply plugin: 'maven-publish'
    File AARFile1 = file("$buildDir/outputs/aar/my_aar_file1.aar")
    File AARFile2 = file("$buildDir/outputs/aar/my_aar_file2.aar")
    publishing {
    publications {
        AAR1(MavenPublication) {
            groupId repoFolder
            version libVersion
            // Tell maven to prepare the generated "*.aar" file for publishing
            if (AARFile1.exists()) {
                artifactId libRelease
                artifact(AARFile1)
            } else {
                println 'AAR1 files not found in' + AARFile1.absolutePath
            }
        }
        AAR2(MavenPublication) {
            groupId repoFolder
            version libVersion
            // Tell maven to prepare the generated "*.aar" file for publishing
            if (AARFile2.exists()) {
                artifactId libDebug
                artifact(AARFile2)
            } else {
                println 'AAR2 files not found in' + AARFile2.absolutePath
            }
        }
    }
}

artifactory {
    contextUrl = "https://bintray.com/jfrog/artifactory:8080"
    publish {
        repository {
            // The Artifactory repository key to publish to
            repoKey = 'my_key'
           username = 'my_username'
           password = 'my_encrypt_password'
        }
        defaults {
            // Tell the Artifactory Plugin which artifacts should be published to Artifactory.
            if (AARFile1.exists() || AARFile2.exists()) {
                publications('AAR1', 'AAR2')
                publishArtifacts = true
                // Properties to be attached to the published artifacts.
                properties = ['qa.level': 'basic', 'dev.team':'Me' ]
                // Publish generated POM files to Artifactory (true by default)
                publishPom = true
            }
        }
    }
}

我看到Gradle任务列表如下:

executing tasks: [assembleIntegrated]
    AAR1 files not found in /myfolder/.../my_lib_project/app/build/outputs/aar/my_aar_file1.aar
    AAR2 files not found in /myfolder/.../my_lib_project/app/build/outputs/aar/my_aar_file2.aar
      .
      .
      .
    > Task :app:preBuild UP-TO-DATE
    > Task :app:test UP-TO-DATE
    > Task :app:check
    > Task :app:build
    > Task :app:artifactoryPublish
    > Task :artifactoryDeploy

发生了,因为您将文件手动添加到Maven出版物中。当Maven发布运行时,这些文件不存在。因此,您应该手动配置任务依赖项。当您在项目中添加出版物时,Gradle将通过您的出版物名称和回购名称的组合生成一些任务。这样的东西: publish{publicationName}PublicationTo{RepositoryName}Repository。因此,您应该将这些任务设置为取决于assembleIntegration任务。

或者您可以使用Android-Maven-Publish插件,可以自动执行此工作。

最新更新