I'm creating a library that'll eventually be a maven artifact that can be utilised by other projects. It uses RESTlet as a REST client.

While my artifact/library is platform neutral, the dependencies it has are not. RESTlet comes in multiple editions, there's one for GAE, one for JEE etc etc. Each has its own group id, org.restlet.gae for example:

<dependency>
   <groupId>org.restlet.gae</groupId>
   <artifactId>org.restlet</artifactId>
   <version>2.2-M6</version>
</dependency>

Ideally I'd like users of the library to be able to specify the exact RESTlet edition themselves. What's the best way to package my library up that will cause the least hastle for its users?

I've look all over but can't find a guide/best practice for this sort of thing.

有帮助吗?

解决方案

I have this same exact situation. I have a java lib which depends on Restlet and is used by my GAE server and my Android client.

For the lib, I mark the restlet dependency as optional, and specify "provided" scope, since it is provided by the containing app. I use the jse edition when building the lib, but I don't think it would matter which one you use; as the interface is the same.

<dependency>
  <groupId>org.restlet.jse</groupId>
  <artifactId>org.restlet</artifactId>
  <version>${restlet.version}</version>
  <optional>true</optional>
  <scope>provided</scope>
</dependency>

For my Android client, I specify the android edition:

<dependency>
  <groupId>org.restlet.android</groupId>
  <artifactId>org.restlet</artifactId>
  <version>${restlet.version}</version>
</dependency>

And for my GAE service, I specify the gae edition:

<dependency>
  <groupId>org.restlet.gae</groupId>
  <artifactId>org.restlet</artifactId>
  <version>${restlet.version}</version>
</dependency>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top