HIRS/tools/tcg_eventlog_tool/build.gradle
2023-09-06 16:10:16 -04:00

132 lines
3.6 KiB
Groovy

import java.util.concurrent.TimeUnit
plugins {
id "java"
// id "findbugs"
// id "checkstyle"
id "com.netflix.nebula.ospackage" version "11.4.0"
}
// Get version from main project gradle
def packVersion = properties.get("packageVersion");
def jarVersion = properties.get("jarVersion");
//println "packageVersion is ${projVersion}"
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
repositories {
mavenCentral()
flatDir { dirs "lib" }
}
dependencies {
implementation project(':HIRS_Utils')
implementation libs.jcommander
implementation libs.commons.io
// implementation libs.checkstyle
// implementation libs.findbugs
// testCompile libs.testng
}
ext.configDir = new File(projectDir, 'config')
//ext.checkstyleConfigDir = "$configDir/checkstyle"
//ext.findbugsConfigDir = "$configDir/findbugs"
//checkstyle {
// toolVersion = '5.7'
// configFile = checkstyleConfigFile
// configProperties.put('basedir', checkstyleConfigDir)
// ignoreFailures = false
// showViolations = true
//}
//findbugs {
// toolVersion = '3.0.0'
// ignoreFailures = false
// effort = 'max'
//}
jar {
// Keep jar clean:
exclude 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA', 'META-INF/*.MF'
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
manifest {
attributes(
"Main-Class": "hirs.tcg_eventlog.Main",
'Class-Path':configurations.runtimeClasspath.files.collect { it.getName() }.join(' ')
)
}
//jar name format: [archiveBaseName]-[archiveAppendix]-[archiveVersion]-[archiveClassifier].[archiveExtension]
archiveVersion = jarVersion
}
// Produce packages
ospackage {
packageName = 'tcg-eventlog-tool'
os = LINUX
arch = NOARCH
version = "$packVersion"
release = '1'
user 'root'
fileMode = 0755
into ('/opt/hirs/eventlog/lib') {
from jar.outputs.files
from configurations.runtimeClasspath
}
into ('/opt/hirs/eventlog/scripts') {
from ('scripts') {
exclude {
FileTreeElement details ->
details.file.name.endsWith('.bat')
}
}
}
into ('/opt/hirs/eventlog/docs') {
from ('docs') {
exclude {
FileTreeElement details ->
details.file.name.endsWith('.odt')
}
}
from('./') {
include {
FileTreeElement details ->
details.file.name.endsWith('.md')
}
}
}
// Copy vendor-table into /tmp to avoid conflict with the ACA
into('/tmp/elt/default-properties') {
from ('../../HIRS_Utils/src/main/resources/vendor-table.json') {
fileMode 0664
addParentDirs = true
}
}
// place elt link in system path to enable command line access
link("/usr/local/bin/elt", "/opt/hirs/eventlog/scripts/eventlog.sh", 0x755)
// PostInstall
//postInstall "cp ../../HIRS_Utils/build/libs/* /opt/hirs/eventlog/lib/."
// Copy files from /opt/elt/default-properties/ to avoid conflicts with the ACA
postInstall "cp /tmp/elt/default-properties/* /opt/hirs/default-properties/."
postInstall "rm -rf /tmp/elt"
// Uninstall
// copy files to where package manager exspects them and remove project files
preUninstall "mkdir -p /tmp/elt/default-properties"
preUninstall "cp /opt/hirs/default-properties/vendor-table.json /tmp/elt/default-properties/."
postUninstall "rm -rf /tmp/elt"
buildRpm {
arch = X86_64
}
buildDeb {
arch = X86_64
}
}