[ 
http://jira.codehaus.org/browse/MASSEMBLY-420?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=236764#action_236764
 ] 

John Casey edited comment on MASSEMBLY-420 at 9/28/10 2:40 PM:
---------------------------------------------------------------

Creating empty archives was never part of the design of the assembly plugin; it 
was a bug in the plexus-archiver at one point.

If the assembly contains no files, by design it should fail to alert the user 
that something has gone wrong. It's not considered sane to create a 
distribution archive that contains nothing.

For a more detailed discussion about building an assembly at the parent level, 
see: 
http://maven.apache.org/plugins/maven-assembly-plugin/faq.html#module-binaries

and: 
http://maven.apache.org/plugins/maven-assembly-plugin/examples/multimodule/module-binary-inclusion-simple.html


NOTE: Those pages are both in dire need of updating. I've made the changes, but 
will wait to push the new site until the release of this plugin.

So, until that release, those pages will give BAD ADVICE on this topic.

Here is the gist:

{noformat}
If your assembly includes module binaries, those binaries won't be available to 
the assembly plugin except in special cases. This is normally seen when the 
Assembly Plugin is bound to a phase of the standard build lifecycle in the 
parent POM of a multimodule build. It is a result of the way Maven sorts and 
executes the build process for a multimodule project layout.

In a multimodule hierarchy, when a child module declares the parent POM in its 
<parent/> section, Maven interprets this to mean that the parent project's 
build must be completed before the child build can start. This ensures that the 
parent project is in its final form by the time the child needs access to its 
POM information. In cases where the Assembly Plugin is included as part of that 
parent project's build process, it will execute along with everything else as 
part of the parent build - before the child build can start. If the assembly 
descriptor used in that parent build references module binaries, it effectively 
expects the child build to be completed before the assembly is processed. This 
leads to a recursive dependency situation, where the child build depends on the 
parent build to complete before it can start, while the parent build depends on 
the presence of child-module artifacts to complete successfully. Since these 
artifacts are missing, the Assembly Plugin will complain about missing 
artifacts, and the build will fail.

In many cases, you can avoid this problem by adding a new child module whose 
sole purpose is to produce your assembly. In the POM for this new project, add 
dependency definitions for any of the module binaries you had previously 
referenced. This will ensure the new assembly child is built last. Then, move 
your assembly descriptor into this new child module. At this point, you have 
the option of either changing all moduleSet/binaries references to 
dependencySet references, or you can keep the moduleSets and instead set the 
useAllReactorProjects flag to true for each moduleSet.

Obviously, any fileSet or file references you may have in this descriptor may 
need to be adjusted or have the files they reference moved into the new child 
module alongside the descriptor itself.

In cases where you absolutely must use module-binaries references, you should 
create an assembly-child POM mentioned above, then insert 
<useAllReactorProjects>true<useAllReactorProjects> to each of your moduleSet 
sections. Then, bind the assembly in your assembly-child POM (normally to the 
package phase) using the single goal. When you execute the build from the 
top-level POM, Maven should generated your assembly in the new child project.

NOTE: The useAllReactorProjects flag is only available in version 2.2-beta-6 
and higher.
{noformat}

      was (Author: jdcasey):
    Creating empty archives was never part of the design of the assembly 
plugin; it was a bug in the plexus-archiver at one point.

If the assembly contains no files, by design it should fail to alert the user 
that something has gone wrong. It's not considered sane to create a 
distribution archive that contains nothing.

For a more detailed discussion about building an assembly at the parent level, 
see: 
http://maven.apache.org/plugins/maven-assembly-plugin/faq.html#module-binaries

and: 
http://maven.apache.org/plugins/maven-assembly-plugin/examples/multimodule/module-binary-inclusion-simple.html


NOTE: Those pages are both in dire need of updating. I've made the changes, but 
will wait to push the new site until the release of this plugin.

So, until that release, those pages will give BAD ADVICE on this topic.

Here is the gist:

{code:xml}
        <p><b>If your assembly includes module binaries, those binaries won't 
be available to the assembly plugin except in special cases.</b> This is 
normally seen
           when the Assembly Plugin is bound to a phase of the standard build 
lifecycle in the <b>parent POM</b> of a multimodule build.
           It is a result of the way Maven sorts and executes the build process 
for a multimodule project layout.
        </p>
        <p>In a multimodule hierarchy, when a child module declares the parent 
POM in its &lt;parent/&gt; section, Maven interprets this to mean that the 
parent
           project's build must be completed before the child build can start. 
This ensures that the parent project is in its final form by the time the child
           needs access to its POM information. In cases where the Assembly 
Plugin is included as part of that parent project's build process, it will 
execute
           along with everything else as part of the parent build - <b>before 
the child build can start</b>. If the assembly descriptor used in that parent 
build
           references module binaries, it effectively expects the child build 
to be completed <b>before the assembly is processed</b>. This leads to a 
recursive
           dependency situation, where the child build depends on the parent 
build to complete before it can start, while the parent build depends on the 
presence
           of child-module artifacts to complete successfully. Since these 
artifacts are missing, the Assembly Plugin will complain about missing 
artifacts, and
           the build will fail.
        </p>
        <p>In many cases, you can avoid this problem by adding a new child 
module whose sole purpose is to produce your assembly. In the POM for this new 
project,
           add dependency definitions for any of the module binaries you had 
previously referenced. This will ensure the new assembly child is built last.
           Then, move your assembly descriptor into this new child module. At 
this point, you have the option of either changing all moduleSet/binaries 
references 
           to dependencySet references, <b>or you can keep the moduleSets and 
instead set the useAllReactorProjects flag to <i>true</i> for each 
moduleSet.</b>
        </p>
        <p>
           Obviously, any fileSet or file references you may have in this 
descriptor may need
           to be adjusted or have the files they reference moved into the new 
child module alongside the descriptor itself.
        </p>
        <p>In cases where you absolutely must use module-binaries references, 
you should create an assembly-child POM mentioned above, then insert
           
<code>&lt;useAllReactorProjects&gt;true&lt;useAllReactorProjects&gt;</code> to 
each of your <code>moduleSet</code> sections. Then, bind the assembly
           in your assembly-child POM (normally to the <code>package</code> 
phase) using the <code>single</code> goal. When you execute the build from the 
top-level POM,
           Maven should generated your assembly in the new child project.
        </p>
        <p><b>NOTE:</b> The useAllReactorProjects flag is only available in 
version 2.2-beta-6 and higher.</p>
{code}
  
> maven fails when packing parent pom
> -----------------------------------
>
>                 Key: MASSEMBLY-420
>                 URL: http://jira.codehaus.org/browse/MASSEMBLY-420
>             Project: Maven 2.x Assembly Plugin
>          Issue Type: Bug
>    Affects Versions: 2.2-beta-3
>         Environment: Windows Vista
>            Reporter: Karsten Ohme
>            Assignee: John Casey
>            Priority: Blocker
>             Fix For: 2.2-beta-6
>
>
> I have a parent module and multiple sub modules. I must build all submodules 
> manually, because the parent assembly cannot be created.
> I have defined the assembly plugin in the parent.
> [INFO] [assembly:single {execution: make-assembly}]
> [WARNING] Cannot include project artifact: org.foo.bar:j2se:pom:1
> .0.2-SNAPSHOT; it doesn't have an associated file or directory.
> [INFO]
> ------------------------------------------------------------------------
> [ERROR] BUILD ERROR
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Failed to create assembly: Error creating assembly archive
> jar-with-dependencies: You must set at least one file.
> In previous releases it was working.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira


Reply via email to