v0.2 Refactor #9
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "core"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::fs::{File, OpenOptions};
|
||||
use std::io::Read;
|
||||
use std::path::PathBuf;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -28,6 +28,11 @@ impl Prey {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_entry_point<P: AsRef<Path>>(&mut self, entry_point: P) -> &mut Self {
|
||||
self.package.entry_point = entry_point.as_ref().to_path_buf();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn entry_point(&self) -> PathBuf {
|
||||
self.package.entry_point.clone()
|
||||
}
|
||||
|
||||
@@ -67,32 +67,10 @@ impl WorkspaceHandler {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/*
|
||||
/// Future `build` method.
|
||||
pub fn compile(&self, target: Option<PathBuf>) -> crate::Result<()> {
|
||||
let mut target = target.unwrap_or(self.nest.default_package());
|
||||
if !target.is_file() {
|
||||
// Use is_file to skip messing with pathing for src/
|
||||
// If target is not a file (explicit entry point), check if it's a known package
|
||||
// and use that's package's default entry point.
|
||||
target = target.join(
|
||||
self.packages
|
||||
.get(&target)
|
||||
.ok_or(Error::UnknownPackage)?
|
||||
.entry_point(),
|
||||
);
|
||||
}
|
||||
|
||||
//java::Compiler::new();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
*/
|
||||
|
||||
pub fn init(&mut self) -> crate::Result<&mut Self> {
|
||||
// ORDER MATTERS.
|
||||
let is_empty = read_dir(self.project_root.as_path()).is_ok_and(|tree| tree.count() == 0);
|
||||
|
||||
// ORDER MATTERS. THIS MUST COME FIRST.
|
||||
// Make config file.
|
||||
self.write_nest()?;
|
||||
|
||||
@@ -150,7 +128,7 @@ impl WorkspaceHandler {
|
||||
for target in targets.iter() {
|
||||
// Possibly come up with a source file handler for this?
|
||||
if let Ok(_) = compiler.clone().compile(target.path.as_path()) {
|
||||
// No, this does not run O(1)
|
||||
// TODO: Prevent unnecessary recompile
|
||||
//target.update()?;
|
||||
}
|
||||
}
|
||||
@@ -173,17 +151,13 @@ impl WorkspaceHandler {
|
||||
// Use is_file to skip messing with pathing for src/
|
||||
// If target is not a file (explicit entry point), check if it's a known package
|
||||
// and use that's package's default entry point.
|
||||
entry_point = entry_point.join(
|
||||
self.packages
|
||||
.get(&entry_point)
|
||||
.ok_or(Error::UnknownPackage)?
|
||||
.entry_point(),
|
||||
);
|
||||
entry_point = self
|
||||
.packages
|
||||
.get(&entry_point)
|
||||
.ok_or(Error::UnknownPackage)?
|
||||
.entry_point();
|
||||
}
|
||||
|
||||
// JRE pathing will be messed up without this.
|
||||
std::env::set_current_dir(Self::DIR_TARGET)?;
|
||||
|
||||
java::runtime::JVMBuilder::new(Self::DIR_TARGET)
|
||||
.assertions(assertions)
|
||||
.monitor(true)
|
||||
@@ -305,7 +279,9 @@ impl WorkspaceHandler {
|
||||
.create_new(true)
|
||||
.open(main.join(F_PREY_TOML))
|
||||
{
|
||||
f.write_all(toml::to_string_pretty(&Prey::new("main"))?.as_bytes())?;
|
||||
f.write_all(
|
||||
toml::to_string_pretty(&Prey::new("main").with_entry_point("Main"))?.as_bytes(),
|
||||
)?;
|
||||
}
|
||||
|
||||
// Make src/main/Main.java
|
||||
@@ -323,7 +299,9 @@ impl WorkspaceHandler {
|
||||
.create_new(true)
|
||||
.open(test.join(F_PREY_TOML))
|
||||
{
|
||||
f.write_all(toml::to_string_pretty(&Prey::new("test"))?.as_bytes())?;
|
||||
f.write_all(
|
||||
toml::to_string_pretty(&Prey::new("test").with_entry_point("MainTest"))?.as_bytes(),
|
||||
)?;
|
||||
}
|
||||
|
||||
// Make src/test/MainTest.java
|
||||
|
||||
Reference in New Issue
Block a user