dataMetaBuild 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/.yardopts +1 -0
- data/PostInstall.txt +2 -0
- data/README.md +59 -0
- data/Rakefile +13 -0
- data/bin/dataMetaMvnDepsPaths.rb +103 -0
- data/lib/dataMetaBuild.rb +34 -0
- data/test/test_dataMetaBuild.rb +16 -0
- data/test/test_helper.rb +4 -0
- metadata +59 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b03800f5e3233f50142e39062a52d342602c25c2
|
4
|
+
data.tar.gz: 3f198a794dec5f01f079410da3c68d392fddfab2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 946750909d7a1aa977557413d36cfdab97f03ee7133c0396ce119929cc6dc44a2d01a0b4bb48aaaca395a98cde189235aace24f2e3a52e95eb06fd858fb00ac8
|
7
|
+
data.tar.gz: 74b9c358d3a2e0e5ccf5bfda921c5b9e2b348029b61ffb63ab656dc6185a36530ff5a7794e38d89710e9dd66bf9eaeef2c66036bd4e25ab4dc63a2b623214195
|
data/.yardopts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--title "DataMeta Building" -r README.md --charset UTF-8 lib/**/* - README.md
|
data/PostInstall.txt
ADDED
data/README.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# dataMetaBuild
|
2
|
+
|
3
|
+
Utilities for building and deploying applications and gems.
|
4
|
+
|
5
|
+
References to this gem's:
|
6
|
+
|
7
|
+
* [Source](https://github.com/eBayDataMeta/DataMeta-gems)
|
8
|
+
|
9
|
+
## DESCRIPTION:
|
10
|
+
|
11
|
+
See the [DataMeta Project](https://github.com/eBayDataMeta/DataMeta).
|
12
|
+
|
13
|
+
## FEATURES/PROBLEMS:
|
14
|
+
|
15
|
+
* None
|
16
|
+
|
17
|
+
## SYNOPSIS:
|
18
|
+
|
19
|
+
### Maven dependencies artifacts local paths
|
20
|
+
|
21
|
+
To distribute a Java application, you may need a list of paths to the app dependency JARs.
|
22
|
+
|
23
|
+
To build such list for a Maven project, use the `dataMetaMvnDepsPaths.rb` runnable on this gem.
|
24
|
+
|
25
|
+
Ran in the directory with the `pom.xml` for the project, it would output a file with
|
26
|
+
the name <tt>dataMetaMvnDepsPaths.</tt><i>scope</i> for each of the scope used in the project **except** `system` , for example:
|
27
|
+
|
28
|
+
```
|
29
|
+
dataMetaMvnDepsPaths.compile
|
30
|
+
dataMetaMvnDepsPaths.system
|
31
|
+
dataMetaMvnDepsPaths.test
|
32
|
+
dataMetaMvnDepsPaths.runtime
|
33
|
+
```
|
34
|
+
|
35
|
+
You can specify a different file prefix in the first parameter to the runnable.
|
36
|
+
|
37
|
+
Each file would have a full path to a dependency artifact on each line for all dependencies in the scope, for example:
|
38
|
+
|
39
|
+
```
|
40
|
+
/home/uid/.m2/repository/junit/junit/4.11/junit-4.11.jar
|
41
|
+
```
|
42
|
+
|
43
|
+
The script will look for your local Maven repository in your `$HOME/.m2/repository` which is pretty much hard-set
|
44
|
+
for Maven.
|
45
|
+
|
46
|
+
Those files can be used for deployment scripts, for cross-project dependency analysis etc.
|
47
|
+
|
48
|
+
## REQUIREMENTS:
|
49
|
+
|
50
|
+
* No special requirements
|
51
|
+
|
52
|
+
## INSTALL:
|
53
|
+
|
54
|
+
gem install dataMetaBuild
|
55
|
+
|
56
|
+
## LICENSE:
|
57
|
+
|
58
|
+
[Apache v 2.0](https://github.com/eBayDataMeta/DataMeta/blob/master/LICENSE.md)
|
59
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# or adjust as needed.
|
2
|
+
%w(yard rake/testtask).each{ |r| require r}
|
3
|
+
|
4
|
+
Rake::TestTask.new do |t|
|
5
|
+
t.libs << 'test'
|
6
|
+
end
|
7
|
+
|
8
|
+
desc 'Regen RDocs'
|
9
|
+
task :default => :docs
|
10
|
+
|
11
|
+
YARD::Rake::YardocTask.new('docs') {|r|
|
12
|
+
r.stats_options = ['--list-undoc']
|
13
|
+
}
|
@@ -0,0 +1,103 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Build path lists for the Maven project in the current directory
|
3
|
+
|
4
|
+
require 'open3'
|
5
|
+
require 'set'
|
6
|
+
|
7
|
+
H1 ||= '*' * 15
|
8
|
+
|
9
|
+
# Collectable Maven scopes: http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html
|
10
|
+
SCOPES = Set.new %W(compile runtime test)
|
11
|
+
# provided, system, import are not intresting for deployment
|
12
|
+
|
13
|
+
MVN_LOCAL_REPO = File.join(ENV['HOME'], '.m2', 'repository')
|
14
|
+
|
15
|
+
raise ArgumentError, %|Maven local repository "#{
|
16
|
+
MVN_LOCAL_REPO}" is not a directory on the local filesystem| unless File.directory?(MVN_LOCAL_REPO)
|
17
|
+
|
18
|
+
@outFileNamePfx = $*[0] || "#{File.basename(__FILE__)[/[^\.]+/]}"
|
19
|
+
|
20
|
+
OUTS = Hash.new { |h,k| h[k] = File.open("#{@outFileNamePfx}.#{k}", mode: 'wb')}
|
21
|
+
|
22
|
+
@srcLine = nil
|
23
|
+
@lineNum = 0
|
24
|
+
|
25
|
+
class Dep
|
26
|
+
attr_reader :group, :artifact, :packaging, :version, :scope, :classifier
|
27
|
+
|
28
|
+
class << self
|
29
|
+
def parse(source)
|
30
|
+
depParts = source.split(/\s+/)[1].split(':')
|
31
|
+
case depParts.length
|
32
|
+
when 5
|
33
|
+
grp, art, pack, ver, scp = depParts
|
34
|
+
clz = nil
|
35
|
+
when 6
|
36
|
+
grp, art, pack, clz, ver, scp = depParts
|
37
|
+
else
|
38
|
+
raise ArgumentError, "Unsupported dependencies format, arr=#{depParts.inspect}"
|
39
|
+
|
40
|
+
end
|
41
|
+
Dep.new(grp, art, pack, ver, scp, clz)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def initialize(group, artifact, packaging, version, scope, classifier = nil)
|
46
|
+
@group, @artifact, @packaging, @version, @scope, @classifier = group, artifact, packaging, version, scope, classifier
|
47
|
+
%W(group artifact packaging version scope).each { |varName|
|
48
|
+
v = instance_variable_get('@' + varName)
|
49
|
+
raise ArgumentError, %|The value for <#{varName}> is missing| unless v && !v.empty?
|
50
|
+
}
|
51
|
+
end
|
52
|
+
|
53
|
+
def toPath
|
54
|
+
fullPath = File.join(MVN_LOCAL_REPO, @group.split('.'), @artifact, @version, "#{
|
55
|
+
@artifact}-#{@version}#{@classifier ? '-' + @classifier : ''}.#{@packaging}")
|
56
|
+
# Make sure it actually resolves to a valid file on the local FS, unless it's in the system scope
|
57
|
+
# that can be anywhere and are of little concern
|
58
|
+
raise ArgumentError, %|"#{fullPath}" is not a file| unless File.file?(fullPath)
|
59
|
+
fullPath
|
60
|
+
end
|
61
|
+
end
|
62
|
+
cmd = 'mvn dependency:list'
|
63
|
+
puts %|Running "#{cmd}"|
|
64
|
+
o,e,s= Open3.capture3(cmd)
|
65
|
+
|
66
|
+
unless s.to_i == 0
|
67
|
+
puts %|#{H1} OUT #{H1}
|
68
|
+
#{o}
|
69
|
+
#{H1} ERR #{H1}
|
70
|
+
#{e}
|
71
|
+
#{H1} state=#{s.inspect}
|
72
|
+
|
|
73
|
+
raise RuntimeError, %|ERRORS running "#{cmd}"|
|
74
|
+
end
|
75
|
+
|
76
|
+
@stage = :init
|
77
|
+
@exitCode = 0
|
78
|
+
o.split("\n").each { |line|
|
79
|
+
begin
|
80
|
+
@srcLine = line.strip
|
81
|
+
@lineNum += 1
|
82
|
+
case @stage
|
83
|
+
when :init
|
84
|
+
@stage = :parse if %r{^\[INFO\]\s+The following files have been resolved:$} =~ @srcLine
|
85
|
+
when :parse
|
86
|
+
break if @srcLine == '[INFO]'
|
87
|
+
dep = Dep.parse(@srcLine)
|
88
|
+
OUTS[dep.scope].puts dep.toPath if SCOPES.member?(dep.scope)
|
89
|
+
else
|
90
|
+
raise RuntimeError, %|Unsupported stage "#{@stage}"|
|
91
|
+
end
|
92
|
+
|
93
|
+
rescue Exception => x
|
94
|
+
$stderr.puts %|ERROR while processing line ##{@lineNum}: >>>#{@srcLine}<<<\n#{x.message}\n#{x.backtrace.join("\n")}|
|
95
|
+
@exitCode = 1
|
96
|
+
break
|
97
|
+
end
|
98
|
+
|
99
|
+
}
|
100
|
+
|
101
|
+
OUTS.values.each {|f| f.close}
|
102
|
+
exit @exitCode if @exitCode != 0
|
103
|
+
puts "Saved dependency path list to:\n\t#{OUTS.values.map{|f| f.path}.join("\n\t")}\nDone."
|
@@ -0,0 +1,34 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
2
|
+
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
=begin rdoc
|
6
|
+
|
7
|
+
Utilities for building and deploying applications.
|
8
|
+
|
9
|
+
@!attribute [rw] target
|
10
|
+
@return [String] build target directory name.
|
11
|
+
@see TARGET_DIR
|
12
|
+
=end
|
13
|
+
|
14
|
+
class DataMetaBuild
|
15
|
+
# Current version
|
16
|
+
VERSION = '1.0.0'
|
17
|
+
|
18
|
+
# Default build target directory, to mimic Maven it's literally "<tt>target</tt>".
|
19
|
+
TARGET_DIR = 'target'
|
20
|
+
|
21
|
+
attr_accessor :target
|
22
|
+
|
23
|
+
# Initializes the instance with the given target directory, defaulted to TARGET_DIR
|
24
|
+
def initialize(target = TARGET_DIR); @target = target end
|
25
|
+
|
26
|
+
# Creates target if it does not exist.
|
27
|
+
def init; FileUtils.mkpath target end
|
28
|
+
|
29
|
+
# Removes target if it exists.
|
30
|
+
def clean
|
31
|
+
FileUtils.remove_dir(target, true) if File.exists? target_dir
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# keep this underscore naming in the test subdir, it's easier to append files names to test
|
2
|
+
require './test/test_helper.rb'
|
3
|
+
|
4
|
+
# Unit test cases for the DataMetaBuild.
|
5
|
+
# Assertions: http://ruby-doc.org/stdlib-1.9.3/libdoc/test/unit/rdoc/Test/Unit/Assertions.html
|
6
|
+
class TestNewGem < Test::Unit::TestCase
|
7
|
+
|
8
|
+
# an empty stub for now
|
9
|
+
def setup;
|
10
|
+
end
|
11
|
+
|
12
|
+
# method stub
|
13
|
+
def assert_true
|
14
|
+
#assert_equal('a', "a")
|
15
|
+
end
|
16
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dataMetaBuild
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Michael Bergens
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-01-15 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: DataMeta Utilities for building applications
|
14
|
+
email: michael.bergens@gmail.com
|
15
|
+
executables:
|
16
|
+
- dataMetaMvnDepsPaths.rb
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- ".yardopts"
|
21
|
+
- PostInstall.txt
|
22
|
+
- README.md
|
23
|
+
- Rakefile
|
24
|
+
- bin/dataMetaMvnDepsPaths.rb
|
25
|
+
- lib/dataMetaBuild.rb
|
26
|
+
- test/test_dataMetaBuild.rb
|
27
|
+
- test/test_helper.rb
|
28
|
+
homepage: https://github.com/eBayDataMeta
|
29
|
+
licenses:
|
30
|
+
- Apache-2.0
|
31
|
+
metadata: {}
|
32
|
+
post_install_message:
|
33
|
+
rdoc_options:
|
34
|
+
- "--title"
|
35
|
+
- "--line-numbers"
|
36
|
+
- "--all"
|
37
|
+
- "--title=dataMetaBuild-1.0.0"
|
38
|
+
- "--main"
|
39
|
+
- README.rdoc
|
40
|
+
require_paths:
|
41
|
+
- lib
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
requirements: []
|
53
|
+
rubyforge_project:
|
54
|
+
rubygems_version: 2.5.1
|
55
|
+
signing_key:
|
56
|
+
specification_version: 4
|
57
|
+
summary: Build Utilities
|
58
|
+
test_files:
|
59
|
+
- test/test_dataMetaBuild.rb
|