В тестах, когда я установил полный путь к pom.xml, все работает отлично:Maven распознаватель из pom.xml, Shrinkwrap
{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»Я должен включать в себя все dependencie. s от pom.xml
в военный архив, который развернут во время аркиллианских тестов, есть ли обходной путь? В идеале я хотел бы повторно использовать 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();
Вы работаете в Linux? – AndrewSmiley
@AndrewSmiley, да, я. – Alexandr
@ Александр это еще лучше. –