forked from mtmse/dotify.api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
206 lines (184 loc) · 4.56 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
// For bnd
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'biz.aQute.bnd:biz.aQute.bnd.gradle:4.1.0'
}
}
plugins {
id 'java'
id 'maven-publish'
id 'signing'
id 'pmd'
}
apply plugin: 'biz.aQute.bnd.builder'
group = 'org.daisy.dotify'
sourceCompatibility = 1.8
targetCompatibility = 1.8
sourceSets {
main { java { srcDir 'src' } resources { srcDir 'src' } }
test { java { srcDir 'test' } resources { srcDir 'test' } }
}
compileJava {
options.encoding = 'UTF-8'
}
compileTestJava {
options.encoding = 'UTF-8'
}
def repoRevision = System.getenv("REPO_REVISION")!=null?System.getenv("REPO_REVISION"):repositoryRevision
javadoc {
options.encoding = 'UTF-8'
options.source = 8
options.links('https://docs.oracle.com/javase/8/docs/api/')
options.overview = 'src/javadoc-overview.html'
}
repositories {
mavenCentral()
//mavenLocal()
//maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
dependencies {
compileOnly 'org.osgi:org.osgi.service.component.annotations:1.3.0'
testCompileOnly 'org.osgi:org.osgi.service.component.annotations:1.3.0'
testImplementation group: "junit", name: "junit", version: "4.12"
testImplementation "org.mockito:mockito-core:1.10.19"
}
def matchesPackageInfo() {
def v = (version =~ /([\d]+\.[\d]+)/)[0][1]
//println v
FileTree tree = fileTree(dir: 'src')
tree.include('**/packageinfo')
def hasMatch = false;
tree.each {File f ->
String contents = f.getText('UTF-8')
hasMatch |= contents.matches("version \\Q$v\\E")
}
return hasMatch
}
// this is executed during the configuration phase
task verifyPackageInfo() {
def hasPackageInfo = matchesPackageInfo()
//println hasPackageInfo
if (!hasPackageInfo) {
def v = (version =~ /([\d]+\.[\d]+)/)[0][1]
throw new GradleException("No packageinfo matching bundle version: $v")
}
}
jar {
manifest {
attributes(
'-sources': 'true',
'Export-Package': 'org.daisy.dotify.api.*',
'Automatic-Module-Name': "$moduleName",
'Bundle-Name': "$moduleName",
'Bundle-SymbolicName': "$moduleName",
'Built-By': System.getProperty("user.name"),
'Built-On': new Date().format('yyyy-MM-dd'),
'Repository-Revision': "$repoRevision",
'Repository-URL': "$repositoryURL",
'Include-Resource': 'LICENSE, NOTICE'
)
}
}
task javadocJar(type: Jar) {
classifier = 'javadoc'
from javadoc
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
signing {
required { isReleaseVersion }
sign publishing.publications
}
publishing {
//Only upload if a git hash is supplied. On Travis only upload snapshots.
//enabled = repoRevision.size()==40 && System.getenv("TRAVIS_BUILD_ID")!=null
publications {
maven(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
/*
if (isReleaseVersion) {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
}*/
pom {
name = 'dotify.api'
packaging = 'jar'
description = 'Dotify API'
url = "$repositoryURL"
scm {
connection = "$repositorySCM"
developerConnection = "$repositorySCM"
url = "$repositoryURL"
}
licenses {
license {
name = 'LGPL'
url = 'http://www.gnu.org/licenses/lgpl.html'
}
}
developers {
developer {
id = 'joel'
name = 'Joel Håkansson'
}
}
developers {
developer {
id = 'paulrambags'
name = 'Paul Rambags'
}
}
}
}
}
repositories {
maven {
def stagingRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : stagingRepoUrl
credentials {
username = sonatypeUsername
password = sonatypePassword
}
}
}
}
pmd.ruleSets = [
// New rule sets:
//'category/java/bestpractices.xml',
//'category/java/codestyle.xml',
//'category/java/design.xml',
//'category/java/documentation.xml',
//'category/java/errorprone.xml',
'category/java/multithreading.xml',
//'category/java/performance.xml',
'category/java/security.xml',
// Old rule sets (use for now):
'java-basic',
'java-braces',
//'java-clone',
//'java-codesize',
//'java-comments',
//'java-controversial',
//'java-coupling',
//'java-design',
//'java-empty',
'java-finalizers',
'java-imports',
//'java-optimizations',
'java-strictexception',
//'java-strings',
'java-typeresolution',
//'java-unnecessary',
'java-unusedcode'
]
wrapper {
distributionType = Wrapper.DistributionType.ALL
}