-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.gradle
More file actions
154 lines (133 loc) · 3.89 KB
/
build.gradle
File metadata and controls
154 lines (133 loc) · 3.89 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
plugins {
id 'java'
id 'jacoco'
id 'maven'
id 'maven-publish'
id 'com.gradle.build-scan' version '1.16'
id 'signing'
}
javadoc {
source = sourceSets.main.allJava
classpath = configurations.compile
}
jacoco {
toolVersion = "0.8.1"
reportsDir = file("$buildDir/customJacocoReportDir")
}
jacocoTestReport {
reports {
xml.enabled true
csv.enabled false
html.destination file("${buildDir}/jacocoHtml")
}
}
group 'com.timeafunction'
version '0.1-SNAPSHOT'
sourceCompatibility = 1.8
dependencies {
testCompileOnly(
'junit:junit:4.12'
)
testImplementation(
'org.junit.jupiter:junit-jupiter-api:5.1.0'
)
testRuntimeOnly(
'org.junit.jupiter:junit-jupiter-engine:5.1.0'
)
}
test {
useJUnitPlatform()
}
buildScan {
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
termsOfServiceAgree = 'yes'
publishAlways()
}
repositories {
mavenCentral()
}
publishing {
publications {
maven(MavenPublication) {
groupId = 'io.github.rahulbaphana'
artifactId = 'time-me'
version = '0.1-SNAPSHOT'
from components.java
}
}
}
task packageJavadoc(type: Jar, dependsOn: 'javadoc') {
from javadoc.destinationDir
classifier = 'javadoc'
}
task packageSources(type: Jar, dependsOn: 'classes') {
from sourceSets.main.allSource
classifier = 'sources'
}
artifacts {
archives packageJavadoc
archives packageSources
}
gradle.taskGraph.whenReady { taskGraph ->
if (taskGraph.allTasks.any { it instanceof Sign }) {
allprojects { ext."signing.keyId" = System.getenv('GPG_KEY_ID') }
allprojects { ext."signing.secretKeyRingFile" = System.getenv('GPG_KEY_LOCATION') }
allprojects { ext."signing.password" = System.getenv('GPG_PASSPHRASE') }
}
if (taskGraph.allTasks.any { it.name == 'build' || it.name == 'assemble' }) {
tasks.findAll { it.name == 'signArchives' || it.name == 'signDocsJar' || it.name == 'signTestJar' }.each { task ->
task.enabled = false
}
}
}
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment {
MavenDeployment deployment -> signing.signPom(deployment)
}
repository(url: maven2_url) {
authentication(userName: System.getenv('SONATYPE_USERNAME'), password: System.getenv('SONATYPE_PASSWORD'))
}
snapshotRepository(url: snapshot_url) {
authentication(userName: System.getenv('SONATYPE_USERNAME'), password: System.getenv('SONATYPE_PASSWORD'))
}
pom.project {
name project_name
packaging 'jar'
description project_description
url project_url
scm {
connection project_scm
developerConnection project_scm
url project_url
}
licenses {
license {
name project_license_name
url project_license_url
}
}
developers {
developer {
id project_developer
name project_developer
}
}
}
}
}
}
signing {
sign configurations.archives
}
build.dependsOn.remove(signArchives)
def uploadAndRelease(def username, def password, def repoDir) {
def proc = ["./uploadAndRelease.sh", username, password, repoDir].execute([], file("${rootDir.toString()}/gradle"))
proc.waitForProcessOutput(System.out, System.err)
}
task publishToNexusAndClose(dependsOn: 'publish'){
doLast {
uploadAndRelease(System.getenv('SONATYPE_USERNAME'), System.getenv('SONATYPE_PASSWORD'), "$rootDir/build/deploy")
}
}