-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathbuild.gradle
182 lines (159 loc) · 5.34 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
buildscript {
ext.kotlin_version = '1.9.20'
repositories {
mavenCentral()
maven {
url 'https://plugins.gradle.org/m2/'
}
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.github.gmazzo:gradle-buildconfig-plugin:3.0.3"
}
}
plugins {
id 'com.github.kt3k.coveralls' version '2.12.2'
id 'com.github.gmazzo.buildconfig' version '3.0.3'
id 'java'
id 'maven-publish'
id 'signing'
id 'checkstyle'
}
apply plugin: 'checkstyle'
apply plugin: 'kotlin'
apply plugin: 'jacoco'
apply plugin: 'java-library'
apply plugin: 'com.github.gmazzo.buildconfig'
apply plugin: 'maven-publish'
apply plugin: 'java'
apply plugin: 'signing'
group = 'org.filestack'
sourceCompatibility = 21
version = file(new File('VERSION')).text.trim() // Get version string from VERSION text file
dependencies {
implementation 'com.squareup.okhttp3:okhttp:5.0.0-alpha.14'
implementation 'com.google.code.gson:gson:2.10.1'
implementation 'io.reactivex.rxjava2:rxjava:2.2.21'
compileOnly 'com.google.code.findbugs:jsr305:3.0.2'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.mockito:mockito-core:2.19.0'
testImplementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'com.squareup.okhttp3:mockwebserver:5.0.0-alpha.14'
testImplementation 'com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0'
testImplementation 'org.hamcrest:hamcrest-library:1.3'
}
// Add generated build-config directories to the main source set, so that the
// IDE doesn't complain when the app references BuildConfig classes
sourceSets {
main {
java {
srcDir new File(buildDir, 'gen/buildconfig')
}
}
}
buildConfig {
className = "FilestackBuildConfig"
packageName = project.group
buildConfigField 'String', 'VERSION', "\"${project.version}\""
}
// Added task to validate required Doc directory and files path
task validateDirAndFileForBuild {
doLast {
def dir = file("$projectDir/docs")
if (!dir.exists()) {
throw new GradleException("Required directory is missing: ${dir.absolutePath}")
}
def customFile = file("$projectDir/config/javadoc/javadoc.txt")
if (!customFile.exists() || !customFile.isFile()) {
throw new GradleException("Invalid file path: ${customFile.absolutePath}")
}
}
}
// Build fails, if required javadoc validation fails
build.dependsOn validateDirAndFileForBuild
javadoc {
destinationDir new File(projectDir, '/docs')
options.optionFiles(new File(projectDir, '/config/javadoc/javadoc.txt'))
}
repositories {
mavenCentral()
}
// Create javadoc artifact jar
task javadocJar(type: Jar, dependsOn: javadoc) {
archiveClassifier = 'javadoc'
from javadoc.destinationDir
}
// Create source artifact jar
task sourcesJar(type: Jar, dependsOn: classes) {
archiveClassifier = 'sources'
from sourceSets.main.allSource
}
// Put unit and integration test reports in separate directories
tasks.withType(Test) {
reports.html.destination = file("${reporting.baseDir}/${name}")
}
// Updated latest version to be compatible with JDK21
checkstyle {
toolVersion = "10.18.2"
}
// Due to induced vulnerabilities, added code to exclude unused "org.codehaus.plexus" package.
// Downloaded as Transitive(child) dependencies from Checkstyle plugin but not used in application.
configurations.all {
exclude group: 'org.codehaus.plexus'
}
jacocoTestReport {
reports {
xml.required = true
html.required = true
}
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions {
jvmTarget = "21"
}
}
publishing {
publications {
filestackJava(MavenPublication) {
groupId = 'org.filestack'
artifactId = 'filestack-java'
version = file(new File('VERSION')).text.trim()
from components.java
artifact sourcesJar
artifact javadocJar
pom {
name = 'filestack-java'
description = 'Official Java SDK for Filestack - API and content management system that makes it easy to add powerful file uploading and transformation capabilities to any web or mobile application.'
url = 'https://github.com/filestack/filestack-java'
inceptionYear = '2017'
licenses {
license {
name = 'Apache-2.0'
url = 'https://opensource.org/license/apache-2-0'
}
}
developers {
developer {
id = 'filestack'
name = 'Filestack'
email = 'dev@filestack.com'
}
}
scm {
connection = 'scm:git:git:github.com/filestack/filestack-java.git'
developerConnection = 'scm:git:ssh://github.com/filestack/filestack-java.git'
url = 'https://github.com/filestack/filestack-java'
}
}
}
}
repositories {
maven {
url = layout.projectDirectory.dir('releases')
}
}
}
signing {
useGpgCmd()
sign publishing.publications.filestackJava
}