-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle
157 lines (134 loc) · 4.45 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
/*
* This file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Java library project to get you started.
* For more details take a look at the 'Building Java & JVM projects' chapter in the Gradle
* User Manual available at https://docs.gradle.org/6.8.2/userguide/building_java_projects.html
*/
plugins {
// Apply the java-library plugin for API and implementation separation.
id 'java-library'
id 'jacoco'
id 'maven'
id 'signing'
id 'com.palantir.git-version' version '0.12.3'
}
group = "ninja.codingsolutions"
archivesBaseName = "solar-edge-api-client"
version gitVersion()
ext {
repoPath = System.getenv('GH_REPO_PATH')
ghToken = System.getenv('GH_TOKEN')
authorName = System.getenv('AUTHOR_NAME')
authorId = System.getenv('AUTHOR_ID')
authorEmail = System.getenv('AUTHOR_EMAIL')
projectName = System.getenv('PROJECT_NAME')
projectUrl = System.getenv('PROJECT_URL')
scmUrl = System.getenv('SCM_URL')
}
repositories {
// Use JCenter for resolving dependencies.
jcenter()
}
dependencies {
compileOnly 'org.projectlombok:lombok:1.18.18'
annotationProcessor 'org.projectlombok:lombok:1.18.16'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.12.2'
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.12.2'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.1'
testCompile "org.mockito:mockito-core:3.8.0"
testCompileOnly 'org.projectlombok:lombok:1.18.16'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.16'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.1'
testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.12.2'
testImplementation 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.12.2'
}
task javadocJar(type: Jar) {
classifier = 'javadoc'
from javadoc
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}
tasks.named('test') {
// Use junit platform for unit tests.
useJUnitPlatform()
}
test {
finalizedBy jacocoTestReport
}
jacocoTestReport {
dependsOn test
}
jacocoTestReport {
reports {
xml.enabled true
}
}
artifacts {
archives javadocJar, sourcesJar
}
signing {
def signingKey = findProperty("signingKey")
def signingPassword = findProperty("signingPassword")
if(signingKey == null || signingPassword == null)
return
project.logger.lifecycle('Signing Archives')
useInMemoryPgpKeys(signingKey, signingPassword)
sign configurations.archives
}
def getEnvironmentVarIfDef(varName, defValue) {
def varValue = System.getenv(varName)
if (varValue != null)
return varValue
else
return defValue
}
//allow building witout sonatype oss info
if (!project.hasProperty("ossrhUsername")) {
ext.ossrhUsername = getEnvironmentVarIfDef("OSSRH_USERNAME", "OSSRH-USERNAME-SHOULD-BE-DEFINED-EXTERNALLY")
}
//allow building without sonatype oss info
if (!project.hasProperty("ossrhPassword")) {
ext.ossrhPassword = getEnvironmentVarIfDef("OSSRH_PASSWORD", "OSSRH-PASSWORD-SHOULD-BE-DEFINED-EXTERNALLY")
}
//maven central
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
pom.project {
name projectName
packaging 'jar'
// optionally artifactId can be defined here
description 'A simple API that abstracts fetching data from the solar edge api and getting back a POJO'
url projectUrl
scm {
connection 'scm:git:' + scmUrl
developerConnection 'scm:git:' + scmUrl
url scmUrl
}
licenses {
license {
name 'The MIT License (MIT)'
url 'https://mit-license.org/'
}
}
developers {
developer {
id authorId
name authorName
email authorEmail
}
}
}
}
}
}