I tried to search for existing questions but cant find any - feels like my question is quite simple but probably because it's quite specific I cant find the answers anywhere.
Anyways - I have 2 projects with Maven where the second depends on/needs some classes of the first. In certain cases I want the dependency to be on the JAR rather than a project dependency.
I solved this by creating an additional jar with maven-jar-plugin, where i included the needed classes. The jar was correctly created and was output in ${project.build.directory}. But the pom of project A is located in the same directory, that is/was a pain for me and for project B, cause of the dependencies used in project A. (is there a way to ignore the pom located in ${project.build.directory} ??? like:
<dependency>
<groupId>projectA.groupId</groupId>
<artifactId>A</artifactId>
<version>1x-SNAPSHOT</version>
<classifier>classes</classifier>
-> <ignorePom>true</ignorePom>
</dependency>
).
Now I´m using the system scope for the dependency and its working fine after adding the systempath. Although the scope system must be avoided everywhere it is possible. The Systempath is annoying me because this is not a good practice and because of the absolute path.
I know that i can install the created jar into the repository by using
mvn install:install -file
but i want to automate this process as good as possible, what would you suggest?
thanks in advance
The best solution is to use a repository manager and do a real release of the first jar and make a real dependency where you need.
Based on what you wrote i would recommend to create a separate maven project which contains the classes which will be used by several other modules make a release of it and simply use a dependency on that module. This will solve your problem completely.