You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Victor Okunev <ve...@gmail.com> on 2007/10/13 01:23:18 UTC

help: can't exclude files from EAR file

Folks,

I need to build an EAR file composed of just one WAR file using
Maven2. However, in addition to the WAR file, the resulting EAR file
contains all the JARs that the web module has dependencies on, as well
as the pom.xml. How do I exclude everything but WAR file and
application.xml from the EAR file?

I tried   <earSourceExcludes>**/*.jar,pom.xml</earSourceExcludes>, but
it seems Maven just ignores it.

Here is my pom file:

<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>
  <parent>
  <groupId>mygroupid</groupId>
  <artifactId>abc</artifactId>
  <version>1.0-SNAPSHOT</version>
  </parent>
  <artifactId>xyz</artifactId>
  <packaging>ear</packaging>
  <name>ear_assembly</name>

  <dependencies>
    <dependency>
      <groupId>mygroupid</groupId>
      <artifactId>web</artifactId>
      <version>${project.version}</version>
      <type>war</type>
    </dependency>
  </dependencies>
   <build>
      <plugins>
         <plugin>
            <artifactId>maven-ear-plugin</artifactId>
            <configuration>
            <earSourceExcludes>**/*.jar,pom.xml</earSourceExcludes>
            <fileNameMapping/>
               <archive>
                  <manifest>
                     <addClasspath>true</addClasspath>
                  </manifest>
               </archive>
            </configuration>
         </plugin>
      </plugins>
   </build>

</project>

Thanks,

Victor

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


Re: help: can't exclude files from EAR file

Posted by Jon913 <jo...@discovery.co.za>.
You can exclude the dependencies in the following way:

-----------------------------------------------------------

-- First pom.xml --
<project>
 <groupId>za.co.someCompany</groupId>
 <artifactId>MyDependencies</artifactId>
 <packaging>pom</packaging>
 <version>1.0</version>
..
 <dependencies>
  <dependency>
      <groupId>za.co.someCompany</groupId>
      <artifactId>A-PROJECT-DEPENDENCY</artifactId>
      <version>${version}</version>
      <scope>compile</scope>
  </dependency>
 </dependencies>
..
</project>



-- Second pom.xml (The one that builds the EAR) --
<project>
 <groupId>za.co.someCompany</groupId>
 <artifactId>MyEarBuilder</artifactId>
 <packaging>ear</packaging>
 <version>1.0</version>
..
 <dependencies>
  <dependency>
      <groupId>za.co.someCompany</groupId>
      <artifactId>MyDependencies</artifactId>
      <version>${version}</version>
      <scope>provided</scope>
  </dependency>
 </dependencies>
..
</project>



-- Third pom.xml (The one that builds the WAR) --
<project>
 <groupId>za.co.someCompany</groupId>
 <artifactId>MyWarBuilder</artifactId>
 <packaging>war</packaging>
 <version>1.0</version>
..
 <dependencies>
  <dependency>
      <groupId>za.co.someCompany</groupId>
      <artifactId>MyDependencies</artifactId>
      <version>${version}</version>
      <scope>compile</scope>
  </dependency>
 </dependencies>
..
</project>
-----------------------------------------------------------

So what just happened here?

There is a pom.xml that defines all the dependencies for a specific project.
The War builder sees these dependencies as compile scope, therefore will
build them into the lib.
The Ear builder sees them as provided, so won't include them in the EAR.

If the above code gives errors, it's because I haven't run it yet, just
wrote it down here :P. But the solution definitely works well.
Hope this helps you :)



Stephane Nicoll-2 wrote:
> 
> Well, the dependencies should be declared only in your war project. If
> you declare them in the parent pom, it's a dependency of the EAR
> project as well (hence it packages it).
> 
> invoke mvn dependency:resolve on both projects to see the result.
> 
> You can use dependencyManagement to share the way you handle your
> dependencies.
> 
> HTH,
> Stéphane
> 
> On 10/13/07, Victor Okunev <ve...@gmail.com> wrote:
>> I need to bundle the libs in the WAR only. There is just one web
>> module in my app.
>>
>> Victor
>>
>> On 10/12/07, Wayne Fay <wa...@gmail.com> wrote:
>> > Are your libs being bundled in the WAR, as well as the EAR? Or are you
>> > making the libs available in your j2ee container's lib directory such
>> > that they are shared among several apps?
>> >
>> > If you don't want the libs bundled in your WAR nor EAR, you should
>> > just change the scope to provided.
>> >
>> > Wayne
>> >
>> > On 10/12/07, Victor Okunev <ve...@gmail.com> wrote:
>> > > Folks,
>> > >
>> > > I need to build an EAR file composed of just one WAR file using
>> > > Maven2. However, in addition to the WAR file, the resulting EAR file
>> > > contains all the JARs that the web module has dependencies on, as
>> well
>> > > as the pom.xml. How do I exclude everything but WAR file and
>> > > application.xml from the EAR file?
>> > >
>> > > I tried   <earSourceExcludes>**/*.jar,pom.xml</earSourceExcludes>,
>> but
>> > > it seems Maven just ignores it.
>> > >
>> > > Here is my pom file:
>> > >
>> > > <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>
>> > >  <parent>
>> > >  <groupId>mygroupid</groupId>
>> > >  <artifactId>abc</artifactId>
>> > >  <version>1.0-SNAPSHOT</version>
>> > >  </parent>
>> > >  <artifactId>xyz</artifactId>
>> > >  <packaging>ear</packaging>
>> > >  <name>ear_assembly</name>
>> > >
>> > >  <dependencies>
>> > >    <dependency>
>> > >      <groupId>mygroupid</groupId>
>> > >      <artifactId>web</artifactId>
>> > >      <version>${project.version}</version>
>> > >      <type>war</type>
>> > >    </dependency>
>> > >  </dependencies>
>> > >   <build>
>> > >      <plugins>
>> > >         <plugin>
>> > >            <artifactId>maven-ear-plugin</artifactId>
>> > >            <configuration>
>> > >            <earSourceExcludes>**/*.jar,pom.xml</earSourceExcludes>
>> > >            <fileNameMapping/>
>> > >               <archive>
>> > >                  <manifest>
>> > >                     <addClasspath>true</addClasspath>
>> > >                  </manifest>
>> > >               </archive>
>> > >            </configuration>
>> > >         </plugin>
>> > >      </plugins>
>> > >   </build>
>> > >
>> > > </project>
>> > >
>> > > Thanks,
>> > >
>> > > Victor
>> > >
>> > > ---------------------------------------------------------------------
>> > > 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
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
> 
> 
> -- 
> Large Systems Suck: This rule is 100% transitive. If you build one,
> you suck" -- S.Yegge
> 
> ---------------------------------------------------------------------
> 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/help%3A-can%27t-exclude-files-from-EAR-file-tf4616593s177.html#a13273509
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: help: can't exclude files from EAR file

Posted by Stephane Nicoll <st...@gmail.com>.
Well, the dependencies should be declared only in your war project. If
you declare them in the parent pom, it's a dependency of the EAR
project as well (hence it packages it).

invoke mvn dependency:resolve on both projects to see the result.

You can use dependencyManagement to share the way you handle your dependencies.

HTH,
Stéphane

On 10/13/07, Victor Okunev <ve...@gmail.com> wrote:
> I need to bundle the libs in the WAR only. There is just one web
> module in my app.
>
> Victor
>
> On 10/12/07, Wayne Fay <wa...@gmail.com> wrote:
> > Are your libs being bundled in the WAR, as well as the EAR? Or are you
> > making the libs available in your j2ee container's lib directory such
> > that they are shared among several apps?
> >
> > If you don't want the libs bundled in your WAR nor EAR, you should
> > just change the scope to provided.
> >
> > Wayne
> >
> > On 10/12/07, Victor Okunev <ve...@gmail.com> wrote:
> > > Folks,
> > >
> > > I need to build an EAR file composed of just one WAR file using
> > > Maven2. However, in addition to the WAR file, the resulting EAR file
> > > contains all the JARs that the web module has dependencies on, as well
> > > as the pom.xml. How do I exclude everything but WAR file and
> > > application.xml from the EAR file?
> > >
> > > I tried   <earSourceExcludes>**/*.jar,pom.xml</earSourceExcludes>, but
> > > it seems Maven just ignores it.
> > >
> > > Here is my pom file:
> > >
> > > <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>
> > >  <parent>
> > >  <groupId>mygroupid</groupId>
> > >  <artifactId>abc</artifactId>
> > >  <version>1.0-SNAPSHOT</version>
> > >  </parent>
> > >  <artifactId>xyz</artifactId>
> > >  <packaging>ear</packaging>
> > >  <name>ear_assembly</name>
> > >
> > >  <dependencies>
> > >    <dependency>
> > >      <groupId>mygroupid</groupId>
> > >      <artifactId>web</artifactId>
> > >      <version>${project.version}</version>
> > >      <type>war</type>
> > >    </dependency>
> > >  </dependencies>
> > >   <build>
> > >      <plugins>
> > >         <plugin>
> > >            <artifactId>maven-ear-plugin</artifactId>
> > >            <configuration>
> > >            <earSourceExcludes>**/*.jar,pom.xml</earSourceExcludes>
> > >            <fileNameMapping/>
> > >               <archive>
> > >                  <manifest>
> > >                     <addClasspath>true</addClasspath>
> > >                  </manifest>
> > >               </archive>
> > >            </configuration>
> > >         </plugin>
> > >      </plugins>
> > >   </build>
> > >
> > > </project>
> > >
> > > Thanks,
> > >
> > > Victor
> > >
> > > ---------------------------------------------------------------------
> > > 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
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


-- 
Large Systems Suck: This rule is 100% transitive. If you build one,
you suck" -- S.Yegge

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


Re: help: can't exclude files from EAR file

Posted by Wayne Fay <wa...@gmail.com>.
There may be another way (better) to do it, but one easy to solve this
is to simply copy and paste the dependencies from your WAR into your
EAR and then change all the scopes to provided.

Wayne

On 10/12/07, Victor Okunev <ve...@gmail.com> wrote:
> I need to bundle the libs in the WAR only. There is just one web
> module in my app.
>
> Victor
>
> On 10/12/07, Wayne Fay <wa...@gmail.com> wrote:
> > Are your libs being bundled in the WAR, as well as the EAR? Or are you
> > making the libs available in your j2ee container's lib directory such
> > that they are shared among several apps?
> >
> > If you don't want the libs bundled in your WAR nor EAR, you should
> > just change the scope to provided.
> >
> > Wayne
> >
> > On 10/12/07, Victor Okunev <ve...@gmail.com> wrote:
> > > Folks,
> > >
> > > I need to build an EAR file composed of just one WAR file using
> > > Maven2. However, in addition to the WAR file, the resulting EAR file
> > > contains all the JARs that the web module has dependencies on, as well
> > > as the pom.xml. How do I exclude everything but WAR file and
> > > application.xml from the EAR file?
> > >
> > > I tried   <earSourceExcludes>**/*.jar,pom.xml</earSourceExcludes>, but
> > > it seems Maven just ignores it.
> > >
> > > Here is my pom file:
> > >
> > > <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>
> > >  <parent>
> > >  <groupId>mygroupid</groupId>
> > >  <artifactId>abc</artifactId>
> > >  <version>1.0-SNAPSHOT</version>
> > >  </parent>
> > >  <artifactId>xyz</artifactId>
> > >  <packaging>ear</packaging>
> > >  <name>ear_assembly</name>
> > >
> > >  <dependencies>
> > >    <dependency>
> > >      <groupId>mygroupid</groupId>
> > >      <artifactId>web</artifactId>
> > >      <version>${project.version}</version>
> > >      <type>war</type>
> > >    </dependency>
> > >  </dependencies>
> > >   <build>
> > >      <plugins>
> > >         <plugin>
> > >            <artifactId>maven-ear-plugin</artifactId>
> > >            <configuration>
> > >            <earSourceExcludes>**/*.jar,pom.xml</earSourceExcludes>
> > >            <fileNameMapping/>
> > >               <archive>
> > >                  <manifest>
> > >                     <addClasspath>true</addClasspath>
> > >                  </manifest>
> > >               </archive>
> > >            </configuration>
> > >         </plugin>
> > >      </plugins>
> > >   </build>
> > >
> > > </project>
> > >
> > > Thanks,
> > >
> > > Victor
> > >
> > > ---------------------------------------------------------------------
> > > 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
> >
> >
>
> ---------------------------------------------------------------------
> 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: help: can't exclude files from EAR file

Posted by Victor Okunev <ve...@gmail.com>.
I need to bundle the libs in the WAR only. There is just one web
module in my app.

Victor

On 10/12/07, Wayne Fay <wa...@gmail.com> wrote:
> Are your libs being bundled in the WAR, as well as the EAR? Or are you
> making the libs available in your j2ee container's lib directory such
> that they are shared among several apps?
>
> If you don't want the libs bundled in your WAR nor EAR, you should
> just change the scope to provided.
>
> Wayne
>
> On 10/12/07, Victor Okunev <ve...@gmail.com> wrote:
> > Folks,
> >
> > I need to build an EAR file composed of just one WAR file using
> > Maven2. However, in addition to the WAR file, the resulting EAR file
> > contains all the JARs that the web module has dependencies on, as well
> > as the pom.xml. How do I exclude everything but WAR file and
> > application.xml from the EAR file?
> >
> > I tried   <earSourceExcludes>**/*.jar,pom.xml</earSourceExcludes>, but
> > it seems Maven just ignores it.
> >
> > Here is my pom file:
> >
> > <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>
> >  <parent>
> >  <groupId>mygroupid</groupId>
> >  <artifactId>abc</artifactId>
> >  <version>1.0-SNAPSHOT</version>
> >  </parent>
> >  <artifactId>xyz</artifactId>
> >  <packaging>ear</packaging>
> >  <name>ear_assembly</name>
> >
> >  <dependencies>
> >    <dependency>
> >      <groupId>mygroupid</groupId>
> >      <artifactId>web</artifactId>
> >      <version>${project.version}</version>
> >      <type>war</type>
> >    </dependency>
> >  </dependencies>
> >   <build>
> >      <plugins>
> >         <plugin>
> >            <artifactId>maven-ear-plugin</artifactId>
> >            <configuration>
> >            <earSourceExcludes>**/*.jar,pom.xml</earSourceExcludes>
> >            <fileNameMapping/>
> >               <archive>
> >                  <manifest>
> >                     <addClasspath>true</addClasspath>
> >                  </manifest>
> >               </archive>
> >            </configuration>
> >         </plugin>
> >      </plugins>
> >   </build>
> >
> > </project>
> >
> > Thanks,
> >
> > Victor
> >
> > ---------------------------------------------------------------------
> > 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
>
>

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


Re: help: can't exclude files from EAR file

Posted by Wayne Fay <wa...@gmail.com>.
Are your libs being bundled in the WAR, as well as the EAR? Or are you
making the libs available in your j2ee container's lib directory such
that they are shared among several apps?

If you don't want the libs bundled in your WAR nor EAR, you should
just change the scope to provided.

Wayne

On 10/12/07, Victor Okunev <ve...@gmail.com> wrote:
> Folks,
>
> I need to build an EAR file composed of just one WAR file using
> Maven2. However, in addition to the WAR file, the resulting EAR file
> contains all the JARs that the web module has dependencies on, as well
> as the pom.xml. How do I exclude everything but WAR file and
> application.xml from the EAR file?
>
> I tried   <earSourceExcludes>**/*.jar,pom.xml</earSourceExcludes>, but
> it seems Maven just ignores it.
>
> Here is my pom file:
>
> <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>
>  <parent>
>  <groupId>mygroupid</groupId>
>  <artifactId>abc</artifactId>
>  <version>1.0-SNAPSHOT</version>
>  </parent>
>  <artifactId>xyz</artifactId>
>  <packaging>ear</packaging>
>  <name>ear_assembly</name>
>
>  <dependencies>
>    <dependency>
>      <groupId>mygroupid</groupId>
>      <artifactId>web</artifactId>
>      <version>${project.version}</version>
>      <type>war</type>
>    </dependency>
>  </dependencies>
>   <build>
>      <plugins>
>         <plugin>
>            <artifactId>maven-ear-plugin</artifactId>
>            <configuration>
>            <earSourceExcludes>**/*.jar,pom.xml</earSourceExcludes>
>            <fileNameMapping/>
>               <archive>
>                  <manifest>
>                     <addClasspath>true</addClasspath>
>                  </manifest>
>               </archive>
>            </configuration>
>         </plugin>
>      </plugins>
>   </build>
>
> </project>
>
> Thanks,
>
> Victor
>
> ---------------------------------------------------------------------
> 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