Skip to content

Commit e3f799f

Browse files
authored
Merge pull request #18 from Nuix/refactor/redesign_engine_wrapper
Refactor/redesign engine wrapper
2 parents 610fdef + 3b1d438 commit e3f799f

75 files changed

Lines changed: 33182 additions & 3057 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
Ignored
2+
TestData
3+
TestOutput
24

35
IntelliJ/build/*
46
IntelliJ/engine/*

IntelliJ/build.gradle

Lines changed: 0 additions & 158 deletions
This file was deleted.

IntelliJ/build.gradle.kts

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
plugins {
2+
id("java")
3+
}
4+
5+
group = "com.nuix.enginebaseline"
6+
version = "9.10"
7+
8+
val sourceCompatibility = 11
9+
val targetCompatibility = 11
10+
11+
// Directory where the Nuix Engine is located - used as a root for other directories and passed
12+
// to runtimes as an environment variable.
13+
val nuixEngineDirectory: String = System.getenv("NUIX_ENGINE_DIR")
14+
if(nuixEngineDirectory.isNullOrEmpty()){
15+
throw InvalidUserDataException("Please populate the environment variable 'NUIX_ENGINE_DIR' with directory containing a Nuix Engine release")
16+
}
17+
val engineLibDir = "${nuixEngineDirectory}\\lib"
18+
// Nuix engine distributable dirs "bin" and "bin/x86" need to be on the PATH for engine
19+
// to work correctly so we will define the directories relative to this project then set below
20+
val engineBinDir = "${nuixEngineDirectory}\\bin"
21+
val engineBinX86Dir = "${nuixEngineDirectory}\\bin\\x86"
22+
23+
repositories {
24+
mavenCentral()
25+
}
26+
27+
dependencies {
28+
implementation("org.jetbrains:annotations:24.0.1")
29+
30+
compileOnly("org.projectlombok:lombok:1.18.26")
31+
annotationProcessor("org.projectlombok:lombok:1.18.26")
32+
33+
testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.2")
34+
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.2")
35+
36+
testImplementation("net.datafaker:datafaker:1.9.0")
37+
38+
implementation(fileTree(baseDir = engineLibDir) {
39+
include(
40+
"**/*log*.jar",
41+
"**/*joda*.jar",
42+
"**/*commons*.jar",
43+
"**/*guava*.jar",
44+
"**/*gson*.jar",
45+
// All Nuix API jars
46+
"**/nuix-*.jar"
47+
)
48+
})
49+
50+
testRuntimeOnly(fileTree(baseDir = engineLibDir) {
51+
include("*.jar")
52+
})
53+
}
54+
55+
java {
56+
toolchain {
57+
languageVersion.set(JavaLanguageVersion.of(11))
58+
}
59+
}
60+
61+
fun configTestEnv(test: Test) {
62+
// Define a temp directory that we should be able to write to. Used in several places to
63+
// provide a temp directory that engine can use!
64+
val nuixTempDirectory = findProperty("tempDir") ?: "${System.getenv("LOCALAPPDATA")}\\Temp\\Nuix"
65+
66+
// Necessary for newer versions of Nuix. Without this you will likely see
67+
// an error regarding loading the BouncyCastle crypto library at run-time
68+
test.jvmArgs(
69+
"--add-exports=java.base/jdk.internal.loader=ALL-UNNAMED",
70+
"-Xmx4G",
71+
"-Djava.io.tmpdir=\"${nuixTempDirectory}\"",
72+
)
73+
74+
// Going to pass location of test data so tests can obtain, extract and otherwise use
75+
// test data they may need. For example, if your test needs a Nuix case and there is a zip
76+
// file containing that case hosted online, your test might first see if the zip is already present
77+
// in the TestData directory, if not it can download it there and reuse it on future invocations.
78+
val testDataDirectory = "${projectDir}\\..\\TestData"
79+
80+
// Specify output directory that tests can use to store output for post test review
81+
val testOutputDirectory = "${projectDir}\\..\\TestOutput\\${System.currentTimeMillis()}"
82+
83+
test.setEnvironment(
84+
// Add our engine release's bin and bin/x86 to PATH
85+
Pair("PATH","${System.getenv("PATH")};${engineBinDir};${engineBinX86Dir}"),
86+
87+
// Define where tests can place re-usable test data
88+
Pair("TEST_DATA_DIRECTORY",testDataDirectory),
89+
90+
// Define where tests can write output produce for later review
91+
Pair("TEST_OUTPUT_DIRECTORY",testOutputDirectory),
92+
93+
// Forward ENV username and password
94+
Pair("NUIX_USERNAME",System.getenv("NUIX_USERNAME")),
95+
Pair("NUIX_PASSWORD",System.getenv("NUIX_PASSWORD")),
96+
97+
// Forward LOCALAPPDATA and APPDATA
98+
Pair("LOCALAPPDATA",System.getenv("LOCALAPPDATA")),
99+
Pair("APPDATA",System.getenv("APPDATA")),
100+
101+
// We need to make sure we set these so workers will properly resolve temp dir
102+
// (when using a worker based operation via EngineWrapper).
103+
Pair("TEMP",nuixTempDirectory),
104+
Pair("TMP",nuixTempDirectory),
105+
106+
Pair("NUIX_ENGINE_DIR", nuixEngineDirectory)
107+
)
108+
}
109+
110+
tasks.getByName<Test>("test") {
111+
useJUnitPlatform()
112+
configTestEnv(this)
113+
}
114+
115+
tasks.getByName<Javadoc>("javadoc"){
116+
setDestinationDir(File("${projectDir}/docs"))
117+
}

0 commit comments

Comments
 (0)