无法找到存储库容器上参数[]的方法jcenter() [英] Could not find method jcenter() for arguments [] on repository container

查看:219
本文介绍了无法找到存储库容器上参数[]的方法jcenter()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Gradle和bintray的新手。我想发布这个项目,以便Maven和SBT用户随时可以使用它。我不是这个软件包的原始作者;它似乎已被放弃;我只想发布当前的HEAD。

〜/ .gradle / gradle.properties 类似于:

  bintrayUser = mslinn 
bintrayKey = blahblah

build.gradle 看起来像这样。:

  buildscript {
repositories {
jcenter()
}
依赖关系{
classpath'com.jfrog.bintray.gradle:gradle-bintray -plugin:1.0'
}
}
apply plugin:'com.jfrog.bintray'

allprojects {
apply plugin:'idea'

group ='org.jfrog.example.bintray.gradle'
version ='1.0'
}

子项目{
apply plugin :'java'
apply plugin:'maven-publish'
apply plugin:'com.jfrog.bintray'

sourceCompatibility = 1.6
targetCompatibility = 1.6

依赖关系{
testCompile'junit:junit:4.7'
}

//创建源代码/ javadoc jars的自定义任务
任务sourcesJar(类型:Jar,dependsOn:类){
classifier ='sources'$源于源的
.main.allSource
}

任务javadocJar(类型:Jar,dependsOn:javadoc){
classifier ='javadoc'$ j
from javadoc.destinationDir
}

//将javadoc / source jar任务添加为工件
artifacts {
archives sourcesJar //,javadocJar
}

repositories {
jcenter()
}

发布{
publications {
mavenJava(MavenPublication){
if(plugins.hasPlugin('war' )){
from components.web
} else {
from components.java
}

工件sourcesJar {
classifiersources
}

artifact javadocJar {
classifierjavadoc
}
}
}
}

bintray {
user = bintrayUser //这通常来自于〜/ .gradle $中的gradle.properties文件
key = bintrayKey //这通常来自〜/ .gradle中的gradle.properties文件
publications = [ 'mavenJava'] //见出版物关闭
pkg {//如果不存在,将创建包
repo ='Java-WebSocket'
// userOrg ='myorg'// // an当回购属于用户的组织之一时,可选的组织名称
name ='Java-WebSocket'
desc ='当前已废弃项目的头部'
licenses = ['MIT']
labels = ['websocket','java']
}
}
}

任务包装器(类型:包装器){
gradleVersion = '1.10'
}

以下是问题:

  $ gradle bintray上传

失败:生成失败,出现异常。

*其中:
构建文件'/var/work/experiments/websockets/Java-WebSocket/build.gradle'行:3

*出错了:
评估根项目Java-WebSocket时发生问题。
>无法找到存储库容器上参数[]的方法jcenter()。

*尝试:
使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获取更多日志输出。

BUILD FAILED

我正在寻找关于如何解决错误消息和任何安装问题的建议,我可能会遇到这种情况,包括将此项目加入到JCenter中,以便所有已发布的bintray项目都可以使用。

>



Gradle在版本1.7中添加了 jcenter()快捷方式。它之前的任何版本都将失败,并出现此异常。
您仍然可以使用jcenter作为正常的maven repo来添加它:

 存储库{
maven {
urlhttps://jcenter.bintray.com
}
....
}


I'm new to Gradle and bintray. I want to publish this project so it is readily available to Maven and SBT users. I am not the original author of this package; it appears to have been abandoned; I just want to publish the current HEAD.

~/.gradle/gradle.properties is something like:

bintrayUser=mslinn
bintrayKey=blahblah

build.gradle looks like this.:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'
    }
}
apply plugin: 'com.jfrog.bintray'

allprojects {
    apply plugin: 'idea'

    group = 'org.jfrog.example.bintray.gradle'
    version = '1.0'
}

subprojects {
    apply plugin: 'java'
    apply plugin: 'maven-publish'
    apply plugin: 'com.jfrog.bintray'

    sourceCompatibility = 1.6
    targetCompatibility = 1.6

    dependencies {
        testCompile 'junit:junit:4.7'
    }

    // custom tasks for creating source/javadoc jars
    task sourcesJar(type: Jar, dependsOn: classes) {
        classifier = 'sources'
        from sourceSets.main.allSource
    }

    task javadocJar(type: Jar, dependsOn: javadoc) {
        classifier = 'javadoc'
        from javadoc.destinationDir
    }

    // add javadoc/source jar tasks as artifacts
    artifacts {
        archives sourcesJar //, javadocJar
    }

    repositories {
        jcenter()
    }

    publishing {
        publications {
            mavenJava(MavenPublication) {
                if (plugins.hasPlugin('war')) {
                    from components.web
                } else {
                    from components.java
                }

                artifact sourcesJar {
                    classifier "sources"
                }

                artifact javadocJar {
                    classifier "javadoc"
                }
            }
        }
    }

    bintray {
        user = bintrayUser //this usually comes form gradle.properties file in ~/.gradle
        key = bintrayKey //this usually comes form gradle.properties file in ~/.gradle
        publications = ['mavenJava'] // see publications closure
        pkg { //package will be created if does not exist
            repo = 'Java-WebSocket'
//            userOrg = 'myorg' // an optional organization name when the repo belongs to one of the user's orgs
            name = 'Java-WebSocket'
            desc = 'Current HEAD of abandoned project'
            licenses = ['MIT']
            labels = ['websocket', 'java']
        }
    }
}

task wrapper(type: Wrapper) {
    gradleVersion = '1.10'
}

Here is the problem:

$ gradle bintrayUpload

FAILURE: Build failed with an exception.

* Where:
Build file '/var/work/experiments/websockets/Java-WebSocket/build.gradle' line: 3

* What went wrong:
A problem occurred evaluating root project 'Java-WebSocket'.
> Could not find method jcenter() for arguments [] on repository container.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

I'm looking for advice on how to solve the error message, and advice on any setup issues I am likely to encounter including this project into JCenter so the published bintray project is available to all.

解决方案

Just to summarize the discussion in comments:

Gradle added jcenter() shortcut in version 1.7. Any version prior to it will fail with this exception. You can still work with jcenter by adding it as a normal maven repo:

repositories {
    maven {
        url "https://jcenter.bintray.com"
    }
    ....
}

这篇关于无法找到存储库容器上参数[]的方法jcenter()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆