I could not find a way to add individual files to shaded jar, I think this
is something not possible.
I workarounded the problem by packageing these individual files into a jar
file using a maven project. Then I included this jar as a dependency in my
t4-core-all project and in Shade plugin configuration and it works perfect.

Thanks for introducing me to Shade Plugin, it helped me a lot.

Regards,

Olivier

2008/9/9 John Prystash <[EMAIL PROTECTED]>

> My experience with shade plugin is quite limited, I've only included other
> dependencies that are external to my project, not individual files.
> You might be able to create an assembly that packages the shaded jar with
> the additional files as long as you do not need the files packaged in the
> jar.  That approach probably wouldn't help if you need the files on the
> classpath.
>
>
>
> ----- Original Message ----
> From: Olivier THIERRY <[EMAIL PROTECTED]>
> To: Maven Users List <users@maven.apache.org>
> Sent: Monday, September 8, 2008 4:29:08 AM
> Subject: Re: How to merge pom files ?
>
> Thanks a lot John, this is exactly what I needed :)
>
> Based on the plugin configuration you suggested, I added
> promoteTransitiveDependencies property and set it to true so that
> transitive
> dependencies become direct dependencies in the shaded jar.
>
> But I have one problem yet : I need to add some files to the shaded jar. I
> saw you can exclude files from the shaded jar with filters property, but I
> can't see a way to add a new file to the shaded jar. I thought about
> creating a new artifact in M2 repository with these files to add and add
> this artifact to the artifactSet includes property. It should work but I
> wonder if there's an easier way to do it. Do you have any idea about this ?
>
> Regards,
>
> Olivier
>
>
> 2008/9/5 John Prystash <[EMAIL PROTECTED]>
>
> > You might want to take a look at the shade plugin
> >
> > http://maven.apache.org/plugins/maven-shade-plugin/
> >
> > A configuration like the following should create a jar containing the
> > classes from the two t4 jars you depend on:
> >
> >     <plugin>
> >        <groupId>org.apache.maven.plugins</groupId>
> >        <artifactId>maven-shade-plugin</artifactId>
> >         <executions>
> >          <execution>
> >            <phase>package</phase>
> >            <goals>
> >               <goal>shade</goal>
> >            </goals>
> >            <configuration>
> >              <artifactSet>
> >                <includes>
> >                  <include>t4:t4-core-utils</include>
> >                  <include>t4:t4-common-utils</include>
> >                </includes>
> >              </artifactSet>
> >            </configuration>
> >          </execution>
> >        </executions>
> >      </plugin>
> >
> >
> >
> > ----- Original Message ----
> > From: Olivier THIERRY <[EMAIL PROTECTED]>
> > To: users@maven.apache.org
> > Sent: Friday, September 5, 2008 10:52:00 AM
> > Subject: How to merge pom files ?
> >
> > Hi all,
> >
> > I have two Maven projects named t4-core-utils and t4-core-commons. They
> > build jar artifacts and install them to my M2 repository.
> > Now I want to build a jar that merges both jars (extract files from these
> > jars and add them to a new jar) then install it to M2 repository so that
> it
> > can be used as a dependency in other Maven projects.
> >
> > I tried to use Maven Assembly plugin to achieve this. I could create the
> > new
> > jar and install it to M2 repo, but I have problems with the way pom file
> is
> > generated in M2 repo.
> >
> > The pom.xml is as following (t4-parent is used for dependency management)
> :
> >
> > <project xmlns="http://maven..apache.org/POM/4.0.0";
> >         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> >         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> > http://maven.apache.org/maven-v4_0_0.xsd";>
> >      <modelVersion>4.0.0</modelVersion>
> >      <groupId>t4</groupId>
> >      <artifactId>t4-core-all</artifactId>
> >      <packaging>jar</packaging>
> >    <parent>
> >        <groupId>t4</groupId>
> >        <artifactId>t4-parent</artifactId>
> >        <version>1.0-SNAPSHOT</version>
> >    </parent>
> >      <version>1.0-SNAPSHOT</version>
> >      <name>T4 Core All</name>
> >     <dependencies>
> >          <dependency>
> >              <groupId>t4</groupId>
> >              <artifactId>t4-core-utils</artifactId>
> >              <version>${version}</version>
> >          </dependency>
> >          <dependency>
> >              <groupId>fr.horoquartz.t4</groupId>
> >              <artifactId>t4-core-commons</artifactId>
> >              <version>${version}</version>
> >          </dependency>
> >      </dependencies>
> >    <build>
> >          <plugins>
> >              <plugin>
> >                  <artifactId>maven-assembly-plugin</artifactId>
> >                  <configuration>
> >                    <descriptors>
> >
> > <descriptor>src/main/assembly/t4-core-all.xml</descriptor>
> >                      </descriptors>
> >                      <appendAssemblyId>false</appendAssemblyId>
> >                  </configuration>
> >                <executions>
> >                    <execution>
> >                        <phase>package</phase>
> >                        <goals>
> >                            <goal>attached</goal>
> >                        </goals>
> >                    </execution>
> >                </executions>
> >              </plugin>
> >          </plugins>
> >      </build>
> > </project>
> >
> > And the t4-core-all.xml file :
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <assembly xmlns="http://maven.apache.org/POM/4.0.0"; xmlns:xsi="
> > http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="
> >
> >
> http://maven.apache.org/POM/4.0.0../../../../exchange-ws-api/assembly-1.1.0-SNAPSHOT.xsd
> > ">
> >    <id>t4-core-all</id>
> >      <formats>
> >        <format>jar</format>
> >      </formats>
> >      <includeBaseDirectory>false</includeBaseDirectory>
> >      <dependencySets>
> >           <dependencySet>
> >               <unpack>true</unpack>
> >               <unpackOptions>
> >                   <excludes>
> >                       <exclude>META-INF/persistence.xml</exclude>
> >                       <exclude>META-INF/ejb-jar.xml</exclude>
> >                   </excludes>
> >              </unpackOptions>
> >
> <useTransitiveDependencies>false</useTransitiveDependencies>
> >        </dependencySet>
> >      </dependencySets>
> >    <files>
> >        <file>
> >            <source>src/main/assembly/persistence.xml</source>
> >            <outputDirectory>META-INF</outputDirectory>
> >        </file>
> >        <file>
> >            <source>src/main/assembly/ejb-jar.xml</source>
> >            <outputDirectory>META-INF</outputDirectory>
> >        </file>
> >    </files>
> > </assembly>
> >
> > The pom generated for t4-core-all just contains dependencies to
> > t4-core-utils and t4-core-commons. So when adding t4-core-all as a
> > dependency, I have all classes twice, in t4-core-all and in
> t4-core-commons
> > or t4-core-utils ... Actually what I need is that the pom for t4-core-all
> > contains transitive dependencies from t4-core-utils and t4-core-commons
> > (for
> > example hibernate, commons-lang, etc...), and not dependencies to
> > t4-core-utils and t4-core-commons. A kind of pom merging. Is there a way
> to
> > do this ?
> >
> > Thanks in advance,
> >
> > Olivier
> >
> >
> >
> >
> >
>
>
>
> --
> Seules 2 choses sont infinies : l'univers et la bêtise humaine ; et encore
> pour l'univers, je ne suis pas sûr … (Einstein)
>
>
>
>
>



-- 
Seules 2 choses sont infinies : l'univers et la bêtise humaine ; et encore
pour l'univers, je ne suis pas sûr … (Einstein)

Reply via email to