diff --git a/src/test/java/spoon/support/compiler/SpoonPomTest.java b/src/test/java/spoon/support/compiler/SpoonPomTest.java index 21bf4919910..78e54f1bc84 100644 --- a/src/test/java/spoon/support/compiler/SpoonPomTest.java +++ b/src/test/java/spoon/support/compiler/SpoonPomTest.java @@ -6,8 +6,12 @@ import spoon.support.StandardEnvironment; import java.io.IOException; +<<<<<<< HEAD import java.util.List; import java.util.regex.Pattern; +======= +import java.nio.file.Paths; +>>>>>>> 7c8b18599... Added test for getting maven source directory from ancestors import static org.junit.Assert.*; @@ -51,4 +55,20 @@ public void checkProfilesModules(String path, String[] expected, Pattern profile assertEquals(expected[i], modules.get(i).getName()); } } + + public void getSourceDirectory() throws IOException, XmlPullParserException { + checkSourceDirectory( + "src/test/resources/maven-launcher/hierarchy", + Paths.get("src/test/resources/maven-launcher/hierarchy/child/src").toAbsolutePath().toString() + ); + } + + public void checkSourceDirectory(String path, String expected) throws IOException, XmlPullParserException { + SpoonPom pomModel = new SpoonPom(path, null, MavenLauncher.SOURCE_TYPE.APP_SOURCE, new StandardEnvironment()); + + SpoonPom childModel = pomModel.getModules().get(0); + //contract: source directory is derived from parent pom.xml if not declared in the current + // (childModel) SpoonPom + assertEquals(expected, childModel.getSourceDirectories().get(0).getAbsolutePath(), expected); + } } \ No newline at end of file diff --git a/src/test/resources/maven-launcher/hierarchy/child/pom.xml b/src/test/resources/maven-launcher/hierarchy/child/pom.xml new file mode 100644 index 00000000000..7ca625d0612 --- /dev/null +++ b/src/test/resources/maven-launcher/hierarchy/child/pom.xml @@ -0,0 +1,16 @@ + + + 4.0.0 + + sample.text + parent + 0.0.1-SNAPSHOT + .. + + sample.text + child + 0.0.1-SNAPSHOT + + jar + \ No newline at end of file diff --git a/src/test/resources/maven-launcher/hierarchy/pom.xml b/src/test/resources/maven-launcher/hierarchy/pom.xml new file mode 100644 index 00000000000..26a04bff958 --- /dev/null +++ b/src/test/resources/maven-launcher/hierarchy/pom.xml @@ -0,0 +1,24 @@ + + + 4.0.0 + + sample.text + project + 2.2.2.RELEASE + + + sample.text + parent + 0.0.1-SNAPSHOT + + pom + + + child + + + + ${project.basedir}/src + + \ No newline at end of file