-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathbuild.gradle
221 lines (191 loc) · 6.95 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
/*
* Copyright (c) 2014-present Snowplow Analytics Ltd. All rights reserved.
*
* This program is licensed to you under the Apache License Version 2.0,
* and you may not use this file except in compliance with the Apache License Version 2.0.
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the Apache License Version 2.0 is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
*/
import java.time.Duration
plugins {
id 'java-library'
id 'maven-publish'
id 'io.github.gradle-nexus.publish-plugin' version '1.1.0'
id 'signing'
id 'idea'
}
wrapper.gradleVersion = '6.5.0'
group = 'com.snowplowanalytics'
archivesBaseName = 'snowplow-java-tracker'
version = '2.1.0'
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
def javaVersion = JavaVersion.VERSION_1_8
repositories {
mavenCentral()
}
configure([compileJava, compileTestJava]) {
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
options.encoding = 'UTF-8'
}
java {
registerFeature('okhttpSupport') {
usingSourceSet(sourceSets.main)
}
registerFeature('apachehttpSupport') {
usingSourceSet(sourceSets.main)
}
}
test {
useJUnitPlatform {
includeEngines 'junit-vintage'
}
}
dependencies {
// Apache Commons
api 'commons-net:commons-net:3.10.0'
api 'commons-codec:commons-codec:1.16.0'
// Apache HTTP
apachehttpSupportApi 'org.apache.httpcomponents.client5:httpclient5:5.3'
// Square OK HTTP
okhttpSupportApi 'com.squareup.okhttp3:okhttp:4.12.0'
// SLF4J logging API
api 'org.slf4j:slf4j-api:2.0.11'
testImplementation 'org.slf4j:slf4j-simple:2.0.11'
// Jackson JSON processor
api 'com.fasterxml.jackson.core:jackson-databind:2.16.1'
api 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.16.1'
// Testing libraries
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.1'
testCompileOnly 'junit:junit:4.13.2'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
testImplementation 'com.squareup.okhttp3:mockwebserver:4.12.0'
}
task sourceJar(type: Jar, dependsOn: 'generateSources') {
from sourceSets.main.allJava
}
task generateSources {
project.ext.set("outputDir", "$projectDir/src/main/java/com/snowplowanalytics/snowplow/tracker")
doFirst {
println outputDir
def srcFile = new File((String) outputDir, "Version.java")
srcFile.parentFile.mkdirs()
srcFile.write(
"""/*
* Copyright (c) 2014-present Snowplow Analytics Ltd. All rights reserved.
*
* This program is licensed to you under the Apache License Version 2.0,
* and you may not use this file except in compliance with the Apache License Version 2.0.
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the Apache License Version 2.0 is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
*/
package com.snowplowanalytics.snowplow.tracker;
// DO NOT EDIT. AUTO-GENERATED.
/**
* The release version of the Snowplow Java tracker.
*/
public class Version {
static final String TRACKER = "java-$project.version";
static final String VERSION = "$project.version";
}
""")
}
}
compileJava.dependsOn generateSources
compileJava.source generateSources.outputs.files, sourceSets.main.java
task printVersion {
doLast {
print "$project.version"
}
}
// custom tasks for creating source/javadoc jars
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
// add javadoc/source jar tasks as artifacts
artifacts {
archives sourcesJar, javadocJar
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
groupId group
artifactId 'snowplow-java-tracker'
version version
suppressPomMetadataWarningsFor('apachehttpSupportApiElements')
suppressPomMetadataWarningsFor('apachehttpSupportRuntimeElements')
suppressPomMetadataWarningsFor('okhttpSupportApiElements')
suppressPomMetadataWarningsFor('okhttpSupportRuntimeElements')
pom {
name = 'snowplow-java-tracker'
description = 'Snowplow event tracker for Java. Add analytics to your Java desktop and server apps, servlets and games.'
url = 'https://github.com/snowplow/snowplow-java-tracker/'
inceptionYear = '2014'
packaging = 'jar'
groupId = 'com.snowplowanalytics'
licenses {
license {
name = 'Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution = 'repo'
}
}
scm {
connection = 'https://github.com/snowplow/snowplow-java-tracker.git'
url = 'https://github.com/snowplow/snowplow-java-tracker'
}
developers {
developer {
name = 'Snowplow Analytics Ltd'
email = '[email protected]'
organization = 'Snowplow Analytics Ltd'
organizationUrl = 'http://snowplowanalytics.com'
}
}
organization {
name = 'com.snowplowanalytics'
url = 'http://snowplowanalytics.com'
}
}
}
}
}
nexusPublishing {
repositories {
sonatype {
username = System.getenv('SONA_USER')
password = System.getenv('SONA_PASS')
}
}
transitionCheckOptions {
maxRetries.set(360)
delayBetween.set(Duration.ofSeconds(20))
}
}
signing {
if (System.getenv('ORG_GRADLE_PROJECT_signingKey') && System.getenv('ORG_GRADLE_PROJECT_signingPassword')) {
println 'Found signing credentials. Signing...'
def signingKey = findProperty("signingKey")
def signingPassword = findProperty("signingPassword")
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.mavenJava
println 'Used useInMemoryPgpKeys()'
}
}