forked from eclipse-keyple/keyple-java
/
build.gradle
232 lines (185 loc) · 7.16 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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
apply from: "../../build.gradle"
apply plugin: 'com.android.library'
apply plugin: 'maven'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
//apply plugin: 'org.eclipse.keyple'
archivesBaseName = "keyple-android-plugin-nfc"
group 'org.eclipse.keyple'
project.description = 'Keyple Plugin Android Nfc'
android {
compileSdkVersion 29
buildToolsVersion '29.0.2'
defaultConfig {
minSdkVersion 19
targetSdkVersion 29
versionName project.version
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_6
}
testOptions {
unitTests {
returnDefaultValues = true//mock Log Android object
includeAndroidResources = true
}
}
lintOptions {
abortOnError false
}
//generate output aar with a qualified name : with version number
libraryVariants.all { variant ->
variant.outputs.all { output ->
if (outputFile != null && outputFileName.endsWith('.aar')) {
outputFileName = "${archivesBaseName}-${version}.aar"
}
}
}
//create a task to generate javadoc for each variants
libraryVariants.all { variant ->
task("generate${variant.name.capitalize()}Javadoc", type: Javadoc) {
description "Generates Javadoc for variant ${variant.name.capitalize()}"
//println "Create Javadoc Task for variant ${variant.name.capitalize()}"
source = variant.javaCompile.source
options.links("http://docs.oracle.com/javase/6/docs/api/")
options.links("http://d.android.com/reference/")
//println 'classpath : ' + classpath.getFiles()
//println 'options links : ' + options.links
//println 'source : ' + source.getFiles()
// First add all of your dependencies to the classpath, then add the android jars
doFirst {
//doFirst is needed else we get the error "Cannot create variant 'android-lint' after configuration" with gradle 4.4+
classpath = files(variant.javaCompile.classpath.files, project.android.getBootClasspath())
}
classpath += files(android.getBootClasspath())
// We're excluding these generated files
exclude '**/BuildConfig.java'
exclude '**/R.java'
failOnError = false
destinationDir = file("${project.docsDir}/javadoc")
//destinationDir = file(System.getProperty("user.home") +"/pages")
}
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
test.java.srcDirs += 'src/test/kotlin'
}
}
//build sources jar
task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.sourceFiles
}
//declare javadoc and sources jar as artifacts also
artifacts {
archives androidSourcesJar, 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
}
}
/* from https://central.sonatype.org/pages/gradle.html */
uploadArchives {
repositories {
mavenDeployer {
//define local or remote upload repository (based on the doSign variable)
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)
}
pom.project {
name project.description
description project.description
url "https://projects.eclipse.org/projects/iot.keyple"
packaging "aar"
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.implementation, 'compile')
addMapping(2, configurations.testImplementation, 'test')
addMapping(3, configurations.androidTestImplementation, 'test')
}
}
}
}
}
repositories {
mavenLocal()
mavenCentral()
google()
jcenter()
}
task installPlugin{
group 'keyple'
description 'Builds and installs the keyple Android NFC plugin library into maven local repository'
dependsOn ':keyple-plugin:keyple-plugin-android-nfc:uploadArchives'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//keyple-core project
implementation group: 'org.eclipse.keyple', name: 'keyple-java-core', version: project.version
//android
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
//logging
implementation "org.slf4j:slf4j-api:1.7.25"
implementation 'com.jakewharton.timber:timber:4.7.1' //Android
implementation 'com.arcao:slf4j-timber:3.1@aar' //SLF4J binding for Timber
/*
Tests
*/
/** Test **/
testImplementation "junit:junit:4.12"
/** Mocking for tests **/
testImplementation "io.mockk:mockk:1.9"
/** Allow to use Android SDK in JVM */
testImplementation 'org.robolectric:robolectric:4.3.1'
}