maven-cli 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/.gitlab-ci.yml +24 -0
- data/.rspec +2 -0
- data/CHANGELOG +7 -0
- data/CONTRIBUTING.md +38 -0
- data/Gemfile +4 -0
- data/LICENSE +202 -0
- data/README.md +64 -0
- data/Rakefile +22 -0
- data/bin/maven-cli +26 -0
- data/lib/mavencli.rb +31 -0
- data/lib/mavencli/cli.rb +70 -0
- data/lib/mavencli/downloader.rb +74 -0
- data/lib/mavencli/version.rb +20 -0
- data/maven-cli.gemspec +48 -0
- data/spec/files/maven-metadata.xml +36 -0
- data/spec/mavencli/cli_spec.rb +80 -0
- data/spec/mavencli/downloader_spec.rb +91 -0
- data/spec/mavencli/stubs/servers_stubs.rb +64 -0
- data/spec/mavencli_spec.rb +7 -0
- data/spec/spec_helper.rb +45 -0
- metadata +242 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: a7477c96b8ce0bd10f2e0fecc3cbe6c953da3d68
|
|
4
|
+
data.tar.gz: 1e4423fc97b285e9ab7ba75f1b61d56e124f0739
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: da11e072a7e428db945c5ca3dc2b11e521a658cfa406e0e9d4ae1baecd074c3e9f090a0bdbf95201385c54dcfb9ebda50c911522a70247cd724ed0888e2324af
|
|
7
|
+
data.tar.gz: 73b0587485728a7ad32132a8534197235005af5525840a600d997eb99dd4060195614cf702650482140b37750d004938d7cefa8b7e5d560ef5dc78dcf4d10f33
|
data/.gitignore
ADDED
data/.gitlab-ci.yml
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
image: sbernard/arch-kitchen-docker
|
|
2
|
+
|
|
3
|
+
rubocop:
|
|
4
|
+
script:
|
|
5
|
+
- rubocop
|
|
6
|
+
|
|
7
|
+
lines_length:
|
|
8
|
+
script:
|
|
9
|
+
- >
|
|
10
|
+
curl https://gitlab.com/s4m/checks/raw/master/check_lines_length.sh |
|
|
11
|
+
bash
|
|
12
|
+
|
|
13
|
+
git_history:
|
|
14
|
+
script:
|
|
15
|
+
- >
|
|
16
|
+
curl https://gitlab.com/s4m/checks/raw/master/check_git_history.sh |
|
|
17
|
+
bash
|
|
18
|
+
|
|
19
|
+
before_script:
|
|
20
|
+
- bundle install
|
|
21
|
+
|
|
22
|
+
rspec:
|
|
23
|
+
script:
|
|
24
|
+
- rspec
|
data/.rspec
ADDED
data/CHANGELOG
ADDED
data/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
Contributing
|
|
2
|
+
------------
|
|
3
|
+
|
|
4
|
+
You are more than welcome to submit issues and merge requests to this project.
|
|
5
|
+
|
|
6
|
+
### Tests
|
|
7
|
+
|
|
8
|
+
Your commits must not break any tests.
|
|
9
|
+
|
|
10
|
+
### Commits format
|
|
11
|
+
|
|
12
|
+
Your commits must pass `git log --check` and messages should be formated
|
|
13
|
+
like this (based on this excellent
|
|
14
|
+
[post](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)):
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
Summarize change in 50 characters or less
|
|
18
|
+
|
|
19
|
+
Provide more detail after the first line. Leave one blank line below the
|
|
20
|
+
summary and wrap all lines at 72 characters or less.
|
|
21
|
+
|
|
22
|
+
If the change fixes an issue, leave another blank line after the final
|
|
23
|
+
paragraph and indicate which issue is fixed in the specific format
|
|
24
|
+
below.
|
|
25
|
+
|
|
26
|
+
Fix #42
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Also do your best to factor commits appropriately, ie not too large with
|
|
30
|
+
unrelated things in the same commit, and not too small with the same small
|
|
31
|
+
change applied N times in N different commits. If there was some accidental
|
|
32
|
+
reformatting or whitespace changes during the course of your commits, please
|
|
33
|
+
rebase them away before submitting the MR.
|
|
34
|
+
|
|
35
|
+
### Files
|
|
36
|
+
|
|
37
|
+
All files must be 80 columns width formatted (actually 79), exception only
|
|
38
|
+
when it is really not possible.
|
data/Gemfile
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright (c) 2016 Sam4Mobile
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
data/README.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
MavenCLI
|
|
2
|
+
========
|
|
3
|
+
|
|
4
|
+
Simple maven cli tool.
|
|
5
|
+
|
|
6
|
+
Installation
|
|
7
|
+
------------
|
|
8
|
+
|
|
9
|
+
Install as a gem:
|
|
10
|
+
|
|
11
|
+
$ gem install maven-cli
|
|
12
|
+
|
|
13
|
+
Usage
|
|
14
|
+
-----
|
|
15
|
+
|
|
16
|
+
You can have an interactive help using:
|
|
17
|
+
|
|
18
|
+
$ maven-cli help
|
|
19
|
+
|
|
20
|
+
Examples
|
|
21
|
+
--------
|
|
22
|
+
|
|
23
|
+
To download a jar from maven repository (http://repo.maven.apache.org/maven2)
|
|
24
|
+
|
|
25
|
+
$ maven-cli download <group> <artifact> <version>
|
|
26
|
+
|
|
27
|
+
For instance: `maven-cli download com.google.guava guava 19.0`
|
|
28
|
+
|
|
29
|
+
To download a jar from a non standard repository
|
|
30
|
+
|
|
31
|
+
$ maven-cli download <group> <artifact> <version> -r <repository>
|
|
32
|
+
|
|
33
|
+
To download a jar from maven repository and save it to file
|
|
34
|
+
|
|
35
|
+
$ maven-cli download <group> <artifact> <version> -o <outfile>
|
|
36
|
+
|
|
37
|
+
Contributing
|
|
38
|
+
------------
|
|
39
|
+
|
|
40
|
+
Please read carefully [CONTRIBUTING.md](CONTRIBUTING.md) before making a merge
|
|
41
|
+
request.
|
|
42
|
+
|
|
43
|
+
License and Author
|
|
44
|
+
------------------
|
|
45
|
+
|
|
46
|
+
- Author:: DPS Team (<dps.team@s4m.io>)
|
|
47
|
+
- Author:: Samuel Bernard (<samuel.bernard@s4m.io>)
|
|
48
|
+
- Author:: Richard Delaplace (<richard.delaplace@s4m.io>)
|
|
49
|
+
|
|
50
|
+
```text
|
|
51
|
+
Copyright (c) 2016 Sam4Mobile
|
|
52
|
+
|
|
53
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
54
|
+
you may not use this file except in compliance with the License.
|
|
55
|
+
You may obtain a copy of the License at
|
|
56
|
+
|
|
57
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
58
|
+
|
|
59
|
+
Unless required by applicable law or agreed to in writing, software
|
|
60
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
61
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
62
|
+
See the License for the specific language governing permissions and
|
|
63
|
+
limitations under the License.
|
|
64
|
+
```
|
data/Rakefile
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2016 Sam4Mobile
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
#
|
|
16
|
+
|
|
17
|
+
require 'bundler/gem_tasks'
|
|
18
|
+
require 'rspec/core/rake_task'
|
|
19
|
+
|
|
20
|
+
RSpec::Core::RakeTask.new(:spec) { |task| task.verbose = false }
|
|
21
|
+
|
|
22
|
+
task default: :spec
|
data/bin/maven-cli
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/ruby
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2016 Sam4Mobile
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
#
|
|
17
|
+
|
|
18
|
+
# Trap interrupts to quit cleanly. See
|
|
19
|
+
# https://twitter.com/mitchellh/status/283014103189053442
|
|
20
|
+
Signal.trap('INT') { exit 1 }
|
|
21
|
+
|
|
22
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), %w(.. lib))
|
|
23
|
+
require 'rubygems'
|
|
24
|
+
require 'mavencli'
|
|
25
|
+
|
|
26
|
+
MavenCLI.start
|
data/lib/mavencli.rb
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/urs/bin/ruby
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2016 Sam4Mobile
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
#
|
|
17
|
+
|
|
18
|
+
# Maven CLI class
|
|
19
|
+
module MavenCLI
|
|
20
|
+
class << self
|
|
21
|
+
Dir[File.join(File.dirname(__FILE__), '*', '*.rb')].each do |file|
|
|
22
|
+
require file
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def start
|
|
26
|
+
MavenCLI::CLI.start(ARGV)
|
|
27
|
+
rescue => e
|
|
28
|
+
puts e
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
data/lib/mavencli/cli.rb
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
#!/usr/bin/ruby
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2016 Sam4Mobile
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
#
|
|
17
|
+
|
|
18
|
+
require 'thor'
|
|
19
|
+
|
|
20
|
+
module MavenCLI
|
|
21
|
+
# Simple CLI for maven_download
|
|
22
|
+
class CLI < Thor
|
|
23
|
+
desc 'version', 'Print maven-cli current version'
|
|
24
|
+
def version
|
|
25
|
+
puts "MavenCLI version #{MavenCLI::VERSION}"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
desc 'download GROUP ARTIFACT VERSION [options]', 'Download an artifact'
|
|
29
|
+
option(
|
|
30
|
+
:repository,
|
|
31
|
+
aliases: ['-r'],
|
|
32
|
+
default: 'https://repo.maven.apache.org/maven2',
|
|
33
|
+
desc: 'Requested repository. For exemple, http://myserver.com/myrepo'
|
|
34
|
+
)
|
|
35
|
+
option(
|
|
36
|
+
:classifier,
|
|
37
|
+
aliases: ['-c'],
|
|
38
|
+
desc: 'Classifier of the requested artifact.'
|
|
39
|
+
)
|
|
40
|
+
option(
|
|
41
|
+
:packaging,
|
|
42
|
+
aliases: ['-p'],
|
|
43
|
+
default: 'jar',
|
|
44
|
+
desc: 'Packaging of the requested artifact.'
|
|
45
|
+
)
|
|
46
|
+
option(
|
|
47
|
+
:output_file,
|
|
48
|
+
aliases: ['-o'],
|
|
49
|
+
desc: 'Output file.'
|
|
50
|
+
)
|
|
51
|
+
option(
|
|
52
|
+
:quiet,
|
|
53
|
+
aliases: ['-q'],
|
|
54
|
+
type: :boolean,
|
|
55
|
+
default: false,
|
|
56
|
+
desc: 'Silently do the job'
|
|
57
|
+
)
|
|
58
|
+
option(
|
|
59
|
+
:simulation,
|
|
60
|
+
aliases: ['-s'],
|
|
61
|
+
type: :boolean,
|
|
62
|
+
default: false,
|
|
63
|
+
desc: 'Simulation mode. Do nothing'
|
|
64
|
+
)
|
|
65
|
+
def download(group, artifact, version)
|
|
66
|
+
downloader = MavenCLI::Downloader.new(group, artifact, version, options)
|
|
67
|
+
downloader.download
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
#!/usr/bin/ruby
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2016 Sam4Mobile
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
#
|
|
17
|
+
|
|
18
|
+
require 'faraday'
|
|
19
|
+
require 'uri'
|
|
20
|
+
require 'xmlsimple'
|
|
21
|
+
|
|
22
|
+
module MavenCLI
|
|
23
|
+
# This is a simple file downloader class.
|
|
24
|
+
class Downloader
|
|
25
|
+
def initialize(group, artifact, version, opts)
|
|
26
|
+
path = "#{group.tr('.', '/')}/#{artifact}/#{version}"
|
|
27
|
+
artifact_name = filename(artifact, version, opts, path)
|
|
28
|
+
@target = "#{opts['repository']}/#{path}/#{artifact_name}"
|
|
29
|
+
@outfile = opts['output_file'].nil? ? artifact_name : opts['output_file']
|
|
30
|
+
@quiet = opts['quiet']
|
|
31
|
+
@simulation = opts['simulation']
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def download
|
|
35
|
+
File.write(@outfile, http_get(@target)) unless @simulation
|
|
36
|
+
puts "#{@outfile} has been Downloaded." unless @quiet
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
private
|
|
40
|
+
|
|
41
|
+
def filename(artifact, version, opts, path)
|
|
42
|
+
name = "#{artifact}-#{version.split('-').first}"
|
|
43
|
+
if version.include? 'SNAPSHOT'
|
|
44
|
+
xml = http_get("#{opts['repository']}/#{path}/maven-metadata.xml")
|
|
45
|
+
name += "-#{timestamp(xml)}-#{buildnumber(xml)}"
|
|
46
|
+
end
|
|
47
|
+
name += "-#{opts['classifier']}" unless opts['classifier'].nil?
|
|
48
|
+
name += ".#{opts['packaging']}"
|
|
49
|
+
name
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def timestamp(xml)
|
|
53
|
+
versioning_node = XmlSimple.xml_in(xml)['versioning'].first
|
|
54
|
+
snapshot_node = versioning_node['snapshot'].first
|
|
55
|
+
snapshot_node['timestamp'].first
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def buildnumber(xml)
|
|
59
|
+
versioning_node = XmlSimple.xml_in(xml)['versioning'].first
|
|
60
|
+
snapshot_node = versioning_node['snapshot'].first
|
|
61
|
+
snapshot_node['buildNumber'].first
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def http_get(url)
|
|
65
|
+
conn = Faraday.new
|
|
66
|
+
conn.ssl.verify = false if URI.parse(url).scheme == 'https'
|
|
67
|
+
res = conn.get(url)
|
|
68
|
+
unless res.success?
|
|
69
|
+
raise "Unable to download #{url}: Status: #{res.status}"
|
|
70
|
+
end
|
|
71
|
+
res.body
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/usr/bin/ruby
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2016 Sam4Mobile
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
#
|
|
17
|
+
|
|
18
|
+
module MavenCLI
|
|
19
|
+
VERSION = '1.0.0'.freeze
|
|
20
|
+
end
|
data/maven-cli.gemspec
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2016 Sam4Mobile
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
#
|
|
16
|
+
|
|
17
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
18
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
19
|
+
require 'mavencli/version'
|
|
20
|
+
|
|
21
|
+
Gem::Specification.new do |s|
|
|
22
|
+
s.name = 'maven-cli'
|
|
23
|
+
s.version = MavenCLI::VERSION
|
|
24
|
+
s.authors = ['Samuel Bernard', 'Richard Delaplace']
|
|
25
|
+
s.email = 'dps.team@s4m.io'
|
|
26
|
+
s.license = 'Apache-2.0'
|
|
27
|
+
|
|
28
|
+
s.summary = 'Tool to interact with Maven repositories with CLI'
|
|
29
|
+
s.description = IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
|
30
|
+
s.homepage = 'https://gitlab.com/s4m-gems/maven-cli'
|
|
31
|
+
|
|
32
|
+
s.files = `git ls-files`.lines.map(&:chomp)
|
|
33
|
+
s.bindir = 'bin'
|
|
34
|
+
s.executables = `git ls-files bin/*`.lines.map do |exe|
|
|
35
|
+
File.basename(exe.chomp)
|
|
36
|
+
end
|
|
37
|
+
s.require_paths = ['lib']
|
|
38
|
+
|
|
39
|
+
s.add_development_dependency 'bundler', '~> 1.12'
|
|
40
|
+
s.add_development_dependency 'rspec', '~> 3.5'
|
|
41
|
+
s.add_development_dependency 'rake', '~> 11.2'
|
|
42
|
+
s.add_development_dependency 'rubocop', '~> 0.43'
|
|
43
|
+
s.add_development_dependency 'webmock', '~> 2.1'
|
|
44
|
+
|
|
45
|
+
s.add_dependency 'thor', '~> 0.19'
|
|
46
|
+
s.add_dependency 'faraday', '~> 0.9'
|
|
47
|
+
s.add_dependency 'xml-simple', '~> 1.1'
|
|
48
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<metadata modelVersion="1.1.0">
|
|
2
|
+
<groupId>com.mygroup</groupId>
|
|
3
|
+
<artifactId>test1</artifactId>
|
|
4
|
+
<version>0.0.0-SNAPSHOT</version>
|
|
5
|
+
<versioning>
|
|
6
|
+
<snapshot>
|
|
7
|
+
<timestamp>19831018.151200</timestamp>
|
|
8
|
+
<buildNumber>1</buildNumber>
|
|
9
|
+
</snapshot>
|
|
10
|
+
<lastUpdated>19831018151200</lastUpdated>
|
|
11
|
+
<snapshotVersions>
|
|
12
|
+
<snapshotVersion>
|
|
13
|
+
<extension>jar</extension>
|
|
14
|
+
<value>1.0.0-19831018.151200-1</value>
|
|
15
|
+
<updated>19831018151200</updated>
|
|
16
|
+
</snapshotVersion>
|
|
17
|
+
<snapshotVersion>
|
|
18
|
+
<extension>pom</extension>
|
|
19
|
+
<value>1.0.0-19831018.151200-1</value>
|
|
20
|
+
<updated>19831018151200</updated>
|
|
21
|
+
</snapshotVersion>
|
|
22
|
+
<snapshotVersion>
|
|
23
|
+
<classifier>sources</classifier>
|
|
24
|
+
<extension>jar</extension>
|
|
25
|
+
<value>1.0.0-19831018.151200-1</value>
|
|
26
|
+
<updated>19831018151200</updated>
|
|
27
|
+
</snapshotVersion>
|
|
28
|
+
<snapshotVersion>
|
|
29
|
+
<classifier>javadoc</classifier>
|
|
30
|
+
<extension>jar</extension>
|
|
31
|
+
<value>1.0.0-19831018.151200-1</value>
|
|
32
|
+
<updated>19831018151200</updated>
|
|
33
|
+
</snapshotVersion>
|
|
34
|
+
</snapshotVersions>
|
|
35
|
+
</versioning>
|
|
36
|
+
</metadata>
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2016 Sam4Mobile
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
#
|
|
16
|
+
|
|
17
|
+
require 'spec_helper'
|
|
18
|
+
|
|
19
|
+
dir = File.dirname(__FILE__)
|
|
20
|
+
nexus = 'https://nexus.mydomain.net/repository/maven-public'
|
|
21
|
+
|
|
22
|
+
dl_test = [
|
|
23
|
+
'test-1.0.0.jar',
|
|
24
|
+
'test-2.0.0-19831018.151200-1.jar',
|
|
25
|
+
'test-3.0.0.jar',
|
|
26
|
+
'test-4.0.0.tgz',
|
|
27
|
+
'test-5.0.0_test.jar',
|
|
28
|
+
'test-6.0.0.jar',
|
|
29
|
+
'test-7.0.0.jar'
|
|
30
|
+
].map { |file| File.join(dir, '..', '..', file) }
|
|
31
|
+
|
|
32
|
+
describe MavenCLI::CLI do
|
|
33
|
+
context 'version' do
|
|
34
|
+
it 'prints the version.' do
|
|
35
|
+
out = "MavenCLI version #{MavenCLI::VERSION}\n"
|
|
36
|
+
expect { start(self) }.to output(out).to_stdout
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
context 'download com/mygroup test 1.0.0 -s' do
|
|
41
|
+
it 'should simulate a download without option via CLI.' do
|
|
42
|
+
out = "#{File.basename(dl_test[0])} has been Downloaded.\n"
|
|
43
|
+
expect { start(self) }.to output(out).to_stdout
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
context 'download com/mygroup test 2.0.0-SNAPSHOT -s ' do
|
|
48
|
+
it 'should simulate a download a snapshot version via CLI.' do
|
|
49
|
+
out = "#{File.basename(dl_test[1])} has been Downloaded.\n"
|
|
50
|
+
expect { start(self) }.to output(out).to_stdout
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
context "download com/mygroup test 3.0.0 -r #{nexus} -s" do
|
|
55
|
+
it 'should simulate a download with option --repository via CLI.' do
|
|
56
|
+
out = "#{File.basename(dl_test[2])} has been Downloaded.\n"
|
|
57
|
+
expect { start(self) }.to output(out).to_stdout
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
context 'download com/mygroup test 4.0.0 -p tgz -s' do
|
|
62
|
+
it 'should simulate a download with option --packaging via CLI.' do
|
|
63
|
+
out = "#{File.basename(dl_test[3])} has been Downloaded.\n"
|
|
64
|
+
expect { start(self) }.to output(out).to_stdout
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
context "download com/mygroup test 5.0.0 -o #{dl_test[4]} -s" do
|
|
69
|
+
it 'should simulate a download with option --output-file via CLI.' do
|
|
70
|
+
out = "#{dl_test[4]} has been Downloaded.\n"
|
|
71
|
+
expect { start(self) }.to output(out).to_stdout
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
context 'download com/mygroup test 6.0.0 -q -s' do
|
|
76
|
+
it 'should simulate a download with option --quiet via CLI.' do
|
|
77
|
+
expect { start(self) }.to output('').to_stdout
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2016 Sam4Mobile
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
#
|
|
16
|
+
|
|
17
|
+
require 'spec_helper'
|
|
18
|
+
|
|
19
|
+
dir = File.dirname(__FILE__)
|
|
20
|
+
nexus = 'https://nexus.mydomain.net/repository/maven-public'
|
|
21
|
+
|
|
22
|
+
dl_test = [
|
|
23
|
+
'test-1.0.0.jar',
|
|
24
|
+
'test-2.0.0-19831018.151200-1.jar',
|
|
25
|
+
'test-3.0.0.jar',
|
|
26
|
+
'test-4.0.0.tgz',
|
|
27
|
+
'test-5.0.0_test.jar',
|
|
28
|
+
'test-6.0.0.jar',
|
|
29
|
+
'test-7.0.0.jar'
|
|
30
|
+
].map { |file| File.join(dir, '..', '..', file) }
|
|
31
|
+
|
|
32
|
+
describe MavenCLI::Downloader do
|
|
33
|
+
context 'download com/mygroup test 1.0.0' do
|
|
34
|
+
it 'downloads without option.' do
|
|
35
|
+
out = "test-1.0.0.jar has been Downloaded.\n"
|
|
36
|
+
expect { start(self) }.to output(out).to_stdout
|
|
37
|
+
expect { print File.read(dl_test[0]) }.to output('OK').to_stdout
|
|
38
|
+
File.delete(dl_test[0])
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
context 'download com/mygroup test 2.0.0-SNAPSHOT' do
|
|
43
|
+
it 'downloads a snapshot version.' do
|
|
44
|
+
out = "test-2.0.0-19831018.151200-1.jar has been Downloaded.\n"
|
|
45
|
+
expect { start(self) }.to output(out).to_stdout
|
|
46
|
+
expect { print File.read(dl_test[1]) }.to output('OK').to_stdout
|
|
47
|
+
File.delete(dl_test[1])
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
context "download com/mygroup test 3.0.0 -r #{nexus}" do
|
|
52
|
+
it 'downloads with option --repository.' do
|
|
53
|
+
out = "test-3.0.0.jar has been Downloaded.\n"
|
|
54
|
+
expect { start(self) }.to output(out).to_stdout
|
|
55
|
+
expect { print File.read(dl_test[2]) }.to output('OK').to_stdout
|
|
56
|
+
File.delete(dl_test[2])
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
context 'download com/mygroup test 4.0.0 -p tgz' do
|
|
61
|
+
it 'downloads with option --packaging.' do
|
|
62
|
+
out = "test-4.0.0.tgz has been Downloaded.\n"
|
|
63
|
+
expect { start(self) }.to output(out).to_stdout
|
|
64
|
+
expect { print File.read(dl_test[3]) }.to output('OK').to_stdout
|
|
65
|
+
File.delete(dl_test[3])
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
context "download com/mygroup test 5.0.0 -o #{dl_test[4]}" do
|
|
70
|
+
it 'downloads with option --output-file.' do
|
|
71
|
+
out = "#{dl_test[4]} has been Downloaded.\n"
|
|
72
|
+
expect { start(self) }.to output(out).to_stdout
|
|
73
|
+
expect { print File.read(dl_test[4]) }.to output('OK').to_stdout
|
|
74
|
+
File.delete(dl_test[4])
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
context 'download com/mygroup test 6.0.0 -q' do
|
|
79
|
+
it 'downloads with option --quiet.' do
|
|
80
|
+
expect { start(self) }.to output('').to_stdout
|
|
81
|
+
File.delete(dl_test[5])
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
context "download com/mygroup test 7.0.0 -r #{nexus}" do
|
|
86
|
+
it 'fails to download an absent artifact.' do
|
|
87
|
+
out = 'Unable to download .* Status: 404'
|
|
88
|
+
expect { start(self) }.to raise_error(RuntimeError, /#{out}/)
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2016 Sam4Mobile
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
#
|
|
16
|
+
|
|
17
|
+
require 'spec_helper'
|
|
18
|
+
|
|
19
|
+
dir = File.dirname(__FILE__)
|
|
20
|
+
meta_file = 'maven-metadata.xml'
|
|
21
|
+
xml_content = File.read(File.join(dir, '..', '..', 'files', meta_file))
|
|
22
|
+
maven = 'http://repo.maven.apache.org/maven2'
|
|
23
|
+
nexus = 'https://nexus.mydomain.net/repository/maven-public'
|
|
24
|
+
artifact = 'test'
|
|
25
|
+
tests = {
|
|
26
|
+
artifact => [
|
|
27
|
+
[200, maven, 'com/mygroup', '1.0.0', 'jar'],
|
|
28
|
+
[
|
|
29
|
+
200,
|
|
30
|
+
maven,
|
|
31
|
+
'com/mygroup',
|
|
32
|
+
'2.0.0-SNAPSHOT',
|
|
33
|
+
'jar',
|
|
34
|
+
'19831018.151200',
|
|
35
|
+
'1'
|
|
36
|
+
],
|
|
37
|
+
[200, nexus, 'com/mygroup', '3.0.0', 'jar'],
|
|
38
|
+
[200, maven, 'com/mygroup', '4.0.0', 'tgz'],
|
|
39
|
+
[200, maven, 'com/mygroup', '5.0.0', 'jar'],
|
|
40
|
+
[200, maven, 'com/mygroup', '6.0.0', 'jar'],
|
|
41
|
+
[404, nexus, 'com/mygroup', '7.0.0', 'jar']
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
RSpec.configure do |config|
|
|
46
|
+
config.before(:each) do
|
|
47
|
+
tests[artifact].each do |array|
|
|
48
|
+
vernum = array[3].split('-').first
|
|
49
|
+
file = "#{artifact}-#{vernum}"
|
|
50
|
+
file += "-#{array[5]}" unless array[5].nil?
|
|
51
|
+
file += "-#{array[6]}" unless array[6].nil?
|
|
52
|
+
file += ".#{array[4]}"
|
|
53
|
+
xml = "#{array[1]}/#{array[2]}/#{artifact}/#{array[3]}/#{meta_file}"
|
|
54
|
+
test = "#{array[1]}/#{array[2]}/#{artifact}/#{array[3]}/#{file}"
|
|
55
|
+
|
|
56
|
+
xml_status = array[3].include?('SNAPSHOT') ? array[0] : 404
|
|
57
|
+
stub_request(:get, xml)
|
|
58
|
+
.to_return(status: xml_status, body: xml_content, headers: {})
|
|
59
|
+
|
|
60
|
+
stub_request(:get, test)
|
|
61
|
+
.to_return(status: array[0], body: 'OK', headers: {})
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2016 Sam4Mobile
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
#
|
|
16
|
+
|
|
17
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
|
18
|
+
require 'mavencli'
|
|
19
|
+
require 'webmock/rspec' # Most tests will use webmock
|
|
20
|
+
|
|
21
|
+
# Force expect syntax over should
|
|
22
|
+
RSpec.configure do |config|
|
|
23
|
+
config.expect_with :rspec do |c|
|
|
24
|
+
c.syntax = :expect
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
dir = File.dirname(__FILE__)
|
|
29
|
+
# Load helpers
|
|
30
|
+
Dir[File.join(dir, 'helpers', '*.rb')].each { |file| require file }
|
|
31
|
+
|
|
32
|
+
def now
|
|
33
|
+
Time.new.strftime('%Y-%m-%dT%H:%M:%S%z').insert(-3, ':')
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Load stubs
|
|
37
|
+
files = File.join(dir, 'mavencli', 'stubs', '*.rb')
|
|
38
|
+
Dir[files].each { |file| require file }
|
|
39
|
+
|
|
40
|
+
# To test the cli
|
|
41
|
+
def start(caller_object, subcommand = nil)
|
|
42
|
+
cmd = caller_object.class.description.split(' ')
|
|
43
|
+
args = [subcommand, *cmd].compact
|
|
44
|
+
MavenCLI::CLI.start(args)
|
|
45
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: maven-cli
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Samuel Bernard
|
|
8
|
+
- Richard Delaplace
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2016-10-11 00:00:00.000000000 Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: bundler
|
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
|
17
|
+
requirements:
|
|
18
|
+
- - "~>"
|
|
19
|
+
- !ruby/object:Gem::Version
|
|
20
|
+
version: '1.12'
|
|
21
|
+
type: :development
|
|
22
|
+
prerelease: false
|
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
24
|
+
requirements:
|
|
25
|
+
- - "~>"
|
|
26
|
+
- !ruby/object:Gem::Version
|
|
27
|
+
version: '1.12'
|
|
28
|
+
- !ruby/object:Gem::Dependency
|
|
29
|
+
name: rspec
|
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
|
31
|
+
requirements:
|
|
32
|
+
- - "~>"
|
|
33
|
+
- !ruby/object:Gem::Version
|
|
34
|
+
version: '3.5'
|
|
35
|
+
type: :development
|
|
36
|
+
prerelease: false
|
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
38
|
+
requirements:
|
|
39
|
+
- - "~>"
|
|
40
|
+
- !ruby/object:Gem::Version
|
|
41
|
+
version: '3.5'
|
|
42
|
+
- !ruby/object:Gem::Dependency
|
|
43
|
+
name: rake
|
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
|
45
|
+
requirements:
|
|
46
|
+
- - "~>"
|
|
47
|
+
- !ruby/object:Gem::Version
|
|
48
|
+
version: '11.2'
|
|
49
|
+
type: :development
|
|
50
|
+
prerelease: false
|
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
52
|
+
requirements:
|
|
53
|
+
- - "~>"
|
|
54
|
+
- !ruby/object:Gem::Version
|
|
55
|
+
version: '11.2'
|
|
56
|
+
- !ruby/object:Gem::Dependency
|
|
57
|
+
name: rubocop
|
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
|
59
|
+
requirements:
|
|
60
|
+
- - "~>"
|
|
61
|
+
- !ruby/object:Gem::Version
|
|
62
|
+
version: '0.43'
|
|
63
|
+
type: :development
|
|
64
|
+
prerelease: false
|
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
66
|
+
requirements:
|
|
67
|
+
- - "~>"
|
|
68
|
+
- !ruby/object:Gem::Version
|
|
69
|
+
version: '0.43'
|
|
70
|
+
- !ruby/object:Gem::Dependency
|
|
71
|
+
name: webmock
|
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
|
73
|
+
requirements:
|
|
74
|
+
- - "~>"
|
|
75
|
+
- !ruby/object:Gem::Version
|
|
76
|
+
version: '2.1'
|
|
77
|
+
type: :development
|
|
78
|
+
prerelease: false
|
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
80
|
+
requirements:
|
|
81
|
+
- - "~>"
|
|
82
|
+
- !ruby/object:Gem::Version
|
|
83
|
+
version: '2.1'
|
|
84
|
+
- !ruby/object:Gem::Dependency
|
|
85
|
+
name: thor
|
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
|
87
|
+
requirements:
|
|
88
|
+
- - "~>"
|
|
89
|
+
- !ruby/object:Gem::Version
|
|
90
|
+
version: '0.19'
|
|
91
|
+
type: :runtime
|
|
92
|
+
prerelease: false
|
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
94
|
+
requirements:
|
|
95
|
+
- - "~>"
|
|
96
|
+
- !ruby/object:Gem::Version
|
|
97
|
+
version: '0.19'
|
|
98
|
+
- !ruby/object:Gem::Dependency
|
|
99
|
+
name: faraday
|
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
|
101
|
+
requirements:
|
|
102
|
+
- - "~>"
|
|
103
|
+
- !ruby/object:Gem::Version
|
|
104
|
+
version: '0.9'
|
|
105
|
+
type: :runtime
|
|
106
|
+
prerelease: false
|
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
108
|
+
requirements:
|
|
109
|
+
- - "~>"
|
|
110
|
+
- !ruby/object:Gem::Version
|
|
111
|
+
version: '0.9'
|
|
112
|
+
- !ruby/object:Gem::Dependency
|
|
113
|
+
name: xml-simple
|
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
|
115
|
+
requirements:
|
|
116
|
+
- - "~>"
|
|
117
|
+
- !ruby/object:Gem::Version
|
|
118
|
+
version: '1.1'
|
|
119
|
+
type: :runtime
|
|
120
|
+
prerelease: false
|
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
122
|
+
requirements:
|
|
123
|
+
- - "~>"
|
|
124
|
+
- !ruby/object:Gem::Version
|
|
125
|
+
version: '1.1'
|
|
126
|
+
description: |
|
|
127
|
+
MavenCLI
|
|
128
|
+
========
|
|
129
|
+
|
|
130
|
+
Simple maven cli tool.
|
|
131
|
+
|
|
132
|
+
Installation
|
|
133
|
+
------------
|
|
134
|
+
|
|
135
|
+
Install as a gem:
|
|
136
|
+
|
|
137
|
+
$ gem install maven-cli
|
|
138
|
+
|
|
139
|
+
Usage
|
|
140
|
+
-----
|
|
141
|
+
|
|
142
|
+
You can have an interactive help using:
|
|
143
|
+
|
|
144
|
+
$ maven-cli help
|
|
145
|
+
|
|
146
|
+
Examples
|
|
147
|
+
--------
|
|
148
|
+
|
|
149
|
+
To download a jar from maven repository (http://repo.maven.apache.org/maven2)
|
|
150
|
+
|
|
151
|
+
$ maven-cli download <group> <artifact> <version>
|
|
152
|
+
|
|
153
|
+
For instance: `maven-cli download com.google.guava guava 19.0`
|
|
154
|
+
|
|
155
|
+
To download a jar from a non standard repository
|
|
156
|
+
|
|
157
|
+
$ maven-cli download <group> <artifact> <version> -r <repository>
|
|
158
|
+
|
|
159
|
+
To download a jar from maven repository and save it to file
|
|
160
|
+
|
|
161
|
+
$ maven-cli download <group> <artifact> <version> -o <outfile>
|
|
162
|
+
|
|
163
|
+
Contributing
|
|
164
|
+
------------
|
|
165
|
+
|
|
166
|
+
Please read carefully [CONTRIBUTING.md](CONTRIBUTING.md) before making a merge
|
|
167
|
+
request.
|
|
168
|
+
|
|
169
|
+
License and Author
|
|
170
|
+
------------------
|
|
171
|
+
|
|
172
|
+
- Author:: DPS Team (<dps.team@s4m.io>)
|
|
173
|
+
- Author:: Samuel Bernard (<samuel.bernard@s4m.io>)
|
|
174
|
+
- Author:: Richard Delaplace (<richard.delaplace@s4m.io>)
|
|
175
|
+
|
|
176
|
+
```text
|
|
177
|
+
Copyright (c) 2016 Sam4Mobile
|
|
178
|
+
|
|
179
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
180
|
+
you may not use this file except in compliance with the License.
|
|
181
|
+
You may obtain a copy of the License at
|
|
182
|
+
|
|
183
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
184
|
+
|
|
185
|
+
Unless required by applicable law or agreed to in writing, software
|
|
186
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
187
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
188
|
+
See the License for the specific language governing permissions and
|
|
189
|
+
limitations under the License.
|
|
190
|
+
```
|
|
191
|
+
email: dps.team@s4m.io
|
|
192
|
+
executables:
|
|
193
|
+
- maven-cli
|
|
194
|
+
extensions: []
|
|
195
|
+
extra_rdoc_files: []
|
|
196
|
+
files:
|
|
197
|
+
- ".gitignore"
|
|
198
|
+
- ".gitlab-ci.yml"
|
|
199
|
+
- ".rspec"
|
|
200
|
+
- CHANGELOG
|
|
201
|
+
- CONTRIBUTING.md
|
|
202
|
+
- Gemfile
|
|
203
|
+
- LICENSE
|
|
204
|
+
- README.md
|
|
205
|
+
- Rakefile
|
|
206
|
+
- bin/maven-cli
|
|
207
|
+
- lib/mavencli.rb
|
|
208
|
+
- lib/mavencli/cli.rb
|
|
209
|
+
- lib/mavencli/downloader.rb
|
|
210
|
+
- lib/mavencli/version.rb
|
|
211
|
+
- maven-cli.gemspec
|
|
212
|
+
- spec/files/maven-metadata.xml
|
|
213
|
+
- spec/mavencli/cli_spec.rb
|
|
214
|
+
- spec/mavencli/downloader_spec.rb
|
|
215
|
+
- spec/mavencli/stubs/servers_stubs.rb
|
|
216
|
+
- spec/mavencli_spec.rb
|
|
217
|
+
- spec/spec_helper.rb
|
|
218
|
+
homepage: https://gitlab.com/s4m-gems/maven-cli
|
|
219
|
+
licenses:
|
|
220
|
+
- Apache-2.0
|
|
221
|
+
metadata: {}
|
|
222
|
+
post_install_message:
|
|
223
|
+
rdoc_options: []
|
|
224
|
+
require_paths:
|
|
225
|
+
- lib
|
|
226
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
227
|
+
requirements:
|
|
228
|
+
- - ">="
|
|
229
|
+
- !ruby/object:Gem::Version
|
|
230
|
+
version: '0'
|
|
231
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
232
|
+
requirements:
|
|
233
|
+
- - ">="
|
|
234
|
+
- !ruby/object:Gem::Version
|
|
235
|
+
version: '0'
|
|
236
|
+
requirements: []
|
|
237
|
+
rubyforge_project:
|
|
238
|
+
rubygems_version: 2.5.1
|
|
239
|
+
signing_key:
|
|
240
|
+
specification_version: 4
|
|
241
|
+
summary: Tool to interact with Maven repositories with CLI
|
|
242
|
+
test_files: []
|