【发布时间】:2015-02-12 17:54:27
【问题描述】:
我是 Gradle 和 bintray 的新手。我想发布this project,以便 Maven 和 SBT 用户可以随时使用它。我不是这个包的原作者;它appears to have been abandoned;我只想发布当前的 HEAD。
~/.gradle/gradle.properties 类似于:
bintrayUser=mslinn
bintrayKey=blahblah
build.gradle 看起来像这样。:
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'
}
问题来了:
$ 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
我正在寻找有关如何解决错误消息的建议,以及有关我可能遇到的任何设置问题的建议,包括将此项目纳入 JCenter,以便所有人都可以使用已发布的 bintray 项目。
【问题讨论】:
-
你可能使用的是旧版本的 gradle,它还没有这个方法。
gradle -version说什么? -
今天通过 apt-get 在 XUbuntu 上安装。 $ gradle -version ---------------------------------------------- -------------- Gradle 1.5 ---------------------------------- -------------------------- Gradle 构建时间:2014 年 6 月 15 日星期日下午 3:27:36 UTC Groovy:1.8.6 Ant: Apache Ant(TM) 版本 1.9.4 编译于 2014 年 5 月 9 日 Ivy:非官方版本 JVM:1.8.0_25 (Oracle Corporation 25.25-b02) OS:Linux 3.16.0-28-generic amd64
-
那是一个相当老的 Gradle 版本,确实没有
jcenter()。当然,您始终可以将 JCenter 配置为常规 Maven 存储库 (maven { url "..." }),而不是使用快捷方式。 -
gradle 1.5 已经很老了。当前版本是 2.2.1。最后一个 1.x 版本是 1.12。您应该升级,并考虑使用 gradle 包装器:gradle.org/docs/current/userguide/gradle_wrapper.html。
-
所以apt-get提供的Gradle已经过时了。我想知道如何通知适当的人以便他们可以更新 .deb?我会添加这个 ppa,似乎它应该给我当前版本:launchpad.net/~cwchien/+archive/ubuntu/gradle