我正在尝试用官方Gradle plugin将我的人工制品部署到Bintray。与我的期望相反,该插件不使用build.gradle中设置的版本,而是自动生成如下的随机版本字符串:
myproject-build_ewroptgflyd6opkee3goj0l63$_run_closure10$_closure30@3afaa4d9.jar
myproject-build_ewroptgflyd6opkee3goj0l63$_run_closure10$_closure30@3afaa4d9-javadoc.jar
myproject-build_ewroptgflyd6opkee3goj0l63$_run_closure10$_closure30@3afaa4d9-sources.jar
我的build.gradle看起来像这样。我在线比较了我的配置和几种配置,但没有发现任何差异。
plugins {
id "com.jfrog.bintray" version "1.8.0"
}
group = 'com.test'
version = '0.1'
allprojects {
apply plugin: 'java'
apply plugin: 'maven-publish'
repositories {
jcenter()
mavenCentral()
}
sourceCompatibility = 1.9
targetCompatibility = 1.9
}
/****************************************
* Single library "fat-jar" containing all sub projects and 3rd party dependencies
****************************************/
configurations {
childJars
}
dependencies {
subprojects.each {
childJars project(it.path)
}
}
jar {
dependsOn configurations.childJars
exclude('**/logback.xml')
from { configurations.childJars.collect { zipTree(it) } }
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives sourcesJar
archives javadocJar
}
/****************************************
* Bintray deployment (needed for Maven Central)
****************************************/
bintray {
user = System.getenv('BINTRAY_USER') // bintray username (not organisation)
key = System.getenv('BINTRAY_KEY') // api-key
override = true
publications = ['MavenCustom']
pkg {
repo = 'my-repository'
name = 'my-package'
userOrg = 'my-organisation'
licenses = ['AGPL-V3']
websiteUrl = 'https://github.com/myproject'
issueTrackerUrl = 'https://github.com/myproject/issues'
vcsUrl = 'https://github.com/myproject.git'
}
version {
name = project.version
released = new Date()
}
}
// Create the pom configuration:
def pomConfig = {
licenses {
license {
name 'GNU AFFERO GENERAL PUBLIC LICENSE, Version 3.0'
url 'https://www.gnu.org/licenses/agpl.txt'
distribution 'repo'
}
}
developers {
developer {
id 'developer-id'
name 'developer-name'
email 'developer@me'
}
}
scm {
url 'https://github.com/myproject'
connection 'https://git@github.com/myproject.git'
developerConnection 'scm:git:https://github.com/myproject.git'
}
}
publishing {
publications {
MavenCustom(MavenPublication) {
from components.java
artifact sourcesJar {
classifier "sources"
}
artifact javadocJar {
classifier "javadoc"
}
groupId project.group
artifactId project.name
version project.version
pom.withXml {
def root = asNode()
root.appendNode('description', 'descr')
root.appendNode('name', 'Project Name')
root.appendNode('url', 'https://github.com/myproject')
root.children().last() + pomConfig
}
}
}
}
model {
tasks.generatePomFileForMavenCustomPublication {
destination = file("$buildDir/libs/pom.xml")
}
}