0

I'll present a simplified version of our problem, but know that we have way more than 2 projects, and so on.

So, at our job, we have 2 projects -

  • A
  • B

where B depends on A through ivy.
Recently we added configurations to the mix, mainly default and test.
The problem we ran into is that in A we have test utilities, which B needs in order to run it's own tests, so we need B to get these utilities from A.
We've thought of 2 ways to solve this:

  • make the test configuration public
  • create a new conf - test-utils - that will be public, and A will publish it's own tests under that configuration

The problem is that both solutions seem somewhat forced, and I wanted to get an idea how people do this world-wide.

Any ideas?

orirab
  • 2,915
  • 1
  • 24
  • 48
  • I would suggest you create a 3rd project called "test utils" and get it to publish it's artifact into your repository. That way the same sort of tests can be run in Project A and B, pulling dependencies independently and increasing decoupling. – Mark O'Connor Jan 24 '16 at 15:12
  • The problem is that we have many more such pairs of projects, and I don't want to create so many new projects, and refactor the relevant code – orirab Jan 24 '16 at 16:02

1 Answers1

0

Note: This answer assumes you're using a Maven repository manager. (Something like Nexus or Artifactory).

I suggest that you upload an additional "test-utils" artifact when publishing Project A. This means the primary Maven artifact would be:

<dependency>
  <groupId>com.mycompany</groupId>
  <artifactId>ProjectA</artifactId>
  <version>1.0.1</version>
</dependency>

and the second artifact is:

<dependency>
  <groupId>com.mycompany</groupId>
  <artifactId>ProjectA</artifactId>
  <version>1.0.1</version>
  <classifier>test-utils</classifier>
</dependency>

For more details on how ivy publishes and retrieves additional artifacts from a Maven repository I would suggest reading the following:

Community
  • 1
  • 1
Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185
  • See my comment to your comment – orirab Jan 24 '16 at 16:42
  • @orirab Yes, and I provided an answer that did not involve creating a new project. I did assume that you're using a Maven repository (based on the law of averages). Maven has only limited support for configurations.... Now... if you're using an ivy repository then using a second "test" configuration suddenly becomes an option. – Mark O'Connor Jan 24 '16 at 17:58
  • I just re-read your answer, and it seems I didn't understand it before. But if I get you now, you're suggesting I follow the second course I suggested in the question, right? To clarify, the basic problem we have is that the tests and the utils are mixed together, and I don't want to separate them right now. – orirab Jan 25 '16 at 10:30