Skip to content

Commit

Permalink
#4 moving projet structs
Browse files Browse the repository at this point in the history
  • Loading branch information
hlafaille committed Mar 14, 2024
1 parent c6ce041 commit 297b665
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 33 deletions.
4 changes: 1 addition & 3 deletions src/backend/context.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use std::{env, error, io, result};

use crate::backend::project::Config;

use super::project::get_config_from_fs;
use super::{project::get_config_from_fs, Config};

/// Represents the context of the currently loaded project.
pub struct ProjectContext {
Expand Down
33 changes: 3 additions & 30 deletions src/backend/project.rs
Original file line number Diff line number Diff line change
@@ -1,36 +1,9 @@
use crate::util::pathutil;

use super::{context::{get_project_context, AbsoltuePaths, ProjectContext}, lock};
use super::{context::{get_project_context, AbsoltuePaths, ProjectContext}, lock, Config, Project, Toolchain};
use serde::{Deserialize, Serialize};
use std::{collections::HashMap, error, fs, io, result};

/// Represents an `espresso.toml` file
#[derive(Deserialize, Serialize, Debug)]
pub struct Config {
pub project: Project,
pub toolchain: Toolchain,
// pub dependencies_maven: std::collections::HashMap<String, String>,
pub dependencies_fs: std::collections::HashMap<String, String>,
}

/// Represents information about the currently loaded Project
#[derive(Deserialize, Serialize, Debug)]
pub struct Project {
/// Name of the project (ex: `My Espresso Project`)
pub name: String,
/// Version of the project (ex: `1.0.0`)
pub version: String,
/// Java base package in dot notation (ex: `com.me.project`)
pub base_package: String,
}

/// Represents toolchain information
#[derive(Deserialize, Serialize, Debug)]
pub struct Toolchain {
/// Path to the JDK toolchain (ex: `${JAVA_HOME}`)
pub path: String,
}

/**
* Load the project at the current working directory
*/
Expand Down Expand Up @@ -111,10 +84,10 @@ fn initialize_config(name: String, base_package: String, ap: &AbsoltuePaths) ->
toolchain: Toolchain {
path: "${JAVA_HOME}".to_string(),
},
dependencies: HashMap::new(),
dependencies_fs: HashMap::new(),
};

write_config(&base_config, ap);
write_config(&base_config, ap)?;

Ok(())
}
Expand Down

0 comments on commit 297b665

Please sign in to comment.