What you have looks fairly correct. I don't see your dependency section
but I'm assuming you declared a dependency with classifier tests? (like
shown here:
http://maven.apache.org/guides/mini/guide-attached-tests.html). If so,
then you may be seeing these issues: (which may actually be a core
issue, not a problem with jar itself). I can't really explain why the
build helper plugin changes things.
http://jira.codehaus.org/browse/MJAR-68
http://jira.codehaus.org/browse/MNG-2045

I don't see in your posts which maven version you're using. MNG-2045 was
supposedly fixed in 2.0.8, but there also seem to be comments to the
contrary. Can you give it a try with 2.0.8 (if you haven't) and with
2.0.9-RC8?

--Brian

-----Original Message-----
From: Robert Reiner [mailto:[EMAIL PROTECTED] 
Sent: Saturday, April 05, 2008 12:50 PM
To: [email protected]
Subject: RE: jar does not attach to reactor?


Hi Brian,

what I am trying to accomplish (and what actually works) is this: I have
a
module that implements the persistency layer with JPA. This module
provides
(currently) all implementation and tests against an in-memory database
with
a specific JPA implementation (this is the core module). Now I want to
make
sure that different JPA implementations (hibernate and toplink in my
case)
and different databases (mysql and hsql in my case) are supported. So I
have
some variant modules that (currently) simply provide some configuration
files. I want to use the tests from the core module as is and run them
against the variants' configuration (to make sure they work properly).
In
the future I may add/replace implementation with e.g. hibernate-specific
features (for performance reasons, etc.) - I want to be most flexible,
this
is a project to test what can be accomplished with Maven and (at least
currently) not a product on itself. What I have in mind is a
configuration
for projects like XWiki where different databases and web/application
server
have to be supported (this originates from the discussion raised from
Vincent Massol: 
What is the Best practice for generating variations of an artifacts? -
http://www.mail-archive.com/[email protected]/msg62970.html). So
much
to the background... :-)

So the overall structure is this

- ejb-project
    - core-module
    - variations (variant-parent contains POM all variations inherit
from)
        - variation-A-module
        - variation-B-module
        - ...

Concrete (slightly simplified):

- timesheet-ejb
    - timesheet core (provides test-artifact)
    - timesheet variations
        - timesheet ejb hibernate mysql (uses test-artifact)
        - timesheet ejb hibernate hsql (uses test-artifact)
        - timesheet ejb toplink mysql (uses test-artifact)

I think that you do not get much from the POM as a whole, so I show only
the
relevant parts:

The core module exports the tests like this (copied from my original
post):

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-jar-plugin</artifactId>
  <executions>
    <execution>
      <goals>
        <goal>test-jar</goal>
      </goals>
      <configuration>
      ...
      </configuration>
    </execution>
  </executions>
</plugin>

With the jar-plugin everthing works fine outside a multi-module build.
The
test-artifact gets created and is deployed to the repository. But if I
want
to access these test-artifacts in one of my variant modules from within
a
multi-module build, I have to add the buildhelper-plugin (otherwise
Maven
grabs the latest from the repository).

So the following POM fragment is also part of the core module's POM:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>build-helper-maven-plugin</artifactId>
  <executions>
    <execution>
      <id>attach-artifacts</id>
      <phase>package</phase>
      <goals>
        <goal>attach-artifact</goal>
      </goals>
      <configuration>
        <artifacts>
          <artifact>
            
<file>${basedir}/target/${project.build.finalName}-tests.jar</file>
            <type>jar</type>
            <classifier>tests</classifier>
          </artifact>
        </artifacts>
      </configuration>
    </execution>
  </executions>
</plugin> 

The variant modules inherit from a variant-parent-pom where the
following is
defined (again from my original post):

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-dependency-plugin</artifactId>
  <configuration>
    <overWriteReleases>false</overWriteReleases>
    <overWriteSnapshots>true</overWriteSnapshots>
  </configuration>
  <executions>
    <execution>
      <id>repack-entity-classes</id>
      ....
    </execution>
    <execution>
      <id>unpack-test-classes</id>
      <phase>test-compile</phase>
      <goals>
        <goal>unpack-dependencies</goal>
      </goals>
      <configuration>
       
<outputDirectory>${project.build.testOutputDirectory}</outputDirectory>
        <includeGroupIds>de.smartics.timesheet</includeGroupIds>
        <includeArtifactIds>timesheet-ejb-core</includeArtifactIds>
        <includeClassifiers>tests</includeClassifiers>
     </configuration>
   </execution>
  </executions>
</plugin> 

The concrete variation modules simply put this in their build-section of
their POM:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-dependency-plugin</artifactId>
</plugin>

As I stated above: This actually works as intended. My question is
simply,
why does the jar-plugin not add the test-artifact to the reactor? And is
there more to the reactor than providing artifacts from the current
build?

Sorry for this longish post - could not get it shorter. :-(

Regards,
  Robert



Brian E Fox wrote:
> 
> So are you using the jar plugin to make another jar artifact and
> attaching it with the buildhelper? I'm not completely clear what
you're
> trying to do. Maybe post the pom that is creating the artifact?
> 

-- 
View this message in context:
http://www.nabble.com/jar-does-not-attach-to-reactor--tp16491295s177p165
15432.html
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
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