added modules
This commit is contained in:
parent
e66e517366
commit
db3755d567
4 changed files with 21 additions and 11 deletions
|
|
@ -14,6 +14,7 @@ pub struct Pom {
|
||||||
pub dependencies: Vec<Dependency>,
|
pub dependencies: Vec<Dependency>,
|
||||||
pub dependency_management: Vec<Dependency>,
|
pub dependency_management: Vec<Dependency>,
|
||||||
pub properties: HashMap<String, String>,
|
pub properties: HashMap<String, String>,
|
||||||
|
pub modules: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Debug)]
|
#[derive(PartialEq, Debug)]
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ pub fn get_pom(xml: &str) -> Result<Pom, SaxError> {
|
||||||
let mut dependencies = vec![];
|
let mut dependencies = vec![];
|
||||||
let mut dependency_management = vec![];
|
let mut dependency_management = vec![];
|
||||||
let mut properties = HashMap::new(); // useless assignment...
|
let mut properties = HashMap::new(); // useless assignment...
|
||||||
|
let mut modules = vec![]; // not useless assignment...
|
||||||
|
|
||||||
for child in get_document(xml)?.root.children {
|
for child in get_document(xml)?.root.children {
|
||||||
match child.name.as_str() {
|
match child.name.as_str() {
|
||||||
|
|
@ -27,6 +28,7 @@ pub fn get_pom(xml: &str) -> Result<Pom, SaxError> {
|
||||||
"dependencies" => dependencies = get_dependencies(child),
|
"dependencies" => dependencies = get_dependencies(child),
|
||||||
"dependencyManagement" => dependency_management = get_dependency_mgmt(child),
|
"dependencyManagement" => dependency_management = get_dependency_mgmt(child),
|
||||||
"properties" => properties = get_properties(child),
|
"properties" => properties = get_properties(child),
|
||||||
|
"modules" => add_modules(child, &mut modules),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -41,9 +43,16 @@ pub fn get_pom(xml: &str) -> Result<Pom, SaxError> {
|
||||||
dependencies,
|
dependencies,
|
||||||
dependency_management,
|
dependency_management,
|
||||||
properties,
|
properties,
|
||||||
|
modules,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn add_modules(element: Node, modules: &mut Vec<String>){
|
||||||
|
for module in element.children {
|
||||||
|
modules.push(module.text.expect("Cannot read module name"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn get_properties(element: Node) -> HashMap<String, String> {
|
fn get_properties(element: Node) -> HashMap<String, String> {
|
||||||
let mut properties = HashMap::new();
|
let mut properties = HashMap::new();
|
||||||
for property in element.children {
|
for property in element.children {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
use undeepend::maven::pom_parser::get_pom;
|
use undeepend::maven::pom_parser::get_pom;
|
||||||
use undeepend::xml::dom_parser::get_document;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_pom_parser_is_correct() {
|
fn test_pom_parser_is_correct() {
|
||||||
|
|
@ -27,4 +26,8 @@ fn test_pom_parser_is_correct() {
|
||||||
assert_eq!("objenesis", objenesis.artifact_id);
|
assert_eq!("objenesis", objenesis.artifact_id);
|
||||||
assert_eq!(Some("1.0".to_string()), objenesis.version);
|
assert_eq!(Some("1.0".to_string()), objenesis.version);
|
||||||
assert!(pom.dependency_management.is_empty());
|
assert!(pom.dependency_management.is_empty());
|
||||||
|
|
||||||
|
assert_eq!(2, pom.modules.len());
|
||||||
|
assert_eq!("a", pom.modules[0]);
|
||||||
|
assert_eq!("b", pom.modules[1]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,15 +22,12 @@
|
||||||
<distribution>repo</distribution>
|
<distribution>repo</distribution>
|
||||||
</license>
|
</license>
|
||||||
</licenses>
|
</licenses>
|
||||||
<scm>
|
|
||||||
<url>http://code.google.com/p/mockito/source/browse/</url>
|
<modules>
|
||||||
</scm>
|
<module>a</module>
|
||||||
<developers>
|
<module>b</module>
|
||||||
<developer>
|
</modules>
|
||||||
<id>szczepiq</id>
|
|
||||||
<name>Szczepan Faber</name>
|
|
||||||
</developer>
|
|
||||||
</developers>
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.hamcrest</groupId>
|
<groupId>org.hamcrest</groupId>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue