Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
787 views
in Technique[技术] by (71.8m points)

gradle - Could not find method jcenter() for arguments [] on repository container

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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"
    }
    ....
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...