HIRS/tools/tcg_eventlog_tool/build.gradle

146 lines
3.6 KiB
Groovy
Raw Normal View History

import java.util.concurrent.TimeUnit
plugins {
id "java"
id "com.netflix.nebula.ospackage" version "11.4.0"
id 'checkstyle'
}
// Get version from main project gradle
def packVersion = properties.get("packageVersion");
def jarVersion = properties.get("jarVersion");
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
repositories {
mavenCentral()
flatDir { dirs "lib" }
}
dependencies {
implementation project(':HIRS_Utils')
implementation libs.jcommander
implementation libs.commons.io
}
ext.configDir = new File(projectDir, 'config')
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
}
}
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(' ')
)
}
2024-04-25 17:43:26 +00:00
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
//jar name format: [archiveBaseName]-[archiveAppendix]-[archiveVersion]-[archiveClassifier].[archiveExtension]
archiveVersion = jarVersion
2020-05-29 21:20:06 +00:00
}
// Produce packages
ospackage {
packageName = 'tcg-eventlog-tool'
os = LINUX
arch = NOARCH
version = "$packVersion"
release = '1'
2020-05-29 21:20:06 +00:00
user 'root'
fileMode = 0755
2020-05-29 21:20:06 +00:00
2024-01-16 23:28:40 +00:00
into ('/opt/eltool/lib') {
from jar.outputs.files
from configurations.runtimeClasspath
2020-05-29 21:20:06 +00:00
}
2024-01-16 23:28:40 +00:00
into ('/opt/eltool/scripts') {
from ('scripts') {
2020-05-29 21:20:06 +00:00
exclude {
FileTreeElement details ->
details.file.name.endsWith('.bat')
2020-05-29 21:20:06 +00:00
}
}
2020-05-29 21:20:06 +00:00
}
2024-01-16 23:28:40 +00:00
into ('/opt/eltool/docs') {
from ('docs') {
exclude {
FileTreeElement details ->
details.file.name.endsWith('.odt')
}
2020-05-29 21:20:06 +00:00
}
from('./') {
include {
FileTreeElement details ->
details.file.name.endsWith('.md')
}
}
}
// Copy vendor-table into /tmp to avoid conflict with the ACA
2024-01-16 23:28:40 +00:00
into('/opt/eltool/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
2024-01-16 23:28:40 +00:00
link("/usr/local/bin/elt", "/opt/eltool/scripts/eventlog.sh", 0x755)
2024-01-16 23:28:40 +00:00
// Post Install
postInstall "echo ${jarVersion} > /opt/eltool/VERSION"
// Post Uninstall
postUninstall 'rm -rf /opt/eltool'
buildRpm {
arch = X86_64
requires('hwdata', '0.314', GREATER | EQUAL)
}
buildDeb {
arch = 'amd64'
requires('hwdata', '0.314', GREATER | EQUAL)
2020-05-29 21:20:06 +00:00
}
2024-07-16 15:48:59 +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){
2024-07-17 18:27:26 +00:00
rename( filename ->
"${project.name}.jar")
2024-07-17 15:00:50 +00:00
into '/'
}
archiveBaseName.set(project.name)
destinationDirectory.set(file("$buildDir/distributions"))
2024-07-17 18:27:26 +00:00
archiveFileName.set("${project.name}.zip")
2024-07-17 15:00:50 +00:00
}
buildZip.dependsOn jar
//build.dependsOn buildZip