-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
129 lines (120 loc) · 3.05 KB
/
build.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
plugins {
// code formatting
id "com.diffplug.gradle.spotless" version "1.3.2"
// publishing
id "com.jfrog.bintray" version "1.5"
}
//////////////////////////////////////////
// ENFORCE FORMATTING ON THE MISC FILES //
//////////////////////////////////////////
spotless {
format 'misc', {
target '**/.gitignore', '**/*.gradle', '**/*.md', '**/*.sh'
indentWithTabs()
trimTrailingWhitespace()
endWithNewline()
}
freshmark {}
}
///////////////////////////////
// CREATES THE EXTENSION JAR //
///////////////////////////////
apply plugin: 'java'
jar {
manifest.attributes(
'Export-Package': PKG,
'Fragment-Host': 'system.bundle; extension:=framework',
'Bundle-ManifestVersion': '2',
'Bundle-License': 'public domain - http://unlicense.org/',
'Bundle-SymbolicName': project.name,
'Bundle-Version': version,
)
}
/////////////
// PUBLISH //
/////////////
// MavenCentral requires source jar
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allJava
}
// MavenCentral requires javadoc jar
def makeLink = { url, text -> "<a href=\"${url}\" style=\"text-transform: none;\">${text}</a>" }
def javadocInfo = '<h2>' + makeLink("https://${VCS_URL}", "${group}:${name}:${version}") +
' by ' + makeLink('http://www.diffplug.com', 'DiffPlug') + '</h2>'
javadoc {
options.addStringOption('Xdoclint:none', '-quiet')
options.header javadocInfo
options.footer javadocInfo
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
// pulls the credentials from either the environment variable or gradle.properties
def cred = {
if (System.env[it] != null) {
return System.env[it]
} else if (project.hasProperty(it)) {
return project[it]
} else {
return 'unknown_' + it
}
}
apply plugin: 'maven-publish'
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
pom.withXml {
// add MavenCentral requirements to the POM
asNode().children().last() + {
resolveStrategy = Closure.DELEGATE_FIRST
name project.name
description project.description
url "https://${VCS_URL}"
scm {
url "https://${VCS_URL}"
connection "scm:git:git://${VCS_URL}"
developerConnection "scm:git:ssh:git@${VCS_URL}"
}
licenses {
license {
name 'Public Domain'
url 'http://unlicense.org/'
distribution 'repo'
}
}
developers {
developer {
id 'nedtwigg'
name 'Ned Twigg'
email '[email protected]'
}
}
}
}
}
}
}
// upload releases to bintray and then mavenCentral
bintray {
user = cred('bintray_user')
key = cred('bintray_pass')
publications = ['mavenJava']
publish = true
pkg {
repo = 'opensource'
name = project.name.substring(BINTRAY_NAME_BASE.length())
userOrg = project.org
licenses = ['Unlicense']
vcsUrl = "https://${VCS_URL}"
version {
name = project.version
}
}
}
publish.dependsOn(bintrayUpload)
bintrayUpload.dependsOn(['generatePomFileForMavenJavaPublication', jar, sourcesJar, javadocJar])