You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Christian Schulte <cs...@schulte.it> on 2005/11/05 01:00:10 UTC

[m2] multi-module support broken in assembly-plugin ?

Hi,

Could it be that the assembly plugin does not support multi-module 
projects correctly ?
I have the following project structure:

Root
|--Module1
|--Module2
|--Module3

So somewhere in Root's pom.xml I have

<modules>
  <module>Module1</module>
  <module>Module2</module>
  <module>Module3</module>
</modules>

I now want the assembly plugin to build a jar file of all three ModuleX 
jar files and it does not work. When I do mvn assembly:assembly it does 
not use the three modules. If I put

<dependencies>
  <dependency>
     <groupId>groupId</groupId>
     <artifactId>Module1</artifactId>
  </dependcy>
  <dependency>
     <groupId>groupId</groupId>
     <artifactId>Module2</artifactId>
  </dependcy>
  <dependency>
     <groupId>groupId</groupId>
     <artifactId>Module3</artifactId>
  </dependcy>
</dependencies>

into Root's pom.xml Maven complains about cyclic dependencies. So if the 
<modules>...</modules> section already defines the modules as 
dependencies why does the assembly plugin not see them ? If this section 
would not introduce a dependency to the modules why should maven 
complain about the cyclic dependencies ? What is the correct way to use 
the assembly plugin then ?

I looked at the source to see how things are intended to work. If I make 
the following change:

schulte@smtp:~/maven2-cvs/maven-site/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly$ 
svn diff
Index: AbstractUnpackingMojo.java
===================================================================
--- AbstractUnpackingMojo.java  (Revision 330942)
+++ AbstractUnpackingMojo.java  (Arbeitskopie)
@@ -130,7 +130,7 @@

                 String key = artifact.getGroupId() + ":" + 
artifact.getArtifactId() + ":" + artifact.getVersion();

-                if ( !reactorArtifacts.containsKey( key ) && 
!dependencies.containsKey( key ) )
+                if ( !dependencies.containsKey( key ) )
                 {
                     dependencies.put( key, artifact );
                 }


mvn assembly:assembly starts aggregating the contents of the jar files 
of the modules. There is just one thing which then still does not work 
and that are the different manifest files are lost and I get a default 
manifest in the assembled jar file. I definetly need help with this.

-- 
Christian


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


Re: [m2] multi-module support broken in assembly-plugin ?

Posted by Alexandre Poitras <al...@gmail.com>.
I proposed a solution about that problem with the assembly plugin about
aggregating multiple projects. If I have some free time, I try to write it
myself.
http://jira.codehaus.org/browse/MNG-1406

On 11/5/05, Kenney Westerhof <ke...@apache.org> wrote:
>
> On Sat, 5 Nov 2005, Christian Schulte wrote:
>
> > Hi,
> >
> > Could it be that the assembly plugin does not support multi-module
> > projects correctly ?
> > I have the following project structure:
> >
> > Root
> > |--Module1
> > |--Module2
> > |--Module3
> >
> > So somewhere in Root's pom.xml I have
> >
> > <modules>
> > <module>Module1</module>
> > <module>Module2</module>
> > <module>Module3</module>
> > </modules>
> >
> > I now want the assembly plugin to build a jar file of all three ModuleX
> > jar files and it does not work. When I do mvn assembly:assembly it does
> > not use the three modules. If I put
> >
> > <dependencies>
> > <dependency>
> > <groupId>groupId</groupId>
> > <artifactId>Module1</artifactId>
> > </dependcy>
> > <dependency>
> > <groupId>groupId</groupId>
> > <artifactId>Module2</artifactId>
> > </dependcy>
> > <dependency>
> > <groupId>groupId</groupId>
> > <artifactId>Module3</artifactId>
> > </dependcy>
> > </dependencies>
>
> That's the fix allright.
>
> The assembly plugin just works on the current project, it does recurse but
> it will create an assembly for all child projects too if they have the
> assembly plugin configured.
>
> >
> > into Root's pom.xml Maven complains about cyclic dependencies. So if the
> > <modules>...</modules> section already defines the modules as
>
> No, they don't automatically define them as dependencies! You really need
> a dependencies section.
>
> > dependencies why does the assembly plugin not see them ? If this section
>
> See above - they're not dependencies.
>
> > would not introduce a dependency to the modules why should maven
> > complain about the cyclic dependencies ? What is the correct way to use
> > the assembly plugin then ?
>
> The cyclic dependencies are because of another reason. My guess is that
> you have a <dependency> in ModuleX on the root pom. You should remove that
> dependency and just use the <parent> tag - you'll inherit whatever is
> defined in the root pom.
>
> > I looked at the source to see how things are intended to work. If I make
> > the following change:
> >
> > schulte@smtp
> :~/maven2-cvs/maven-site/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly$
> > svn diff
> > Index: AbstractUnpackingMojo.java
> > ===================================================================
> > --- AbstractUnpackingMojo.java (Revision 330942)
> > +++ AbstractUnpackingMojo.java (Arbeitskopie)
> > @@ -130,7 +130,7 @@
> >
> > String key = artifact.getGroupId() + ":" +
> > artifact.getArtifactId() + ":" + artifact.getVersion();
> >
> > - if ( !reactorArtifacts.containsKey( key ) &&
> > !dependencies.containsKey( key ) )
> > + if ( !dependencies.containsKey( key ) )
> > {
> > dependencies.put( key, artifact );
> > }
>
> That code specified that if a <dependency> tag in the assembly descriptor
> was not a reactor project ANd not a dependency, then make it a dependency.
>
> Your patch looks sane to me - something being a reactor project doesn't
> implicate that it's a dependency. But I would have to look at more context
> code to be sure why this was done this way.
>
> > mvn assembly:assembly starts aggregating the contents of the jar files
> > of the modules. There is just one thing which then still does not work
> > and that are the different manifest files are lost and I get a default
> > manifest in the assembled jar file. I definetly need help with this.
>
> Which manifest file should be used? You can't merge them. You'll have to
> specify a new manifest file for the aggregated jar to use.
>
>
> -- Kenney
>
> > --
> > Christian
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
>
> --
> Kenney Westerhof
> http://www.neonics.com
> GPG public key: http://www.gods.nl/~forge/kenneyw.key
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


--
Alexandre Poitras
Québec, Canada

Re: [m2] multi-module support broken in assembly-plugin ?

Posted by Kenney Westerhof <ke...@apache.org>.
On Sat, 5 Nov 2005, Christian Schulte wrote:

> Hi,
>
> Could it be that the assembly plugin does not support multi-module
> projects correctly ?
> I have the following project structure:
>
> Root
> |--Module1
> |--Module2
> |--Module3
>
> So somewhere in Root's pom.xml I have
>
> <modules>
>   <module>Module1</module>
>   <module>Module2</module>
>   <module>Module3</module>
> </modules>
>
> I now want the assembly plugin to build a jar file of all three ModuleX
> jar files and it does not work. When I do mvn assembly:assembly it does
> not use the three modules. If I put
>
> <dependencies>
>   <dependency>
>      <groupId>groupId</groupId>
>      <artifactId>Module1</artifactId>
>   </dependcy>
>   <dependency>
>      <groupId>groupId</groupId>
>      <artifactId>Module2</artifactId>
>   </dependcy>
>   <dependency>
>      <groupId>groupId</groupId>
>      <artifactId>Module3</artifactId>
>   </dependcy>
> </dependencies>

That's the fix allright.

The assembly plugin just works on the current project, it does recurse but
it will create an assembly for all child projects too if they have the
assembly plugin configured.

>
> into Root's pom.xml Maven complains about cyclic dependencies. So if the
> <modules>...</modules> section already defines the modules as

No, they don't automatically define them as dependencies! You really need
a dependencies section.

> dependencies why does the assembly plugin not see them ? If this section

See above - they're not dependencies.

> would not introduce a dependency to the modules why should maven
> complain about the cyclic dependencies ? What is the correct way to use
> the assembly plugin then ?

The cyclic dependencies are because of another reason. My guess is that
you have a <dependency> in ModuleX on the root pom. You should remove that
dependency and just use the <parent> tag - you'll inherit whatever is
defined in the root pom.

> I looked at the source to see how things are intended to work. If I make
> the following change:
>
> schulte@smtp:~/maven2-cvs/maven-site/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly$
> svn diff
> Index: AbstractUnpackingMojo.java
> ===================================================================
> --- AbstractUnpackingMojo.java  (Revision 330942)
> +++ AbstractUnpackingMojo.java  (Arbeitskopie)
> @@ -130,7 +130,7 @@
>
>                  String key = artifact.getGroupId() + ":" +
> artifact.getArtifactId() + ":" + artifact.getVersion();
>
> -                if ( !reactorArtifacts.containsKey( key ) &&
> !dependencies.containsKey( key ) )
> +                if ( !dependencies.containsKey( key ) )
>                  {
>                      dependencies.put( key, artifact );
>                  }

That code specified that if a <dependency> tag in the assembly descriptor
was not a reactor project ANd not a dependency, then make it a dependency.

Your patch looks sane to me - something being a reactor project doesn't
implicate that it's a dependency. But I would have to look at more context
code to be sure why this was done this way.

> mvn assembly:assembly starts aggregating the contents of the jar files
> of the modules. There is just one thing which then still does not work
> and that are the different manifest files are lost and I get a default
> manifest in the assembled jar file. I definetly need help with this.

Which manifest file should be used? You can't merge them. You'll have to
specify a new manifest file for the aggregated jar to use.


-- Kenney

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

--
Kenney Westerhof
http://www.neonics.com
GPG public key: http://www.gods.nl/~forge/kenneyw.key

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


Re: [m2] multi-module support broken in assembly-plugin ?

Posted by Anuerin Diaz <ra...@gmail.com>.
hi,

   i just use the src\main\assembly\dep.xml to manage my assemblies[1]
but i am using the assembly:directory goal to package my artifacts
because i just need to put all artifacts in a certain directory.

   or am i not understanding your problem correctly?

[1] http://maven.apache.org/maven2/guides/mini/guide-assemblies.html

ciao!

On 11/5/05, Christian Schulte <cs...@schulte.it> wrote:
> Hi,
>
> Could it be that the assembly plugin does not support multi-module
> projects correctly ?
> I have the following project structure:
>
> Root
> |--Module1
> |--Module2
> |--Module3
>
> So somewhere in Root's pom.xml I have
>
> <modules>
>   <module>Module1</module>
>   <module>Module2</module>
>   <module>Module3</module>
> </modules>
>
> I now want the assembly plugin to build a jar file of all three ModuleX
> jar files and it does not work. When I do mvn assembly:assembly it does
> not use the three modules. If I put
>
> <dependencies>
>   <dependency>
>      <groupId>groupId</groupId>
>      <artifactId>Module1</artifactId>
>   </dependcy>
>   <dependency>
>      <groupId>groupId</groupId>
>      <artifactId>Module2</artifactId>
>   </dependcy>
>   <dependency>
>      <groupId>groupId</groupId>
>      <artifactId>Module3</artifactId>
>   </dependcy>
> </dependencies>
>
> into Root's pom.xml Maven complains about cyclic dependencies. So if the
> <modules>...</modules> section already defines the modules as
> dependencies why does the assembly plugin not see them ? If this section
> would not introduce a dependency to the modules why should maven
> complain about the cyclic dependencies ? What is the correct way to use
> the assembly plugin then ?
>
> I looked at the source to see how things are intended to work. If I make
> the following change:
>
> schulte@smtp:~/maven2-cvs/maven-site/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly$
> svn diff
> Index: AbstractUnpackingMojo.java
> ===================================================================
> --- AbstractUnpackingMojo.java  (Revision 330942)
> +++ AbstractUnpackingMojo.java  (Arbeitskopie)
> @@ -130,7 +130,7 @@
>
>                  String key = artifact.getGroupId() + ":" +
> artifact.getArtifactId() + ":" + artifact.getVersion();
>
> -                if ( !reactorArtifacts.containsKey( key ) &&
> !dependencies.containsKey( key ) )
> +                if ( !dependencies.containsKey( key ) )
>                  {
>                      dependencies.put( key, artifact );
>                  }
>
>
> mvn assembly:assembly starts aggregating the contents of the jar files
> of the modules. There is just one thing which then still does not work
> and that are the different manifest files are lost and I get a default
> manifest in the assembled jar file. I definetly need help with this.
>
> --
> Christian
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


--

"Programming, an artform that fights back"

Anuerin G. Diaz
Registered Linux User #246176
Friendly Linux Board @ http://mandrivausers.org/index.php
http://capsule.ramfree17.org , when you absolutely have nothing else
better to do

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