Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 40 additions & 40 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions crates/bindings/tmc-langs-node/jest/maven-exercise/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>17</source>
<target>17</target>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class AppTest {
public void trol() {
App.main(null);
assertEquals("Hello Maven!\n", mio.getSysOut());
ReflectionUtils.newInstanceOfClass("App");
ReflectionUtils.newInstanceOfClass("fi.helsinki.cs.maventest.App");


System.out.println("Tests executed");
Expand Down
50 changes: 49 additions & 1 deletion crates/plugins/java/src/maven_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ impl LanguagePlugin for MavenPlugin {
let mut iter = archive.iter()?;

let project_dir = loop {
// try to find pom.xml
let next = iter.with_next(|file| {
let file_path = file.path()?;

Expand All @@ -143,8 +144,55 @@ impl LanguagePlugin for MavenPlugin {
}
}
Ok(Continue(()))
})?;
if let Some(Some(root)) = next.break_value() {
return Ok(root);
}

// accept any dir with src/main/*.java
let root = iter.with_next(|file| {
let file_path = file.path()?;

let components = file_path.iter();
let mut in_src = false;
let mut in_src_main = false;
for next in components {
if in_src_main {
if Path::new(next).extension() == Some(OsStr::new("java")) {
let root = file_path
.iter()
.take_while(|c| c != &OsStr::new("main"))
.collect();
return Ok(Break(Some(root)));
}
} else {
break;
}

if in_src {
if next == "main" {
in_src_main = true;
} else {
break;
}
} else {
break;
}

if next == "src" {
in_src = true;
} else {
break;
}
}
if file.is_file() && file_path.extension() == Some(OsStr::new("java")) {
if let Some(pom_parent) = file_path.parent() {
return Ok(Break(Some(pom_parent.to_path_buf())));
}
}
Ok(Continue(()))
});
match next? {
match root? {
Continue(_) => continue,
Break(project_dir) => break project_dir,
}
Expand Down
Loading
Loading