Copying dependencies (including reactor modules)

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Copying dependencies (including reactor modules)

Mark Raynsford-3
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


attachment0 (235 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Copying dependencies (including reactor modules)

Mark Prins
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.


Reply | Threaded
Open this post in threaded view
|

Re: Copying dependencies (including reactor modules)

Mark Raynsford-3
On 2018-10-21T22:27:28 +0200
mark <[hidden email]> 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


attachment0 (235 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Copying dependencies (including reactor modules)

Mark Raynsford-3
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


attachment0 (235 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Copying dependencies (including reactor modules)

Mark Raynsford-3
In reply to this post by Mark Raynsford-3
I've put together a small plugin to address this issue:

https://github.com/io7m/halite

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


attachment0 (235 bytes) Download Attachment