Here is a problem description:
There is an external jpa_repository_module
maven module, that has finalName
property defined:
<artifactId>jpa_repository_module</artifactId>
<packaging>jar</packaging>
<version>1.0.0-SNAPSHOT</version>
<name>jpa_repository_module</name>
...
<build>
<finalName>jpa_repository</finalName>
Which means, when it is built, it should look like: jpa_repository.jar In this module jpa entities are defined, so in a persistence.xml file in order to tell hibernate where entities can be found I use jar-file attribute: jpa_repository.jar
In a module, where integration tests are defined (jpa_web_module
), dependency on jpa_repository
looks:
<artifactId>jpa_web_module</artifactId>
<packaging>war</packaging>
<version>1.0.0-SNAPSHOT</version>
<name>jpa_web_module</name>
...
<dependency>
<groupId>com.savdev.jpa</groupId>
<artifactId>jpa_repository_module</artifactId>
</dependency>
A version of jpa_repository_module is taken from a parent module of jpa_web_module but it should not be an issue.
In an integration test a war file is created using shrinkwrap:
File[] files = Maven.resolver().loadPomFromFile(baseDir + File.separator + "pom.xml")
.importDependencies(ScopeType.COMPILE).resolve().withTransitivity().asFile();
Here is the most interesting part:
when I start integration tests, via maven command line, the file name consists of a module name and a version, instead of jpa_repository.jar. It looks:
/WEB-INF/lib/jpa_repository_module-1.0.0-SNAPSHOT.jar
when I start integration test via IDE(intellij idea), which should reuse maven configuration from pom.xml, and I expect to have the same result, the name of the file looks:
/WEB-INF/lib/jpa_repository_module-4640894041796562425.jar
The jar file, that contains a list of jpa entities does not look like it is configured in persistence.xml file. As a result I get: org.hibernate.MappingException : Unknown entity ...
exception. Also this name differs when I run test via command line/via IDE.
The question is, how I can control name of a jar file? How can I tell shrinkwrap to use finalName from jpa_repository_module module, but not a name of a module itself and its version?
As a solution, I can always rename files manually, and resolve the issue, but it is better to have control via configuration.
Aucun commentaire:
Enregistrer un commentaire