Gradle Artifactory发布错误

时间:2015-02-18 14:13:17

标签: gradle artifactory

我正在使用Gradle和Artifactory,我使用了一个无效的示例example site我有这样的错误消息:

Extension of type 'PublishingExtension' does not exist. Currently registered extension types: [DefaultExtraPropert iesExtension, DefaultArtifactPublicationSet_Decorated, ReportingExtension_Decorated, DefaultProjectComponentContai ner_Decorated, DefaultProjectSourceSet_Decorated, DefaultBinaryContainer_Decorated]

我在这行中有错误:

defaults{
    publications ('mavenJava')
}

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

在审查了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
        }
    }
}

非常感谢

2 个答案:

答案 0 :(得分:11)

您没有应用预期与maven-publish插件一起提供的artifactory插件。

请查看the documentationthis answer也可能会有帮助(请注意插件名称的更改)。

答案 1 :(得分:3)

由于Artifactory docs使用过时的Android Studio& amp; gradle插件版本,所以这是我的工作conf与AS 1.5.1和gradle 1.5.0:

global build.gradle

buildscript {
  repositories {
    jcenter()
  }
  dependencies {
    classpath 'com.android.tools.build:gradle:1.5.0'
    classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4+"
  }
}

module build.gradle

apply plugin: 'com.jfrog.artifactory'
apply plugin: 'com.android.library'
apply plugin: 'maven-publish'

publishing{
  publications {
    maven(MavenPublication)  {
        groupId packageName
        version = libraryVersion
        artifactId project.getName()
        artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")
    }
  }
}

artifactory {
  contextUrl = // yours
  publish {
    repository {
        // The Artifactory repository key to publish to
        repoKey = 'libs-release-local'
        username = // yours
        password = // yours
    }
    defaults {
        publishArtifacts = true
        publications ('maven')

        // Properties to be attached to the published artifacts.
        properties = ['qa.level': 'basic', 'dev.team': 'core']
        // Publish generated POM files to Artifactory (true by default)
        publishPom = true
    }
  }
}