1

I'm preparing a workshop where they may be no Internet connection. Because of that, I'd like to provide every dependency/plugin of the project, so attendees can work on it, completely offline.

I've got a basic Maven project with some dependencies and two plugins.

First, I created an alternate local repository:

mvn -Dmaven.repo.local=dependencies dependency:go-offline

Then, I expected the following command to run fine, but it doesn't! And I some mentioned missing plugins are not available in maven central or within the maven distribution:

mvn -o -Dmaven.repo.local=dependencies package

This fail with the following error message:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.6:resources (default-resources) on project XXX: Execution default-resources of goal org.apache.maven.plugins:maven-resources-plugin:2.6:resources failed: Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: The following artifacts could not be resolved: org.apache.maven:maven-profile:jar:2.0.6, org.apache.maven:maven-repository-metadata:jar:2.0.6, org.apache.maven:maven-plugin-registry:jar:2.0.6, classworlds:classworlds:jar:1.1-alpha-2: Cannot access central (https://repo.maven.apache.org/maven2) in offline mode and the artifact org.apache.maven:maven-profile:jar:2.0.6 has not been downloaded from it before.

Any idea how to get these missing bits while creating an alternate local repo? Thanks in advance!

fbiville
  • 8,407
  • 7
  • 51
  • 79

3 Answers3

1

Based on this issue in the plugin's Jira this problem is still not resolved. The best work around so far is to package the project online once, using the custom repository.

mvn -Dmaven.repo.local=dependencies dependency:go-offline

then

mvn -Dmaven.repo.local=dependencies package

and finally

mvn -Dmaven.repo.local=dependencies -o package

If your workshop go farther than deploy, you should check that next goals run fine offline too!

Romain
  • 301
  • 2
  • 7
  • The second step means the attendee first needs to build online. Thanks for linking the issue, though! – fbiville Apr 05 '17 at 13:13
  • Depends what you want to do with the local repository. I expect that you want to share the one you build with the go-offline goal? If so, you can share it after running the initial package goal (done before the workshop of course). No additional dependency should be needed. – Romain Apr 05 '17 at 13:33
1

can you declare pluginManagement for every plugin that is used by your packaging? That should enable downloading when dependency:go-offline is called.

(in addition, this will improve stability for your build, since you'll be sure that changing Maven version won't change plugins versions)

Can you confirm this works? (now, I have ideas to improve this, but won't be available before a few months at least...)

hboutemy
  • 301
  • 2
  • 8
0

The documentation seems to suggest that you need to run:

  mvn dependency:resolve-plugins

Before go-offline

Could you try it?

See: https://people.apache.org/~aramirez/maven-dependency-plugin/go-offline-mojo.html

Aurélien Thieriot
  • 5,853
  • 2
  • 24
  • 25
  • No, based on [link](http://maven.apache.org/plugins/maven-dependency-plugin/usage.html), The dependency:go-offline mojo goal is exactly the same as calling mvn dependency:resolve dependency:resolve-plugins. – Romain Apr 05 '17 at 11:36