You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Mark Raynsford <or...@io7m.com.INVALID> on 2018/10/21 18:02:10 UTC

Copying dependencies (including reactor modules)

Hello.

I'd like to, for an arbitrary project (in other words, a project for
which I cannot edit the pom.xml files), copy the project's artifacts
and the project's dependency artifacts into a directory.

The maven-dependency-plugin copy-dependencies goal *nearly* does this,
but it'll fail as soon as it's asked to copy an artifact from the
reactor. For example, if I pick one of my projects at random and run:

$ cd git/com.github/io7m/jregions
$ mvn dependency:copy-dependencies -DincludeScope=runtime \
  -DoutputDirectory=/tmp/out/

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] 
[INFO] com.io7m.jregions                                                  [pom]
[INFO] com.io7m.jregions.core                                             [jar]
[INFO] com.io7m.jregions.generators                                       [jar]
[INFO] com.io7m.jregions.documentation                                    [jar]
[INFO] com.io7m.jregions.tests                                            [jar]
[INFO] 
[INFO] ----------------< com.io7m.jregions:com.io7m.jregions >-----------------
[INFO] Building com.io7m.jregions 2.1.0-SNAPSHOT                          [1/5]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO] 
[INFO] --- maven-dependency-plugin:3.1.0:copy-dependencies (default-cli) @ com.io7m.jregions ---
[INFO] 
[INFO] --------------< com.io7m.jregions:com.io7m.jregions.core >--------------
[INFO] Building com.io7m.jregions.core 2.1.0-SNAPSHOT                     [2/5]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-dependency-plugin:3.1.0:copy-dependencies (default-cli) @ com.io7m.jregions.core ---
[INFO] com.io7m.junreachable:com.io7m.junreachable.core:jar:2.1.1 already exists in destination.
[INFO] com.io7m.jaffirm:com.io7m.jaffirm.core:jar:2.0.0 already exists in destination.
[INFO] 
[INFO] -----------< com.io7m.jregions:com.io7m.jregions.generators >-----------
[INFO] Building com.io7m.jregions.generators 2.1.0-SNAPSHOT               [3/5]
[INFO] --------------------------------[ jar ]---------------------------------
Downloading from apache-snapshots-repo: https://repository.apache.org/content/repositories/snapshots/com/io7m/jregions/com.io7m.jregions.core/2.1.0-SNAPSHOT/maven-metadata.xml
Downloading from sonatype-snapshots-repo: https://oss.sonatype.org/content/repositories/snapshots/com/io7m/jregions/com.io7m.jregions.core/2.1.0-SNAPSHOT/maven-metadata.xml
Downloading from apache-snapshots-repo: https://repository.apache.org/content/repositories/snapshots/com/io7m/jregions/com.io7m.jregions.core/2.1.0-SNAPSHOT/com.io7m.jregions.core-2.1.0-SNAPSHOT.jar
Downloading from sonatype-snapshots-repo: https://oss.sonatype.org/content/repositories/snapshots/com/io7m/jregions/com.io7m.jregions.core/2.1.0-SNAPSHOT/com.io7m.jregions.core-2.1.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] com.io7m.jregions 2.1.0-SNAPSHOT ................... SUCCESS [  1.008 s]
[INFO] com.io7m.jregions.core ............................. SUCCESS [  0.212 s]
[INFO] com.io7m.jregions.generators ....................... FAILURE [  1.921 s]
[INFO] com.io7m.jregions.documentation .................... SKIPPED
[INFO] com.io7m.jregions.tests 2.1.0-SNAPSHOT ............. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.669 s
[INFO] Finished at: 2018-10-21T18:59:31+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project com.io7m.jregions.generators: Could not resolve dependencies for project com.io7m.jregions:com.io7m.jregions.generators:jar:2.1.0-SNAPSHOT: Could not find artifact com.io7m.jregions:com.io7m.jregions.core:jar:2.1.0-SNAPSHOT in apache-snapshots-repo (https://repository.apache.org/content/repositories/snapshots) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :com.io7m.jregions.generators

Is there a way to do this? My goal is to be able to type:

$ cd git/com.github/io7m/jregions
$ mvn magic-copier:copy -DoutputDirectory=/tmp/out

... and end up with all of the project's runtime artifacts, and the
transitive runtime-scoped dependencies of the project, in /tmp/out.

I'm not opposed to writing a custom plugin to do this, but I'd prefer
to avoid that if possible.

-- 
Mark Raynsford | http://www.io7m.com


Re: Copying dependencies (including reactor modules)

Posted by Mark Raynsford <or...@io7m.com.INVALID>.
OK, so I've apparently run into a dead end with this (which I find
pretty mind-blowing - this should be utterly trivial to accomplish).

The maven-dependency-plugin approach would work, except that it'll fail
due to trying to resolve reactor modules from the repository - even if
those modules are explicitly excluded via the various configuration
properties.

The maven-assembly-plugin approach would presumably work, except that
the plugin really requires various bits of POM configuration to work. I
attempted to patch the plugin to accept an output directory and a
descriptor file via properties, but it seems that the output directory
in particular is not so easy to override (it defaults to
${project.build.outputDirectory} and adding a property to override that
appears not to work).

Am I really going to have to write a whole new plugin just to get the
transitive closure of jar files that make up a given project?

-- 
Mark Raynsford | http://www.io7m.com


Re: Copying dependencies (including reactor modules)

Posted by matteosilv <ma...@gmail.com>.
I don't need to build the reactor project, i just need the
maven-dependency-plugin, with the task dependency:copy-dependencies to
download in a specific folder, its dependencies, but only the external ones,
excluding other projects that may be in the reactor.

E.g.

A depends on EXT.1 EXT.2 and B

B depends on EXT.3 and

if i run the task on A but B was not installed before in the local repo, it
fails, even if i try to exclude B, because is going to check the transitive
dependencies of B, i suppose. I could try to exclude transitive
dependencies, but, even if it works,  this would exclude also transitive
dependencies of EXT.1 and EXT.2 that i need.






--
Sent from: http://maven.40175.n5.nabble.com/Maven-Users-f40176.html

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


Re: Copying dependencies (including reactor modules)

Posted by Mark Raynsford <or...@io7m.com.INVALID>.
'Ello.

On 2018-12-06T03:29:43 -0700
matteosilv <ma...@gmail.com> wrote:

> This is the exact same behavior i need to acomplish, but i can't do it after
> package phase, because i need the dependencies (excluding the ones that are
> projects in my multi-module build) in a specific folder in order to run a
> development server.

As part of a test suite?

> It's pretty weird imho, that, when excluding a groupId, the plugin still
> tries to download dependencies with that groupId, even if later it is going
> to exclude them!

Which plugin are you referring to here?

-- 
Mark Raynsford | http://www.io7m.com


Re: Copying dependencies (including reactor modules)

Posted by matteosilv <ma...@gmail.com>.
This is the exact same behavior i need to acomplish, but i can't do it after
package phase, because i need the dependencies (excluding the ones that are
projects in my multi-module build) in a specific folder in order to run a
development server.

It's pretty weird imho, that, when excluding a groupId, the plugin still
tries to download dependencies with that groupId, even if later it is going
to exclude them!



--
Sent from: http://maven.40175.n5.nabble.com/Maven-Users-f40176.html

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


Re: Copying dependencies (including reactor modules)

Posted by Mark Raynsford <or...@io7m.com.INVALID>.
I've put together a small plugin to address this issue:

https://github.com/io7m/halite

-- 
Mark Raynsford | http://www.io7m.com


Re: Copying dependencies (including reactor modules)

Posted by Mark Raynsford <or...@io7m.com.INVALID>.
On 2018-10-21T22:27:28 +0200
mark <mc...@gmail.com> wrote:
> 
> I'd look into a packaging plugin like m-assembly-p with a "dir" format 
> and not a dependency gathering plugin because project artifacts are not 
> dependencies
> 
> https://maven.apache.org/plugins/maven-assembly-plugin/

'Ello.

Thanks for the suggestion. Unfortunately, the Assembly plugin seems to
be a no-go because it's not possible to specify a descriptor file on
the command line via a property. It has to be specified in a POM file
somewhere.

-- 
Mark Raynsford | http://www.io7m.com


Re: Copying dependencies (including reactor modules)

Posted by mark <mc...@gmail.com>.
On 10/21/18 8:02 PM, Mark Raynsford wrote:
> Hello.
>
> I'd like to, for an arbitrary project (in other words, a project for
> which I cannot edit the pom.xml files), copy the project's artifacts
> and the project's dependency artifacts into a directory.
>
> The maven-dependency-plugin copy-dependencies goal *nearly* does this,
> but it'll fail as soon as it's asked to copy an artifact from the
> reactor. For example, if I pick one of my projects at random and run:
>
> $ cd git/com.github/io7m/jregions
> $ mvn dependency:copy-dependencies -DincludeScope=runtime \
>    -DoutputDirectory=/tmp/out/

I'd look into a packaging plugin like m-assembly-p with a "dir" format 
and not a dependency gathering plugin because project artifacts are not 
dependencies

https://maven.apache.org/plugins/maven-assembly-plugin/



--
Disclaimer;
This message is just a reflection of what I thought at the time of 
sending. The message may contain information that is not intended for 
you or that you don't understand.