maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Laird Nelson <ljnel...@gmail.com>
Subject Re: Unpacking jars into target/classes
Date Thu, 21 Mar 2013 02:40:33 GMT
On Sat, Mar 2, 2013 at 12:32 PM, Joachim Durchholz <jo@durchholz.org> wrote:

> I have two jars from an external source and need to merge their contents
> into the target/classes tree until the process-classes phase.
> I'm not sure what plugin(s) can be used to achieve this effect.
>

Offhand I would say you can use the maven-dependency-plugin's unpack goal
(documented here:
http://maven.apache.org/plugins/maven-dependency-plugin/unpack-mojo.html).

It is perfectly legal to bind the unpack goal to the (say) process-classes
phase twice, with different executions.

So you could do something like this (I'm typing from memory; sure to make
syntax mistakes; hope you get the idea):

<plugin>
  <artifactId>maven-dependency-plugin</artifactId>
  <executions>
    <execution>
      <id>Unpack the first jar into ${project.build.outputDirectory}</id>
      <phase>process-classes</phase>
      <goals>
        <goal>unpack</goal>
      </goals>
      <configuration>
        <!-- here is where the magic happens -->
      </configuration>
    </execution>
    <execution>
      <id>Unpack the second jar into ${project.build.outputDirectory}</id>
      <phase>process-classes</phase>
      <goals>
        <goal>unpack</goal>
      </goals>
      <configuration>
        <!-- here is where more magic happens -->
      </configuration>
    </execution>
  </executions>
</plugin>

I do something very much like this in my JPA pseudo-archetype (
https://github.com/ljnelson/jpa-archetype/blob/master/pom.xml).

In your case, where you cannot or will not install the artifacts into your
local Maven repository/cache--a totally legitimate state of affairs, I
know; anyone who has worked in a large company has faced this--you would
make sure to declare a dependency in <scope>system</scope>:

<dependency>
  <groupId>whatever</groupId>
  <artifactId>first-jar-file</artifactId>
  <scope>system</scope>

<systemPath>${hopefullySomePropertyHereToMakeYourBuildReproducible}/path/to/first-jar-file.jar</systemPath>
</dependency>

This would be the first dependency unpacked in the stanza I showed above.

I hope this helps you out.

Best,
Laird

-- 
http://about.me/lairdnelson

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message