You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Christofer Dutz <ch...@c-ware.de> on 2019/03/22 13:12:30 UTC

Using maven-dependency-plugin:unpack in "mvn compile" build

Hi,

we are currently having a little problem with our build.
A user complained about not being able to build with a “mvn compile”.
The reason is that we have one module that builds a web-client (bundled as war) and a server module to which the client is copied.
We are using the maven-dependency-plugin:unpack to unpack the artifact into the server war. This works fine as long as we built to at least the “package” phase.
If the user builds to something before that, the build fails as the pointer to the client pints to a directory instead of an archive.

Is there a way to do some sort of “unpack-or-copy” that copies if it’s just a pre-package phase and does the normal unpack if the archives have been created.

Would be happy to not tell them “just don’t do a `mvn compile` but at least a `mvn package`.


Chris

Re: Using maven-dependency-plugin:unpack in "mvn compile" build

Posted by Christofer Dutz <ch...@c-ware.de>.
Hi Thomas,

thanks for that info ... I had totally forgotten the prepare-package phase ... of course using this would reduce a lot of problems.
I changed our build accordingly. I guess if someone does a "mvn prepare-package" ... well I guess then he's just looking for trouble ;-)

Chris

Am 24.03.19, 18:22 schrieb "Thomas Broyer" <t....@gmail.com>:

    Rule of thumb: in a react build, don't ever use any lifecycle phase prior
    to package, and if you want to skip tests, use -DskipTests or
    -Dmaven.test.skip. Corollary: stick with "package" and "verify" (I consider
    "mvn install" is an anti-pattern).
    BTW, as another rule of thumb, use "processClasses" rather than "compile".
    If you have users that want to do otherwise, i.e. "mvn processClasses" or
    "mvn compile" (or even "mvn test") in a reactor build, then tell them you
    rule/assumption, and let them come in with the workaround ;-)
    
    In your specific case though, maybe you should do the unpacking at a later
    stage, e.g. prepare-package ?
    
    On Sun, Mar 24, 2019 at 11:51 AM Christofer Dutz <ch...@c-ware.de>
    wrote:
    
    > Hi Maxim,
    >
    > unfortunately that doesn't help.
    > The problem is that if we do a "mvn compile" no archiving (jar/war
    > building) is done at all ...
    > Guess what we would need, would be profiles based on the last maven phase
    > being built.
    > So if:
    > - "last phase < package" --> Copy the content without unpacking (as the
    > File reference returned by dependency resolution references the
    > target/classes directory)
    > - "last phase > package" --> Unpack the content (as the File reference
    > returned by dependency resolution references a Jar/war file)
    >
    > Chris
    >
    >
    > Am 22.03.19, 15:02 schrieb "Maxim Solodovnik" <so...@gmail.com>:
    >
    >     Hello Chris,
    >
    >     Maybe <archiveClasses>true</archiveClasses> of maven-war-plugin
    >     can help?
    >
    >     On Fri, 22 Mar 2019 at 20:12, Christofer Dutz <
    > christofer.dutz@c-ware.de>
    >     wrote:
    >
    >     > Hi,
    >     >
    >     > we are currently having a little problem with our build.
    >     > A user complained about not being able to build with a “mvn compile”.
    >     > The reason is that we have one module that builds a web-client
    > (bundled as
    >     > war) and a server module to which the client is copied.
    >     > We are using the maven-dependency-plugin:unpack to unpack the
    > artifact
    >     > into the server war. This works fine as long as we built to at least
    > the
    >     > “package” phase.
    >     > If the user builds to something before that, the build fails as the
    >     > pointer to the client pints to a directory instead of an archive.
    >     >
    >     > Is there a way to do some sort of “unpack-or-copy” that copies if
    > it’s
    >     > just a pre-package phase and does the normal unpack if the archives
    > have
    >     > been created.
    >     >
    >     > Would be happy to not tell them “just don’t do a `mvn compile` but at
    >     > least a `mvn package`.
    >     >
    >     >
    >     > Chris
    >     >
    >
    >
    >     --
    >     WBR
    >     Maxim aka solomax
    >
    >
    >
    


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

Re: Using maven-dependency-plugin:unpack in "mvn compile" build

Posted by Thomas Broyer <t....@gmail.com>.
Rule of thumb: in a react build, don't ever use any lifecycle phase prior
to package, and if you want to skip tests, use -DskipTests or
-Dmaven.test.skip. Corollary: stick with "package" and "verify" (I consider
"mvn install" is an anti-pattern).
BTW, as another rule of thumb, use "processClasses" rather than "compile".
If you have users that want to do otherwise, i.e. "mvn processClasses" or
"mvn compile" (or even "mvn test") in a reactor build, then tell them you
rule/assumption, and let them come in with the workaround ;-)

In your specific case though, maybe you should do the unpacking at a later
stage, e.g. prepare-package ?

On Sun, Mar 24, 2019 at 11:51 AM Christofer Dutz <ch...@c-ware.de>
wrote:

> Hi Maxim,
>
> unfortunately that doesn't help.
> The problem is that if we do a "mvn compile" no archiving (jar/war
> building) is done at all ...
> Guess what we would need, would be profiles based on the last maven phase
> being built.
> So if:
> - "last phase < package" --> Copy the content without unpacking (as the
> File reference returned by dependency resolution references the
> target/classes directory)
> - "last phase > package" --> Unpack the content (as the File reference
> returned by dependency resolution references a Jar/war file)
>
> Chris
>
>
> Am 22.03.19, 15:02 schrieb "Maxim Solodovnik" <so...@gmail.com>:
>
>     Hello Chris,
>
>     Maybe <archiveClasses>true</archiveClasses> of maven-war-plugin
>     can help?
>
>     On Fri, 22 Mar 2019 at 20:12, Christofer Dutz <
> christofer.dutz@c-ware.de>
>     wrote:
>
>     > Hi,
>     >
>     > we are currently having a little problem with our build.
>     > A user complained about not being able to build with a “mvn compile”.
>     > The reason is that we have one module that builds a web-client
> (bundled as
>     > war) and a server module to which the client is copied.
>     > We are using the maven-dependency-plugin:unpack to unpack the
> artifact
>     > into the server war. This works fine as long as we built to at least
> the
>     > “package” phase.
>     > If the user builds to something before that, the build fails as the
>     > pointer to the client pints to a directory instead of an archive.
>     >
>     > Is there a way to do some sort of “unpack-or-copy” that copies if
> it’s
>     > just a pre-package phase and does the normal unpack if the archives
> have
>     > been created.
>     >
>     > Would be happy to not tell them “just don’t do a `mvn compile` but at
>     > least a `mvn package`.
>     >
>     >
>     > Chris
>     >
>
>
>     --
>     WBR
>     Maxim aka solomax
>
>
>

Re: Using maven-dependency-plugin:unpack in "mvn compile" build

Posted by Christofer Dutz <ch...@c-ware.de>.
Hi Maxim,

unfortunately that doesn't help.
The problem is that if we do a "mvn compile" no archiving (jar/war building) is done at all ...
Guess what we would need, would be profiles based on the last maven phase being built.
So if:
- "last phase < package" --> Copy the content without unpacking (as the File reference returned by dependency resolution references the target/classes directory)
- "last phase > package" --> Unpack the content (as the File reference returned by dependency resolution references a Jar/war file)

Chris


Am 22.03.19, 15:02 schrieb "Maxim Solodovnik" <so...@gmail.com>:

    Hello Chris,
    
    Maybe <archiveClasses>true</archiveClasses> of maven-war-plugin
    can help?
    
    On Fri, 22 Mar 2019 at 20:12, Christofer Dutz <ch...@c-ware.de>
    wrote:
    
    > Hi,
    >
    > we are currently having a little problem with our build.
    > A user complained about not being able to build with a “mvn compile”.
    > The reason is that we have one module that builds a web-client (bundled as
    > war) and a server module to which the client is copied.
    > We are using the maven-dependency-plugin:unpack to unpack the artifact
    > into the server war. This works fine as long as we built to at least the
    > “package” phase.
    > If the user builds to something before that, the build fails as the
    > pointer to the client pints to a directory instead of an archive.
    >
    > Is there a way to do some sort of “unpack-or-copy” that copies if it’s
    > just a pre-package phase and does the normal unpack if the archives have
    > been created.
    >
    > Would be happy to not tell them “just don’t do a `mvn compile` but at
    > least a `mvn package`.
    >
    >
    > Chris
    >
    
    
    -- 
    WBR
    Maxim aka solomax
    


Re: Using maven-dependency-plugin:unpack in "mvn compile" build

Posted by Maxim Solodovnik <so...@gmail.com>.
Hello Chris,

Maybe <archiveClasses>true</archiveClasses> of maven-war-plugin
can help?

On Fri, 22 Mar 2019 at 20:12, Christofer Dutz <ch...@c-ware.de>
wrote:

> Hi,
>
> we are currently having a little problem with our build.
> A user complained about not being able to build with a “mvn compile”.
> The reason is that we have one module that builds a web-client (bundled as
> war) and a server module to which the client is copied.
> We are using the maven-dependency-plugin:unpack to unpack the artifact
> into the server war. This works fine as long as we built to at least the
> “package” phase.
> If the user builds to something before that, the build fails as the
> pointer to the client pints to a directory instead of an archive.
>
> Is there a way to do some sort of “unpack-or-copy” that copies if it’s
> just a pre-package phase and does the normal unpack if the archives have
> been created.
>
> Would be happy to not tell them “just don’t do a `mvn compile` but at
> least a `mvn package`.
>
>
> Chris
>


-- 
WBR
Maxim aka solomax