Skip to content

Commit 0d6781a

Browse files
committed
Fix submission prep
1 parent 2df63b5 commit 0d6781a

File tree

25 files changed

+634
-95
lines changed

25 files changed

+634
-95
lines changed

Cargo.lock

Lines changed: 40 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/bindings/tmc-langs-node/jest/maven-exercise/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
<artifactId>maven-compiler-plugin</artifactId>
2222
<version>3.11.0</version>
2323
<configuration>
24-
<source>17</source>
25-
<target>17</target>
24+
<source>11</source>
25+
<target>11</target>
2626
</configuration>
2727
</plugin>
2828
<plugin>

crates/bindings/tmc-langs-node/jest/maven-exercise/src/test/java/fi/helsinki/cs/maventest/AppTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class AppTest {
1616
public void trol() {
1717
App.main(null);
1818
assertEquals("Hello Maven!\n", mio.getSysOut());
19-
ReflectionUtils.newInstanceOfClass("App");
19+
ReflectionUtils.newInstanceOfClass("fi.helsinki.cs.maventest.App");
2020

2121

2222
System.out.println("Tests executed");

crates/plugins/java/src/maven_plugin.rs

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ impl LanguagePlugin for MavenPlugin {
134134
let mut iter = archive.iter()?;
135135

136136
let project_dir = loop {
137+
// try to find pom.xml
137138
let next = iter.with_next(|file| {
138139
let file_path = file.path()?;
139140

@@ -143,8 +144,55 @@ impl LanguagePlugin for MavenPlugin {
143144
}
144145
}
145146
Ok(Continue(()))
147+
})?;
148+
if let Some(Some(root)) = next.break_value() {
149+
return Ok(root);
150+
}
151+
152+
// accept any dir with src/main/*.java
153+
let root = iter.with_next(|file| {
154+
let file_path = file.path()?;
155+
156+
let mut components = file_path.iter();
157+
let mut in_src = false;
158+
let mut in_src_main = false;
159+
while let Some(next) = components.next() {
160+
if in_src_main {
161+
if Path::new(next).extension() == Some(OsStr::new("java")) {
162+
let root = file_path
163+
.iter()
164+
.take_while(|c| c != &OsStr::new("main"))
165+
.collect();
166+
return Ok(Break(Some(root)));
167+
}
168+
} else {
169+
break;
170+
}
171+
172+
if in_src {
173+
if next == "main" {
174+
in_src_main = true;
175+
} else {
176+
break;
177+
}
178+
} else {
179+
break;
180+
}
181+
182+
if next == "src" {
183+
in_src = true;
184+
} else {
185+
break;
186+
}
187+
}
188+
if file.is_file() && file_path.extension() == Some(OsStr::new("java")) {
189+
if let Some(pom_parent) = file_path.parent() {
190+
return Ok(Break(Some(pom_parent.to_path_buf())));
191+
}
192+
}
193+
Ok(Continue(()))
146194
});
147-
match next? {
195+
match root? {
148196
Continue(_) => continue,
149197
Break(project_dir) => break project_dir,
150198
}

0 commit comments

Comments
 (0)