Skip to content

Commit f70bc3d

Browse files
committed
[+] Better external running instructions
1 parent 2422b03 commit f70bc3d

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,23 @@ Final Project for CSC207
1212

1313
### Run a specific class in an external terminal
1414

15-
`./gradlew classes testClasses && build/jdk19/Contents/Home/bin/java -cp "build/classes/java/main:build/classes/java/test" org.hydev.mcpm.<class>`
15+
This is very useful to test terminal operations since the Gradle running environment isn't a tty, and IntelliJ IDEA's built-in terminal barely supports Xterm escape sequences.
16+
17+
For this, I've set up a custom gradle task `printCp` that will print out the classpath needed to run the classes with dependencies. It will print in stderr instead of stdout in order for bash to easily separate out the classpath. You can obtain the classpath in a bash variable by:
18+
19+
`cp="$(./gradlew classes testClasses printCp 2>&1 > /dev/null)" && echo "$cp"`
20+
21+
(Unfortunately since Windows doesn't support Bash, you'll need to use a Bash-compatible environment on Windows, either cygwin / git bash or WSL)
22+
23+
Then, you can run your class with:
24+
25+
`java19 -cp "$cp" org.hydev.mcpm.<class>`
26+
27+
For example, you can test the progress bar with:
28+
29+
`java19 -cp "$cp" org.hydev.mcpm.client.interaction.ProgressBar`
30+
31+
If you don't have JDK 19 installed or if you don't know where it's installed, you can use our JDK downloader tool to download a local version of JDK 19 without installing on the system. (TODO: Add tutorial after merging PR #8)
1632

1733
## Brainstorm
1834

build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ if (hasProperty('buildScan')) {
7575
}
7676
}
7777

78+
task printCp() {
79+
System.err.println sourceSets.main.runtimeClasspath.asPath;
80+
}
81+
7882
test {
7983
useJUnitPlatform()
8084
testLogging.showStandardStreams = true

0 commit comments

Comments
 (0)