[hab] Add Gradle Scaffolding support to `hab plan init`.
@@ -23,6 +23,7 @@ use hcore::package::PackageIdent;
use common::ui::{UI, Status};
const SCAFFOLDING_GO_IDENT: &'static str = "core/scaffolding-go";
+const SCAFFOLDING_GRADLE_IDENT: &'static str = "core/scaffolding-gradle";
const SCAFFOLDING_NODE_IDENT: &'static str = "core/scaffolding-node";
const SCAFFOLDING_RUBY_IDENT: &'static str = "core/scaffolding-ruby";
@@ -43,6 +44,16 @@ pub fn scaffold_check(ui: &mut UI, maybe_scaffold: Option<&str>) -> Result<Optio
ui.para("")?;
Ok(Some(ident))
}
+ SCAFFOLDING_GRADLE_IDENT |
+ "gradle" => {
+ let ident = PackageIdent::from_str(SCAFFOLDING_GRADLE_IDENT).unwrap();
+ ui.status(
+ Status::Using,
+ &format!("Gradle Scaffolding '{}'", ident),
+ )?;
+ ui.para("")?;
+ Ok(Some(ident))
+ }
SCAFFOLDING_NODE_IDENT |
"node" => {
let ident = PackageIdent::from_str(SCAFFOLDING_NODE_IDENT).unwrap();
@@ -97,6 +108,15 @@ fn autodiscover_scaffolding(ui: &mut UI) -> Result<Option<PackageIdent>> {
)?;
ui.para("")?;
Ok(Some(ident))
+ } else if is_project_gradle(&current_path) {
+ let ident = PackageIdent::from_str(SCAFFOLDING_GRADLE_IDENT).unwrap();
+ ui.begin("We've detected a Gradle codebase")?;
+ ui.status(
+ Status::Using,
+ &format!("Scaffolding package: '{}'", ident),
+ )?;
+ ui.para("")?;
+ Ok(Some(ident))
} else if is_project_node(&current_path) {
let ident = PackageIdent::from_str(SCAFFOLDING_NODE_IDENT).unwrap();
ui.begin("We've detected a Node.js codebase")?;
@@ -143,6 +163,18 @@ where
return false;
}
+fn is_project_gradle<T>(path: T) -> bool
+where
+ T: AsRef<Path>,
+{
+ if path.as_ref().join("build.gradle").is_file() ||
+ path.as_ref().join("settings.gradle").is_file()
+ {
+ return true;
+ }
+ return false;
+}
+
fn is_project_node<T>(path: T) -> bool
where
T: AsRef<Path>,
