-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.gradle
More file actions
137 lines (114 loc) · 3.57 KB
/
build.gradle
File metadata and controls
137 lines (114 loc) · 3.57 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
plugins {
id 'java-library'
id 'maven-publish'
id 'signing'
}
group = 'co.lettermint'
version = '1.2.0'
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
withSourcesJar()
withJavadocJar()
}
repositories {
mavenCentral()
}
dependencies {
// HTTP Client
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
// JSON Processing
implementation 'com.fasterxml.jackson.core:jackson-databind:2.21.2'
// Testing
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.1'
testImplementation 'com.squareup.okhttp3:mockwebserver:4.12.0'
}
test {
useJUnitPlatform()
}
// Generate BuildInfo.java with version from Gradle
def generatedSrcDir = layout.buildDirectory.dir('generated/sources/buildinfo/java/main')
tasks.register('generateBuildInfo') {
def outputDir = generatedSrcDir
outputs.dir(outputDir)
doLast {
def dir = outputDir.get().asFile
dir.mkdirs()
def packageDir = new File(dir, 'co/lettermint')
packageDir.mkdirs()
new File(packageDir, 'BuildInfo.java').text = """package co.lettermint;
/**
* Auto-generated build information.
*/
public final class BuildInfo {
public static final String VERSION = "${project.version}";
private BuildInfo() {}
}
"""
}
}
sourceSets.main.java.srcDir(generatedSrcDir)
compileJava.dependsOn(generateBuildInfo)
sourcesJar.dependsOn(generateBuildInfo)
jar {
manifest {
attributes(
'Implementation-Title': 'Lettermint Java SDK',
'Implementation-Version': version
)
}
}
publishing {
publications {
maven(MavenPublication) {
from components.java
pom {
name = 'Lettermint Java SDK'
description = 'Official Java SDK for the Lettermint API'
url = 'https://github.com/lettermint/lettermint-java'
licenses {
license {
name = 'MIT License'
url = 'https://opensource.org/licenses/MIT'
}
}
developers {
developer {
name = 'Lettermint'
email = '[email protected]'
organization = 'Lettermint'
organizationUrl = 'https://lettermint.co'
}
}
scm {
connection = 'scm:git:git://github.com/lettermint/lettermint-java.git'
developerConnection = 'scm:git:ssh://github.com:lettermint/lettermint-java.git'
url = 'https://github.com/lettermint/lettermint-java/tree/main'
}
}
}
}
repositories {
maven {
name = 'sonatypeCentral'
url = uri('https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/')
credentials {
username = System.getenv('OSSRH_USERNAME') ?: ''
password = System.getenv('OSSRH_PASSWORD') ?: ''
}
}
}
}
signing {
// Uses ORG_GRADLE_PROJECT_signingKey, signingKeyId, signingPassword from env
def signingKey = findProperty('signingKey')
def signingKeyId = findProperty('signingKeyId')
def signingPassword = findProperty('signingPassword') ?: ''
if (signingKey) {
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
}
sign publishing.publications.maven
}
tasks.withType(Sign) {
onlyIf { findProperty('signingKey') != null }
}