В тестах, когда я задаю полный путь к pom.xml, все работает нормально:
{code}
File[] files = Maven.resolver().loadPomFromFile("/full/system/path/pom.xml").importDependencies(ScopeType.TEST, ScopeType.PROVIDED).resolve().withTransitivity().asFile();
{code}
Во многих примерах используется только pom.xml, поэтому я попробовал:
{code}
File[] files = Maven.resolver().loadPomFromFile("pom.xml").importDependencies(ScopeType.TEST, ScopeType.PROVIDED).resolve().withTransitivity().asFile();
{code}
Но в этом случае я получаю исключение:
Path to the pom.xml file must be defined and accessible
Тот же результат, если я попытаюсь передать ""../pom.xml". Я должен включить все зависимости от pom.xml
в военный архив, который развернут во время тестов arquillian, есть ли обходной путь? В идеале я хотел бы повторно использовать pom.xml, который используется для сборки проекта Я не хочу иметь отдельный файл pom.xml в папке «src/test/resources».
EDIT: у меня есть основная идея @baba, но вместо того, чтобы копировать pom.xml, я установил свойство basedir
через фильтрацию ресурсов maven:
Я добавил файл tests.properties
в test/resources
, добавил свойство в файл:
basedir=${basedir}
В pom.xml я использовал [http://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html]
<build>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
</testResource>
</testResources>
В тестах я загрузил все зависимости:
ResourceBundle resourceBundle = ResourceBundle.getBundle ("tests");
String baseDir = resourceBundle.getString("basedir");
File[] files = Maven.resolver().loadPomFromFile(baseDir + File.separator + "pom.xml").importDependencies(ScopeType.TEST, ScopeType.PROVIDED).resolve().withTransitivity().asFile();