Gradle Artifactory发布错误

Mäū*_*nas 14 artifactory gradle

我正在使用Gradle和Artifactory,我使用的示例在此示例站点中无法正常工作我有以下错误消息:

Extension of type 'PublishingExtension' does not exist. Currently registered extension types: [DefaultExtraPropert iesExtension, DefaultArtifactPublicationSet_Decorated, ReportingExtension_Decorated, DefaultProjectComponentContai ner_Decorated, DefaultProjectSourceSet_Decorated, DefaultBinaryContainer_Decorated]
Run Code Online (Sandbox Code Playgroud)

我在这行中有错误:

defaults{
    publications ('mavenJava')
}
Run Code Online (Sandbox Code Playgroud)

有人可以帮我解决这个问题,我长期坚持这个问题.

在查看JBaruch建议的链接并与代码进行比较后,我更改了插件,但仍然是同样的问题.也许我在混淆什么?(这就是我发布完整源代码的原因)

buildscript {
    repositories {
        maven {
            url 'http://.../artifactory/libs-release'
            credentials {
                username = "${artifactory_user}"
                password = "${artifactory_password}"
            }
            name = "maven-main-cache"
        }
    }
    dependencies {
        classpath "org.jfrog.buildinfo:build-info-extractor-gradle:3.0.1"
    }
}

apply plugin: 'scala'
apply plugin: 'maven-publish'
apply plugin: "com.jfrog.artifactory"

version = '1.0.0-SNAPSHOT'
group = 'com.buransky'

repositories {
    add buildscript.repositories.getByName("maven-main-cache")
}

dependencies {
    compile 'org.scala-lang:scala-library:2.11.2'
}

tasks.withType(ScalaCompile) {
    scalaCompileOptions.useAnt = false
}

artifactory {
    contextUrl = "${artifactory_contextUrl}"
    publish {
        repository {
            repoKey = 'libs-snapshot-local'
            username = "${artifactory_user}"
            password = "${artifactory_password}"
            maven = true

        }
        defaults{
            publications ('mavenJava')
        }
    }
}

publishing {
    publications {
        mavenJava(MavenPublication) {
            from components.java
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

非常感谢你

JBa*_*uch 11

您没有应用maven-publish插件中预期存在的artifactory插件.

请看一下文档,这个答案也许有帮助(注意插件名称的变化).