MavenToPKGBUILD 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 16b553b7dde81a9312b17aa8f48f8f0020758cab2752322cec52a8ff8cab9f11
4
+ data.tar.gz: 49d513d07af90fcbe771be266bdb4cbb843573ff502b8133563c82dfd33875be
5
+ SHA512:
6
+ metadata.gz: 4eadb3d7b5b23d291e5899ff49eab96799201d5df1414c1448a201c62ff8549ab4e491ac662f0b7c0dafe00788407570a104f606eae674286e77192e9f92cbe0
7
+ data.tar.gz: fbb99ad22d278bedb5415961eb7e37fb1816020f2a4c644901381def469a2605785bce6cf8642e039f0969ddac15c086ded185429d1bb4f23750747e9d4e2447
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /test/
10
+ /jedis/
11
+ /redis/
12
+ /commons-pool2/
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at poqudrof@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/Rea-lity-Tech/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in MavenToPKGBUILD.gemspec
6
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,37 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "MavenToPKGBUILD/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "MavenToPKGBUILD"
8
+ spec.version = MavenToPKGBUILD::VERSION
9
+ spec.authors = ["Jeremy Laviole"]
10
+ spec.email = ["laviole@rea.lity.tech"]
11
+
12
+ spec.summary = %q{Create packages for Arch linux (AUR) for Maven dependencies.}
13
+ spec.description = %q{The packages are installed in /usr/share/java, as it is recommended in the PKGBUILD for java guide. For now and in the future I try to stick to the official guidelines.
14
+
15
+ This is a first implementation to manage dependencies for java programs that share jar files. The goal is to distribute java programs and its dependencies separated in a clean way. However the current risk is that we have to create dozens or hundreds of packages for large projects.}
16
+
17
+ spec.homepage = "https://github.com/Rea-lity-Tech/MavenToPKGBUILD"
18
+
19
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
20
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
21
+ # if spec.respond_to?(:metadata)
22
+ # spec.metadata["allowed_push_host"] = "http://mygemserver.com"
23
+ # else
24
+ # raise "RubyGems 2.0 or newer is required to protect against " \
25
+ # "public gem pushes."
26
+ # end
27
+
28
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
29
+ f.match(%r{^(test|spec|features)/})
30
+ end
31
+ spec.bindir = "exe"
32
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
33
+ spec.require_paths = ["lib"]
34
+
35
+ spec.add_development_dependency "bundler", "~> 1.16"
36
+ spec.add_development_dependency "rake", "~> 10.0"
37
+ end
data/README.md ADDED
@@ -0,0 +1,86 @@
1
+ # MavenToPKGBUILD
2
+ Create packages for Arch linux (AUR) for Maven dependencies.
3
+
4
+ The packages are installed in `/usr/share/java`, as it is recommended in the PKGBUILD for [java guide](https://wiki.archlinux.org/index.php/Java_package_guidelines). For now and in the future I try to stick to the official guidelines.
5
+
6
+ This is a first implementation to manage dependencies for java programs that share jar files. The goal is to distribute java programs and its dependencies separated in a clean way.
7
+ However the current risk is that we have to create dozens or hundreds of packages for large projects.
8
+
9
+ Please do not submit the generated PKGBUILDs to the ArchLinux repository without filling out all the required informations.
10
+
11
+ ## How to use
12
+
13
+ #### 1. Build a specific project:
14
+
15
+ `pkg-maven DATABASE.yaml PROJECT`
16
+
17
+ You can try it:
18
+
19
+ `pkg-maven package.yaml jedis`
20
+
21
+ #### 2. Build all the projects:
22
+
23
+
24
+ Create a package for each dependency in the database. It is quite simple for now and does not handle double entry or version conflicts.
25
+
26
+ `pkg-maven DATABASE.yaml all`
27
+
28
+ You can try it:
29
+
30
+ `pkg-maven package.yaml all`
31
+
32
+ #### 3. Build a package by its name.
33
+
34
+ You can also try it:
35
+
36
+ `pkg-maven jedis redis.clients 2.9.0`
37
+
38
+ This will create a package for **one jar only**. You can get get its dependencies by going in the folder and running the `pkg-maven-list-deps` script.
39
+
40
+ ``` bash
41
+ cd jedis
42
+ pkg-maven-list-deps jedis.yaml ## here jedis.yaml is the output file name, the default is deps.yaml
43
+ ```
44
+ You can then use the `jedis.yaml` to create more packages !
45
+
46
+ If the generated name does not seem correct, you can add a `name` field:
47
+
48
+ ``` yaml
49
+ jedis:
50
+ groupid: redis.clients
51
+ artifactid: jedis
52
+ version: 2.9.0
53
+ name: redis
54
+ ```
55
+
56
+ With this modification, the package name will be: `java-redis`.
57
+
58
+ ## Options
59
+
60
+ There are three ways to build a package. Either you want to package a specific jar, a jar with packages for each dependency, or a jar with its dependency included in one big jar.
61
+
62
+
63
+ ## Installing a package
64
+
65
+ After the package(s) are built, you can install it with pacman.
66
+
67
+ Here is an example:
68
+
69
+ `sudo pacman -U pkgs/java-jedis-2.9.0-1-any.pkg.tar.xz`
70
+
71
+
72
+ ## Running an application
73
+
74
+ The program `pkg-maven-list-deps` creates a `classpath.txt` that contains all the dependencies. You can use this way:
75
+
76
+ ``` bash
77
+ CP=$(<classpath.txt)
78
+ java -cp $CP:target/* tech.lity.rea.nectar.camera.Test
79
+ ```
80
+
81
+
82
+ ### TODO:
83
+
84
+ * Gemify this.
85
+ * Better parsing.
86
+ * Large scale tests.
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "MavenToPKGBUILD"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/exe/pkg-maven ADDED
@@ -0,0 +1,91 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+
5
+ require 'MavenToPKGBUILD'
6
+
7
+ options = {}
8
+ op = OptionParser.new do |opts|
9
+ opts.banner = "Usage: pkg-maven file.yaml [name/all] [options]"
10
+
11
+ opts.on("-f", "--full", "Fetch all dependencies") do |v|
12
+ options[:full] = v
13
+ end
14
+
15
+ opts.on("-c", "--compact", "Put all dependencies with the jar") do |v|
16
+ options[:compact] = v
17
+ end
18
+
19
+ opts.on("-aARCH", "--arch=ARCH", "Selected architure, x86_64 by default.") do |n|
20
+ options[:arch] = n
21
+ end
22
+
23
+ opts.on("-vVERSION", "--version=VERSION", "Minor version, default is 1.") do |n|
24
+ options[:version] = n
25
+ end
26
+
27
+ opts.on("-h", "--help", "Prints this help") do
28
+ puts opts
29
+ exit
30
+ end
31
+ end
32
+ op.parse!
33
+
34
+ if(ARGV.size <= 1)
35
+ puts op
36
+ exit
37
+ end
38
+
39
+ # p options
40
+ # p ARGV
41
+
42
+ include MavenToPKGBUILD
43
+
44
+
45
+ if(ARGV[0].end_with? '.yaml' or ARGV[0].end_with? ".yml")
46
+ files = YAML.load_file ARGV[0]
47
+
48
+ arch = ARGV[2] unless ARGV[2].nil?
49
+
50
+ # case 1: build all.
51
+ if(ARGV[1].eql? "all")
52
+
53
+ ## Filter the non-platform deps from javacpp-presets
54
+
55
+ without_platform = files.map do |dep|
56
+ next if files.has_key?(dep[0]+"-platform")
57
+ dep[1]
58
+ end.compact!
59
+ ## reject the empty ones created by next
60
+
61
+ without_platform.each{ |pkg| puts "BUILD" + pkg.to_s ; build_pkg(pkg, options) }
62
+ return
63
+ end
64
+
65
+ # case 2: build a specific one
66
+ pkg = files[ARGV[1]]
67
+ unless pkg.nil?
68
+ build_pkg(pkg, options)
69
+ return
70
+ end
71
+
72
+ return
73
+ end
74
+
75
+ # case 3: build from command line.
76
+ if(ARGV.size < 3)
77
+ puts "Not enough arguments: name groupid version [artifactId]"
78
+ return
79
+ end
80
+
81
+ name = ARGV[0] # redis
82
+ groupid = ARGV[1] # redis.clients
83
+ version = ARGV[2] # 2.9.0
84
+ artifactid = name
85
+
86
+ arch = ARGV[3] unless ARGV[3].nil?
87
+
88
+ #artifactid = ARGV[3] if ARGV.size > 3 # jedis
89
+
90
+ # build it !
91
+ build(name, groupid, version, artifactid, options)
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'yaml'
4
+ require 'MavenToPKGBUILD'
5
+
6
+ include MavenToPKGBUILD
7
+
8
+ if ARGV[0] != nil
9
+ output = ARGV[0]
10
+ else
11
+ output = "deps.yaml"
12
+ end
13
+
14
+ # platforms = ["linux", "windows", "macosx"]
15
+ # archs = ["x86_64", "x86", "arm"]
16
+
17
+ platform="linux"
18
+ arch="x86_64"
19
+
20
+ tmp = "tmp.txt"
21
+ `mvn dependency:list -Djavacpp.platform=#{platform}-#{arch} -DoutputFile=#{tmp}`
22
+
23
+ lines = File.readlines tmp
24
+ lines = lines.drop 2
25
+
26
+ all_deps = {}
27
+ all_deps_jar = ""
28
+ prefix = "/usr/share/java/"
29
+
30
+ lines.each do |l|
31
+ groupid, artifactid, type, version = l.strip.split ":"
32
+
33
+ next if artifactid.nil? or artifactid.empty?
34
+
35
+ # puts "Dependency: " + artifactid.to_s
36
+ dep = {}
37
+ dep["groupid"] = groupid
38
+ dep["artifactid"] = artifactid
39
+ dep["version"] = version
40
+
41
+ all_deps[artifactid] = dep
42
+ end
43
+
44
+
45
+ # TODO: Ignore completely ?!!
46
+ without_platform = all_deps.map do |dep|
47
+ next if all_deps.has_key?(dep[0]+"-platform")
48
+ dep[1]
49
+ end.compact!
50
+ ## reject the empty ones created by next
51
+
52
+ without_platform.each do |dep|
53
+ ## jar name
54
+ v = create_pkg_version(dep["version"])
55
+ n = dep["artifactid"]
56
+
57
+ dep_file = prefix + n + "-" + v + ".jar"
58
+
59
+ if File.exist?(dep_file)
60
+ puts "File FOUND: " + dep_file
61
+ else
62
+ puts "Missing : " + dep_file
63
+ end
64
+
65
+ all_deps_jar = all_deps_jar + ":" unless all_deps_jar.empty?
66
+ all_deps_jar = all_deps_jar + dep_file
67
+ end
68
+
69
+
70
+ File.open(output, 'w') {|f| f.write all_deps.to_yaml }
71
+ File.open("classpath.txt", 'w') {|f| f.write all_deps_jar }
72
+
@@ -0,0 +1,290 @@
1
+ require 'yaml'
2
+ require "MavenToPKGBUILD/version"
3
+
4
+
5
+ module MavenToPKGBUILD
6
+
7
+ def create_pkg_version(version)
8
+ version.delete_prefix("'").delete_suffix("'").split("-").first
9
+ end
10
+
11
+ def build_pkg(pkg, options)
12
+ build(pkg["name"], pkg["groupid"], pkg["version"], pkg["artifactid"], options)
13
+ end
14
+
15
+ def build(name, groupid, version, artifactid, options) # arch="x86_64", full=false, compact=false)
16
+
17
+ name = artifactid if name.nil?
18
+
19
+ arch = "x86_64"
20
+ arch = options[:arch] unless options[:arch].nil?
21
+
22
+ full = false
23
+ full = options[:full] unless options[:full].nil?
24
+
25
+ compact = false
26
+ compact = options[:compact] unless options[:compact].nil?
27
+
28
+ pkgrel = "1"
29
+ pkgrel = options[:version] unless options[:version].nil?
30
+
31
+ puts "Starting to build #{name}, #{groupid}, #{version}, #{artifactid}. "
32
+
33
+ javacpp = false
34
+
35
+ ## Sometimes there are quotes in version names.
36
+ pkgversion = version.delete_prefix("'").delete_suffix("'")
37
+
38
+ javacppversion = ""
39
+ compact_pkg = ""
40
+ compact_pkg = "-compact" if compact
41
+
42
+ platform = "linux"
43
+ foldername = name
44
+
45
+ pkgarch = "any"
46
+
47
+ if(groupid.eql? "org.bytedeco.javacpp-presets" and artifactid.end_with? "-platform")
48
+ puts "JavaCPP platform building"
49
+ javacpp = true
50
+ name = artifactid.split("-platform").first
51
+ pkgversion, javacppversion = pkgversion.split "-"
52
+ pkgrel = javacppversion+pkgrel
53
+ pkgarch = arch
54
+ else
55
+ pkgversion = pkgversion.split("-").first
56
+ end
57
+
58
+ ## 1. build the directory
59
+ begin
60
+ Dir.mkdir foldername
61
+ Dir.mkdir "pkgs"
62
+ rescue => e
63
+
64
+ end
65
+
66
+ ## 2. create the PGKBUILD
67
+ pkgbuild = <<-PKGBUILD
68
+ # Maintainer: RealityTech <laviole@rea.lity.tech>
69
+ pkgname=java-#{name}#{compact_pkg}
70
+ pkgver=#{pkgversion}
71
+ pkgrel=#{pkgrel}
72
+ pkgdesc=""
73
+ arch=('#{pkgarch}')
74
+ url=""
75
+ license=('GPL')
76
+ groups=()
77
+ depends=('java-runtime')
78
+ makedepends=('maven' 'jdk8-openjdk' 'git')
79
+ provides=("${pkgname%-git}")
80
+ conflicts=("${pkgname%-git}")
81
+ replaces=()
82
+
83
+ build() {
84
+ cd "$startdir"
85
+
86
+ PKGBUILD
87
+
88
+ if javacpp
89
+ pkgbuild = pkgbuild + " mvn dependency:copy-dependencies\n "
90
+ else
91
+ pkgbuild = pkgbuild + " mvn dependency:copy-dependencies -Djavacpp.platform=#{platform}-#{arch} \n "
92
+ end
93
+
94
+ if compact
95
+ pkgbuild = pkgbuild + " mvn package -Djavacpp.platform=#{platform}-#{arch} \n "
96
+ end
97
+
98
+ ## Continue building
99
+ pkgbuild2 = <<-PKGBUILD2
100
+
101
+ }
102
+
103
+ package() {
104
+
105
+ PKGBUILD2
106
+
107
+ # opencv-3.4.0-1.4.jar -> #{name}-#{version}-#{javacppversion}.jar
108
+ # opencv-platform-3.4.0-1.4.jar -> #{name}-platform-#{version}-#{javacppversion}.jar
109
+ # opencv-3.4.0-1.4-linux-x86_64.jar -> #{name}-#{version}-#{javacppversion}-#{platform}-#{arch}.jar
110
+ # javacpp-1.4.jar -> javacpp-#{javacppversion}.jar ## Not sure yet!
111
+
112
+ if compact
113
+ pkgbuild3 = " installCompact '#{name}' '#{artifactid}' '-jar-with-dependencies' \n"
114
+
115
+ else
116
+
117
+ if full
118
+ pkgbuild3 = " installAll '#{name}'"
119
+ else
120
+ if javacpp
121
+ pkgbuild3 = <<-PKGBUILD3
122
+
123
+ # jar-name, output-jar-name, link-name
124
+ installJavaCPP '#{name}-#{pkgversion}-#{javacppversion}.jar' '#{name}-#{pkgversion}.jar' '#{name}.jar'
125
+ installJavaCPP '#{name}-platform-#{pkgversion}-#{javacppversion}.jar' '#{name}-platform-#{pkgversion}.jar' '#{name}-platform.jar'
126
+
127
+ installJavaCPP '#{name}-#{pkgversion}-#{javacppversion}-#{platform}-#{arch}.jar' '#{name}-#{pkgversion}-#{platform}-#{arch}.jar' '#{name}-#{platform}-#{arch}.jar'
128
+
129
+ PKGBUILD3
130
+
131
+ else
132
+ pkgbuild3 = <<-PKGBUILD3
133
+
134
+ installOne '#{name}' '#{artifactid}'
135
+
136
+ PKGBUILD3
137
+ end
138
+ end
139
+ end
140
+
141
+ pkgbuild4 = <<-PKGBUILD4
142
+
143
+ }
144
+
145
+ installOne() {
146
+ local name=$1
147
+ local artifact=$2
148
+ local opt=$3
149
+ install -m644 -D ${startdir}/target/dependency/${artifact}-#{version}${opt}.jar ${pkgdir}/usr/share/java/${name}/${pkgver}/${name}-${pkgver}.jar
150
+ cd ${pkgdir}/usr/share/java/
151
+ ln -sr ${name}/${pkgver}/${name}-${pkgver}.jar $name.jar
152
+ ln -sr ${name}/${pkgver}/${name}-${pkgver}.jar $name-${pkgver}.jar
153
+ }
154
+
155
+ installCompact() {
156
+ local name=$1
157
+ local artifact=$2
158
+ local opt=$3
159
+ install -m644 -D ${startdir}/target/${name}-#{version}${opt}.jar ${pkgdir}/usr/share/java/${name}/${pkgver}/${name}-${pkgver}${opt}.jar
160
+ cd ${pkgdir}/usr/share/java/
161
+ ln -sr ${name}/${pkgver}/${name}-${pkgver}${opt}.jar $name${opt}.jar
162
+ }
163
+
164
+
165
+ installAll() {
166
+ local name=$1
167
+ mkdir -p ${pkgdir}/usr/share/java/${name}-with-deps/${pkgver}
168
+ install -m644 -D ${startdir}/target/dependency/*.jar ${pkgdir}/usr/share/java/${name}-with-deps/${pkgver}/
169
+ # links ?
170
+ # ln -sr ${name}/${pkgver}/${name}-${pkgver}.jar $name.jar
171
+ }
172
+
173
+ installJavaCPP() {
174
+ local jarname=$1
175
+ local outputname=$2
176
+ local name=$3
177
+ install -m644 -D ${startdir}/target/dependency/${jarname} ${pkgdir}/usr/share/java/#{name}/${pkgver}/${outputname}
178
+ cd ${pkgdir}/usr/share/java/
179
+ ln -sr #{name}/${pkgver}/${outputname} $name
180
+ ln -sr #{name}/${pkgver}/${outputname} ${outputname}
181
+ }
182
+
183
+
184
+ PKGBUILD4
185
+
186
+ ## Install in a maven-like environment ?
187
+ ## ${groupId.replace('.','/')}/${artifactId}/${version}/${artifactId}-${version}${classifier==null?'':'-'+classifier}.${type}
188
+
189
+ pkgbuild = pkgbuild + pkgbuild2 + pkgbuild3 + pkgbuild4
190
+
191
+ # write pkgbuild
192
+ puts "writing pkgbuild..."
193
+ File.open(foldername+"/PKGBUILD", 'w') { |file| file.write(pkgbuild) }
194
+
195
+ # create the POM
196
+
197
+ pom = <<-POM
198
+ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
199
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
200
+ <modelVersion>4.0.0</modelVersion>
201
+ <groupId>tech.lity.rea</groupId>
202
+ <artifactId>#{name}</artifactId>
203
+ <version>1-dummy</version>
204
+ <packaging>jar</packaging>
205
+
206
+ <name>#{name}</name>
207
+ <description></description>
208
+ <url></url>
209
+
210
+ <repositories>
211
+ <repository>
212
+ <id>clojars.org</id>
213
+ <url>http://clojars.org/repo</url>
214
+ </repository>
215
+
216
+ <repository>
217
+ <id>ossrh</id>
218
+ <url>https://oss.sonatype.org/content/repositories/snapshots</url>
219
+ </repository>
220
+
221
+ <repository>
222
+ <id>central</id>
223
+ <name>Maven Repository Switchboard</name>
224
+ <layout>default</layout>
225
+ <url>http://repo1.maven.org/maven2</url>
226
+ <snapshots>
227
+ <enabled>true</enabled>
228
+ </snapshots>
229
+ </repository>
230
+ </repositories>
231
+
232
+ <dependencies>
233
+ <dependency>
234
+ <groupId>#{groupid}</groupId>
235
+ <artifactId>#{artifactid}</artifactId>
236
+ <version>#{version}</version>
237
+ </dependency>
238
+ </dependencies>
239
+ POM
240
+
241
+ if compact
242
+ pom = pom + <<-POM2
243
+
244
+ <build>
245
+ <plugins>
246
+ <plugin>
247
+ <groupId>org.apache.maven.plugins</groupId>
248
+ <artifactId>maven-assembly-plugin</artifactId>
249
+ <executions>
250
+ <execution>
251
+ <phase>package</phase>
252
+ <goals>
253
+ <goal>single</goal>
254
+ </goals>
255
+ <configuration>
256
+ <descriptorRefs>
257
+ <descriptorRef>jar-with-dependencies</descriptorRef>
258
+ </descriptorRefs>
259
+ </configuration>
260
+ </execution>
261
+ </executions>
262
+ </plugin>
263
+ </plugins>
264
+ </build>
265
+ POM2
266
+ end
267
+
268
+ pom = pom + " </project> "
269
+
270
+ # write pom
271
+ puts "Writing pom..."
272
+ File.open(foldername+"/pom.xml", 'w') { |file| file.write(pom) }
273
+
274
+ currentdir = Dir.pwd
275
+
276
+ Dir.chdir foldername
277
+ `makepkg -f >> build.log`
278
+ `cp *.pkg.tar.xz ../pkgs`
279
+
280
+ Dir.chdir currentdir
281
+
282
+ puts "Finished, you can check the folder #{name}."
283
+
284
+ end
285
+
286
+
287
+
288
+
289
+
290
+ end
@@ -0,0 +1,3 @@
1
+ module MavenToPKGBUILD
2
+ VERSION = "0.1.0"
3
+ end
data/package.yaml ADDED
@@ -0,0 +1,9 @@
1
+ ---
2
+ jedis:
3
+ artifactid: jedis
4
+ groupid: redis.clients
5
+ version: 2.9.0
6
+ commons-pool2:
7
+ artifactid: commons-pool2
8
+ groupid: org.apache.commons
9
+ version: 2.4.2
data/pkgs/.keep ADDED
File without changes
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: MavenToPKGBUILD
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jeremy Laviole
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-02-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: |-
42
+ The packages are installed in /usr/share/java, as it is recommended in the PKGBUILD for java guide. For now and in the future I try to stick to the official guidelines.
43
+
44
+ This is a first implementation to manage dependencies for java programs that share jar files. The goal is to distribute java programs and its dependencies separated in a clean way. However the current risk is that we have to create dozens or hundreds of packages for large projects.
45
+ email:
46
+ - laviole@rea.lity.tech
47
+ executables:
48
+ - pkg-maven
49
+ - pkg-maven-list-deps
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - ".gitignore"
54
+ - CODE_OF_CONDUCT.md
55
+ - Gemfile
56
+ - LICENSE
57
+ - MavenToPKGBUILD.gemspec
58
+ - README.md
59
+ - Rakefile
60
+ - bin/console
61
+ - bin/setup
62
+ - exe/pkg-maven
63
+ - exe/pkg-maven-list-deps
64
+ - lib/MavenToPKGBUILD.rb
65
+ - lib/MavenToPKGBUILD/version.rb
66
+ - package.yaml
67
+ - pkgs/.keep
68
+ homepage: https://github.com/Rea-lity-Tech/MavenToPKGBUILD
69
+ licenses: []
70
+ metadata: {}
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubygems_version: 3.0.2
87
+ signing_key:
88
+ specification_version: 4
89
+ summary: Create packages for Arch linux (AUR) for Maven dependencies.
90
+ test_files: []