-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
105 lines (94 loc) · 3.29 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*
Example project to build and run a Notes application on your local machine.
*/
plugins {
id 'java'
id 'application' // allows 'run' task.
id 'eclipse' // allows dependencies to be exported to .classpath
}
mainClassName = 'DominoAPILocalExample'
String notesInstallation = '/Applications/HCL Notes.app/Contents/MacOS/'
if (!notesInstallation) {
throw new GradleException("Missing configured path for Notes installation. Set notesInstallation in build.gradle.")
}
else if (!(new File(notesInstallation).exists())) {
throw new GradleException("Invalid configured path for Notes installation ($notesInstallation). Check notesInstallation in build.gradle.")
}
String notesJarExtDir = "$notesInstallation/jvm/lib/ext"
String notesJarPath = "$notesJarExtDir/Notes.jar"
String envPath = System.getenv('PATH')
if (!envPath) {
logger.warn "Missing PATH environment variable."
envPath = '' // default to empty string to avoid null errors later
}
// change envPath as needed
if (notesInstallation.toLowerCase().startsWith('/applications/')) { // treat as macOS
if (!(new File(notesJarPath).exists())) {
// alternative location for macOS: /Applications/HCL Notes.app/Contents/Resources/jvm/lib/ext/Notes.jar
logger.info "Notes.jar not found at $notesJarPath"
notesJarExtDir = "$notesInstallation/../Resources/jvm/lib/ext"
notesJarPath = "$notesJarExtDir/Notes.jar"
}
if (!(new File(notesJarPath).exists())) {
// alternative location for macOS and Notes 14: /Applications/HCL Notes.app/Contents/Resources/ndext/Notes.jar
logger.info "Notes.jar not found at $notesJarPath"
notesJarExtDir = "$notesInstallation/../Resources/ndext"
notesJarPath = "$notesJarExtDir/Notes.jar"
}
if (!(new File(notesJarPath).exists())) {
logger.info "Notes.jar not found at $notesJarPath"
throw new GradleException("ERROR: Could not find Notes.jar")
}
logger.info("Notes JAR path: $notesJarPath")
}
else { // treat as Windows
// update PATH
envPath = "$envPath;$notesInstallation"
println "Updated PATH: $envPath"
}
logger.debug "Environment"
System.env.each {
logger.debug "${it.key}:${it.value}"
}
repositories {
mavenCentral()
}
sourceSets {
main {
java {
srcDirs = ['src/main/java']
}
}
}
// Required for Java 8 Language server support
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
// Local JAR dependency
implementation files(notesJarPath)
}
/*
OPTIONAL: Configuration to let this build and run in Moonshine
Use "clean runApp" for the Gradle command
*/
task runApp(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
main = mainClassName // deprecated in later versions of Gradle - use mainClass
environment('DYLD_LIBRARY_PATH', notesInstallation)
environment('PATH', envPath)
// args 'appArg1'
}
/*
OPTIONAL: Configuration to let the application run as an executable jar. Commands:
gradle clean build
export DYLD_LIBRARY_PATH=%NotesInstallationPath%
export JAVA_HOME=%Path-to-JDK-8%
$JAVA_HOME/bin/java -jar build/libs/DominoAPILocalExample.jar
*/
jar {
manifest {
attributes 'Main-Class': "$mainClassName",
// URL-encode any spaces in the classpath, and make sure that it starts with a / on Windows
'Class-Path': "./* ${notesJarPath.replaceAll(' ', '%20').replaceAll('^\\w+:', '/$0')}"
}
}