I could see three approaches to this:
1. Create a new project for the storage test helper classes.  But this
separates the test code from the project it's providing help for.
2. Move the test helper classes to the main jar for the storage project.
This shouldn't cause huge problems for normal users that don't use the
helper classes, but is a bit inelegant.
3. Have the storage project create two artifacts: the main jar and a jar
containing the test helper classes.  Doing this would require either a
new plugin to generate the new jar or modifying an existing plugin to do
this (probably the jar plugin).  You could just put custom code into
your maven.xml, but then no one else would be able to take advantage of
the solution.

As a head start, here's a maven.xml that should do it.  I'll leave it as
an exercise for the reader to make a plugin out of it.  

<project 
  xmlns:j="jelly:core"
  xmlns:ant="jelly:ant"
  xmlns:artifact="artifact">

  <goal name="testjar" description="Create the deliverable test jar
file.">
    <ant:jar
 
jarfile="${maven.build.dir}/${pom.artifactId}-test-${pom.currentVersion}
.jar"
      basedir="${maven.test.dest}"
      index="${maven.jar.index}"
      compress="${maven.jar.compress}"
      excludes="${maven.jar.excludes}"> 
    </ant:jar>
  </goal>
  
  <goal name="testjar:install" description="Install the test jar to the
local repository">
    <artifact:install
 
artifact="${maven.build.dir}/${pom.artifactId}-test-${pom.currentVersion
}.jar"
      type="jar"
      project="${pom}"
    />
  </goal>
  
  <goal name="testjar:deploy" description="Deploy the test jar to the
remote repository">
    <artifact:deploy
 
artifact="${maven.build.dir}/${pom.artifactId}-test-${pom.currentVersion
}.jar"
      type="jar"
      project="${pom}"
    />
  </goal>

  <postGoal name="jar:jar">
    <attainGoal name="testjar"/>
  </postGoal>

  <postGoal name="jar:install">
    <attainGoal name="testjar:install"/>
  </postGoal>

  <postGoal name="jar:deploy">
    <attainGoal name="testjar:deploy"/>
  </postGoal>
  
</project>



-----Original Message-----
From: Wim Deblauwe [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, May 04, 2005 4:25 AM
To: Maven Users List
Subject: Re: Dependency on test class

We have the exact same problem. We currently have no solution other then
copying the AbstractXXXTestCase to each project, which is not good
obviously. Anybody's thought on this subject is highly appreciated.

Maybe there should be a testjar:deploy goal? This would jar the test
classes and deploy them. Other projects could then depend on that one...

regards,

Wim

On 5/3/05, David Jackman <[EMAIL PROTECTED]> wrote:
> For what it's worth (probably not much), I think this isn't the best 
> approach.
> Essentially, core has a dependency on the test code of storage.
> Expressing the dependency this way will break if any of the following
> happens:
> * The storage project moves to a new location
> * Core's dependency on storage is for a different version than the 
> current version of storage
> * The version of the storage project code on my machine doesn't match 
> the version that I'm downloading as a dependency for core If the risk 
> of any of these things is low, then this approach becomes less 
> dangerous.
> 
> It would be better to have some project (maybe storage, maybe 
> something
> else) create a jar that contains this dependency, then have the core 
> project use the Maven dependency management to get it.
> 
> ..David..
> 
> 
> -----Original Message-----
> From: Petr Adamek [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, May 03, 2005 8:57 AM
> To: Maven Users List
> Subject: Re: Dependency on test class
> 
> baleineca wrote:
> 
> >I am using a preGoal for the test dependency.  This goes in the 
> >maven.xml (in your case it woud be 'core').
> >
> >In your case, from looking at your layout, it would be something like

> >this.  Adjust the pathelement to suit your need.
> >(xmlns:ant="jelly:ant" and xmlns:m="jelly:maven" in the script
below).
> >
> >        <preGoal name="test:compile">
> >                <ant:path id="requiredTestSrc">
> >                        <ant:pathelement 
>
>location="${basedir}/../storage/test/java/org/xiqe/storage/converters"
> >/>
> >                </ant:path>
> >                <m:addPath id="maven.test.compile.src.set"
> >refid="requiredTestSrc" />
> >        </preGoal>
> >
> >Hope it helps.
> >
> >
> It has helped, thank you very much :-).
> 
> --
> Ing. Petr Adamek
> Faculty of Informatics, Masaryk University, Brno
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to