HIRS/tools/tcg_rim_tool/build.gradle
2024-07-17 14:27:26 -04:00

168 lines
4.0 KiB
Groovy

plugins {
id "java"
id 'com.netflix.nebula.ospackage' version '11.4.0'
id 'com.intershop.gradle.jaxb' version '5.1.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.bouncycastle
implementation libs.glassfish.json
implementation libs.glassfish.jaxb.runtime
implementation libs.jcommander
implementation libs.jakarta.api
implementation libs.jakarta.xml
implementation libs.commons.codec
implementation libs.hibernate.core
implementation libs.jackson.databind
implementation 'org.apache.logging.log4j:log4j-core:2.19.0'
implementation libs.guava
compileOnly libs.lombok
implementation libs.lombok
annotationProcessor libs.lombok
testImplementation libs.testng
}
test {
testLogging.showStandardStreams true
}
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 {
exclude 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA', 'META-INF/*.MF'
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
manifest {
attributes "Main-Class": "hirs.swid.Main"
}
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
//jar name format: [archiveBaseName]-[archiveAppendix]-[archiveVersion]-[archiveClassifier].[archiveExtension]
archiveVersion = jarVersion
}
ospackage {
packageName = 'tcg-rim-tool'
os = LINUX
arch = NOARCH
version = "$packVersion"
release = '1'
user 'root'
fileMode = 0755
into ('/opt/rimtool/lib') {
from jar.outputs.files
from configurations.runtimeClasspath
from 'libs'
}
into ('/opt/rimtool/scripts') {
from ('scripts') {
exclude {
FileTreeElement details ->
details.file.name.endsWith('.bat')
}
}
}
into ('/opt/rimtool/docs') {
from('./') {
include {
FileTreeElement details ->
details.file.name.endsWith('.md')
}
}
}
into ('/opt/rimtool/data') {
from('src/test/resources/') {
}
}
link("/usr/local/bin/rim", "/opt/rimtool/scripts/rimtool.sh", 0x755)
// Post Install
postInstall "echo ${jarVersion} > /opt/rimtool/VERSION"
// Post Uninstall
postUninstall 'rm -rf /opt/rimtool'
}
buildRpm {
arch = X86_64
}
buildDeb {
arch = 'amd64'
}
task buildZip(type: Zip){
dependsOn jar
dependsOn jar
from(tasks.jar.archiveFile){
rename( filename ->
"${project.name}.jar")
into '/'
}
from('./build/resources/test/rim_fields.json'){
into '/'
}
from('../../.ci/tcg-rim-tool/configs/Base_Rim_Config.json'){
into '/'
}
from('../../.ci/tcg-rim-tool/eventlogs/TpmLog.bin'){
into '/'
}
from('../../.ci/tcg-rim-tool/keys/PC_OEM1_rim_signer_rsa_3k_sha384.key'){
into '/'
}
from('../../.ci/tcg-rim-tool/certs/PC_OEM1_rim_signer_rsa_3k_sha384.pem'){
into '/'
}
from('../../.ci/tcg-rim-tool/certs/PC_OEM1_Cert_Chain.pem'){
into '/'
}
archiveBaseName.set(project.name)
destinationDirectory.set(file("$buildDir/distributions"))
archiveFileName.set("${project.name}.zip")
}
buildZip.dependsOn jar
//build.dependsOn buildZip