我对Gradle和bintray不熟悉。我想要发布这个项目,以便Maven和SBT用户可以方便地使用。我不是这个软件包的原始作者;它似乎已被放弃;我只想发布当前头部。
~/.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 -version
显示什么? - JB NizetGradle 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) 操作系统:Linux 3.16.0-28-generic amd64 - Mike Slinnjcenter()
。当然,您可以将JCenter配置为常规的Maven存储库(maven { url "..." }
),而不是使用快捷方式。 - Peter Niederwieser