You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by aldana <al...@gmx.de> on 2007/08/13 18:08:25 UTC

maven plugin alternative to assembly plugin

hi,

does anybody know an alternative to assembly plugin which is mainly putting
all stuff into a single jar.

would prefer a layout where libraries are organized as following:

-mainJar.jar
-lib/
  -dependentJar1
  -dependentJar2
  -...

the main task would be to set up Manifest.MF from mainJar.jar correctly so
neccessary classpaths are set correctly and reference to outside living
lib/*.jar.


-- 
View this message in context: http://www.nabble.com/maven-plugin-alternative-to-assembly-plugin-tf4262116s177.html#a12129079
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: maven plugin alternative to assembly plugin

Posted by aldana <al...@gmx.de>.
hi again,

i tried to search in archive to find out how to achieve packaging a release
like stated below. no success (maybe wrong keywords...).

that's why i would like to ask you for an example how to do this. i really
need to get rid of this muddy copy all into one jar assembly...

many thanks again.



Dirk Olmes-4 wrote:
> 
>> hi,
>>
>> does anybody know an alternative to assembly plugin which is mainly
>> putting all stuff into a single jar.
>>
>> would prefer a layout where libraries are organized as following:
>>
>> -mainJar.jar
>> -lib/
>>   -dependentJar1
>>   -dependentJar2
>>   -...
>>
>> the main task would be to set up Manifest.MF from mainJar.jar correctly
>> so
>> neccessary classpaths are set correctly and reference to outside living
>> lib/*.jar.
> 
> That's perfectly doable with the assembly plugin and the jar plugin. I'm
> not at my machine right now so I cannot provide you with the exaxt
> details. Search the archive, though, this has been done before. Or bug me
> per mail next week when I'm back home to send you the example config.
> 
> -dirk
> 
> -- 
> Anyway kids, have fun, play nicely, be good. And remember - if it ain't
> broke, hit it again.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/maven-plugin-alternative-to-assembly-plugin-tf4262116s177.html#a12294278
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: maven plugin alternative to assembly plugin

Posted by Zarick Lau <za...@gmail.com>.
Yes, this is absolutely doable.

Checkout the mailing, I ask post back one answer using the assembly
plugin to achieve similar result you desire.

BTW, why you want alt. plugin?

On 8/14/07, Dirk Olmes <di...@xanthippe.ping.de> wrote:
> > hi,
> >
> > does anybody know an alternative to assembly plugin which is mainly
> > putting all stuff into a single jar.
> >
> > would prefer a layout where libraries are organized as following:
> >
> > -mainJar.jar
> > -lib/
> >   -dependentJar1
> >   -dependentJar2
> >   -...
> >
> > the main task would be to set up Manifest.MF from mainJar.jar correctly so
> > neccessary classpaths are set correctly and reference to outside living
> > lib/*.jar.
>
> That's perfectly doable with the assembly plugin and the jar plugin. I'm
> not at my machine right now so I cannot provide you with the exaxt
> details. Search the archive, though, this has been done before. Or bug me
> per mail next week when I'm back home to send you the example config.
>
> -dirk
>
> --
> Anyway kids, have fun, play nicely, be good. And remember - if it ain't
> broke, hit it again.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: maven plugin alternative to assembly plugin

Posted by Dirk Olmes <di...@xanthippe.ping.de>.
> hi,
>
> does anybody know an alternative to assembly plugin which is mainly
> putting all stuff into a single jar.
>
> would prefer a layout where libraries are organized as following:
>
> -mainJar.jar
> -lib/
>   -dependentJar1
>   -dependentJar2
>   -...
>
> the main task would be to set up Manifest.MF from mainJar.jar correctly so
> neccessary classpaths are set correctly and reference to outside living
> lib/*.jar.

That's perfectly doable with the assembly plugin and the jar plugin. I'm
not at my machine right now so I cannot provide you with the exaxt
details. Search the archive, though, this has been done before. Or bug me
per mail next week when I'm back home to send you the example config.

-dirk

-- 
Anyway kids, have fun, play nicely, be good. And remember - if it ain't
broke, hit it again.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: maven plugin alternative to assembly plugin

Posted by aldana <al...@gmx.de>.
thanks, saved my day!
one little correction and suggestion (and a last question for maven-jar
plugin):

<assembly>
  ...
  <fileSets>
    <fileSet>
      <includes>
        <include>${artifactId}-*.jar</include>
      </includes>
      <directory>${basedir}/target</directory>
      <!-- output directory empty, so does get copied to root (you wrote
lib/)-->
      <outputDirectory></outputDirectory>      
    </fileSet>
  </fileSets>

  <dependencySet>
   <!-- there could be conflicts (hence there are often libs called
commons-xxx.jar, prepend  groupId to ensure that nothing gets overwritten
-->      
<outputFileNameMapping>${groupId}-${artifactId}-${version}-${classifier}.${extension}</outputFileNameMapping>
      <outputDirectory>lib</outputDirectory>
    </dependencySet>
</dependencySets>
...
</assembly> 


for
<outputFileNameMapping>${groupId}-${artifactId}-${version}-${classifier}.${extension}</outputFileNameMapping>
i need to adjust the classpath string in MANIFEST.MF. unfortunately making
<classpathPrefix>lib/${groupId}-${artifactId}-${version}-${classifier}.${extension}.</classpathPrefix>
does not work, because it is interpreted as a directory.
how is it possible to set the classpath equal to the library names in lib/
folder configured in assembly plugin?



-- 
View this message in context: http://www.nabble.com/maven-plugin-alternative-to-assembly-plugin-tf4262116s177.html#a12311490
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: maven plugin alternative to assembly plugin

Posted by Zarick Lau <za...@gmail.com>.
On 8/14/07, aldana <al...@gmx.de> wrote:
>
> hi,
>
> does anybody know an alternative to assembly plugin which is mainly putting
> all stuff into a single jar.
>
> would prefer a layout where libraries are organized as following:
>
> -mainJar.jar
> -lib/
>   -dependentJar1
>   -dependentJar2
>   -...
>
> the main task would be to set up Manifest.MF from mainJar.jar correctly so
> neccessary classpaths are set correctly and reference to outside living
> lib/*.jar.

This is two different piece of configuration effort.

First, configure pom so that, the Manifest of mainJar to add classpath
for all dependency, and also enable "classpathPrefix" configuration to
"lib".

Put this fragment in your pom:
<!-- Fragment in POM -->
<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-jar-plugin</artifactId>
      <configuration>
        <archive>
          <manifest>
            <addClasspath>true</addClasspath>
            <classpathPrefix>lib</classpathPrefix>
          </manifest>
        </archive>
      </configuration>
    </plugin>
  </plugins>
</build>



Secondly, use assembly plugin, put all dependency to "lib/" and put
the mainjar to
top level, the assembly descriptor should be some like this:

<!-- Fragment in pom.xml -->
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <executions>
          <execution>
            <id>assemble</id>
            <phase>package</phase>
            <goals>
              <goal>directory-inline</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <finalName>package</finalName>
          <appendAssemblyId>false</appendAssemblyId>
          <descriptors>
            <descriptor>src/main/assembly/binary.xml</descriptor>
          </descriptors>
        </configuration>
      </plugin>
    </plugins>
  </build>


<!-- File: assembly descriptor, src/main/assembly/binary.xml -->
<assembly>
  <id>binary</id>
  <formats>
    <format>zip</format>
  </formats>
  <includeBaseDirectory>true</includeBaseDirectory>
  <baseDirectory>all-in-one</baseDirectory>
  <fileSets>
    <fileSet>
      <includes>
        <include>${artifactId}-*.jar</include>
      </includes>
      <directory>${basedir}/target</directory>
      <outputDirectory>lib</outputDirectory>
      <lineEnding>keep</lineEnding>
      <fileMode>0644</fileMode>
    </fileSet>
  </fileSets>
  <dependencySets>
    <dependencySet>
      <outputDirectory>lib</outputDirectory>
    </dependencySet>
  </dependencySets>
</assembly>

Cheers,
Zarick

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org