You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by CheapLisa <li...@purpleblade.net> on 2009/01/04 18:11:19 UTC

Problems with maven building a "super jar"

I have a project directory like:
	C:\home\projects\<myproject>
	
In <myproject> there is <myproject>\pom.xml

This pom is a top level pom (for many modules and those modules have
sub-modules)
and the packageing is set to "pom".

What I want is to build one super jar that includes all jars in my project
and all jars that were downloaded as dependencies (and dependencies of
dependencies).

How do I do this?

I included in my top level pom in the build section the maven-assembly
plugin
but that just created a jar with some apache classes and did not include my
jars (my modules) or any dependencies (like Spring, Log4J, etc).

This is the <build> section of my top level pom.xml
(<packaging>pom</packaging>
    <build>
            <plugins>
                <!-- Compiler -->
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.6</source>
                        <target>1.6</target>
                        <showDeprecation>true</showDeprecation>
                        <showWarnings>true</showWarnings>
                        <!-- Commented out fork to see if it fixes continuum
build -->
                        <!-- <fork>true</fork> -->
                    </configuration>
                    <!-- <compilerOption>-enableassertions</compilerOption>
-->
                </plugin>

                <!--
******************************************************************** -->
                <plugin> <!-- build a single superjar with all this project
.jars and all dependent jars like spring, log4j etc (every <dependency>
section will result in the inclusion of one or more jars in the super pom
-->
                    <artifactId>maven-assembly-plugin</artifactId>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>assembly</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <descriptorRefs>
                           
<descriptorRef>jar-with-dependencies</descriptorRef>
                        </descriptorRefs>
                    </configuration>
                </plugin>


-- 
View this message in context: http://www.nabble.com/Problems-with-maven-building-a-%22super-jar%22-tp21278586p21278586.html
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: Problems with maven building a "super jar"

Posted by CheapLisa <li...@purpleblade.net>.
thanks, I went over those, but nothing is being built.

I think the problem is that my top level project has no /src/main/java
directory.  In fact there is no /src/ directory at all meaning the pom.xml
(parent pom) of all sub modules has no dependencies.

It just has many modules which have sub modules.  The assembly plugin just
includes unpacked jars of dependencies but since there are no dependencies,
nothing is included in the jar.

How do I tell the assembly plugin to include all jars of submodules ? (the
top level project is just a container for sub-modules).  

I think most projects are like this so there must be a way.

LM



Baptiste MATHUS-4 wrote:
> 
> Lisa, I see you have learnt some good practice from your recent experience
> :
> no hello, no thanks. So far, so good :-/.
> 
> About having jars inside your jar, I suppose you want the other jars not
> to
> be unpacked. I asume you're familiar with the fact that having jars inside
> your jar isn't standard and just won't work by default.
> 
> Reading this
> http://maven.apache.org/plugins/maven-assembly-plugin/descriptor-refs.html#jar-with-dependencieswill
> show you why everything is unpacked (that's the default), but you
> surelyy already read this twice.
> 
> Maybe also have a look here:
> http://maven.apache.org/plugins/maven-assembly-plugin/examples/multimodule/module-binary-inclusion-simple.html.
> From what you describe, it might be what you need.
> 
> Cheers
> 
> 2009/1/4 CheapLisa <li...@purpleblade.net>
> 
>>
>> I have a project directory like:
>>        C:\home\projects\<myproject>
>>
>> In <myproject> there is <myproject>\pom.xml
>>
>> This pom is a top level pom (for many modules and those modules have
>> sub-modules)
>> and the packageing is set to "pom".
>>
>> What I want is to build one super jar that includes all jars in my
>> project
>> and all jars that were downloaded as dependencies (and dependencies of
>> dependencies).
>>
>> How do I do this?
>>
>> I included in my top level pom in the build section the maven-assembly
>> plugin
>> but that just created a jar with some apache classes and did not include
>> my
>> jars (my modules) or any dependencies (like Spring, Log4J, etc).
>>
>> This is the <build> section of my top level pom.xml
>> (<packaging>pom</packaging>
>>    <build>
>>            <plugins>
>>                <!-- Compiler -->
>>                <plugin>
>>                    <artifactId>maven-compiler-plugin</artifactId>
>>                    <configuration>
>>                        <source>1.6</source>
>>                        <target>1.6</target>
>>                        <showDeprecation>true</showDeprecation>
>>                        <showWarnings>true</showWarnings>
>>                        <!-- Commented out fork to see if it fixes
>> continuum
>> build -->
>>                        <!-- <fork>true</fork> -->
>>                    </configuration>
>>                    <!--
>> <compilerOption>-enableassertions</compilerOption>
>> -->
>>                </plugin>
>>
>>                <!--
>> ******************************************************************** -->
>>                <plugin> <!-- build a single superjar with all this
>> project
>> .jars and all dependent jars like spring, log4j etc (every <dependency>
>> section will result in the inclusion of one or more jars in the super pom
>> -->
>>                    <artifactId>maven-assembly-plugin</artifactId>
>>                    <executions>
>>                        <execution>
>>                            <phase>package</phase>
>>                            <goals>
>>                                <goal>assembly</goal>
>>                            </goals>
>>                        </execution>
>>                    </executions>
>>                    <configuration>
>>                        <descriptorRefs>
>>
>> <descriptorRef>jar-with-dependencies</descriptorRef>
>>                        </descriptorRefs>
>>                    </configuration>
>>                </plugin>
>>
>>
> 
> -- 
> Baptiste <Batmat> MATHUS - http://batmat.net
> Sauvez un arbre,
> Mangez un castor !
> 
> 

-- 
View this message in context: http://www.nabble.com/Problems-with-maven-building-a-%22super-jar%22-tp21278586p21279021.html
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: Problems with maven building a "super jar"

Posted by CheapLisa <li...@purpleblade.net>.
What I want to do is to include all jars from all modules/sub-modules that
are built from the top level when I do "mvn compile install".

in the top level C:\projects\<myproject>\pom.xml 

there is no /src/main/java directory to build.  It is a top level
project/container only for submodules and the packaging in the top level
pom.xml is simply "pom".

How do I build a super jar containing all jars that were built as a result
of having a <module> line in a pom (or sub module pom), and have all
dependencies that that jar needs (downloaded to .m2/repository/ )
be included in a super jar?

thanks

I get this error:
 [INFO] Failed to create assembly: Error creating assembly archive superjar:
You must set at least on
e file.

--- This is my assembly.xml (I'm not sure exactly what everything here does
- got it from an example online)


<assembly>
  <id>superjar</id>
  <includeBaseDirectory>true</includeBaseDirectory>

  <moduleSets>
    <moduleSet>
        <includeSubModules>true</includeSubModules>
        <binaries>
            <outputDirectory>
                ${module.artifactId}-${module.version}
            </outputDirectory>

            <dependencySets>
                <dependencySet/>
            </dependencySets>
        </binaries>
    </moduleSet>
  </moduleSets>
  <formats>
    <format>jar</format>
  </formats>


</assembly>

-- 
View this message in context: http://www.nabble.com/Problems-with-maven-building-a-%22super-jar%22-tp21278586p21279575.html
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: Problems with maven building a "super jar"

Posted by Baptiste MATHUS <ml...@batmat.net>.
Lisa, I see you have learnt some good practice from your recent experience :
no hello, no thanks. So far, so good :-/.

About having jars inside your jar, I suppose you want the other jars not to
be unpacked. I asume you're familiar with the fact that having jars inside
your jar isn't standard and just won't work by default.

Reading this
http://maven.apache.org/plugins/maven-assembly-plugin/descriptor-refs.html#jar-with-dependencieswill
show you why everything is unpacked (that's the default), but you
surelyy already read this twice.

Maybe also have a look here:
http://maven.apache.org/plugins/maven-assembly-plugin/examples/multimodule/module-binary-inclusion-simple.html.
>From what you describe, it might be what you need.

Cheers

2009/1/4 CheapLisa <li...@purpleblade.net>

>
> I have a project directory like:
>        C:\home\projects\<myproject>
>
> In <myproject> there is <myproject>\pom.xml
>
> This pom is a top level pom (for many modules and those modules have
> sub-modules)
> and the packageing is set to "pom".
>
> What I want is to build one super jar that includes all jars in my project
> and all jars that were downloaded as dependencies (and dependencies of
> dependencies).
>
> How do I do this?
>
> I included in my top level pom in the build section the maven-assembly
> plugin
> but that just created a jar with some apache classes and did not include my
> jars (my modules) or any dependencies (like Spring, Log4J, etc).
>
> This is the <build> section of my top level pom.xml
> (<packaging>pom</packaging>
>    <build>
>            <plugins>
>                <!-- Compiler -->
>                <plugin>
>                    <artifactId>maven-compiler-plugin</artifactId>
>                    <configuration>
>                        <source>1.6</source>
>                        <target>1.6</target>
>                        <showDeprecation>true</showDeprecation>
>                        <showWarnings>true</showWarnings>
>                        <!-- Commented out fork to see if it fixes continuum
> build -->
>                        <!-- <fork>true</fork> -->
>                    </configuration>
>                    <!-- <compilerOption>-enableassertions</compilerOption>
> -->
>                </plugin>
>
>                <!--
> ******************************************************************** -->
>                <plugin> <!-- build a single superjar with all this project
> .jars and all dependent jars like spring, log4j etc (every <dependency>
> section will result in the inclusion of one or more jars in the super pom
> -->
>                    <artifactId>maven-assembly-plugin</artifactId>
>                    <executions>
>                        <execution>
>                            <phase>package</phase>
>                            <goals>
>                                <goal>assembly</goal>
>                            </goals>
>                        </execution>
>                    </executions>
>                    <configuration>
>                        <descriptorRefs>
>
> <descriptorRef>jar-with-dependencies</descriptorRef>
>                        </descriptorRefs>
>                    </configuration>
>                </plugin>
>
>

-- 
Baptiste <Batmat> MATHUS - http://batmat.net
Sauvez un arbre,
Mangez un castor !