You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Jeremie BOUSQUET <je...@gmail.com> on 2009/12/02 13:06:33 UTC

Issue with assembly plugin executions and phase binding (prepare-package)

Hello,

I have some questions about assembly and inheritance...
Purpose is to generate a tar.gz archive, containing a text file with the
list of checksums of the tar.gz content (excluding the checksums file itself
of course).
So the wanted order of execution would be :
- call assembly plugin with "directory-single" to generate folder
(prepare-package)
- call antrun plugin to generate checksums file from and in previous folder
(prepare-package)
- call assembly plugin with "single" to create final archive file
(package)

Antrun plugin is located first in list of plugins, and is binded to phase
"package", goal "run".

My assembly plugin is next and configured with the following executions :

<execution>
  <id>prepare-checksums</id>
  <phase>prepare-package</phase>
  <goals><goal>directory-single</goal></goals>
  <configuration>
    <descriptorRefs><descriptorRef>tar-gz</descriptorRef></descriptorRefs>
  </configuration>
</execution>
<execution>
  <phase>package</phase>
  <goals><goal>single</goal></goals>
  <configuration>

<descriptorRefs><descriptorRef>tar-gz-from-dir</descriptorRef></descriptorRefs>
  </configuration>
</execution>

The parent of this pom just declares assembly plugin and version, binding
the default execution to phase package and goal single, overloaded in this
pom.

If I bind the first execution (prepare-checksums) to "directory-single", the
following error occur :

[INFO] Error creating assembly: Error adding file
'com.gemalto.europetelcosoft.projects.country.customer.w_project_sample:SayHello:jar:1.0-SNAPSHOT'
to archive: Z:\MKS\CUBv2\Dev\sample-project-2.0.1\SayHello\target\classes
isn't a file.

This is not occurring only in m2eclipse, but in maven 2.2.1 command line
also.

The workaround I found, was to configure my assembly like this :

<execution>
  <id>prepare-checksums</id>
  <phase>package</phase>
  <goals><goal>directory-single</goal></goals>
  <configuration>
    <descriptorRefs><descriptorRef>tar-gz</descriptorRef></descriptorRefs>
  </configuration>
</execution>
<execution>
  <phase>package</phase>
  <goals><goal>assembly</goal></goals>
  <configuration>

<descriptorRefs><descriptorRef>tar-gz-from-dir</descriptorRef></descriptorRefs>
  </configuration>
</execution>

And configure antrun to be bound to package phase (and located after
assembly plugin).

So the execution becomes :
1- [assembly:single {execution: default}] generates the .tar.gz
2- [assembly:directory-single {execution: prepare-checksums}] generate
content folder
3- [antrun:run {execution: generate-checksum}] generates checksums the
checksum file
4- [assembly:assembly {execution: default}] generates tar.gz a second time
5- [assembly:single {execution: default}] generates tar.gz a third time
6- [assembly:directory-single {execution: prepare-checksums}] again
7- [antrun:run {execution: generate-checksum}]

I believe step 4 is the beginning of the forked life-cycle caused by goal
"assembly". Then all package phase is re-executed. I believe also that
"default" executions of "assembly:single" come from the parent pom, while
"default" executions of "assembly:assembly" come from this pom. Strangely,
it seems these default executions are not overloaded but executed twice,
maybe because goal is different. That being so, it's not possible to use
"skipAssembly" on the child pom for the "assembly:single", because you're
not permitted to declare the same execution twice in the same pom (even
though both are executed, it's a bit strange).
As expected, removing the assembly plugin declaration in the parent removes
steps 1, 5 and 6.

So I see 2 problems here, and would be grateful to hear any comments :
- why isn't it possible to bind "assembly:directory-single" to another phase
than "package" ?
- why the default execution is not inherited the same way named executions
are ? Why Maven would consider 2 different "default" executions in parent
and child only because goal is different ? I would expect the child to
impose it's declared goal.


I'm using Maven 2.2.1 command-line.

Thanks for help,
Jeremie

Re: Issue with assembly plugin executions and phase binding (prepare-package)

Posted by JeremieB <je...@gmail.com>.
SOLVED

Ok I understood my mistake ... The error was normal, as it was bound to a
phase before package, my assembly wasn't able to found the jar file
generated during ... package. So the error, not related to directory-single.

So I could simply remove the error by doing the following bindings in this
order :
- jar:jar bound to prepare-package
- antrun:run bound to package
- assembly:directory-single bound to prepare-package
- assembly:single bound to package

So when launching "mvn package", everything is generated at the right time
and in the right place :)
The result, of course, is a bit convoluted and complex... :/ And I hope that
binding "jar" to another phase will not have unexpected side-effects.

-- 
View this message in context: http://old.nabble.com/Issue-with-assembly-plugin-executions-and-phase-binding--%28prepare-package%29-tp26607839p26792351.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: Issue with assembly plugin executions and phase binding (prepare-package)

Posted by JeremieB <je...@gmail.com>.
In fact, my solution does not work at all ...

My package is correctly generated with wanted files generated by antrun
inside of it, but I believe as I use goal "assembly" instead of "single",
the related tar.gz is not attached and so not deployed.

I see the following logs :
"[WARNING] Removing: assembly from forked lifecycle, to prevent recursive
invocation"

So it's not usable, as I want this file to be deployed as it was.

Is there any way to achieve the following order of operations in a pom ? :
- assembly:directory-single to generate a folder
- antrun:run to generate checksums against it
- assembly:single to package final tar.gz archive

I don't want to achieve this in multiple modules, as it is supposed to keep
simple and to become the default for our module archetypes ... But it seems
impossible to put something else between two assembly executions.
-- 
View this message in context: http://old.nabble.com/Issue-with-assembly-plugin-executions-and-phase-binding--%28prepare-package%29-tp26607839p26791178.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