Skip to content

Commit 759f63d

Browse files
authored
Merge pull request #22 from Nuix/convert-to-intellij-idea
Convert to IntelliJ IDEA
2 parents a7d208c + e3f6b06 commit 759f63d

File tree

381 files changed

+27367
-47371
lines changed

Some content is hidden

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

381 files changed

+27367
-47371
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ Ignored
1212
.classpath
1313
.project
1414

15+
TestData
16+
TestOutput
17+
1518
# =============
1619
# Maven entries
1720
# =============

Java/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

Java/SuperUtilities/.gitignore

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
.gradle
2+
build/
3+
!gradle/wrapper/gradle-wrapper.jar
4+
!**/src/main/**/build/
5+
!**/src/test/**/build/
6+
7+
### IntelliJ IDEA ###
8+
.idea/modules.xml
9+
.idea/jarRepositories.xml
10+
.idea/compiler.xml
11+
.idea/libraries/
12+
*.iws
13+
*.iml
14+
*.ipr
15+
out/
16+
!**/src/main/**/out/
17+
!**/src/test/**/out/
18+
19+
### Eclipse ###
20+
.apt_generated
21+
.classpath
22+
.factorypath
23+
.project
24+
.settings
25+
.springBeans
26+
.sts4-cache
27+
bin/
28+
!**/src/main/**/bin/
29+
!**/src/test/**/bin/
30+
31+
### NetBeans ###
32+
/nbproject/private/
33+
/nbbuild/
34+
/dist/
35+
/nbdist/
36+
/.nb-gradle/
37+
38+
### VS Code ###
39+
.vscode/
40+
41+
### Mac OS ###
42+
.DS_Store

Java/SuperUtilities/.idea/.gitignore

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Java/SuperUtilities/.idea/encodings.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Java/SuperUtilities/.idea/gradle.xml

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Java/SuperUtilities/.idea/misc.xml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Java/SuperUtilities/.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Java/SuperUtilities/build.gradle.kts

Lines changed: 277 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,277 @@
1+
import java.nio.file.Paths
2+
import kotlin.io.path.pathString
3+
4+
/*
5+
External Configuration Properties
6+
=================================
7+
Below values can be overridden when invoking gradle build using property arguments, for example:
8+
9+
./gradlew build -Pversion=2.0
10+
11+
group => The group ID
12+
version => The version
13+
nuixEngineDir => Overrides value to engine release otherwise pulled from ENV var NUIX_ENGINE_DIR
14+
tempDir => Used to override temp directory for testing which would otherwise default to dir in localappdata
15+
testDataDir => Directory tests can load test data they depend on from
16+
testOutputDirectory => Root directory where tests may write data while running. Each test run will create a timestamp subdirectory
17+
nuixUsername => Username used to authenticate with CLS (Cloud License Server).
18+
Otherwise, would be pulled from ENV var NUIX_USERNAME
19+
nuixPassword => Password used to authenticate with CLS (Cloud License Server).
20+
Otherwise, would be pulled from ENV var NUIX_PASSWORD
21+
gpr.user => GitHub username for retrieving engine wrapper package used in tests.
22+
Otherwise, would be pulled from ENV var GITHUB_USERNAME
23+
gpr.key => GitHub classic token for retrieving engine wrapper package used in tests, needs at least "read:packages" permission.
24+
Otherwise, would be pulled from ENV var GITHUB_TOKEN
25+
*/
26+
27+
plugins {
28+
id("java")
29+
}
30+
31+
// So we don't get "unmappable character for encoding windows-1252" errors on a Windows machine
32+
tasks.compileJava.get().options.encoding = "UTF-8"
33+
tasks.compileTestJava.get().options.encoding = "UTF-8"
34+
35+
group = findProperty("group") ?: "com.nuix.innovation"
36+
version = findProperty("version") ?: "1.23.0"
37+
38+
project.extra["nuixEngineDirectory"] = findProperty("nuixEngineDirectory") ?: System.getenv("NUIX_ENGINE_DIR")
39+
if (project.extra["nuixEngineDirectory"].toString().isBlank()) {
40+
throw InvalidUserDataException("Please populate the environment variable 'NUIX_ENGINE_DIR' with directory containing a Nuix Engine release")
41+
}
42+
System.out.println("Resolved 'nuixEngineDirectory': " + project.extra["nuixEngineDirectory"].toString())
43+
44+
// Determines where Nuix dependencies can be found and where JARs will be copied to for tasks:
45+
// - copyDependencyJarsToEngine
46+
// - copyJarToEngine
47+
// - copyJarsToEngine (test execution invokes this)
48+
project.extra["engineLibDir"] = Paths.get(project.extra["nuixEngineDirectory"].toString(), "lib").pathString
49+
50+
// Necessary to be on PATH when test is ran which makes use of Nuix engine
51+
project.extra["engineBinDir"] = Paths.get(project.extra["nuixEngineDirectory"].toString(), "bin").pathString
52+
project.extra["engineBinX86Dir"] = Paths.get(project.extra["nuixEngineDirectory"].toString(), "bin", "x86").pathString
53+
54+
// Determines destination for tasks:
55+
// - copyDependencyJarsToApp
56+
// - copyJarToApp
57+
// - copyJarsToApp
58+
project.extra["nuixAppLibDir"] = findProperty("nuixAppLibDir")
59+
60+
// Configures temp directory used in several places during test execution:
61+
// - System property 'java.io.tmpdir'
62+
// - ENV variable 'TEMP'
63+
// - ENV variable 'TMP'
64+
project.extra["nuixTempDirectory"] = findProperty("tempDir")
65+
?: Paths.get(System.getenv("LOCALAPPDATA"), "Temp", "Nuix").pathString
66+
67+
// Directory used to store data a test may rely on (like sample data)
68+
project.extra["testDataDirectory"] = findProperty("testDataDirectory")
69+
?: Paths.get("${projectDir}", "..", "..", "TestData").pathString
70+
71+
// Directory that tests may write data to, unique to each test invocation
72+
project.extra["testOutputDirectory"] = findProperty("testOutputDirectory")
73+
?: Paths.get("${projectDir}", "..", "..", "TestOutput", "${System.currentTimeMillis()}")
74+
75+
repositories {
76+
mavenCentral()
77+
78+
val github_username = project.findProperty("gpr.user") as String? ?: System.getenv("GITHUB_USERNAME")
79+
val github_token = project.findProperty("gpr.key") as String? ?: System.getenv("GITHUB_TOKEN")
80+
81+
maven {
82+
url = uri("https://maven.pkg.github.com/nuix/nuix-java-engine-baseline")
83+
credentials {
84+
username = github_username
85+
password = github_token
86+
}
87+
}
88+
}
89+
90+
// Dependencies referenced using this configuration will be copied as part these tasks:
91+
// - CopyDependencyJarsToApp
92+
// - CopyDependencyJarsToEngine
93+
// - copyJarsToApp
94+
// - copyJarsToEngine (Note this is used to get JARs in place before test run)
95+
val deployedDependency: Configuration by configurations.creating {
96+
isTransitive = true
97+
}
98+
99+
dependencies {
100+
implementation("org.jetbrains.kotlin:kotlin-stdlib:+")
101+
implementation("org.jetbrains:annotations:24.0.1")
102+
compileOnly("org.projectlombok:lombok:1.18.26")
103+
annotationProcessor("org.projectlombok:lombok:1.18.26")
104+
testCompileOnly("org.projectlombok:lombok:1.18.26")
105+
testAnnotationProcessor("org.projectlombok:lombok:1.18.26")
106+
testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.2")
107+
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.2")
108+
109+
// Wrapper class for running tests in engine, pulled from public facing GitHub repository
110+
testImplementation("com.nuix.innovation:enginewrapper:Nuix9.10-v1.1.4")
111+
112+
// Used to extract test data
113+
testImplementation("net.lingala.zip4j:zip4j:2.11.5")
114+
115+
// Dependencies from engine lib referenced during compile time
116+
117+
val compileDependencies = arrayOf(
118+
"*joda*.jar",
119+
"nuix-api*.jar",
120+
"nuix-util-*.jar",
121+
"nuix-data-*.jar",
122+
"nuix-scripting-*.jar",
123+
"aspose-cells-*.jar",
124+
"aspose-pdf-*.jar",
125+
"*slf4j*.jar",
126+
"*log4j*.jar",
127+
"*commons-io*.jar",
128+
"*commons-csv*.jar",
129+
"*commons-math*.jar",
130+
"*commons-lang*.jar",
131+
"*commons-text*.jar",
132+
"*commons-compress*.jar",
133+
"RoaringBitmap-*.jar",
134+
"sqlite*.jar",
135+
"guava*.jar",
136+
"gson*.jar",
137+
"jruby*.jar",
138+
"flying-saucer*.jar",
139+
"jaxb*.jar",
140+
"lucene*.jar",
141+
"jsoup*.jar",
142+
"itext*.jar",
143+
"sevenzip*.jar"
144+
)
145+
val lib = project.extra["engineLibDir"].toString()
146+
compileOnly(fileTree(baseDir = lib) { include(*compileDependencies) })
147+
testCompileOnly(fileTree(baseDir = lib) { include(*compileDependencies) })
148+
149+
// When tests run which make use of NuixEngine wrapper class, it will need to have the
150+
// Nuix Engine dependencies in the lib folder present on the class path
151+
testRuntimeOnly(fileTree(baseDir = project.extra["engineLibDir"].toString()) {
152+
include("*.jar")
153+
})
154+
}
155+
156+
java {
157+
toolchain {
158+
languageVersion.set(JavaLanguageVersion.of(11))
159+
}
160+
}
161+
162+
fun configureTestEnvironment(test: Test) {
163+
// Args passed to JVM running tests
164+
test.jvmArgs(
165+
"--add-exports=java.base/jdk.internal.loader=ALL-UNNAMED", // Engine 9.6(?) and later require this
166+
"-Xmx4G",
167+
"-Djava.io.tmpdir=\"${project.extra["nuixTempDirectory"]}\"",
168+
// "-verbose:class" // Can help troubleshoot weird dependency issues
169+
)
170+
171+
// Configure ENV vars for JVM tests run in
172+
test.setEnvironment(
173+
// Add our engine release's bin and bin/x86 to PATH env var of test JVM process
174+
Pair("PATH", "${System.getenv("PATH")};${project.extra["engineBinDir"]};${project.extra["engineBinX86Dir"]}"),
175+
176+
// Define where tests can place re-usable test data
177+
Pair("TEST_DATA_DIRECTORY", project.extra["testDataDirectory"]),
178+
179+
// Define where tests can write output produce for later review
180+
Pair("TEST_OUTPUT_DIRECTORY", project.extra["testOutputDirectory"]),
181+
182+
// Forward ENV username and password
183+
Pair("NUIX_USERNAME", System.getenv("NUIX_USERNAME")),
184+
Pair("NUIX_PASSWORD", System.getenv("NUIX_PASSWORD")),
185+
186+
// Forward LOCALAPPDATA and APPDATA
187+
Pair("LOCALAPPDATA", System.getenv("LOCALAPPDATA")),
188+
Pair("APPDATA", System.getenv("APPDATA")),
189+
Pair("PROGRAMDATA", System.getenv("PROGRAMDATA")),
190+
191+
// Important to have in some instances, otherwise some code may resolve a local
192+
// path in project tree rather than actual system drive
193+
Pair("SYSTEMDRIVE", System.getenv("SYSTEMDRIVE")),
194+
195+
// We need to make sure we set these so workers will properly resolve temp dir
196+
// (when using a worker based operation via EngineWrapper).
197+
Pair("TEMP", project.extra["nuixTempDirectory"]),
198+
Pair("TMP", project.extra["nuixTempDirectory"]),
199+
200+
Pair("NUIX_ENGINE_DIR", project.extra["nuixEngineDirectory"])
201+
)
202+
}
203+
204+
// Copies compiled JAR to engine lib directory
205+
tasks.register<Copy>("copyJarToEngine") {
206+
dependsOn(tasks.jar)
207+
// You will receive implicit dependency errors without this
208+
mustRunAfter(tasks.compileJava, tasks.compileTestJava)
209+
val jarName = "${rootProject.name}.jar"
210+
duplicatesStrategy = DuplicatesStrategy.INCLUDE
211+
from(tasks.jar)
212+
into(Paths.get(project.extra["engineLibDir"].toString()).toFile())
213+
rename(".*\\.jar", jarName)
214+
}
215+
216+
// Copies 'deployedDependency' JARs and their transitive JARs to engine lib directory
217+
tasks.register<Copy>("copyDependencyJarsToEngine") {
218+
// You will receive implicit dependency errors without this
219+
mustRunAfter(tasks.compileJava, tasks.compileTestJava)
220+
duplicatesStrategy = DuplicatesStrategy.INCLUDE
221+
from(configurations.findByName("deployedDependency"))
222+
into(Paths.get(project.extra["engineLibDir"].toString()).toFile())
223+
rename("(.*)\\.jar", "${rootProject.name}-Dependency-$1.jar")
224+
}
225+
226+
// Copies JAR and 'deployedDependency' JARs to engine lib directory
227+
// Invoked before tests are ran
228+
tasks.register("copyJarsToEngine") {
229+
println("Copying files to engine lib dir...")
230+
dependsOn("copyJarToEngine")
231+
dependsOn("copyDependencyJarsToEngine")
232+
}
233+
234+
// Copies compiled JAR to Nuix Workstation lib directory
235+
// as defined by project.extra["nuixAppLibDir"]
236+
tasks.register<Copy>("copyJarToApp") {
237+
dependsOn(tasks.jar)
238+
val jarName = "${rootProject.name}.jar"
239+
duplicatesStrategy = DuplicatesStrategy.INCLUDE
240+
from(tasks.jar)
241+
into(Paths.get(project.extra["nuixAppLibDir"].toString()).toFile())
242+
rename(".*\\.jar", jarName)
243+
}
244+
245+
// Copies 'deployedDependency' JARs and their transitive JARs to Nuix Workstation lib directory
246+
// as defined by project.extra["nuixAppLibDir"]
247+
tasks.register<Copy>("copyDependencyJarsToApp") {
248+
duplicatesStrategy = DuplicatesStrategy.INCLUDE
249+
from(configurations.findByName("deployedDependency"))
250+
into(Paths.get(project.extra["nuixAppLibDir"].toString()).toFile())
251+
rename("(.*)\\.jar", "${rootProject.name}-Dependency-$1.jar")
252+
}
253+
254+
// Copies JAR and 'deployedDependency' JARs to Nuix Workstation lib directory
255+
// as defined by project.extra["nuixAppLibDir"]
256+
tasks.register("copyJarsToApp") {
257+
println("Copying files to app lib dir...")
258+
dependsOn("copyinJarToApp")
259+
dependsOn("copyDependencyJarsToApp")
260+
}
261+
262+
// Before tests are ran we need to make sure a few things are done:
263+
// - JAR and 'deployedDependency' JARs have been copied to engine lib dir
264+
// - IDE executes our test using JUnit
265+
// - Environment configuration is performed which sets up ENV vars, properties, etc
266+
tasks.test {
267+
dependsOn(tasks.findByName("copyJarsToEngine"))
268+
mustRunAfter("copyDependencyJarsToEngine", "copyJarToEngine")
269+
useJUnitPlatform()
270+
configureTestEnvironment(this)
271+
}
272+
273+
// Customize where Javadoc output is written to
274+
tasks.getByName<Javadoc>("javadoc") {
275+
options.encoding = "UTF-8"
276+
setDestinationDir(Paths.get("$projectDir", "..", "..", "docs").toFile())
277+
}

Java/SuperUtilities/gradle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
nuixEngineDirectory=C:\\EngineRelease\\100.6
2+
nuixAppLibDir=C:\\Program Files\\Nuix\\Nuix 100.6\\lib
Binary file not shown.

0 commit comments

Comments
 (0)