Compare commits

...

3 Commits

Author SHA1 Message Date
Olivia Brooks
ac364caede Add Getting Started guide; update Future Plans; add WSL warning. 2026-01-26 14:31:34 -05:00
Olivia Brooks
7291263903 Improve cli help and add warning. 2026-01-26 14:30:41 -05:00
Olivia Brooks
11737e67f8 Fix Java project structure. 2026-01-26 14:29:43 -05:00
6 changed files with 69 additions and 16 deletions

View File

@@ -22,9 +22,22 @@ worked out over time.
`raven` is only tested under linux. NT and Darwin support is **not** guaranteed.
WSL *may* affect the behaviour of raven. Quirks to be worked out.
## Getting Started
```bash
raven new demo
cd demo
raven run main.Main
```
## Future plans
- [ ] Fix `raven test`. Totally borked.
- [ ] Make `nest run` fall back to an entry point specified in Nest.toml, when
none provided.
- [ ] Fix project structure, eliminate inter-dependencies.
- [ ] Separate out `java.rs` into a dedicated wrapper library.
- [ ] Possibly add support for pulling remote packages via `nest add`. This
will be implemented should there arise a need.

View File

@@ -1,6 +1,12 @@
package main;
public class Main {
public static void main(String[] args) {
System.out.println("Hello, world!");
}
public static int add(int a, int b) {
return a + b;
}
}

12
assets/src/test/Main.java Normal file
View File

@@ -0,0 +1,12 @@
package test;
public class Main {
public static void main(String[] args) {
testAdd();
}
public static void testAdd() {
assert main.Main.add(2, 2) == 4;
}
}

View File

@@ -27,12 +27,12 @@ pub enum Command {
#[clap(flatten)]
assertions: Assertions,
},
/// Run the tests
/// !!! BORKED !!! Run the tests
Test {
#[clap(flatten)]
assertions: Assertions,
},
/// Remove the target directory
/// Remove the target directory and caching
Clean,
}

View File

@@ -10,7 +10,12 @@ pub fn expand_files<P: AsRef<Path>>(path: P) -> anyhow::Result<Vec<PathBuf>> {
Ok(std::fs::read_dir(path)?
.filter_map(|entry| {
let path = entry.ok()?.path();
if path.is_file() { Some(path) } else { None }
if path.is_dir() {
Some(expand_files(path).ok()?)
} else {
Some(vec![path])
}
})
.flatten()
.collect())
}

View File

@@ -18,8 +18,14 @@ use anyhow::Context;
use bytesize::ByteSize;
const DIR_TARGET: LazyLock<PathBuf> = LazyLock::new(|| PathBuf::from("target/"));
const DIR_TEST: LazyLock<PathBuf> = LazyLock::new(|| PathBuf::from("test/"));
const DIR_SRC: LazyLock<PathBuf> = LazyLock::new(|| PathBuf::from("src/"));
/// Cannot flatten this dir out of existence due to IDEs, Linters,
/// and probably also Java expecting it to exist.
const DIR_MAIN: LazyLock<PathBuf> = LazyLock::new(|| DIR_SRC.join("main/"));
/// Once again, I would love to pull this out of src/ and into parent, but
/// I can't do that due to IDEs, linters, and probably also Java expecting it to exist in src/.
const DIR_TEST: LazyLock<PathBuf> = LazyLock::new(|| DIR_SRC.join("test/"));
const F_NEST_TOML: LazyLock<PathBuf> = LazyLock::new(|| PathBuf::from("Nest.toml"));
const F_NEST_LOCK: LazyLock<PathBuf> = LazyLock::new(|| PathBuf::from("Nest.lock"));
@@ -77,8 +83,8 @@ fn init() -> anyhow::Result<()> {
.to_owned();
// Make src, target, tests
for dir in [DIR_SRC, DIR_TARGET, DIR_TEST] {
std::fs::create_dir(dir.clone())?;
for dir in [DIR_SRC, DIR_MAIN, DIR_TARGET, DIR_TEST] {
std::fs::create_dir_all(dir.clone())?;
}
// Make config file.
@@ -114,13 +120,24 @@ fn init() -> anyhow::Result<()> {
)?;
}
// Make Main.java
if let Result::Ok(mut f) = OpenOptions::new()
.write(true)
.create_new(is_empty)
.open(DIR_SRC.clone().join("Main").with_extension(JAVA_EXT_SOURCE))
{
f.write_all(include_bytes!("../assets/Main.java"))?;
// Make src/main/Main.java
if let Result::Ok(mut f) = OpenOptions::new().write(true).create_new(is_empty).open(
DIR_MAIN
.clone()
.join("Main")
.with_extension(JAVA_EXT_SOURCE),
) {
f.write_all(include_bytes!("../assets/src/main/Main.java"))?;
}
// Make src/test/Main.java
if let Result::Ok(mut f) = OpenOptions::new().write(true).create_new(is_empty).open(
DIR_TEST
.clone()
.join("Main")
.with_extension(JAVA_EXT_SOURCE),
) {
f.write_all(include_bytes!("../assets/src/test/Main.java"))?;
}
// git init .
@@ -133,7 +150,6 @@ fn init() -> anyhow::Result<()> {
.read(true)
.open(".gitignore")
{
dbg!();
let mut buf = String::new();
f.read_to_string(&mut buf)?;
@@ -141,7 +157,7 @@ fn init() -> anyhow::Result<()> {
DIR_TARGET.as_path().display().to_string(),
format!("*.{}", JAVA_EXT_CLASS),
] {
if dbg!(!buf.contains(&ignored)) {
if !buf.contains(&ignored) {
f.write(format!("{}\n", ignored).as_bytes())?;
}
}
@@ -192,7 +208,7 @@ fn build() -> anyhow::Result<()> {
for target in targets {
println!("Compiling {}", target.display());
if javac.clone().compile(target.as_path()).is_ok()
if javac.clone().compile(dbg!(target.as_path())).is_ok()
&& let Result::Ok(class) = Class::try_from(target.clone())
{
nest_lock.0.insert(target, class);
@@ -212,6 +228,7 @@ fn run<P: AsRef<Path>>(
entry_point: P,
assertions: bool,
) -> anyhow::Result<(Option<String>, Option<String>)> {
// JRE pathing will be messed up without this.
crate::env::set_cwd(DIR_TARGET.as_path())?;
java::JVMBuilder::new()