nothing published to artifactory using gradle arti

2019-09-10 09:05发布

问题:

I followed the solution given here: upload artifact to artifactory using gradle, but it is not working for me.

Here is my code:

apply plugin: 'artifactory'
apply plugin: 'maven-publish'

/* Specify the repositories to be used for downloading artifacts */
repositories {
    maven {
        url = "${artifactory_contextUrl}/repo"
    }
}
/* Define the repository (in artifactory) where artifactoryPublish task should publish */
artifactory {
    contextUrl = "${artifactory_contextUrl}"
    publish {
        repository {
            repoKey = "${artifactory_repoKey}" 
            username = "${artifactory_user}"
            password = "${artifactory_password}"
        }
    }

    defaults {
        publications ('integTestPublish')
    }

}
publishing {
    publications {
        integTestPublish(MavenPublication) {
            setArtifactId(project.name + '-' + integTestJar.appendix)
            artifact integTestJar.archivePath
        }
    }
}

The error is:

> Could not find method defaults() for arguments [build_3a14r6bjhcvi883gaucf1jd8f0$_run_closure1_closure5_closure9@71bc1581] on root project 'samples'.

GAV used for artifactory plugin is:

classpath group: 'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '2.1.0'

What is wrong here ? can someone point me to DSL/API doc of artifactory plugin version 2.1.0 My gradle version is 1.11

回答1:

As explained in the user guide, artifactory plugin of version 2.X is intended to work with maven plugin, not maven-publish plugin. For working with publications please use artifactory-publish plugin of version 2.X, or, preferably, use version 3.0 of com.jfrog.artifactory plugin. It is intended to work with maven-publish publications and compatible both with Gradle 1 and Gradle 2.

This answer contains a fully working example.