-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
183 lines (163 loc) · 5.36 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
plugins {
id 'java'
id 'idea'
id 'groovy'
id 'jacoco'
id 'signing'
id 'maven-publish'
}
group 'com.github.joutvhu'
version '1.0.0'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
def snapshotVersion = version.endsWith('-SNAPSHOT') || version.endsWith('.SNAPSHOT')
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
annotationProcessor 'org.projectlombok:lombok:1.18.20'
compileOnly 'org.projectlombok:lombok:1.18.20'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.2'
testCompileOnly 'org.projectlombok:lombok:1.18.20'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.20'
}
jar {
manifest {
attributes 'Built-By': 'joutvhu (Giao Ho)'
attributes 'Build-Date': java.time.Instant.now().toString()
attributes 'Bundle-Name': 'Date Parser'
attributes 'Bundle-Vendor': project.group
attributes 'Bundle-SymbolicName': project.name
attributes 'Bundle-Version': project.version
}
into("META-INF/maven/${project.group}/${project.name}") {
from {
generatePomFileForMavenPublication
}
rename {
it.replace('pom-default.xml', 'pom.xml')
}
}
}
task fatJar(type: Jar) {
manifest.from jar.manifest
with jar
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives fatJar, sourcesJar, javadocJar
}
tasks.withType(Test) {
useJUnitPlatform {
includeEngines 'junit-jupiter'
}
filter {
includeTestsMatching 'com.joutvhu.date.parser.*'
}
}
task codeCoverageReport(type: JacocoReport, dependsOn: ['test']) {
executionData test
sourceSets sourceSets.main
reports {
xml.enabled true
xml.destination file("${buildDir}/reports/jacoco/report.xml")
html.enabled false
csv.enabled false
}
}
publishing {
publications {
maven(MavenPublication) {
groupId = group
artifactId = project.name
artifacts = [fatJar, sourcesJar, javadocJar]
version = version
pom {
name = project.name
description = 'Utility to parse String to Date according to a target class, and the pattern strings. And format Date to String based on a pattern string.'
url = 'https://github.com/joutvhu/date-parser'
licenses {
license {
name = 'MIT License'
url = 'https://github.com/joutvhu/date-parser/blob/master/LICENSE'
}
}
developers {
developer {
id = 'joutvhu'
name = 'Giao Ho'
email = '[email protected]'
}
}
scm {
connection = 'scm:git:[email protected]:joutvhu/date-parser.git'
developerConnection = 'scm:git:[email protected]:joutvhu/date-parser.git'
url = 'https://github.com/joutvhu/date-parser'
}
issueManagement {
system = 'Github Issue'
url = 'https://github.com/joutvhu/date-parser/issues'
}
organization {
name = 'Giao Ho'
url = 'https://github.com/joutvhu'
}
withXml {
def dependenciesNode = asNode().appendNode('dependencies')
configurations.implementation.allDependencies.each {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
}
}
}
}
}
repositories {
maven {
name = 'sonatype'
if (snapshotVersion) {
url = 'https://oss.sonatype.org/content/repositories/snapshots'
} else {
url = 'https://oss.sonatype.org/service/local/staging/deploy/maven2'
}
if (project.hasProperty('ossrhUsername') && project.hasProperty('ossrhPassword')) {
credentials {
username = project.ossrhUsername
password = project.ossrhPassword
}
}
}
maven {
name = 'github'
url = 'https://maven.pkg.github.com/joutvhu/date-parser'
if (project.hasProperty('githubUsername') && project.hasProperty('githubPassword')) {
credentials {
username = project.githubUsername
password = project.githubPassword
}
}
}
}
}
signing {
sign publishing.publications.maven
}
tasks.publishMavenPublicationToGithubRepository.configure {
onlyIf { !snapshotVersion }
}