This repository was archived by the owner on Sep 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathbuild.gradle
More file actions
225 lines (189 loc) · 7.56 KB
/
build.gradle
File metadata and controls
225 lines (189 loc) · 7.56 KB
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'maven'
apply plugin: 'org.eclipse.keyple'
apply plugin: 'jacoco'
apply plugin: 'org.sonarqube'
sourceCompatibility = 1.6
archivesBaseName = "keyple-java-core"
project.description ='Keyple Core'
task copyVersionFile {
//generate properties file META-INF/keyple.properties with version number
def props = new Properties()
def dirs = file "src/main/resources/META-INF/"
dirs.mkdirs()
def propertyFile = file "src/main/resources/META-INF/keyple-core.properties"
if(propertyFile.exists()){
props.load(propertyFile.newDataInputStream())
}
if(project.version !="unspecified" && project.version != props.getProperty("version")){
logger.info('Version of keyple core have changed, overwriting src/main/resources/META-INF/keyple-core.properties')
props.setProperty("version", project.version)
props.store(propertyFile.newWriter(), "Properties file generated by gradle")
}else{
logger.info("Version of keyple hasn't changed")
}
}
//copy license file from root folder to each generated artifact
task copyLICENSE(type: Copy) {
from file("${projectDir}/../../../LICENSE")
into file("${buildDir}/resources/main/META-INF/")
}
//copy notice file from root folder to each generated artifact
task copyNOTICE(type: Copy) {
from file("${projectDir}/../../../NOTICE.md")
into file("${buildDir}/resources/main/META-INF/")
}
classes.dependsOn copyLICENSE, copyNOTICE,copyVersionFile
//declare manifest
jar {
manifest {
attributes 'Implementation-Title': project.description,
'Implementation-Version': project.version
}
}
//generate sources jar
task sourcesJar(type: Jar, dependsOn : classes) {
classifier = 'sources'
from sourceSets.main.output, sourceSets.main.java
}
// Javadoc generation
// Copy static custom files (logo)
javadoc {
doLast {
copy {
from "src/main/javadoc/images"
into "$project.buildDir/docs/javadoc/images"
include "*.png"
}
}
}
// Generate javadoc jar
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
javadoc.options.encoding = 'UTF-8'
from javadoc.destinationDir
javadoc.options.overview = "src/main/javadoc/overview.html"
javadoc.options.setUse(true) // adds the "use" link to the navigation bar
javadoc.options.setStylesheetFile(file("src/main/javadoc/keyple-stylesheet.css"))
javadoc.options.setWindowTitle(project.description + " Reference API - " + version)
javadoc.options.setDocTitle(project.description + " Reference API - " + version)
javadoc.options.setHeader("<a target=\"_parent\" href=\"https://keyple.org/\"><img src=\"{@docRoot}/images/keyple.png\" height=\"20px\" style=\"background-color: white; padding: 3px; margin: 0 10px -7px 3px;\"/></a><span style=\"line-height: 30px\"> CORE REFERENCE API - " + version + "</span>")
javadoc.options.setFooter("Copyright © Eclipse Foundation, Inc. All Rights Reserved.")
}
//publish javadoc, sources and jar
artifacts {
archives sourcesJar, javadocJar
}
//sign if needed (based on the doSign variable)
if (project.getProperties().containsKey("doSign") && doSign=="true") {
apply plugin: 'signing'
ext."signing.keyId" = "0C140E36"
//other properties are defined in the gradle.properties
signing {
sign configurations.archives
}
}
//define local or remote upload repository (based on the doSign variable)
/* from https://central.sonatype.org/pages/gradle.html */
uploadArchives {
repositories {
mavenDeployer {
if (project.getProperties().containsKey("doSign") && doSign=="true") {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
}else {
repository(url: mavenLocal().url)
}
}
}
}
//overwrite pom definition values
uploadArchives {
repositories {
mavenDeployer {
pom.project {
name project.description
description project.description
url "https://projects.eclipse.org/projects/iot.keyple"
organization("Eclipse Keyple"){
name "Eclipse Keyple"
url "https://projects.eclipse.org/projects/iot.keyple"
}
scm {
connection 'scm:git:git://github.com/eclipse/keyple-java.git'
developerConnection 'scm:git:https://github.com/eclipse/keyple-java.git'
url 'http://github.com/eclipse/keyple-java/tree/master'
}
licenses {
license {
name 'Eclipse Public License - v 2.0'
url 'https://www.eclipse.org/legal/epl-2.0/'
}
}
developers {
developer {
name 'Olivier Delcroix'
email 'odelcroi@gmail.com'
}
developer {
name 'Jean-Pierre Fortune'
email 'jean-pierre.fortune@ialto.com'
}
developer {
name 'Pierre Terrée'
email 'pierre.terree@calypsonet.org'
}
}
//dependencies mapping is defined manually
pom.scopeMappings.with {
mappings.clear()
addMapping(1, configurations.api, 'compile')//only keyple core add slf4j-api as a compile dependency
addMapping(2, configurations.testImplementation, 'test')
}
}
}
}
}
task installCore{
group 'keyple'
description 'Builds and installs the keyple core library into maven local repository'
dependsOn ':java:component:keyple-core:uploadArchives'
doLast {
println "Keyple Core library ${project.version} has been installed into maven local repo at path : " + project.getRepositories().get(0).getAt("url")
}
}
jacocoTestReport {
reports {
xml.enabled true
csv.enabled false
html.enabled false
}
}
test.finalizedBy jacocoTestReport
sonarqube {
properties {
property "sonar.projectKey", "eclipse_keyple-core"
property "sonar.organization", "eclipse"
property "sonar.host.url", "https://sonarcloud.io"
property "sonar.login", System.getenv('SONAR_LOGIN')
property "sonar.branch.name", System.getenv('BRANCH_NAME')
}
}
dependencies {
// https://mvnrepository.com/artifact/org.slf4j/slf4j-api
api "org.slf4j:slf4j-api:${slf4japi_version}"
api "com.google.code.gson:gson:${gson_version}"
testImplementation "junit:junit:${junit_version}"
// https://search.maven.org/artifact/org.assertj/assertj-core/2.9.1/bundle
testImplementation "org.assertj:assertj-core:${assertj_version}"
// https://mvnrepository.com/artifact/org.mockito/mockito-core
testImplementation "org.mockito:mockito-core:${mockitocore_version}"
//add slf4j simple logger implementation
testImplementation "org.slf4j:slf4j-simple:${slf4jsimple_version}"
}