How to reference a jar (containing only stubs) created with rmic:package maven goal from a POM?

人盡茶涼 提交于 2019-12-24 11:13:09

问题


I have a RMI app and the Stubs are generated with maven (rmic:rmic).

Then I use the rmic:package goal and get a nice little jar with only the stubs.

Now the bis question is: How can I reference this jar from the poms of other projects?

I cant give it an ArtifactId (or do I?!) and when I use the classifier, it downloads all dependecies of the original Project and NOT the jar with the stubs.

Please give me a hint, how I can actually use this jar in a nice behaving maven way :-)

thanks in advance, I vote for stuff and accept answers, so you'll get your points!


回答1:


You could indeed create a project/POM for your Stub Project.

You could bind the rmic:rmic goal to the generate-sources phase of a "Stub Project" POM; so that the compile phase of the build 1) creates the stub classes and then 2) compiles them.

This would then allow you to package the project (as a JAR, or whatever else) and deploy it to a Maven repository like any other project.

From there, you would simply reference the artifact as a <dependency> of the projects that depend on the stubs.




回答2:


Use a classifier of client.

Example:

<!-- This references the stub jar -->
<dependency>
  <groupId>com.example</groupId>
  <artifactId>the-dependency</artifactId>
  <version>1.0</version>
  <classifier>client</classifier>
</dependency>

<!-- This references the jar -->
<dependency>
  <groupId>com.example</groupId>
  <artifactId>the-dependency</artifactId>
  <version>1.0</version>
</dependency>


来源:https://stackoverflow.com/questions/3711270/how-to-reference-a-jar-containing-only-stubs-created-with-rmicpackage-maven-g

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!