-
Notifications
You must be signed in to change notification settings - Fork 0
/
bintray-jvm.gradle
145 lines (126 loc) · 4.05 KB
/
bintray-jvm.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
// publish to bintray
//
// classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.3'
// classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.7.5'
//
// apply from: 'https://raw.githubusercontent.com/danke77/bintray/master/bintray-jvm.gradle'
// gradle clean build bintrayUpload
group = POM_GROUP
version = POM_VERSION_NAME
project.archivesBaseName = POM_ARTIFACT_ID
apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.jfrog.artifactory'
task generateSourcesJar(type: Jar) {
group = 'jar'
from project.sourceSets.main.allSource
classifier = 'sources'
}
task generateJavadocJar(type: Jar) {
group = 'jar'
from project.javadoc.destinationDir
classifier = 'javadoc'
}
artifacts {
archives generateSourcesJar
archives generateJavadocJar
}
def pomConfig = {
licenses {
license {
name POM_LICENCE_NAME
url POM_LICENCE_URL
distribution POM_LICENCE_DIST
}
}
developers {
developer {
id POM_DEVELOPER_ID
name POM_DEVELOPER_NAME
email POM_DEVELOPER_EMAIL
}
}
}
/**
* 不要移动这个 apply 的位置,否则有可能出现
* ’Error: Cannot configure the ‘publishing’ extension after it has been accessed’
* (don’t move this snippet code position)
*/
apply plugin: 'maven-publish'
publishing {
publications {
mavenKotlin(MavenPublication) {
groupId POM_GROUP
artifactId POM_ARTIFACT_ID
version = POM_VERSION_NAME
artifact generateSourcesJar
artifact generateJavadocJar
from components.java
pom.withXml {
def root = asNode()
root.appendNode('description', POM_DESCRIPTION)
root.children().last() + pomConfig
def dependenciesNode = root.appendNode('dependencies')
configurations.compile.allDependencies.each {
if (it.group && it.name && it.version) {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
}
}
}
}
}
}
bintray {
def USER
def KEY
File localPropertiesFile = new File("${rootProject.projectDir}/local.properties")
if (localPropertiesFile.exists()) {
Properties properties = new Properties()
properties.load(localPropertiesFile.newDataInputStream())
USER = properties.getProperty('bintray.user')
KEY = properties.getProperty('bintray.apikey')
} else {
USER = System.getenv('bintray.user')
KEY = System.getenv('bintray.apikey')
}
user = USER
key = KEY
publications = ['mavenKotlin']
publish = true
pkg {
repo = 'maven'
name = POM_NAME
desc = POM_DESCRIPTION
websiteUrl = POM_URL
issueTrackerUrl = POM_SCM_ISSUE_TRACKER_URL
vcsUrl = POM_SCM_CONNECTION
licenses = [POM_LICENCE_NAME]
publicDownloadNumbers = true
}
}
artifactory {
// maven { url "http://localhost:8080/artifactory/gradle-release-local" }
contextUrl = 'http://oss.jfrog.org/artifactory' // 'http://localhost:8080/artifactory'
resolve {
repository {
repoKey = 'libs-release'
}
}
publish {
repository {
repoKey = 'gradle-release-local' //The Artifactory repository key to publish to
username = bintray.user // JFrog的用户名
password = bintray.key // JFrog登录密码
// maven = true
}
defaults {
// Tell the Artifactory Plugin which artifacts should be published to Artifactory.
publications('mavenKotlin')
publishArtifacts = true
// Publish generated POM files to Artifactory (true by default)
publishPom = true
}
}
}