expert 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +15 -0
- data/History.txt +3 -0
- data/README.md +0 -0
- data/Rakefile +18 -0
- data/bin/expert +4 -0
- data/expert.gemspec +19 -0
- data/lib/expert.rb +76 -0
- data/lib/expert/classpath_file.rb +27 -0
- data/lib/expert/cli.rb +21 -0
- data/lib/expert/environment.rb +51 -0
- data/lib/expert/jar_dependency.rb +17 -0
- data/lib/expert/jarfile.rb +40 -0
- data/lib/expert/jarfile_parser.rb +81 -0
- data/lib/expert/jarfile_tokenizer.rb +41 -0
- data/lib/expert/maven.rb +28 -0
- data/lib/expert/pom_file.rb +97 -0
- data/lib/expert/version.rb +5 -0
- data/vendor/apache-maven-3.3.3/LICENSE +305 -0
- data/vendor/apache-maven-3.3.3/NOTICE +8 -0
- data/vendor/apache-maven-3.3.3/README.txt +79 -0
- data/vendor/apache-maven-3.3.3/bin/m2.conf +8 -0
- data/vendor/apache-maven-3.3.3/bin/mvn +232 -0
- data/vendor/apache-maven-3.3.3/bin/mvn.cmd +176 -0
- data/vendor/apache-maven-3.3.3/bin/mvnDebug +41 -0
- data/vendor/apache-maven-3.3.3/bin/mvnDebug.cmd +31 -0
- data/vendor/apache-maven-3.3.3/bin/mvnyjp +42 -0
- data/vendor/apache-maven-3.3.3/boot/plexus-classworlds-2.5.2.jar +0 -0
- data/vendor/apache-maven-3.3.3/conf/logging/simplelogger.properties +25 -0
- data/vendor/apache-maven-3.3.3/conf/settings.xml +257 -0
- data/vendor/apache-maven-3.3.3/conf/toolchains.xml +103 -0
- data/vendor/apache-maven-3.3.3/lib/aether-api-1.0.2.v20150114.jar +0 -0
- data/vendor/apache-maven-3.3.3/lib/aether-api.license +261 -0
- data/vendor/apache-maven-3.3.3/lib/aether-connector-basic-1.0.2.v20150114.jar +0 -0
- data/vendor/apache-maven-3.3.3/lib/aether-connector-basic.license +261 -0
- data/vendor/apache-maven-3.3.3/lib/aether-impl-1.0.2.v20150114.jar +0 -0
- data/vendor/apache-maven-3.3.3/lib/aether-impl.license +261 -0
- data/vendor/apache-maven-3.3.3/lib/aether-spi-1.0.2.v20150114.jar +0 -0
- data/vendor/apache-maven-3.3.3/lib/aether-spi.license +261 -0
- data/vendor/apache-maven-3.3.3/lib/aether-transport-wagon-1.0.2.v20150114.jar +0 -0
- data/vendor/apache-maven-3.3.3/lib/aether-transport-wagon.license +261 -0
- data/vendor/apache-maven-3.3.3/lib/aether-util-1.0.2.v20150114.jar +0 -0
- data/vendor/apache-maven-3.3.3/lib/aether-util.license +261 -0
- data/vendor/apache-maven-3.3.3/lib/aopalliance-1.0.jar +0 -0
- data/vendor/apache-maven-3.3.3/lib/cdi-api-1.0.jar +0 -0
- data/vendor/apache-maven-3.3.3/lib/cdi-api.license +389 -0
- data/vendor/apache-maven-3.3.3/lib/commons-cli-1.2.jar +0 -0
- data/vendor/apache-maven-3.3.3/lib/commons-io-2.2.jar +0 -0
- data/vendor/apache-maven-3.3.3/lib/commons-lang-2.6.jar +0 -0
- data/vendor/apache-maven-3.3.3/lib/ext/README.txt +2 -0
- data/vendor/apache-maven-3.3.3/lib/guava-18.0.jar +0 -0
- data/vendor/apache-maven-3.3.3/lib/javax.inject-1.jar +0 -0
- data/vendor/apache-maven-3.3.3/lib/jsoup-1.7.2.jar +0 -0
- data/vendor/apache-maven-3.3.3/lib/jsoup.license +65 -0
- data/vendor/apache-maven-3.3.3/lib/jsr250-api-1.0.jar +0 -0
- data/vendor/apache-maven-3.3.3/lib/jsr250-api.license +406 -0
- data/vendor/apache-maven-3.3.3/lib/maven-aether-provider-3.3.3.jar +0 -0
- data/vendor/apache-maven-3.3.3/lib/maven-aether-provider.license +202 -0
- data/vendor/apache-maven-3.3.3/lib/maven-artifact-3.3.3.jar +0 -0
- data/vendor/apache-maven-3.3.3/lib/maven-artifact.license +202 -0
- data/vendor/apache-maven-3.3.3/lib/maven-builder-support-3.3.3.jar +0 -0
- data/vendor/apache-maven-3.3.3/lib/maven-builder-support.license +202 -0
- data/vendor/apache-maven-3.3.3/lib/maven-compat-3.3.3.jar +0 -0
- data/vendor/apache-maven-3.3.3/lib/maven-compat.license +202 -0
- data/vendor/apache-maven-3.3.3/lib/maven-core-3.3.3.jar +0 -0
- data/vendor/apache-maven-3.3.3/lib/maven-core.license +202 -0
- data/vendor/apache-maven-3.3.3/lib/maven-embedder-3.3.3.jar +0 -0
- data/vendor/apache-maven-3.3.3/lib/maven-embedder.license +202 -0
- data/vendor/apache-maven-3.3.3/lib/maven-model-3.3.3.jar +0 -0
- data/vendor/apache-maven-3.3.3/lib/maven-model-builder-3.3.3.jar +0 -0
- data/vendor/apache-maven-3.3.3/lib/maven-model-builder.license +202 -0
- data/vendor/apache-maven-3.3.3/lib/maven-model.license +202 -0
- data/vendor/apache-maven-3.3.3/lib/maven-plugin-api-3.3.3.jar +0 -0
- data/vendor/apache-maven-3.3.3/lib/maven-plugin-api.license +202 -0
- data/vendor/apache-maven-3.3.3/lib/maven-repository-metadata-3.3.3.jar +0 -0
- data/vendor/apache-maven-3.3.3/lib/maven-repository-metadata.license +202 -0
- data/vendor/apache-maven-3.3.3/lib/maven-settings-3.3.3.jar +0 -0
- data/vendor/apache-maven-3.3.3/lib/maven-settings-builder-3.3.3.jar +0 -0
- data/vendor/apache-maven-3.3.3/lib/maven-settings-builder.license +202 -0
- data/vendor/apache-maven-3.3.3/lib/maven-settings.license +202 -0
- data/vendor/apache-maven-3.3.3/lib/org.eclipse.sisu.inject-0.3.0.jar +0 -0
- data/vendor/apache-maven-3.3.3/lib/org.eclipse.sisu.inject.license +261 -0
- data/vendor/apache-maven-3.3.3/lib/org.eclipse.sisu.plexus-0.3.0.jar +0 -0
- data/vendor/apache-maven-3.3.3/lib/org.eclipse.sisu.plexus.license +261 -0
- data/vendor/apache-maven-3.3.3/lib/plexus-cipher-1.7.jar +0 -0
- data/vendor/apache-maven-3.3.3/lib/plexus-cipher.license +389 -0
- data/vendor/apache-maven-3.3.3/lib/plexus-component-annotations-1.5.5.jar +0 -0
- data/vendor/apache-maven-3.3.3/lib/plexus-interpolation-1.21.jar +0 -0
- data/vendor/apache-maven-3.3.3/lib/plexus-sec-dispatcher-1.3.jar +0 -0
- data/vendor/apache-maven-3.3.3/lib/plexus-sec-dispatcher.license +389 -0
- data/vendor/apache-maven-3.3.3/lib/plexus-utils-3.0.20.jar +0 -0
- data/vendor/apache-maven-3.3.3/lib/sisu-guice-3.2.5-no_aop.jar +0 -0
- data/vendor/apache-maven-3.3.3/lib/slf4j-api-1.7.5.jar +0 -0
- data/vendor/apache-maven-3.3.3/lib/slf4j-api.license +191 -0
- data/vendor/apache-maven-3.3.3/lib/slf4j-simple-1.7.5.jar +0 -0
- data/vendor/apache-maven-3.3.3/lib/slf4j-simple.license +191 -0
- data/vendor/apache-maven-3.3.3/lib/wagon-file-2.9.jar +0 -0
- data/vendor/apache-maven-3.3.3/lib/wagon-file.license +202 -0
- data/vendor/apache-maven-3.3.3/lib/wagon-http-2.9-shaded.jar +0 -0
- data/vendor/apache-maven-3.3.3/lib/wagon-http-shared-2.9.jar +0 -0
- data/vendor/apache-maven-3.3.3/lib/wagon-http-shared.license +202 -0
- data/vendor/apache-maven-3.3.3/lib/wagon-http.license +202 -0
- data/vendor/apache-maven-3.3.3/lib/wagon-provider-api-2.9.jar +0 -0
- data/vendor/apache-maven-3.3.3/lib/wagon-provider-api.license +202 -0
- metadata +148 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 916ed2662d22a6ac4391d57c19c84e80ae5c154a
|
4
|
+
data.tar.gz: 5680a35349f5c0db60a3538cf9530938bf5b8081
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9b09c9a30d8f558beed1e3c11a9e82b2255a7b96ab2f174d035500a0098a490d51f8219bf459a8e4e93722ee9692b05203319e901c6a5ba1949882fcb617f425
|
7
|
+
data.tar.gz: cf799ff38ae14b103f6a04fc556b53900303e25e690d3ac1376919936155913e2513fe26acec3fd79dc0d1eb4e1e285c0283ebeddc49052500a9be295da8be8d
|
data/Gemfile
ADDED
data/History.txt
ADDED
data/README.md
ADDED
File without changes
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
4
|
+
|
5
|
+
require 'bundler'
|
6
|
+
require 'rspec/core/rake_task'
|
7
|
+
require 'rubygems/package_task'
|
8
|
+
|
9
|
+
require './lib/expert'
|
10
|
+
|
11
|
+
Bundler::GemHelper.install_tasks
|
12
|
+
|
13
|
+
task :default => :spec
|
14
|
+
|
15
|
+
desc 'Run specs'
|
16
|
+
RSpec::Core::RakeTask.new do |t|
|
17
|
+
t.pattern = './spec/**/*_spec.rb'
|
18
|
+
end
|
data/bin/expert
ADDED
data/expert.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), 'lib')
|
2
|
+
require 'expert/version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = 'expert'
|
6
|
+
s.version = ::Expert::VERSION
|
7
|
+
s.authors = ['Cameron Dutro']
|
8
|
+
s.email = ['camertron@gmail.com']
|
9
|
+
s.homepage = 'http://github.com/camertron'
|
10
|
+
|
11
|
+
s.description = s.summary = 'Manage and install jar dependencies (an alternative to jbundler).'
|
12
|
+
|
13
|
+
s.platform = Gem::Platform::RUBY
|
14
|
+
s.has_rdoc = true
|
15
|
+
|
16
|
+
s.require_path = 'lib'
|
17
|
+
s.executables << 'expert'
|
18
|
+
s.files = Dir['{lib,spec,vendor}/**/*', 'Gemfile', 'History.txt', 'README.md', 'Rakefile', 'expert.gemspec']
|
19
|
+
end
|
data/lib/expert.rb
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module Expert
|
4
|
+
autoload :ClasspathFile, 'expert/classpath_file'
|
5
|
+
autoload :Cli, 'expert/cli'
|
6
|
+
autoload :Environment, 'expert/environment'
|
7
|
+
autoload :Jarfile, 'expert/jarfile'
|
8
|
+
autoload :JarDependency, 'expert/jar_dependency'
|
9
|
+
autoload :JarfileParser, 'expert/jarfile_parser'
|
10
|
+
autoload :JarfileTokenizer, 'expert/jarfile_tokenizer'
|
11
|
+
autoload :Maven, 'expert/maven'
|
12
|
+
autoload :PomFile, 'expert/pom_file'
|
13
|
+
|
14
|
+
# The Jarfile declares dependencies. The pom/classpath function like a
|
15
|
+
# Gemfile.lock or Jarfile.lock.
|
16
|
+
DEFAULT_JARFILE_PATH = './Jarfile'
|
17
|
+
DEFAULT_POM_PATH = './pom.xml'
|
18
|
+
DEFAULT_CLASSPATH_FILE = './classpath.txt'
|
19
|
+
MAVEN_VERSION = '3.3.3'
|
20
|
+
|
21
|
+
class << self
|
22
|
+
def environment
|
23
|
+
@environment ||= begin
|
24
|
+
check_bundler_required
|
25
|
+
check_jarfile_exists
|
26
|
+
|
27
|
+
Environment.new(load_jarfile, load_pom, load_classpath)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def jarfile_path
|
32
|
+
ENV.fetch('EXPERT_JARFILE', DEFAULT_JARFILE_PATH)
|
33
|
+
end
|
34
|
+
|
35
|
+
def pom_path
|
36
|
+
ENV.fetch('EXPERT_POM', DEFAULT_POM_PATH)
|
37
|
+
end
|
38
|
+
|
39
|
+
def classpath_file_path
|
40
|
+
ENV.fetch('EXPERT_CLASSPATH_FILE', DEFAULT_CLASSPATH_FILE)
|
41
|
+
end
|
42
|
+
|
43
|
+
protected
|
44
|
+
|
45
|
+
def check_bundler_required
|
46
|
+
unless defined?(Bundler)
|
47
|
+
raise "Bundler hasn't been required. Please run expert in the context "\
|
48
|
+
"of your bundle."
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def check_jarfile_exists
|
53
|
+
unless File.exist?(jarfile_path)
|
54
|
+
raise "Couldn't find a Jarfile at #{jarfile_path}. A Jarfile is "\
|
55
|
+
"required to declare jar dependencies. You can manually specify a "\
|
56
|
+
"Jarfile location via the EXPERT_JARFILE environment variable."
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def load_jarfile
|
61
|
+
Jarfile.from_path(jarfile_path)
|
62
|
+
end
|
63
|
+
|
64
|
+
def load_pom
|
65
|
+
if File.exist?(pom_path)
|
66
|
+
PomFile.from_path(pom_path)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def load_classpath
|
71
|
+
if File.exist?(classpath_file_path)
|
72
|
+
ClasspathFile.from_path(classpath_file_path)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module Expert
|
4
|
+
class ClasspathFile
|
5
|
+
attr_reader :paths
|
6
|
+
|
7
|
+
class << self
|
8
|
+
def from_path(path)
|
9
|
+
new(load(path))
|
10
|
+
end
|
11
|
+
|
12
|
+
protected
|
13
|
+
|
14
|
+
def load(path)
|
15
|
+
File.read(path).split(':')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def initialize(paths)
|
20
|
+
@paths = paths
|
21
|
+
end
|
22
|
+
|
23
|
+
def require_all
|
24
|
+
paths.each { |p| Kernel.require(p) }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/expert/cli.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module Expert
|
4
|
+
class Cli
|
5
|
+
class << self
|
6
|
+
def start(argv)
|
7
|
+
cmd = argv[0].to_sym
|
8
|
+
|
9
|
+
if respond_to?(cmd)
|
10
|
+
public_send(cmd, argv[1..-1])
|
11
|
+
else
|
12
|
+
raise "Couldn't find command '#{cmd}'"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def install(args)
|
17
|
+
Expert.environment.install
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module Expert
|
4
|
+
class DependenciesNotInstalledError < StandardError; end
|
5
|
+
|
6
|
+
class Environment
|
7
|
+
attr_reader :jarfile, :pom, :classpath
|
8
|
+
|
9
|
+
def initialize(jarfile, pom, classpath)
|
10
|
+
@jarfile = jarfile
|
11
|
+
@pom = pom
|
12
|
+
@classpath = classpath
|
13
|
+
end
|
14
|
+
|
15
|
+
def install
|
16
|
+
install_pom
|
17
|
+
install_classpath
|
18
|
+
end
|
19
|
+
|
20
|
+
def installed?
|
21
|
+
pom && classpath
|
22
|
+
end
|
23
|
+
|
24
|
+
def require_all
|
25
|
+
if installed?
|
26
|
+
classpath.require_all
|
27
|
+
else
|
28
|
+
raise DependenciesNotInstalledError,
|
29
|
+
"Maven dependencies haven't been installed yet (did you forget to "\
|
30
|
+
"run `expert install`?)"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
protected
|
35
|
+
|
36
|
+
def install_pom
|
37
|
+
@pom = PomFile.new(jarfile.dependencies)
|
38
|
+
pom.write(Expert.pom_path)
|
39
|
+
end
|
40
|
+
|
41
|
+
def install_classpath
|
42
|
+
mvn.resolve
|
43
|
+
mvn.build_classpath(Expert.classpath_file_path)
|
44
|
+
@classpath = ClasspathFile.from_path(Expert.classpath_file_path)
|
45
|
+
end
|
46
|
+
|
47
|
+
def mvn
|
48
|
+
Expert::Maven
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module Expert
|
4
|
+
class JarDependency
|
5
|
+
attr_reader :group_id, :artifact_id, :version
|
6
|
+
|
7
|
+
def initialize(group_id, artifact_id, version)
|
8
|
+
@group_id = group_id
|
9
|
+
@artifact_id = artifact_id
|
10
|
+
@version = version
|
11
|
+
end
|
12
|
+
|
13
|
+
def classifier
|
14
|
+
"#{group_id}:#{artifact_id}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module Expert
|
4
|
+
class Jarfile
|
5
|
+
attr_reader :dependencies
|
6
|
+
|
7
|
+
class << self
|
8
|
+
def from_path(jarfile_path)
|
9
|
+
new(load(jarfile_path))
|
10
|
+
end
|
11
|
+
|
12
|
+
protected
|
13
|
+
|
14
|
+
def load(jarfile_path)
|
15
|
+
jar_deps = parse(jar_requirements_from_gems.join("\n"))
|
16
|
+
jarfile_deps = parse(File.read(jarfile_path))
|
17
|
+
(jar_deps + jarfile_deps).uniq(&:classifier)
|
18
|
+
end
|
19
|
+
|
20
|
+
def parse(contents)
|
21
|
+
tokens = JarfileTokenizer.tokenize(contents)
|
22
|
+
JarfileParser.new(tokens).dependencies
|
23
|
+
end
|
24
|
+
|
25
|
+
def jar_requirements_from_gems
|
26
|
+
requirements_from_gems.select do |requirement|
|
27
|
+
requirement.respond_to?(:start_with?) && requirement.start_with?('jar ')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def requirements_from_gems
|
32
|
+
Bundler.environment.specs.flat_map(&:requirements)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def initialize(dependencies)
|
37
|
+
@dependencies = dependencies
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module Expert
|
4
|
+
class UnexpectedTokenError < StandardError; end
|
5
|
+
|
6
|
+
class JarfileParser
|
7
|
+
attr_reader :tokens, :index
|
8
|
+
|
9
|
+
def initialize(tokens)
|
10
|
+
@tokens = tokens
|
11
|
+
end
|
12
|
+
|
13
|
+
def each_dependency(&block)
|
14
|
+
rewind
|
15
|
+
each_jar(&block)
|
16
|
+
end
|
17
|
+
|
18
|
+
def dependencies
|
19
|
+
rewind
|
20
|
+
each_jar.to_a
|
21
|
+
end
|
22
|
+
|
23
|
+
protected
|
24
|
+
|
25
|
+
def each_jar
|
26
|
+
if block_given?
|
27
|
+
consume
|
28
|
+
yield jar until eos?
|
29
|
+
else
|
30
|
+
to_enum(__method__)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def jar
|
35
|
+
consume(:jar)
|
36
|
+
consume(:quote)
|
37
|
+
group_id, artifact_id = consume(:string).value.split(':')
|
38
|
+
consume(:quote)
|
39
|
+
consume(:comma)
|
40
|
+
consume(:quote)
|
41
|
+
version = consume(:string).value
|
42
|
+
consume(:quote)
|
43
|
+
JarDependency.new(group_id, artifact_id, version)
|
44
|
+
end
|
45
|
+
|
46
|
+
def consume(type = nil)
|
47
|
+
token = current_token
|
48
|
+
|
49
|
+
if type
|
50
|
+
if current_token.type == type && !eos?
|
51
|
+
@index += 1
|
52
|
+
else
|
53
|
+
raise UnexpectedTokenError,
|
54
|
+
"Expected token of type '#{type}', got '#{current_token.type}'"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
while should_skip_current?
|
59
|
+
@index += 1
|
60
|
+
end
|
61
|
+
|
62
|
+
token
|
63
|
+
end
|
64
|
+
|
65
|
+
def should_skip_current?
|
66
|
+
!eos? && current_token.type == :comment
|
67
|
+
end
|
68
|
+
|
69
|
+
def current_token
|
70
|
+
tokens[index]
|
71
|
+
end
|
72
|
+
|
73
|
+
def eos?
|
74
|
+
index >= tokens.size
|
75
|
+
end
|
76
|
+
|
77
|
+
def rewind
|
78
|
+
@index = 0
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module Expert
|
4
|
+
Token = Struct.new(:type, :value)
|
5
|
+
|
6
|
+
# jar 'org.eclipse.jgit:org.eclipse.jgit', '3.4.1.201406201815-r'
|
7
|
+
class JarfileTokenizer
|
8
|
+
TOKEN_TYPE_REGEXES = {
|
9
|
+
jar: /jar/,
|
10
|
+
quote: /['"]/,
|
11
|
+
comma: /,/,
|
12
|
+
comment: /#.*\z/m
|
13
|
+
}
|
14
|
+
|
15
|
+
TOKEN_TYPES = TOKEN_TYPE_REGEXES.keys
|
16
|
+
DEFAULT_TOKEN_TYPE = :string
|
17
|
+
|
18
|
+
SPLITTER = Regexp.new(
|
19
|
+
"(#{TOKEN_TYPE_REGEXES.values.map(&:source).join('|')})"
|
20
|
+
)
|
21
|
+
|
22
|
+
class << self
|
23
|
+
def tokenize(content)
|
24
|
+
raw_tokens = content.split(SPLITTER)
|
25
|
+
identify(raw_tokens.reject { |t| t.strip.empty? })
|
26
|
+
end
|
27
|
+
|
28
|
+
protected
|
29
|
+
|
30
|
+
def identify(raw_tokens)
|
31
|
+
raw_tokens.map do |token|
|
32
|
+
type = TOKEN_TYPES.find do |type|
|
33
|
+
token =~ TOKEN_TYPE_REGEXES[type]
|
34
|
+
end
|
35
|
+
|
36
|
+
Token.new(type || DEFAULT_TOKEN_TYPE, token)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/expert/maven.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module Expert
|
4
|
+
class Maven
|
5
|
+
|
6
|
+
class << self
|
7
|
+
def execute(cmd)
|
8
|
+
system("#{mvn_path} #{cmd}")
|
9
|
+
end
|
10
|
+
|
11
|
+
def resolve
|
12
|
+
execute('dependency:resolve')
|
13
|
+
end
|
14
|
+
|
15
|
+
def build_classpath(output_file)
|
16
|
+
execute("dependency:build-classpath -Dmdep.outputFile=#{output_file}")
|
17
|
+
end
|
18
|
+
|
19
|
+
def mvn_path
|
20
|
+
@mvn_path ||= File.expand_path(
|
21
|
+
"../../../vendor/apache-maven-#{Expert::MAVEN_VERSION}/bin/mvn",
|
22
|
+
__FILE__
|
23
|
+
)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|