-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathbuild.gradle
More file actions
277 lines (229 loc) · 10.8 KB
/
build.gradle
File metadata and controls
277 lines (229 loc) · 10.8 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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
/*
* This file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Java library project to get you started.
* For more details take a look at the 'Building Java & JVM projects' chapter in the Gradle
* User Manual available at https://docs.gradle.org/6.8.3/userguide/building_java_projects.html
*/
plugins {
id 'java-library'
id 'com.microsoft.identity.buildsystem' version '0.2.5'
id 'maven-publish'
// the below build plugin allows to generate BuildConfig files in a JAVA gradle project.
// BuildConfig files are generated by default in an Android project, however, a non-Android java
// module doesn't really have a concept of BuildConfig. This plugin allows us to create similar
// looking BuildConfig constants in a java project.
id 'com.github.gmazzo.buildconfig' version '3.0.0'
// Test fixtures are commonly used to setup the code under test,
// or provide utilities aimed at facilitating the tests of a component.
// This will automatically create a testFixtures source set, in which you can write your test fixtures.
id "java-test-fixtures"
// This is needed to get Android Studio to resolve test fixtures dependencies
id 'idea'
// Add kotlin support
id 'org.jetbrains.kotlin.jvm'
}
def desugarCode = false
if (project.hasProperty("sugar")) {
desugarCode = sugar.toBoolean()
}
buildSystem {
desugar = desugarCode
}
def enableCodeCoverage = false
if (project.hasProperty("codeCoverageEnabled")) {
enableCodeCoverage = codeCoverageEnabled.toBoolean()
}
codeCoverageReport {
coverage.enabled = enableCodeCoverage
}
repositories {
mavenCentral()
}
apply from: './versioning/version_tasks.gradle'
project.ext.vstsUsername = System.getenv("ENV_VSTS_MVN_ANDROIDCOMMON_USERNAME") != null ? System.getenv("ENV_VSTS_MVN_ANDROIDCOMMON_USERNAME") : project.findProperty("vstsUsername")
project.ext.vstsPassword = System.getenv("ENV_VSTS_MVN_ANDROIDCOMMON_ACCESSTOKEN") != null ? System.getenv("ENV_VSTS_MVN_ANDROIDCOMMON_ACCESSTOKEN") : project.findProperty("vstsMavenAccessToken")
version = getAppVersionName()
task sourcesJar(type: Jar) {
dependsOn generateBuildConfig
from sourceSets.main.java.srcDirs
archiveClassifier.set('sources')
destinationDirectory = reporting.file("$project.buildDir/outputs/jars")
}
// Task to generate javadoc
task generateJavadoc(type: Javadoc) {
dependsOn generateBuildConfig
failOnError false
title = "Microsoft Identity Common Java"
source = sourceSets.main.java
classpath += project.sourceSets.main.compileClasspath
options.memberLevel = JavadocMemberLevel.PUBLIC
options.addBooleanOption('Xdoclint:none', true)
exclude '**/BuildConfig.Java'
exclude '**/R.java'
destinationDir = reporting.file("$project.buildDir/outputs/javadoc")
}
// Task to generate javadoc.jar
task javadocJar(type: Jar, dependsOn: generateJavadoc) {
from javadoc.destinationDir
archiveClassifier.set('javadoc')
destinationDirectory = reporting.file("$project.buildDir/outputs/jars")
}
jar {
manifest {
attributes('Implementation-Title': project.name,
'Implementation-Version': project.version)
}
}
publishing {
publications {
aar(MavenPublication) {
groupId 'com.microsoft.identity'
artifactId 'common4j'
from components.java
pom {
name = 'common4j'
description = 'This library contains common java code shared between the Active Directory ' +
'Authentication Library (ADAL) for Android and the Microsoft ' +
'Authentication Library (MSAL) for Android. This library ' +
'includes only internal classes and is NOT part of the ' +
'public API'
url = 'https://github.com/AzureAD/microsoft-authentication-library-common-for-android'
developers {
developer {
id = 'microsoft'
name = 'Microsoft'
}
}
licenses {
license {
name = 'MIT License'
}
}
inceptionYear = '2021'
scm {
url = 'https://github.com/AzureAD/microsoft-authentication-library-common-for-android/tree/master'
}
properties = [
branch: 'master',
version: project.version
]
}
}
}
repositories {
maven {
name "vsts-maven-adal-android"
url "https://identitydivision.pkgs.visualstudio.com/_packaging/AndroidADAL/maven/v1"
credentials {
username project.ext.vstsUsername
password project.ext.vstsPassword
}
}
}
}
def sliceParameter = "" // will be blank unless specified by developer
def dcParameter = "" // will be blank unless specified by developer
def useMockApiForNativeAuthParameter = false // will be false unless specified by developer
def mockApiUrlParameter = "" // will be blank unless specified by developer
def disableAcquireTokenSilentTimeoutParameter = false // will be false unless specified by developer
def allowOneboxAuthorities = false // will be false unless specified by developer
if (project.hasProperty("slice")) {
sliceParameter = slice
}
if (project.hasProperty("dc")) {
dcParameter = dc
}
// This flag is set to false to allow running tests against our mock APIs
// as our mock API is not a 'real' tenant.
if (project.hasProperty("useMockApiForNativeAuth")) {
useMockApiForNativeAuthParameter = useMockApiForNativeAuth
}
if (project.hasProperty("mockApiUrl")) {
mockApiUrlParameter = mockApiUrl
}
// By adding -PdisableAcquireTokenSilentTimeout in your dev environment, you will no longer subject to the ATS timeout,
// and your life will be much happier during debugging.
if (project.hasProperty("disableAcquireTokenSilentTimeout")) {
disableAcquireTokenSilentTimeoutParameter = true
}
if (project.hasProperty("allowOneboxAuthorities")) {
allowOneboxAuthorities = true
}
sourceSets {
main {
java.srcDirs = ['src/main', "$project.buildDir/generated/source/buildConfig/main"]
buildConfigField("String", "SLICE", "\"$sliceParameter\"")
buildConfigField("String", "DC", "\"$dcParameter\"")
buildConfigField("boolean", "USE_MOCK_API_FOR_NATIVE_AUTH_AUTHORITY", "${useMockApiForNativeAuthParameter}")
buildConfigField("String", "MOCK_API_URL", "\"$mockApiUrlParameter\"")
buildConfigField("boolean", "DISABLE_ACQUIRE_TOKEN_SILENT_TIMEOUT", "${disableAcquireTokenSilentTimeoutParameter}")
buildConfigField("boolean", "ALLOW_ONEBOX_AUTHORITIES", "${allowOneboxAuthorities}")
}
test {
java.srcDirs = ['src/test']
}
}
// This is needed to get Android Studio to resolve test fixtures dependencies
// by default test fixtures dependencies are not resolved in IDE
configurations {
resolvableTestFixturesImplementation {
canBeResolved true;
}
}
configurations.testFixturesImplementation.extendsFrom(configurations.resolvableTestFixturesImplementation);
idea {
module {
// This is needed to get Android Studio to resolve test fixtures dependencies
// by default test fixtures dependencies are not resolved in IDE
scopes.COMPILE.plus += [configurations.resolvableTestFixturesImplementation]
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:${rootProject.ext.kotlinVersion}"
testImplementation "org.jetbrains.kotlin:kotlin-stdlib:${rootProject.ext.kotlinVersion}"
compileOnly "com.github.spotbugs:spotbugs-annotations:$rootProject.ext.spotBugsAnnotationVersion"
compileOnly "org.projectlombok:lombok:$rootProject.ext.lombokVersion"
annotationProcessor "org.projectlombok:lombok:$rootProject.ext.lombokVersion"
implementation "com.nimbusds:nimbus-jose-jwt:$rootProject.ext.nimbusVersion"
implementation "com.google.code.gson:gson:$rootProject.ext.gsonVersion"
implementation "org.json:json:$rootProject.ext.jsonVersion"
implementation "com.github.stephenc.jcip:jcip-annotations:$rootProject.ext.jcipAnnotationVersion"
implementation 'org.apache.httpcomponents.core5:httpcore5:5.3'
testImplementation "cz.msebera.android:httpclient:4.5.8"
testCompileOnly "com.github.spotbugs:spotbugs-annotations:$rootProject.ext.spotBugsAnnotationVersion"
testCompileOnly "org.projectlombok:lombok:$rootProject.ext.lombokVersion"
testAnnotationProcessor "org.projectlombok:lombok:$rootProject.ext.lombokVersion"
testImplementation "junit:junit:$rootProject.ext.junitVersion"
testImplementation "org.mockito:mockito-core:$rootProject.ext.mockitoCoreVersion"
testImplementation "io.mockk:mockk:$rootProject.ext.mockkVersion"
testImplementation "org.mockito:mockito-inline:$rootProject.ext.mockitoCoreVersion"
testImplementation "org.mockito.kotlin:mockito-kotlin:$rootProject.ext.mockitoKotlinVersion"
testFixturesCompileOnly "com.google.code.gson:gson:$rootProject.ext.gsonVersion"
testFixturesCompileOnly "org.mockito:mockito-core:$rootProject.ext.mockitoCoreVersion"
testFixturesCompileOnly "org.mockito.kotlin:mockito-kotlin:$rootProject.ext.mockitoKotlinVersion"
testFixturesCompileOnly "org.powermock:powermock-module-junit4:$rootProject.ext.powerMockVersion"
testFixturesCompileOnly "com.github.spotbugs:spotbugs-annotations:$rootProject.ext.spotBugsAnnotationVersion"
testFixturesCompileOnly "org.projectlombok:lombok:$rootProject.ext.lombokVersion"
testFixturesCompileOnly "org.mockito:mockito-inline:$rootProject.ext.mockitoCoreVersion"
testFixturesAnnotationProcessor "org.projectlombok:lombok:$rootProject.ext.lombokVersion"
resolvableTestFixturesImplementation "org.robolectric:junit:$rootProject.ext.robolectricVersion"
implementation("io.opentelemetry:opentelemetry-api:$rootProject.ext.openTelemetryVersion")
}
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
buildConfig {
// forces the package (of the generated BuildConfig file). Defaults to '${project.group}'
packageName("com.microsoft.identity.common.java")
useJavaOutput() // forces the outputType to 'java'
}
afterEvaluate {
assemble.dependsOn sourcesJar, javadocJar
// these tasks are generated by the buildconfig plugin..for more details, read comment about it
// above in the plugins block.
compileJava.dependsOn generateBuildConfig, generateTestBuildConfig
}
// This is used to generate the pom file for publishing to external maven in maven-release-jobs.yml
tasks.withType(GenerateMavenPom).all {
destination = layout.buildDirectory.file("poms/${project.name}-${project.version}.pom").get().asFile
}