249 lines
9.3 KiB
Groovy
249 lines
9.3 KiB
Groovy
plugins {
|
|
id("com.netflix.nebula.rpm") version "11.11.2"
|
|
id("maven-publish")
|
|
}
|
|
|
|
import org.redline_rpm.header.Flags
|
|
|
|
allprojects {
|
|
version = '2.0.1'
|
|
group = 'ch.psi'
|
|
ext.release = '1'
|
|
ext.jar_suffix = 'fat'
|
|
ext.ex_options= ''
|
|
ext.deploy_type= 'java'
|
|
ext.readonly = true
|
|
ext.plugin = ''
|
|
ext.rpm_requires = []
|
|
//Not forcing workbench to same version, as it can break other apps.
|
|
//If specific minimal version is needed then must be specified in project.
|
|
ext.workbench_version= '2.0.1'
|
|
|
|
repositories {
|
|
mavenLocal()
|
|
mavenCentral()
|
|
maven { url "https://maven.scijava.org/" }
|
|
//maven { url 'https://www.jitpack.io' }
|
|
maven {
|
|
credentials {
|
|
username = githubUser
|
|
password = githubPwd
|
|
}
|
|
url "https://maven.pkg.github.com/paulscherrerinstitute/jcae"
|
|
}
|
|
maven {
|
|
credentials {
|
|
username = githubUser
|
|
password = githubPwd
|
|
}
|
|
url = "https://maven.pkg.github.com/paulscherrerinstitute/bsread_java"
|
|
}
|
|
maven { url "https://maven.scijava.org/content/repositories/adac/" }
|
|
//maven { url "https://artifacts.psi.ch/artifactory/libs-snapshots-local/" }
|
|
maven { url "https://packages.jetbrains.team/maven/p/ij/intellij-dependencies/" }
|
|
}
|
|
|
|
}
|
|
|
|
subprojects {
|
|
plugins.apply('java')
|
|
plugins.apply('java-library')
|
|
plugins.apply('com.netflix.nebula.rpm')
|
|
plugins.apply('maven-publish')
|
|
|
|
ext.timestamp = new Date().format("yyMMddHHmm")
|
|
ext.run_jvargs = ["--add-opens", "java.base/jdk.internal.loader=ALL-UNNAMED", "--add-opens", "java.base/java.util=ALL-UNNAMED", "--add-exports", "java.desktop/sun.awt=ALL-UNNAMED"]
|
|
|
|
if (hasProperty('java_exec_jdk')) {
|
|
ext.java_exec_jdk= java_exec_jdk
|
|
if (java_exec_jdk!=null) System.out.println "Execution JDK:" + java_exec_jdk
|
|
} else {
|
|
ext.java_exec_jdk = null
|
|
}
|
|
|
|
if (!hasProperty('runArgs')) {
|
|
ext.arguments = ''
|
|
} else {
|
|
ext.arguments = runArgs.split (" ")
|
|
}
|
|
|
|
ext.createDefaultTasks = { Project project ->
|
|
['run', 'debug'].each { taskName ->
|
|
project.tasks.register(taskName, JavaExec) {
|
|
dependsOn 'classes'
|
|
systemProperty 'build.time', project.timestamp
|
|
mainClass = project.mainClass
|
|
classpath = project.sourceSets.main.runtimeClasspath
|
|
args project.hasProperty('arguments') ? project.arguments : []
|
|
ignoreExitValue = true
|
|
debug = (taskName == 'debug')
|
|
executable = project.java_exec_jdk
|
|
jvmArgs = project.run_jvargs
|
|
environment 'PSHELL_EX_OPTIONS', project.ex_options
|
|
}
|
|
}
|
|
|
|
def app_name = project.name
|
|
def app_version = project.version.toString()
|
|
def app_title = project.ext.title.toString()
|
|
def app_description = project.ext.desc.toString()
|
|
def app_release = project.ext.release.toString()
|
|
def jar_suffix = project.ext.jar_suffix.toString()
|
|
def ex_options = project.ext.ex_options
|
|
def deploy_type = project.ext.deploy_type
|
|
def readonly = project.ext.readonly
|
|
def package_name = project.name
|
|
def plugin = project.plugin
|
|
def app_path = '/opt/' + package_name + "/" + app_version
|
|
def jar_file_name = app_name + "-" + app_version + ".jar";
|
|
def jar_file_path = app_path + '/lib/' + jar_file_name;
|
|
def fat_jar_file_name = app_name + "-" + app_version + "-" + jar_suffix + ".jar";
|
|
def fat_jar_file_path = app_path + '/lib/' + fat_jar_file_name;
|
|
def sys_bin ='/usr/local/bin/'
|
|
def sys_lib ='/usr/local/lib/'
|
|
def bin_file_name = "${app_name}-${app_version}"
|
|
def plugin_file = plugin + ".java"
|
|
def editor = bin_file_name + "-editor"
|
|
def file_mode = readonly ? 0644: 0777
|
|
//def dir_mode = readonly ? 0755: 0777
|
|
def app_args_var = "APP_${app_name.replace('-', '_').toUpperCase()}_ARGS"
|
|
def proj_requires = project.rpm_requires
|
|
def workbench_version = project.workbench_version
|
|
|
|
project.tasks.register("rpm", Rpm) {
|
|
doFirst {
|
|
def rpmFile = archiveFile.get().asFile
|
|
if (rpmFile.exists()) {
|
|
//Workaround to nebula plugin bug: must first remove old RPMs otherwise the payload digest is corrupted.
|
|
rpmFile.delete()
|
|
}
|
|
}
|
|
//requires 'pshell-workbench'
|
|
requires("pshell-workbench", workbench_version, Flags.GREATER | Flags.EQUAL)
|
|
proj_requires.each { dep ->
|
|
requires dep
|
|
}
|
|
dependsOn 'jar'
|
|
|
|
release = app_release
|
|
version = app_version
|
|
arch 'noarch'
|
|
os LINUX
|
|
reproducibleFileOrder = true
|
|
|
|
title = app_title
|
|
description = app_description
|
|
summary = description
|
|
url = 'https://github.com/paulscherrerinstitute/jstriptool'
|
|
vendor = 'Paul Scherrer Institute'
|
|
license = 'GPL'
|
|
packageName = package_name
|
|
packageGroup = 'Applications'
|
|
packageDescription = 'This application is part of PShell scripting environment for experiments.'
|
|
|
|
user = 'root'
|
|
permissionGroup 'root'
|
|
addParentDirs true
|
|
|
|
directory(app_path, 0755)
|
|
directory(app_path + '/lib', 0755)
|
|
directory(app_path + '/bin', 0755)
|
|
|
|
into app_path
|
|
|
|
if (deploy_type=='java'){
|
|
from ('src/main/java') {
|
|
include plugin_file
|
|
into 'lib'
|
|
fileMode file_mode
|
|
}
|
|
} else if (deploy_type=='jar'){
|
|
from ('build/libs') {
|
|
include jar_file_name
|
|
into 'lib'
|
|
fileMode file_mode
|
|
}
|
|
} else if (deploy_type=='pkg'){
|
|
from ('src/main/pkg'){
|
|
into 'lib'
|
|
includeEmptyDirs = true
|
|
exclude '**/*.class'
|
|
fileMode file_mode
|
|
//createDirectoryEntry = true
|
|
//dirMode dir_mode
|
|
}
|
|
}
|
|
|
|
from('scripts') {
|
|
into 'bin'
|
|
//Add version to startup script name
|
|
rename { String fileName ->
|
|
fileName == "app_startup" ? bin_file_name : fileName
|
|
}
|
|
rename { String fileName ->
|
|
fileName == "app_editor" ? editor : fileName
|
|
}
|
|
expand([
|
|
"app_name": app_name,
|
|
"app_version": app_version,
|
|
"app_args_var": app_args_var,
|
|
"jar_file": jar_file_path,
|
|
"fat_jar_file": fat_jar_file_path,
|
|
"java_file": (deploy_type=='pkg') ? plugin_file : app_path + '/lib/' + plugin_file,
|
|
"pkg_folder": app_path + '/lib',
|
|
"ex_options" :ex_options
|
|
])
|
|
fileMode 0755
|
|
}
|
|
link(sys_bin + bin_file_name, app_path + '/bin/' + bin_file_name)
|
|
link(sys_bin + app_name, sys_bin + bin_file_name)
|
|
}
|
|
|
|
project.afterEvaluate {
|
|
project.publishing {
|
|
publications {
|
|
MyPublication(MavenPublication) {
|
|
from project.components.java
|
|
if (project.tasks.findByName('sourcesJar')) {
|
|
//artifact project.tasks.sourcesJar
|
|
}
|
|
if (project.tasks.findByName('javadocJar')) {
|
|
//artifact project.tasks.javadocJar
|
|
}
|
|
if (project.tasks.findByName('rpm')) {
|
|
artifact project.tasks.rpm
|
|
}
|
|
groupId = project.group
|
|
artifactId = project.name
|
|
version = project.version
|
|
}
|
|
}
|
|
|
|
repositories {
|
|
maven {
|
|
credentials {
|
|
username artifactoryUser
|
|
password artifactoryPwd
|
|
}
|
|
url = artifactoryUrlRel
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
def rpmsTask = tasks.register('rpms') {
|
|
description = 'Generates all RPMs for app subprojects'
|
|
group = 'rpm'
|
|
}
|
|
|
|
afterEvaluate {
|
|
tasks.named('rpms') {
|
|
subprojects.each { subproj ->
|
|
if (subproj.hasProperty('mainClass')) {
|
|
dependsOn("${subproj.path}:rpm")
|
|
}
|
|
}
|
|
}
|
|
} |