2023-03-14 20:45:33 +00:00
|
|
|
import java.util.concurrent.TimeUnit
|
|
|
|
plugins {
|
|
|
|
id "java"
|
2023-09-06 20:09:27 +00:00
|
|
|
id "com.netflix.nebula.ospackage" version "11.4.0"
|
2024-02-02 13:07:08 +00:00
|
|
|
id 'checkstyle'
|
2023-03-14 20:45:33 +00:00
|
|
|
}
|
2023-03-17 18:47:10 +00:00
|
|
|
// Get version from main project gradle
|
|
|
|
def packVersion = properties.get("packageVersion");
|
|
|
|
def jarVersion = properties.get("jarVersion");
|
2020-05-27 21:31:15 +00:00
|
|
|
|
2023-03-14 20:45:33 +00:00
|
|
|
java {
|
|
|
|
toolchain {
|
|
|
|
languageVersion = JavaLanguageVersion.of(17)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-27 21:31:15 +00:00
|
|
|
repositories {
|
2020-11-09 18:04:11 +00:00
|
|
|
mavenCentral()
|
2023-03-17 18:47:10 +00:00
|
|
|
flatDir { dirs "lib" }
|
2020-05-27 21:31:15 +00:00
|
|
|
}
|
|
|
|
|
2023-03-17 18:47:10 +00:00
|
|
|
dependencies {
|
2023-03-14 20:45:33 +00:00
|
|
|
implementation project(':HIRS_Utils')
|
|
|
|
implementation libs.jcommander
|
|
|
|
implementation libs.commons.io
|
2020-05-27 21:31:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ext.configDir = new File(projectDir, 'config')
|
|
|
|
|
2024-02-02 13:07:08 +00:00
|
|
|
checkstyle {
|
|
|
|
toolVersion = '10.12.7'
|
|
|
|
configFile file("${rootDir}/config/checkstyle/checkstyle.xml")
|
|
|
|
}
|
|
|
|
// https://github.com/checkstyle/checkstyle/issues/14211#issuecomment-1884129948
|
|
|
|
configurations.checkstyle {
|
|
|
|
resolutionStrategy.capabilitiesResolution.withCapability("com.google.collections:google-collections") {
|
|
|
|
select("com.google.guava:guava:0")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
checkstyleMain {
|
|
|
|
source ='src/main/java'
|
|
|
|
}
|
|
|
|
tasks.withType(Checkstyle) {
|
|
|
|
reports {
|
|
|
|
xml.required = false
|
|
|
|
html.required = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-27 21:31:15 +00:00
|
|
|
jar {
|
2023-03-17 18:47:10 +00:00
|
|
|
// Keep jar clean:
|
|
|
|
exclude 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA', 'META-INF/*.MF'
|
|
|
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
2020-11-09 18:04:11 +00:00
|
|
|
manifest {
|
2023-03-14 20:45:33 +00:00
|
|
|
attributes(
|
|
|
|
"Main-Class": "hirs.tcg_eventlog.Main",
|
2023-03-17 18:47:10 +00:00
|
|
|
'Class-Path':configurations.runtimeClasspath.files.collect { it.getName() }.join(' ')
|
2023-03-14 20:45:33 +00:00
|
|
|
)
|
2023-03-17 18:47:10 +00:00
|
|
|
}
|
2024-04-25 17:43:26 +00:00
|
|
|
from {
|
|
|
|
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
|
|
|
|
}
|
2023-03-17 18:47:10 +00:00
|
|
|
//jar name format: [archiveBaseName]-[archiveAppendix]-[archiveVersion]-[archiveClassifier].[archiveExtension]
|
|
|
|
archiveVersion = jarVersion
|
2020-05-29 21:20:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Produce packages
|
|
|
|
ospackage {
|
2023-03-14 20:45:33 +00:00
|
|
|
packageName = 'tcg-eventlog-tool'
|
2020-11-09 18:04:11 +00:00
|
|
|
os = LINUX
|
2023-03-14 20:45:33 +00:00
|
|
|
arch = NOARCH
|
|
|
|
version = "$packVersion"
|
|
|
|
release = '1'
|
2020-05-29 21:20:06 +00:00
|
|
|
|
|
|
|
user 'root'
|
2020-11-09 18:04:11 +00:00
|
|
|
fileMode = 0755
|
2020-05-29 21:20:06 +00:00
|
|
|
|
2024-01-16 23:28:40 +00:00
|
|
|
into ('/opt/eltool/lib') {
|
2023-03-14 20:45:33 +00:00
|
|
|
from jar.outputs.files
|
2023-03-17 18:47:10 +00:00
|
|
|
from configurations.runtimeClasspath
|
2020-05-29 21:20:06 +00:00
|
|
|
}
|
2024-01-16 23:28:40 +00:00
|
|
|
into ('/opt/eltool/scripts') {
|
2023-03-14 20:45:33 +00:00
|
|
|
from ('scripts') {
|
2020-05-29 21:20:06 +00:00
|
|
|
exclude {
|
2023-03-14 20:45:33 +00:00
|
|
|
FileTreeElement details ->
|
|
|
|
details.file.name.endsWith('.bat')
|
2020-05-29 21:20:06 +00:00
|
|
|
}
|
2023-03-14 20:45:33 +00:00
|
|
|
}
|
2020-05-29 21:20:06 +00:00
|
|
|
}
|
2024-01-16 23:28:40 +00:00
|
|
|
into ('/opt/eltool/docs') {
|
2023-03-14 20:45:33 +00:00
|
|
|
from ('docs') {
|
|
|
|
exclude {
|
|
|
|
FileTreeElement details ->
|
|
|
|
details.file.name.endsWith('.odt')
|
|
|
|
}
|
2020-05-29 21:20:06 +00:00
|
|
|
}
|
2023-03-17 18:47:10 +00:00
|
|
|
from('./') {
|
|
|
|
include {
|
|
|
|
FileTreeElement details ->
|
|
|
|
details.file.name.endsWith('.md')
|
|
|
|
}
|
|
|
|
}
|
2020-11-09 18:04:11 +00:00
|
|
|
}
|
2023-03-14 20:45:33 +00:00
|
|
|
// Copy vendor-table into /tmp to avoid conflict with the ACA
|
2024-01-16 23:28:40 +00:00
|
|
|
into('/opt/eltool/default-properties') {
|
2020-11-09 18:04:11 +00:00
|
|
|
from ('../../HIRS_Utils/src/main/resources/vendor-table.json') {
|
2023-03-14 20:45:33 +00:00
|
|
|
fileMode 0664
|
|
|
|
addParentDirs = true
|
2020-11-09 18:04:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-14 20:45:33 +00:00
|
|
|
// place elt link in system path to enable command line access
|
2024-01-16 23:28:40 +00:00
|
|
|
link("/usr/local/bin/elt", "/opt/eltool/scripts/eventlog.sh", 0x755)
|
2023-03-17 18:47:10 +00:00
|
|
|
|
2024-01-16 23:28:40 +00:00
|
|
|
// Post Install
|
|
|
|
postInstall "echo ${jarVersion} > /opt/eltool/VERSION"
|
|
|
|
// Post Uninstall
|
|
|
|
postUninstall 'rm -rf /opt/eltool'
|
2021-11-09 13:32:04 +00:00
|
|
|
|
2020-11-09 18:04:11 +00:00
|
|
|
buildRpm {
|
2022-05-03 19:57:54 +00:00
|
|
|
arch = X86_64
|
2020-11-09 18:04:11 +00:00
|
|
|
}
|
|
|
|
buildDeb {
|
2022-05-03 19:57:54 +00:00
|
|
|
arch = X86_64
|
2020-05-29 21:20:06 +00:00
|
|
|
}
|
2024-07-16 15:48:59 +00:00
|
|
|
|
2021-08-02 14:08:33 +00:00
|
|
|
}
|
2024-07-16 15:48:59 +00:00
|
|
|
|
2024-07-17 15:00:50 +00:00
|
|
|
|
|
|
|
task buildZip(type: Zip){
|
|
|
|
dependsOn jar
|
|
|
|
from(tasks.jar.archiveFile){
|
|
|
|
into '/'
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
archiveBaseName.set(project.name)
|
|
|
|
archiveExtension.set('zip')
|
|
|
|
destinationDirectory.set(file("$buildDir/distributions"))
|
|
|
|
}
|
|
|
|
|
|
|
|
buildZip.dependsOn jar
|
|
|
|
//build.dependsOn buildZip
|