-
Notifications
You must be signed in to change notification settings - Fork 17
/
build.gradle
246 lines (214 loc) · 7.2 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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
wrapper {
gradleVersion = '4.5.1'
}
import org.gradle.util.VersionNumber
allprojects {
repositories {
mavenCentral();
}
tasks.withType(Test) {
afterSuite { desc, result ->
if (desc.parent == null) {
logger.lifecycle("${result.successfulTestCount}/${result.testCount} tests passed")
}
}
}
// Version definitions of all of the libraries we're using. They're defined
// here to ensure that all projects are using the same versions of common
// dependencies:
ext.libs = [
bouncycastle: ['org.bouncycastle:bcpkix-jdk15on:1.67', // Bouncy Castle license
'org.bouncycastle:bcprov-ext-jdk15on:1.67'],
jackson: ['com.fasterxml.jackson.core:jackson-core:2.15.2', // Apache 2.0
'com.fasterxml.jackson.core:jackson-annotations:2.15.2',
'com.fasterxml.jackson.core:jackson-databind:2.15.2'],
jcommander: 'com.beust:jcommander:1.72', // Apache 2.0
junit: 'junit:junit:4.13.2', // EPL 1.0
powermock: ['org.powermock:powermock-module-junit4:1.6.5', // Apache 2.0
'org.powermock:powermock-api-mockito:1.6.5']
]
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
// The ospackage plugin has breaking differences based on gradle version
// paccor must support gradle 4.5.1 for the forseeable future
String ospackage_version = "4.9.3" // verified to work with gradle 4.5.1
if ((VersionNumber.parse(gradle.gradleVersion) >= VersionNumber.parse('5.1'))) {
ospackage_version = "8.4.1"
project.logger.lifecycle("Selecting ospackage $ospackage_version for your gradle version $gradle.gradleVersion.")
project.logger.lifecycle("Customize the ospackage_version variable in build.gradle if met with plugin errors.")
}
classpath "com.netflix.nebula:gradle-ospackage-plugin:$ospackage_version"
}
}
apply plugin: 'eclipse'
apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'nebula.ospackage'
apply plugin: 'maven'
apply plugin: 'signing'
ext.refsDir = new File(projectDir, 'refs')
sourceCompatibility = 1.8
dependencies {
implementation libs.bouncycastle
implementation libs.jackson
implementation libs.jcommander
testImplementation libs.junit
testImplementation libs.powermock
}
// Maven packaging and signing
group = 'io.github.nsacyber.paccor'
version = '1.1.4r11'
project.gradle.taskGraph.whenReady { graph ->
project.tasks.findAll().forEach { task ->
if (task.name.contains("signArchives") || task.name.contains("uploadArchives")) {
// If this is set to true, the signing and maven
// properties in gradle.properties must be set.
task.enabled = false
}
}
}
task javadocJar(type: Jar) {
classifier = 'javadoc'
from javadoc
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}
artifacts {
archives javadocJar, sourcesJar
}
signing {
sign configurations.archives
}
uploadArchives {
repositories {
mavenDeployer {
pom.project {
name 'paccor'
packaging 'jar'
// optionally artifactId can be defined here
description 'The Platform Attribute Certificate Creator can gather component details, create, sign, and validate the TCG-defined Platform Credential. #nsacyber'
url 'https://github.com/nsacyber/paccor'
scm {
connection 'scm:git:git://github.com:nsacyber/paccor.git'
developerConnection 'scm:git:git://github.com:nsacyber/paccor.git'
url 'https://github.com/nsacyber/paccor'
}
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
developers {
developer {
id 'iadgovuser29'
name 'iadgovuser29'
email '[email protected]'
organization 'NSA Cybersecurity Directorate'
organizationUrl 'https://github.com/nsacyber'
}
}
}
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: "https://${sonatypeDomain}/service/local/staging/deploy/maven2/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
snapshotRepository(url: "https://${sonatypeDomain}/content/repositories/snapshots/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
}
}
}
// Application packaging into a zip file
def createScript(project, mainClass, name) {
project.tasks.create(name: name, type: CreateStartScripts) {
outputDir = new File(project.buildDir, 'scripts')
mainClassName = mainClass
applicationName = name
classpath = project.tasks[JavaPlugin.JAR_TASK_NAME].outputs.files + project.configurations.runtimeClasspath
}
project.tasks[name].dependsOn(project.jar)
project.applicationDistribution.with {
into("bin") {
from(project.tasks[name])
fileMode = 0755
duplicatesStrategy = 'exclude' // IMPORTANT: eliminates duplicate files within the ZIP
}
}
}
// Suppress standard application plugin behavior in favor of easier to read program declarations below
startScripts.enabled = false
run.enabled = false
createScript(project, 'cli.DeviceObserverCli', 'observer')
createScript(project, 'cli.SigningCli', 'signer')
createScript(project, 'cli.ValidatorCli', 'validator')
// Include files into a ZIP
applicationDistribution.from("scripts/") {
into "scripts"
}
applicationDistribution.from("docs/") {
into "docs"
}
applicationDistribution.from("./") {
include {
FileTreeElement details ->
details.file.name.endsWith('.md')
}
into "./"
}
// Produce packages
ospackage {
packageName='paccor'
os=LINUX
version='1.1.4'
release='11'
into '/opt/paccor'
user 'root'
fileMode=0755
requires('dmidecode', '3.2', GREATER | EQUAL)
requires('ethtool')
requires('jq')
requires('lshw')
requires('nvme-cli')
requires('vim-common')
from(jar.outputs.files) {
into 'lib'
}
from('lib') {
into 'lib'
}
from(configurations.runtimeClasspath) {
into 'lib'
}
from('build/scripts') {
exclude {
FileTreeElement details ->
details.file.name.endsWith('.bat')
}
into 'bin'
}
from('scripts') {
into 'scripts'
}
from('docs') {
exclude {
FileTreeElement details ->
details.file.name.endsWith('.odt')
}
into 'docs'
}
from('./') {
include {
FileTreeElement details ->
details.file.name.endsWith('.md')
}
into './'
}
}