annotate content/Maven/deploying-files.md @ 93:2156317e4779

new blog post
author Dirk Olmes <dirk@xanthippe.ping.de>
date Wed, 13 Feb 2019 21:49:27 +0100
parents
children 1d9382b0329b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
93
2156317e4779 new blog post
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
1 Title: Deploying files with maven-deploy-plugin
2156317e4779 new blog post
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
2 Date: 2019-02-11
2156317e4779 new blog post
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
3 Lang: en
2156317e4779 new blog post
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
4
2156317e4779 new blog post
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
5 We recently had an outage of our Nexus instance at work. The file system went corrupt, nexus would not start up properly complaining about a corrupted Orient DB.
2156317e4779 new blog post
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
6
2156317e4779 new blog post
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
7 The blob store was largely left intact. In hindsight I should have tried to rebuild the OrientDB from the blob store using the _Repair - Reconcile component database from blob store_ task. I found out too late while I already had recovered half of our releases from my local maven repository.
2156317e4779 new blog post
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
8
2156317e4779 new blog post
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
9 I went down the more difficult route of re-uploading artifacts from my local Maven repo into Nexus. While you can upload single artifacts through Nexus' web GUI this approach did not scale. Instead, I used the `maven-deploy-plugin` to upload. Each of our artifacts comes with source accompanied, most expose also tests and test sources. So basically an artifact consists of these files:
2156317e4779 new blog post
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
10
2156317e4779 new blog post
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
11 * my-lib-1.0.jar
2156317e4779 new blog post
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
12 * my-lib-1.0.pom
2156317e4779 new blog post
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
13 * my-lib-1.0-sources.jar
2156317e4779 new blog post
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
14 * my-lib-1.0-tests.jar
2156317e4779 new blog post
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
15 * my-lib-1.0-test-sources.jar
2156317e4779 new blog post
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
16
2156317e4779 new blog post
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
17 All these files need to be uploaded together at once. It took me a little while to understand how to build the commandline for the deploy plugin to accomplish this.
2156317e4779 new blog post
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
18
2156317e4779 new blog post
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
19 The `file` parameter takes the main jar. The `pomFile` paramenter taks the pom file. That's easy. The other files have to be specified using a more convoluted format. Each file name has to specify its classifier and its type, appended to the separate `classifiers` and `types` lists. Finally the `files` list must specify the full file names. A look at the example will make more sense:
2156317e4779 new blog post
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
20
2156317e4779 new blog post
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
21 mvn deploy:deploy-file \
2156317e4779 new blog post
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
22 -Dmaven.repo.local=/tmp/maven-repo \
2156317e4779 new blog post
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
23 -Durl=http://nexus.local/repository/releases \
2156317e4779 new blog post
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
24 -DrepositoryId=releases \
2156317e4779 new blog post
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
25 -Dfile=my-lib-1.0.jar \
2156317e4779 new blog post
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
26 -DpomFile=my-lib-1.0.pom \
2156317e4779 new blog post
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
27 -Dclassifiers=sources,tests,test-sources \
2156317e4779 new blog post
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
28 -Dtypes=jar,jar,jar \
2156317e4779 new blog post
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
29 -Dfiles=my-lib-1.0-sources.jar,mylib-1.0-tests.jar,my-lib-1.0-test-sources.jar
2156317e4779 new blog post
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
30
2156317e4779 new blog post
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
31 You may have noticed that I'm specifying a separate local repository to use during the upload. This is because Maven refuses to upload artifacts from the repo it's currently operating on. Simply using a throw-away temporary local repo helps minimize the amount of fiddling around with local files.