forked from terl/lazysodium-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
201 lines (164 loc) · 5.57 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
/*
* Copyright (c) Terl Tech Ltd • 14/06/19 17:54 • goterl.com
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v2.0. If a copy of the MPL was not distributed with this
* file, you can obtain one at http://mozilla.org/MPL/2.0/.
*/
plugins {
id 'java-library'
id 'application'
id 'signing'
id 'maven'
id 'maven-publish'
id "com.jfrog.bintray" version "1.8.4"
id 'osgi'
}
ext {
artifactId = "lazysodium-java"
groupId = "com.goterl.lazycode"
version = '4.3.4'
description = "Lazysodium (Java) makes it effortless for Java " +
"developers to get started with Libsodium's cryptography."
}
repositories {
jcenter()
}
group project.ext.groupId
version = project.ext.version
mainClassName = "com.goterl.lazycode.lazysodium.LazySodium"
sourceCompatibility = 1.8
targetCompatibility = 1.8
sourceSets {
main {
resources {
srcDirs "src/main/resources"
}
}
}
// Dependencies
dependencies {
implementation 'net.java.dev.jna:jna:5.5.0'
implementation 'co.libly:resource-loader:1.3.10'
implementation 'org.slf4j:slf4j-api:2.0.0-alpha1'
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.28.2'
}
// Tasks
signing {
// This will use the GPG Agent
// to sign the jar
useGpgCmd()
sign configurations.archives
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
task signPom(type: Sign) {
sign project.file("$buildDir/publications/mavenJava/pom-default.xml")
// The signing plugin does not seem to notice
// it when the publications folder with the
// signature has been deleted. So we always
// create a new signature
outputs.upToDateWhen { false }
}
artifacts {
archives sourcesJar, javadocJar
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
groupId project.ext.groupId
artifactId project.ext.artifactId
version project.ext.version
artifact sourcesJar
artifact javadocJar
project.tasks.withType(Sign) {
signatures.all {
def type = it.type
if (it.file.name.endsWith('.tar.gz.asc')) {
// Workaround in case a tar.gz file should published
type = 'tar.gz.asc'
} else if (it.type.equals('xml.asc')) {
// Set correct extension for signature of pom file
type = 'pom.asc'
}
artifact source: it.file, classifier: it.classifier ?: null, extension: type
}
}
pom.withXml {
def root = asNode()
root.appendNode('description', project.ext.description)
root.appendNode('name', project.ext.artifactId)
root.appendNode('url', 'https://github.com/terl/lazysodium-java')
def scm = root.appendNode('scm')
scm.appendNode("connection", "scm:git:git://github.com/terl/lazysodium-java.git")
scm.appendNode("developerConnection", "scm:git:ssh://github.com/terl/lazysodium-java")
scm.appendNode("url", "http://github.com/terl/lazysodium-java")
def license = root.appendNode('licenses').appendNode('license')
license.appendNode('name', 'Mozilla Public License, Version 2.0')
license.appendNode('url', 'http://www.mozilla.org/MPL/2.0/index.txt')
license.appendNode('distribution', 'repo')
def developer = root.appendNode('developers').appendNode('developer')
developer.appendNode('name', 'Terl Tech Ltd')
developer.appendNode('email', '[email protected]')
}
}
}
}
bintray {
user = findProperty("bintray.user")
key = findProperty("bintray.apiKey")
publications = ['mavenJava']
publish = true
pkg {
repo = 'lazysodium-maven'
name = project.ext.artifactId
userOrg = 'terl'
desc = project.ext.description
licenses = ['MPL-2.0']
issueTrackerUrl = "https://github.com/terl/lazysodium-java/issues"
vcsUrl = 'https://github.com/terl/lazysodium-java.git'
version {
name = project.ext.version
released = new java.util.Date()
vcsTag = project.ext.version
}
}
}
model {
tasks.publishMavenJavaPublicationToMavenLocal {
dependsOn project.tasks.withType(Sign)
}
tasks.signPom {
dependsOn tasks.generatePomFileForMavenJavaPublication
}
}
tasks.withType(Test) {
// a collection to track failedTests
ext.failedTests = []
afterTest { descriptor, result ->
if (result.resultType == TestResult.ResultType.FAILURE) {
String failedTest = "${descriptor.className}::${descriptor.name}"
logger.debug("Adding " + failedTest + " to failedTests...")
failedTests << [failedTest]
}
}
afterSuite { suite, result ->
if (!suite.parent) { // will match the outermost suite
// logs each failed test
if (!failedTests.empty) {
logger.lifecycle("Failed tests:")
failedTests.each { failedTest ->
logger.lifecycle("${failedTest}")
}
}
}
}
}