helma/build.gradle

295 lines
7.8 KiB
Groovy
Raw Normal View History

plugins {
id 'application'
id 'com.github.jk1.dependency-license-report' version '2.7'
}
import org.apache.tools.ant.filters.FixCrLfFilter
def jettyLogLevel = '-Dorg.eclipse.jetty.LEVEL=WARN'
// Suppress menu bar and default icon being shown in macos dock (Radar #5754483)
// See https://developer.apple.com/library/content/releasenotes/Java/JavaLeopardUpdate1RN/ResolvedIssues/ResolvedIssues.html
def suppressMacosDockIcon = '-Dapple.awt.UIElement=true'
// This list is used to determine which files need processing of line endings
def textFiles = ['**/*.hac', '**/.html', '**/*.js', '**/*.md', '**/*.properties', '**/*.skin', '**/*.txt', '**/*.xml']
2020-03-16 16:53:52 +01:00
allprojects {
apply plugin: 'java'
2020-03-16 16:53:52 +01:00
compileJava {
2021-03-06 19:01:35 +01:00
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
2020-03-16 16:53:52 +01:00
}
repositories {
mavenCentral()
}
2020-03-16 16:53:52 +01:00
}
version = new Date().format("yyyyMMdd")
2020-03-16 16:53:52 +01:00
tasks.build.dependsOn javadoc, 'jsdoc', 'generateLicenseReport'
tasks.compileJava.dependsOn 'processSource'
2020-03-16 16:53:52 +01:00
// Disable DocLint for now
// See <https://blog.joda.org/2014/02/turning-off-doclint-in-jdk-8-javadoc.html>
if (JavaVersion.current().isJava8Compatible()) {
allprojects {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
}
2020-03-16 16:53:52 +01:00
sourceSets {
main {
java {
// Sources in `src` will be available here after processing
2020-03-16 16:53:52 +01:00
srcDirs = ["$buildDir/src/main/java"]
}
}
}
2020-03-16 16:53:52 +01:00
configurations {
// Wrapping implementation because it does not allow access to its files
// (i.e. cannot be resolved)
library.extendsFrom implementation
}
dependencies {
implementation 'com.google.code.gson:gson:2.10.1'
implementation 'commons-codec:commons-codec:1.17.0'
implementation 'commons-fileupload:commons-fileupload:1.5'
implementation 'commons-logging:commons-logging:1.3.2'
implementation 'commons-net:commons-net:3.10.0'
implementation 'com.sun.mail:javax.mail:1.6.2'
2020-03-15 12:23:18 +01:00
implementation 'javax.servlet:javax.servlet-api:4.0.1'
implementation 'org.ccil.cowan.tagsoup:tagsoup:1.2.1'
implementation 'org.eclipse.jetty:jetty-servlet:9.4.54.v20240208'
implementation 'org.eclipse.jetty:jetty-xml:9.4.54.v20240208'
implementation 'org.mozilla:rhino:1.7.13'
2023-12-30 15:11:41 +01:00
implementation 'org.sejda.imageio:webp-imageio:0.1.6'
implementation 'xerces:xercesImpl:2.12.2'
2020-03-15 12:23:18 +01:00
implementation 'xmlrpc:xmlrpc:2.0.1'
}
2020-05-17 21:36:41 +02:00
def rhinoJar = configurations.library.files.find { jar ->
jar.name.startsWith('rhino')
}
startScripts {
applicationName = 'helma'
classpath = files('../launcher.jar')
2023-08-27 12:06:10 +02:00
mainClass = 'helma.main.launcher.Main'
defaultJvmOpts = [jettyLogLevel, suppressMacosDockIcon]
doLast {
// Work-around to make the classpath above work (launcher.jar is located outside of `lib` dir)
// See https://discuss.gradle.org/t/classpath-in-application-plugin-is-building-always-relative-to-app-home-lib-directory/2012
def unixScriptFile = file getUnixScript()
def windowsScriptFile = file getWindowsScript()
unixScriptFile.text = unixScriptFile.text.replace('$APP_HOME/lib', '$APP_HOME')
windowsScriptFile.text = windowsScriptFile.text.replace('%APP_HOME%\\lib', '%APP_HOME%')
}
}
distributions {
main {
contents {
from project(':launcher').jar
}
}
}
2023-08-27 12:06:10 +02:00
application {
applicationDistribution.from(projectDir) {
include 'modules/**'
include 'LICENSE.md'
include 'README.md'
include 'start.*'
}
2023-08-27 12:06:10 +02:00
applicationDistribution.from(javadoc.destinationDir) {
include '**'
into 'docs/javadoc'
}
2020-03-18 10:35:18 +01:00
2023-08-27 12:06:10 +02:00
applicationDistribution.from("${project.buildDir}/docs/jsdoc") {
include '**'
into 'docs/jsdoc'
}
2023-08-27 12:06:10 +02:00
applicationDistribution.from("${project.buildDir}/reports/dependency-license") {
include '**'
into 'licenses'
}
}
2020-03-16 16:53:52 +01:00
distTar {
2021-04-18 19:45:34 +02:00
dependsOn ':generateLicenseReport', ':javadoc', ':jsdoc'
2024-05-18 15:30:08 +02:00
2020-03-16 16:53:52 +01:00
compression = Compression.GZIP
filesMatching(textFiles) {
filter(FixCrLfFilter.class, eol: FixCrLfFilter.CrLf.newInstance("lf"))
}
}
distZip {
2021-04-18 19:45:34 +02:00
dependsOn ':generateLicenseReport', ':javadoc', ':jsdoc'
filesMatching(textFiles) {
filter(FixCrLfFilter.class, eol: FixCrLfFilter.CrLf.newInstance("crlf"))
}
2020-03-16 16:53:52 +01:00
}
installDist {
dependsOn build
if (!System.getenv('CI')) {
finalizedBy 'update'
}
2020-03-16 16:53:52 +01:00
}
run {
classpath = files('launcher.jar')
jvmArgs jettyLogLevel, suppressMacosDockIcon
2020-03-16 16:53:52 +01:00
}
task processSource(type: Sync) {
def date = new Date().format("MMMM dd, yyyy")
def gitOutput = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe'
standardOutput = gitOutput
errorOutput = new ByteArrayOutputStream()
ignoreExitValue = true
2020-03-16 16:53:52 +01:00
}
def description = date
def tag = gitOutput.toString().trim()
2020-03-16 16:53:52 +01:00
// TODO: Implement extended description in Java code
if (tag) description = "$tag; $description"
2020-03-16 16:53:52 +01:00
from 'src'
filter {
line -> line.replaceAll('__builddate__', date)
} into "${project.buildDir}/src"
2020-03-16 16:53:52 +01:00
}
task update {
def rsyncArgs = ['--archive', '--filter', '- backups']
2020-03-16 16:53:52 +01:00
def confirm = {
ant.input(message: 'Update this installation?', validargs: 'yes,no', addproperty: 'continue')
return ant.continue == 'yes'
2020-03-16 16:53:52 +01:00
}
onlyIf { confirm() }
doFirst {
def backupDir = 'backups/' + new Date().format('yyyyMMdd-HHmmss')
mkdir backupDir
exec {
// Create a backup with rsync instead of a CopyTask because the latter chokes on multi-byte characters
2020-03-16 16:53:52 +01:00
// See https://github.com/gradle/gradle/issues/789
executable 'rsync'
args rsyncArgs
args "$projectDir/", backupDir
}
print "Created backup of ${projectDir} in ${backupDir}"
2020-03-16 16:53:52 +01:00
}
doLast {
exec {
// Using rsync to selectively update the repo directory
2020-03-16 16:53:52 +01:00
executable 'rsync'
args '--delete'
2020-03-16 16:53:52 +01:00
args rsyncArgs
args '--filter', '+ bin/***'
args '--filter', '+ docs/***'
args '--filter', '+ extras/***'
args '--filter', '+ launcher.jar'
args '--filter', '+ lib'
args '--filter', '+ *.jar'
args '--filter', '- *'
2020-03-16 16:53:52 +01:00
args "${installDist.destinationDir}/", projectDir
}
}
}
2020-03-18 10:35:18 +01:00
task jsdoc(type: Exec) {
2020-05-17 21:36:41 +02:00
description 'Generates JSDoc API documentation for the included JavaScript modules.'
group 'Documentation'
2020-03-18 10:35:18 +01:00
def sources = ['modules/core', 'modules/helma', 'modules/jala/code']
def destination = "${project.buildDir}/docs/jsdoc"
sources.each { dir -> inputs.dir dir }
outputs.dir destination
executable 'npx'
args = ['jsdoc', '-d', "$destination"].plus(sources)
}
2020-05-17 21:36:41 +02:00
task xgettext(type: JavaExec) {
description 'Extracts translatable message strings from source code.'
group 'i18n'
classpath = files('launcher.jar')
2023-08-27 12:06:10 +02:00
mainClass = 'helma.main.launcher.Commandline'
2020-05-17 21:36:41 +02:00
// TODO: Decouple from Antville app
args = [
// Root.extractMessages is currently located in antville/code/Global/i18n.js
'antville.extractMessages',
'modules/jala/util/HopKit/scripts/MessageParser.js',
'code compat',
'apps/antville/i18n/antville.pot'
]
}
task po2js(type: JavaExec) {
description 'Converts translated message strings from PO format to JavaScript.'
group 'i18n'
classpath = files(rhinoJar)
2023-08-27 12:06:10 +02:00
mainClass = 'org.mozilla.javascript.tools.shell.Main'
2020-05-17 21:36:41 +02:00
// TODO: Decouple from Antville app
args = [
'modules/jala/util/HopKit/scripts/PoParser.js',
'apps/antville/i18n',
'apps/antville/i18n'
]
}
2020-03-18 10:35:49 +01:00
task rhinoShell(type: JavaExec) {
2020-05-17 21:36:41 +02:00
description 'Runs the interactive Rhino JavaScript shell.'
group 'Application'
classpath = files(rhinoJar)
2023-08-27 12:06:10 +02:00
mainClass = 'org.mozilla.javascript.tools.shell.Main'
standardInput = System.in
}
// Call this task with a function definition using the `-P` parameter, e.g.
// `./gradlew commandLine -Pfunction=manage.getAllApplications`
task commandLine(type: JavaExec) {
2020-05-17 21:36:41 +02:00
description 'Runs a function in a Helma application with `-Pfunction=app.functionName`.'
group 'Application'
classpath = files('launcher.jar')
2023-08-27 12:06:10 +02:00
mainClass = 'helma.main.launcher.Commandline'
args '-h', projectDir, function
}